/* ===========================================================================
   Ukrainian Out Loud — styles.css   (base + layout + components)
   Mobile-first. References the Phase 3 tokens in tokens.css. No new colors/fonts.
   Token names are Phase 3 §6: --surface-base/raised/sunken, --text-primary/
   secondary/muted, --primary, --primary-hover, --on-primary, --accent-gold,
   --stress, --border, --border-strong, --radius-*, --shadow-*, --focus-ring,
   --text-* scale, --phonetic, --cyrillic-hero.
   =========================================================================== */

/* ------------------------------- Reset --------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
body {
  font-family: var(--font-body);
  font-weight: var(--font-weight-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--surface-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, iframe { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
button { font: inherit; cursor: pointer; }
:where(h1, h2, h3) { font-family: var(--font-display); font-weight: var(--font-weight-semibold); line-height: var(--leading-tight); color: var(--text-primary); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

/* --------------------------- A11y primitives --------------------------- */
/* Transparent outline keeps a focus indicator in forced-colors mode;
   the brand ring is the Phase 3 --focus-ring box-shadow. */
:focus-visible { outline: 2px solid transparent; outline-offset: 2px; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.skip-link {
  position: absolute; left: var(--space-2); top: -3rem;
  background: var(--surface-raised); color: var(--text-primary);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); z-index: 100; transition: top .15s ease;
}
.skip-link:focus { top: var(--space-2); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------ Layout --------------------------------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--space-4); }
.section { padding-block: var(--space-7); }
.stack > * + * { margin-top: var(--space-4); }
.prose { max-width: var(--container-reading); }

/* ------------------------------ Header --------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklch, var(--surface-base) 88%, transparent);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  min-height: var(--tap); padding-block: var(--space-3);
}
.wordmark {
  font-family: var(--font-display); font-weight: var(--font-weight-semibold);
  font-size: var(--text-xl); color: var(--text-primary); text-decoration: none; letter-spacing: var(--tracking-tight);
}
.wordmark:hover { color: var(--text-primary); }
.header-nav { display: flex; align-items: center; gap: var(--space-2); }
.header-nav a { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); text-decoration: none; color: var(--text-secondary); font-weight: var(--font-weight-medium); }
.header-nav a:hover { color: var(--text-primary); background: var(--surface-sunken); }

/* Theme toggle */
.theme-toggle {
  display: inline-grid; place-items: center;
  width: var(--tap); height: var(--tap);
  background: transparent; border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  color: var(--text-primary);
}
.theme-toggle:hover { background: var(--surface-sunken); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

/* ------------------------------ Buttons -------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill); border: 1px solid transparent;
  font-weight: var(--font-weight-semibold); text-decoration: none; line-height: 1;
}
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text-primary); }
.btn--ghost:hover { background: var(--surface-sunken); color: var(--text-primary); }

/* ---------------------------- Search bar ------------------------------- */
.searchbar { position: relative; display: flex; align-items: center; }
.searchbar input[type="search"] {
  width: 100%; min-height: var(--tap);
  padding: var(--space-3) var(--space-4) var(--space-3) calc(var(--space-6) + var(--space-2));
  font-size: var(--text-lg); color: var(--text-primary);
  background: var(--surface-sunken); border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}
.searchbar input[type="search"]::placeholder { color: var(--text-muted); }
.searchbar input[type="search"]:focus-visible { border-color: var(--primary); }
.searchbar__icon { position: absolute; left: var(--space-4); color: var(--text-muted); pointer-events: none; }

/* ------------------------------- Hero ---------------------------------- */
.hero { text-align: center; padding-block: var(--space-8) var(--space-7); }
.hero__title { font-size: var(--text-3xl); font-weight: var(--font-weight-semibold); letter-spacing: var(--tracking-tight); }
.hero__tagline { color: var(--text-secondary); font-size: var(--text-lg); margin-top: var(--space-3); }
.hero .searchbar { max-width: 40rem; margin: var(--space-6) auto 0; }

/* ======================================================================= */
/*  PRONUNCIATION BLOCK  — the signature component (Phase 3 §3)             */
/*  Triple-encoded stress: UPPERCASE glyphs (from data) + Inter 700 +       */
/*  --stress color (blue light / gold dark). Never color alone.            */
/* ======================================================================= */
.pron {
  font-family: var(--font-body);
  font-size: var(--phonetic);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-wide);
  color: var(--text-primary);
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 0.12em;
  margin-block: var(--space-3);
}
.pron__syl { font-weight: var(--font-weight-body); }
.pron__dot { color: var(--text-muted); font-weight: var(--font-weight-body); padding-inline: 0.05em; user-select: none; }
.pron__syl--stress {
  font-weight: var(--font-weight-stress);   /* Inter 700  — encoding #1 (weight) */
  color: var(--stress);                     /* blue/gold  — encoding #2 (color)  */
  /* encoding #3 (UPPERCASE) is in the data — no text-transform, so a malformed
     lowercase "stress" run degrades honestly rather than faking it. */
}
/* Graceful degradation: malformed Phonetic → single raw span, no stress styling. */
.pron--raw { font-weight: var(--font-weight-body); color: var(--text-primary); }

/* ------------------------------ Badges --------------------------------- */
.badges { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block: var(--space-3); align-items: center; }
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: var(--space-1) var(--space-3); min-height: 28px;
  font-size: var(--text-2xs); font-weight: var(--font-weight-semibold); line-height: 1;
  border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--surface-sunken); color: var(--text-primary);
}
.chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4); min-height: var(--tap);
  border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
  background: var(--surface-raised); color: var(--text-primary); text-decoration: none; font-weight: var(--font-weight-medium);
}
.chip:hover { background: var(--surface-sunken); color: var(--text-primary); }
.chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.chip__icon { line-height: 1; }

/* ---------------------------- Word card -------------------------------- */
.card-grid { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 40rem) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64rem) { .card-grid { grid-template-columns: repeat(3, 1fr); } }

.word-card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-5); background: var(--surface-raised);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); text-decoration: none; color: var(--text-primary);
  transition: box-shadow .15s ease, transform .15s ease;
}
.word-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); color: var(--text-primary); }
.word-card__cyr { font-family: var(--font-display); font-weight: var(--font-weight-semibold); font-size: var(--text-2xl); }
.word-card__translit { color: var(--text-secondary); font-size: var(--text-sm); font-weight: var(--font-weight-medium); }
.word-card .pron { font-size: var(--text-lg); margin-block: var(--space-2); }
.word-card__meaning { color: var(--text-primary); }

/* --------------------------- Result row -------------------------------- */
.result-row {
  display: flex; align-items: baseline; gap: var(--space-4);
  padding: var(--space-3) var(--space-4); min-height: var(--tap);
  border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text-primary);
}
.result-row:hover { background: var(--surface-sunken); color: var(--text-primary); }
.result-row__cyr { font-family: var(--font-display); font-weight: var(--font-weight-semibold); font-size: var(--text-lg); }
.result-row .pron { font-size: var(--text-base); margin-block: 0; }
.result-row__meaning { color: var(--text-secondary); margin-left: auto; text-align: right; }

/* --------------------------- Category grid ----------------------------- */
.category-card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface-raised); text-decoration: none; color: var(--text-primary);
}
.category-card:hover { background: var(--surface-sunken); color: var(--text-primary); }
.category-card__icon { font-size: var(--text-2xl); line-height: 1; color: var(--accent-gold); }
.category-card__name { font-family: var(--font-display); font-weight: var(--font-weight-semibold); font-size: var(--text-xl); }
.category-card__desc { color: var(--text-secondary); font-size: var(--text-sm); }

/* -------------------------- How it works ------------------------------- */
.steps { display: grid; gap: var(--space-5); grid-template-columns: 1fr; padding: 0; list-style: none; }
@media (min-width: 48rem) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { padding: var(--space-5); }
.step__n {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem;
  border-radius: var(--radius-pill); background: var(--primary); color: var(--on-primary);
  font-weight: var(--font-weight-stress); font-size: var(--text-sm); margin-bottom: var(--space-3);
}
.step__title { font-family: var(--font-display); font-weight: var(--font-weight-semibold); font-size: var(--text-xl); }

/* --------------------------- YouTube facade ---------------------------- */
.yt-facade {
  position: relative; aspect-ratio: 16 / 9; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
  background: var(--surface-sunken); cursor: pointer; display: grid; place-items: center;
}
.yt-facade__poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.yt-facade__play {
  position: relative; z-index: 1; display: inline-grid; place-items: center;
  width: 64px; height: 64px; border-radius: var(--radius-pill);
  background: var(--primary); color: var(--on-primary);
  border: 3px solid var(--accent-gold);   /* Phase 3 §11 gold accent ring */
}
.yt-facade__play:hover { background: var(--primary-hover); }
.yt-facade[data-state="loading"] .yt-facade__play { opacity: .5; }
.yt-facade__fallback {   /* branded fallback when poster missing */
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--text-secondary); font-family: var(--font-display);
}
.yt-embed { position: relative; aspect-ratio: 16 / 9; width: 100%; border: 0; border-radius: var(--radius-lg); overflow: hidden; }

/* --------------------------- MP3 player -------------------------------- */
.audio-player { margin-block: var(--space-4); }
.audio-player[hidden] { display: none; }   /* hidden when Audio URL empty  */
.audio-player audio { width: 100%; }

/* ---------------------------- Share group ------------------------------ */
.share { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.share__label { color: var(--text-muted); font-size: var(--text-sm); }
.share__btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--surface-raised); color: var(--text-primary);
}
.share__btn:hover { background: var(--surface-sunken); }

/* ---------------------------- Breadcrumb ------------------------------- */
.breadcrumb { font-size: var(--text-sm); color: var(--text-muted); padding-top: var(--space-4); }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-2); padding: 0; }
.breadcrumb li { display: flex; gap: var(--space-2); align-items: center; }
.breadcrumb li + li::before { content: "/"; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-primary); text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--text-secondary); }

/* --------------------------- Word page head ---------------------------- */
.word-hero { padding-block: var(--space-6) var(--space-5); }
.word-hero__cyr {
  font-family: var(--font-display); font-weight: var(--font-weight-semibold);
  font-size: var(--cyrillic-hero); letter-spacing: var(--tracking-tight); line-height: 1.05;
}
.word-hero__translit { color: var(--text-secondary); font-size: var(--text-lg); font-weight: var(--font-weight-medium); margin-top: var(--space-2); }
.word-hero__meaning { font-size: var(--text-xl); margin-top: var(--space-3); }

/* ---------------------------- Notes / related -------------------------- */
.notes { background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); }
.related, .notes, .category-link { margin-block: var(--space-6); }
.related h2, .notes h2, .category-link h2 { font-size: var(--text-xl); margin-bottom: var(--space-4); }

/* -------------------- Suggest correction / request banner -------------- */
.suggest { border-top: 1px solid var(--border); padding-block: var(--space-5); color: var(--text-muted); font-size: var(--text-sm); }
.suggest a { color: var(--text-secondary); }
.request-banner {
  margin-block: var(--space-7);
  padding: var(--space-6); border-radius: var(--radius-lg);
  background: var(--surface-sunken); border: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; justify-content: space-between;
}
.request-banner__text h2 { font-size: var(--text-xl); }
.request-banner__text p { color: var(--text-secondary); }

/* ------------------------------ Forms ---------------------------------- */
.form { max-width: var(--container-reading); }
.field { margin-bottom: var(--space-5); }
.field label { display: block; font-weight: var(--font-weight-semibold); margin-bottom: var(--space-2); }
.field .hint { color: var(--text-muted); font-size: var(--text-sm); margin-top: var(--space-1); }
.field input, .field textarea {
  width: 100%; min-height: var(--tap); padding: var(--space-3) var(--space-4);
  font: inherit; color: var(--text-primary); background: var(--surface-sunken);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
}
.field input:focus-visible, .field textarea:focus-visible { border-color: var(--primary); }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--danger); }
.field textarea { min-height: 8rem; resize: vertical; }
.field--checkbox { display: flex; align-items: center; gap: var(--space-3); }
.field--checkbox input { width: auto; min-height: auto; }
/* Honeypot — visually + a11y hidden, still submitted */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ------------------------------ Toast ---------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: var(--space-6); transform: translateX(-50%) translateY(1rem);
  background: var(--surface-raised); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: var(--space-3) var(--space-5);
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 60;
}
.toast[data-visible="true"] { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------------------- Empty state ------------------------------ */
.empty-state { text-align: center; padding-block: var(--space-8); color: var(--text-secondary); }
.empty-state h1, .empty-state h2 { color: var(--text-primary); font-size: var(--text-2xl); margin-bottom: var(--space-3); }

/* ------------------------- Search results area ------------------------- */
.filter-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block: var(--space-5); }
#results { margin-top: var(--space-5); }
#results[hidden], #no-results[hidden] { display: none; }

/* ------------------------------ Footer --------------------------------- */
.site-footer { border-top: 1px solid var(--border); padding-block: var(--space-7); color: var(--text-muted); margin-top: var(--space-9); }
.site-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--text-primary); text-decoration: underline; }
.site-footer__grid { display: flex; flex-wrap: wrap; gap: var(--space-6); justify-content: space-between; }
.site-footer__grid p { color: var(--text-secondary); }
.site-footer__social { display: flex; gap: var(--space-3); }

/* ======================================================================= */
/*  CYRILLIC ON-SCREEN KEYBOARD  (Phase 5.1 addition — inventory #34)       */
/*  For English speakers with no Ukrainian layout. Types into the search /  */
/*  request field at the cursor. Progressive enhancement: shown only with   */
/*  JS (needs JS to insert). Uses only Phase 3 tokens.                       */
/* ======================================================================= */
.cyr { display: none; margin-top: var(--space-3); }
.js .cyr { display: block; }               /* only when JS can do the inserting */

.cyr-toggle {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: var(--tap); padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--surface-raised); color: var(--text-secondary);
  font-weight: var(--font-weight-medium); font-size: var(--text-sm);
}
.cyr-toggle:hover { background: var(--surface-sunken); color: var(--text-primary); }
.cyr-toggle[aria-expanded="true"] { background: var(--surface-sunken); color: var(--text-primary); border-color: var(--primary); }

.cyr-keyboard {
  margin-top: var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface-raised); box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}
.cyr-keyboard[hidden] { display: none; }
.cyr-keyboard__hint { color: var(--text-muted); font-size: var(--text-xs); margin-bottom: var(--space-3); }
.cyr-keyboard__keys { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.cyr-key {
  min-width: 2.75rem; min-height: var(--tap);
  padding-inline: var(--space-2);
  display: inline-grid; place-items: center;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface-base); color: var(--text-primary);
  font-family: var(--font-body); font-size: var(--text-lg); line-height: 1;
}
.cyr-key:hover { background: var(--surface-sunken); }
.cyr-key:active { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.cyr-key--wide { flex: 1 1 6rem; font-size: var(--text-sm); color: var(--text-secondary); }
.cyr-key--action { color: var(--text-secondary); font-size: var(--text-xl); }
