/* ---------------------------------------------------------------------
 * kozha shared components
 *
 * Reusable, token-driven classes that reproduce the canonical (landing)
 * appearance of the shared patterns identified in
 * docs/polish/01-component-inventory.md. Every value here is sourced
 * through --kozha-* tokens from public/styles/tokens.css.
 *
 * Specificity: every rule is wrapped in :where() so .kz-* selectors
 * contribute *zero* specificity. This lets kz-* classes sit next to the
 * inline element- and class-selector legacy rules during the parallel-
 * mode rollout without clobbering responsive overrides like
 * `@media (max-width: 900px) { nav { padding: 0 20px; } }`. As legacy
 * rules are retired in later prompts, the :where() wrapping stays —
 * zero-specificity design-system rules are a feature, not a transition
 * workaround.
 *
 * Do not reach outside the token set when extending this file. If a
 * value you need isn't a token, add it to tokens.css first (and update
 * docs/polish/02-design-system.md).
 * ------------------------------------------------------------------ */

/* ===========================
 * Buttons
 * =========================== */

/* .kz-btn-primary — the large CTA shape (landing .btn-large). Use for
   hero / banner-level primary actions. */
:where(.kz-btn-primary) {
  display: inline-flex;
  align-items: center;
  gap: var(--kozha-space-2);
  font-family: var(--kozha-font-sans);
  font-size: var(--kozha-text-button-lg);
  font-weight: var(--kozha-weight-semibold);
  color: var(--kozha-color-white);
  background: var(--kozha-color-accent);
  border: none;
  border-radius: var(--kozha-radius);
  padding: 14px 28px;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--kozha-duration-slow),
              transform var(--kozha-duration-slow),
              box-shadow var(--kozha-duration-slow);
}
:where(.kz-btn-primary):hover {
  background: var(--kozha-color-accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--kozha-shadow-btn-hover-lg);
}
:where(.kz-btn-primary):focus-visible {
  outline: 2px solid var(--kozha-color-accent);
  outline-offset: 2px;
}

/* .kz-btn-secondary — large ghost CTA (landing .btn-large-ghost). */
:where(.kz-btn-secondary) {
  display: inline-flex;
  align-items: center;
  gap: var(--kozha-space-2);
  font-family: var(--kozha-font-sans);
  font-size: var(--kozha-text-button-lg);
  font-weight: var(--kozha-weight-medium);
  color: var(--kozha-color-ink-2);
  background: var(--kozha-color-white);
  border: 1px solid var(--kozha-color-border);
  border-radius: var(--kozha-radius);
  padding: 14px 28px;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--kozha-duration-slow),
              transform var(--kozha-duration-slow);
}
:where(.kz-btn-secondary):hover {
  background: var(--kozha-color-paper-2);
  transform: translateY(-1px);
}
:where(.kz-btn-secondary):focus-visible {
  outline: 2px solid var(--kozha-color-accent);
  outline-offset: 2px;
}

/* ===========================
 * Text link
 * =========================== */

/* .kz-link — quiet text link on paper (nav-links a). */
:where(.kz-link) {
  color: var(--kozha-color-ink-2);
  font-family: var(--kozha-font-sans);
  font-size: var(--kozha-text-body);
  font-weight: var(--kozha-weight-medium);
  text-decoration: none;
  transition: color var(--kozha-duration-base);
}
:where(.kz-link):hover,
:where(.kz-link):focus-visible {
  color: var(--kozha-color-accent);
}

/* ===========================
 * Input (textarea)
 * =========================== */

/* .kz-input — paper-filled textarea / input (landing .demo-input). */
:where(.kz-input) {
  width: 100%;
  background: var(--kozha-color-paper);
  border: 1px solid var(--kozha-color-border);
  border-radius: var(--kozha-radius-sm);
  padding: 12px 16px;
  font-family: var(--kozha-font-sans);
  font-size: var(--kozha-text-body-lg);
  color: var(--kozha-color-ink);
  outline: none;
  resize: none;
  transition: border-color var(--kozha-duration-base);
  min-height: 56px;
}
:where(.kz-input):focus {
  border-color: var(--kozha-color-accent);
}

/* ===========================
 * Card
 * =========================== */

/* .kz-card — white surface card with hairline border (landing
   .feature-card). Pad via token variants or override per component. */
:where(.kz-card) {
  background: var(--kozha-color-white);
  border: 1px solid var(--kozha-color-border);
  border-radius: var(--kozha-radius);
  padding: var(--kozha-space-8) 28px;
  transition: transform var(--kozha-duration-slow),
              box-shadow var(--kozha-duration-slow),
              border-color var(--kozha-duration-slow);
}
:where(.kz-card):hover {
  transform: translateY(-3px);
  box-shadow: var(--kozha-shadow-card-hover);
  border-color: var(--kozha-color-border-accent);
}

/* ===========================
 * Site shell — header, footer, breadcrumbs, skip-link
 * ===========================
 *
 * These classes ship the prompt-11 unified chrome. Every public page
 * uses .kz-header, .kz-footer, and (for sub-pages) .kz-breadcrumbs so
 * the visitor never feels the layout jump between /, /app, /contribute,
 * /progress, /credits, /governance, the 404, or the per-submission
 * status pages. All sizes, colors, and timings are token-driven.
 */

/* .kz-header — fixed translucent nav. Every top-level page uses this. */
:where(.kz-header) {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--kozha-z-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--kozha-space-4);
  padding: 0 var(--kozha-space-8);
  height: var(--kozha-layout-nav-h);
  background: var(--kozha-color-paper-translucent);
  backdrop-filter: blur(var(--kozha-blur-nav));
  -webkit-backdrop-filter: blur(var(--kozha-blur-nav));
  border-bottom: 1px solid var(--kozha-color-border);
  font-family: var(--kozha-font-sans);
}

:where(.kz-header__logo) {
  font-family: var(--kozha-font-serif);
  font-size: var(--kozha-text-step-title);
  color: var(--kozha-color-ink);
  text-decoration: none;
  letter-spacing: var(--kozha-tracking-tight);
  flex-shrink: 0;
}
:where(.kz-header__logo span) { color: var(--kozha-color-accent); }

:where(.kz-header__nav) {
  display: flex;
  align-items: center;
  gap: var(--kozha-space-8);
  list-style: none;
  margin: 0;
  padding: 0;
}

:where(.kz-header__link) {
  color: var(--kozha-color-ink-2);
  font-family: var(--kozha-font-sans);
  font-size: var(--kozha-text-body);
  font-weight: var(--kozha-weight-medium);
  text-decoration: none;
  position: relative;
  padding: var(--kozha-space-2) 0;
  transition: color var(--kozha-duration-base) var(--kozha-ease-standard);
}
:where(.kz-header__link:hover),
:where(.kz-header__link:focus-visible) {
  color: var(--kozha-color-accent);
}
/* Active state: 2px accent-colored underline. No color change, no weight
   change — one visual distinction per the prompt-11 rule. */
:where(.kz-header__link.is-active)::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 2px;
  background: var(--kozha-color-accent);
  border-radius: var(--kozha-radius-pill);
}

:where(.kz-header__hamburger) {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--kozha-color-ink-2);
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: var(--kozha-radius-sm);
  transition: background var(--kozha-duration-base) var(--kozha-ease-standard);
}
:where(.kz-header__hamburger:hover) { background: var(--kozha-color-paper-2); }
:where(.kz-header__hamburger:focus-visible) {
  outline: 2px solid var(--kozha-color-accent);
  outline-offset: 2px;
}
:where(.kz-header__hamburger svg) { display: block; }

/* Mobile: below 768px the four links collapse into a hamburger that
   opens a full-width dropdown from the header's bottom edge. Single
   180ms fade+slide animation; respects prefers-reduced-motion. */
@media (max-width: 767px) {
  :where(.kz-header) { padding: 0 var(--kozha-space-4); }
  :where(.kz-header__hamburger) { display: inline-flex; }
  :where(.kz-header__nav) {
    display: none;
    position: absolute;
    top: var(--kozha-layout-nav-h);
    left: 0; right: 0;
    flex-direction: column;
    background: var(--kozha-color-paper-translucent-strong);
    backdrop-filter: blur(var(--kozha-blur-nav));
    -webkit-backdrop-filter: blur(var(--kozha-blur-nav));
    border-bottom: 1px solid var(--kozha-color-border);
    padding: var(--kozha-space-2) var(--kozha-space-4) var(--kozha-space-3);
    gap: 0;
  }
  :where(.kz-header.is-open .kz-header__nav) {
    display: flex;
    animation: kz-dropdown-in 180ms var(--kozha-ease-standard);
  }
  :where(.kz-header__nav li) { width: 100%; }
  :where(.kz-header__link) {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: var(--kozha-space-3) 0;
    font-size: var(--kozha-text-body-lg);
    border-bottom: 1px solid var(--kozha-color-border);
  }
  :where(.kz-header__nav li:last-child .kz-header__link) { border-bottom: none; }
  :where(.kz-header__link.is-active)::after {
    left: 0;
    right: auto;
    top: 50%;
    bottom: auto;
    width: 3px;
    height: 20px;
    transform: translateY(-50%);
  }
}

@keyframes kz-dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  :where(.kz-header.is-open .kz-header__nav) { animation: none; }
}

/* .kz-footer — three-column site footer. */
:where(.kz-footer) {
  border-top: 1px solid var(--kozha-color-border);
  padding: var(--kozha-space-10) var(--kozha-space-8);
  background: var(--kozha-color-paper);
  font-family: var(--kozha-font-sans);
}
:where(.kz-footer__inner) {
  max-width: var(--kozha-layout-page-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--kozha-space-10);
  align-items: start;
}
:where(.kz-footer__brand) {
  display: flex;
  flex-direction: column;
  gap: var(--kozha-space-2);
  min-width: 0;
}
:where(.kz-footer__logo) {
  font-family: var(--kozha-font-serif);
  font-size: var(--kozha-text-step-title);
  color: var(--kozha-color-ink);
  text-decoration: none;
  letter-spacing: var(--kozha-tracking-tight);
}
:where(.kz-footer__logo span) { color: var(--kozha-color-accent); }
:where(.kz-footer__mission) {
  font-size: var(--kozha-text-body-sm);
  color: var(--kozha-color-ink-3);
  max-width: 36ch;
  line-height: var(--kozha-leading-normal);
  margin: 0;
}
:where(.kz-footer__cols) {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, auto));
  gap: var(--kozha-space-10);
}
:where(.kz-footer__col-title) {
  font-family: var(--kozha-font-sans);
  font-size: var(--kozha-text-caption-lg);
  font-weight: var(--kozha-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--kozha-tracking-wider);
  color: var(--kozha-color-ink);
  margin: 0 0 var(--kozha-space-3);
}
:where(.kz-footer__col ul) {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--kozha-space-2);
}
:where(.kz-footer__col a) {
  font-size: var(--kozha-text-body-sm);
  color: var(--kozha-color-ink-2);
  text-decoration: none;
  transition: color var(--kozha-duration-base) var(--kozha-ease-standard);
}
:where(.kz-footer__col a:hover),
:where(.kz-footer__col a:focus-visible) {
  color: var(--kozha-color-accent);
}
:where(.kz-footer__meta) {
  display: flex;
  flex-direction: column;
  gap: var(--kozha-space-2);
  text-align: right;
  justify-self: end;
}
:where(.kz-footer__copy) {
  font-size: var(--kozha-text-body-sm);
  color: var(--kozha-color-ink-3);
  margin: 0;
}
:where(.kz-footer__os) {
  font-size: var(--kozha-text-caption-lg);
  color: var(--kozha-color-ink-3);
  margin: 0;
}
:where(.kz-footer__os a) {
  color: var(--kozha-color-ink-2);
  text-decoration: underline;
  text-decoration-color: var(--kozha-color-border);
  text-underline-offset: 3px;
  transition: color var(--kozha-duration-base) var(--kozha-ease-standard);
}
:where(.kz-footer__os a:hover),
:where(.kz-footer__os a:focus-visible) {
  color: var(--kozha-color-accent);
  text-decoration-color: currentColor;
}

@media (max-width: 767px) {
  :where(.kz-footer) { padding: var(--kozha-space-8) var(--kozha-space-4); }
  :where(.kz-footer__inner) {
    grid-template-columns: 1fr;
    gap: var(--kozha-space-6);
  }
  :where(.kz-footer__cols) {
    grid-template-columns: 1fr 1fr;
    gap: var(--kozha-space-5);
  }
  :where(.kz-footer__meta) {
    text-align: left;
    justify-self: stretch;
  }
}

/* .kz-breadcrumbs — plain-text breadcrumb trail for sub-pages. The "›"
   separator is drawn with a ::before so it never gets selected when a
   user copies the trail, and the current-page segment carries
   aria-current="page" for assistive tech. */
:where(.kz-breadcrumbs) {
  font-family: var(--kozha-font-sans);
  font-size: var(--kozha-text-body-sm);
  color: var(--kozha-color-ink-3);
  margin: 0 0 var(--kozha-space-4);
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
}
:where(.kz-breadcrumbs li) {
  display: inline-flex;
  align-items: center;
}
:where(.kz-breadcrumbs a) {
  color: var(--kozha-color-ink-2);
  text-decoration: none;
  transition: color var(--kozha-duration-base) var(--kozha-ease-standard);
}
:where(.kz-breadcrumbs a:hover),
:where(.kz-breadcrumbs a:focus-visible) {
  color: var(--kozha-color-accent);
  text-decoration: underline;
}
:where(.kz-breadcrumbs [aria-current="page"]) {
  color: var(--kozha-color-ink-3);
}
:where(.kz-breadcrumbs li + li)::before {
  content: '\203A';
  color: var(--kozha-color-ink-3);
  padding: 0 var(--kozha-space-2);
}

/* .kz-skip-link — accessible skip-to-main link. Every page includes it
   at the top of <body>. Same visual as the existing skip links, now
   fully token-driven. */
:where(.kz-skip-link) {
  position: absolute;
  top: -100%;
  left: var(--kozha-space-4);
  background: var(--kozha-color-accent);
  color: var(--kozha-color-white);
  padding: var(--kozha-space-2) var(--kozha-space-4);
  border-radius: var(--kozha-radius-sm);
  font-family: var(--kozha-font-sans);
  font-size: var(--kozha-text-body);
  font-weight: var(--kozha-weight-semibold);
  z-index: var(--kozha-z-skip);
  text-decoration: none;
}
:where(.kz-skip-link:focus) { top: var(--kozha-space-2); }

/* ===========================
 * Review badges (prompt-polish 6)
 * ===========================
 *
 * .kz-badge-reviewed   — accent-tinted pill: "Reviewed by Deaf native signer"
 * .kz-badge-unreviewed — muted pill: "Not yet reviewed"
 *
 * Used by the translator chip detail panel and the contribute notation
 * preview. Both stay on a single line; the caller is responsible for
 * wrapping in a flex row if multiple badges are shown.
 */
:where(.kz-badge-reviewed),
:where(.kz-badge-unreviewed) {
  display: inline-flex;
  align-items: center;
  gap: var(--kozha-space-1);
  font-family: var(--kozha-font-sans);
  font-size: var(--kozha-text-caption);
  font-weight: var(--kozha-weight-semibold);
  letter-spacing: var(--kozha-tracking-wide);
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--kozha-radius-pill);
  border: 1px solid transparent;
  line-height: 1.3;
}
:where(.kz-badge-reviewed) {
  color: var(--kozha-badge-reviewed-fg);
  background: var(--kozha-badge-reviewed-bg);
  border-color: var(--kozha-badge-reviewed-border);
}
:where(.kz-badge-unreviewed) {
  color: var(--kozha-badge-unreviewed-fg);
  background: var(--kozha-badge-unreviewed-bg);
  border-color: var(--kozha-badge-unreviewed-border);
}
:where(.kz-badge-reviewed)::before {
  /* Small check mark — inline so the badge stays one piece even when a
     screen reader announces the accompanying text. Aria-hidden is set in
     markup. */
  content: '\2713';
  font-weight: var(--kozha-weight-semibold);
}
:where(.kz-badge-unreviewed)::before {
  content: '\00B7';
  font-size: var(--kozha-text-body);
  line-height: 1;
}
