/* ==========================================================================
   Spellbright by Waystead
   Brand: Waystead tokens (Ink, Paper, Teal, Amber), Sora + Manrope.
   Rules kept from the parent site: the "Waystead" wordmark is always Ink;
   chrome stays neutral; Teal is the product accent; Amber is the waypoint.
   ========================================================================== */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../assets/fonts/manrope-latin-var.woff2") format("woff2");
}
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("../assets/fonts/sora-latin-var.woff2") format("woff2");
}

:root {
  --paper: #FAF8F3;
  --ink: #1B1A20;
  --teal: #0F8B7E;
  --teal-700: #0C7167;
  --teal-50: #ECF6F4;
  --teal-100: #DBEFEC;
  --amber: #F2A31D;
  --amber-50: #FDF4E1;
  --amber-700: #B5750B;

  --bg: var(--paper);
  --surface: #FFFFFF;
  --surface-2: #F3F0E8;
  --line: #E6E1D6;
  --text: var(--ink);
  --muted: #5B5866;
  --accent: var(--teal);
  --accent-strong: var(--teal-700);
  --accent-soft: var(--teal-50);
  --warm-soft: var(--amber-50);
  --good: #1F7A4D;
  --good-soft: #E7F3EC;
  --bad: #B3362B;
  --bad-soft: #FBEAE7;
  --stroke: var(--ink);
  --wordmark: var(--ink);
  --key-bg: #FFFFFF;
  --shadow: 0 1px 0 rgba(27, 26, 32, 0.04), 0 6px 18px -10px rgba(27, 26, 32, 0.25);

  --f-display: "Sora", ui-sans-serif, system-ui, sans-serif;
  --f-body: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-sm: 8px;
  --r: 14px;
  --r-lg: 22px;
  --wrap: 1040px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #141318;
  --surface: #1D1C22;
  --surface-2: #26242C;
  --line: #34323B;
  --text: #F3F1EC;
  --muted: #B4B0BD;
  --accent: #2DB5A5;
  --accent-strong: #5CCFC1;
  --accent-soft: #12302D;
  --warm-soft: #3A2C10;
  --good: #5BC58E;
  --good-soft: #15301F;
  --bad: #F08A7E;
  --bad-soft: #3A1A16;
  --stroke: #F3F1EC;
  --wordmark: #F3F1EC;
  --key-bg: #26242C;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 8px 22px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #141318;
    --surface: #1D1C22;
    --surface-2: #26242C;
    --line: #34323B;
    --text: #F3F1EC;
    --muted: #B4B0BD;
    --accent: #2DB5A5;
    --accent-strong: #5CCFC1;
    --accent-soft: #12302D;
    --warm-soft: #3A2C10;
    --good: #5BC58E;
    --good-soft: #15301F;
    --bad: #F08A7E;
    --bad-soft: #3A1A16;
    --stroke: #F3F1EC;
    --wordmark: #F3F1EC;
    --key-bg: #26242C;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 8px 22px -12px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}

/* ---- Base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 1.0625rem;
  line-height: 1.55;
}
main { flex: 1; outline: none; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent-strong); }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.page { padding-top: 20px; padding-bottom: 48px; }
.stack > * + * { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---- Top bar ----------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: var(--wrap); margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; min-width: 0; }
.brand__mark { width: 34px; height: 34px; flex: none; }
.brand__stroke { fill: none; stroke: var(--wordmark); stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; }
.brand__dot { fill: var(--amber); }
.brand__words { display: flex; flex-direction: column; line-height: 1; }
.brand__name { font-family: var(--f-display); font-weight: 600; font-size: 1.15rem; color: var(--wordmark); letter-spacing: -0.01em; }
.brand__product { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); margin-top: 3px; }
.topbar__nav { display: flex; gap: 4px; }
.topbar__nav a { text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.92rem; padding: 8px 10px; border-radius: var(--r-sm); }
.topbar__nav a:hover, .topbar__nav a[aria-current="page"] { background: var(--surface-2); }
@media (max-width: 700px) { .topbar__nav { display: none; } }

.iconbtn {
  width: 40px; height: 40px; flex: none; display: inline-grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; cursor: pointer;
}
.iconbtn:hover { border-color: var(--muted); }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn svg .fill { fill: currentColor; stroke: none; }
#theme svg { display: none; }
[data-theme-mode="system"] #theme .ico-auto,
[data-theme-mode="light"] #theme .ico-light,
[data-theme-mode="dark"] #theme .ico-dark { display: block; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px; border-radius: 12px;
  font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer;
  border: 2px solid transparent; transition: transform 100ms ease, background-color 150ms ease;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--teal); color: #fff; }
.btn--primary:hover { background: var(--teal-700); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn--ghost:hover { border-color: var(--muted); }
.btn--quiet { background: var(--surface-2); color: var(--text); }
.btn--small { min-height: 40px; padding: 6px 14px; font-size: 0.92rem; border-radius: 10px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill--done { background: var(--good-soft); color: var(--good); }
.pill--warm { background: var(--warm-soft); color: var(--amber-700); }
:root[data-theme="dark"] .pill--warm { color: var(--amber); }

.eyebrow { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }

/* ---- Chunked word (the signature) --------------------------------------
   A word shown as its spelling chunks, each chunk resting on a teal rail;
   the amber waypoint dot marks where the word starts. */
.chunked { display: inline-flex; flex-wrap: wrap; align-items: flex-end; gap: 0.18em; font-family: var(--f-display); font-weight: 700; letter-spacing: 0.02em; }
.chunked__chunk { position: relative; padding: 0 0.04em 0.16em; }
.chunked__chunk::after { content: ""; position: absolute; left: 0.04em; right: 0.04em; bottom: 0; height: 0.09em; min-height: 3px; border-radius: 99px; background: var(--accent); }
.chunked__chunk:first-child::before { content: ""; position: absolute; left: -0.08em; bottom: -0.06em; width: 0.22em; height: 0.22em; min-width: 7px; min-height: 7px; border-radius: 50%; background: var(--amber); }
.chunked__letter { display: inline-block; transition: color 120ms ease, transform 120ms ease; }
.chunked__letter.is-on { color: var(--amber-700); transform: translateY(-0.08em); }
:root[data-theme="dark"] .chunked__letter.is-on { color: var(--amber); }
.chunktext { font-family: var(--f-mono); font-size: 0.9rem; color: var(--muted); letter-spacing: 0.04em; }
.ipa { font-family: var(--f-mono); color: var(--muted); }

/* ---- Home --------------------------------------------------------------- */
.hero { display: grid; gap: 24px; padding: 28px 0 8px; }
.hero h1 { font-size: clamp(2rem, 6.4vw, 3.4rem); max-width: 15ch; }
.hero__lede { font-size: 1.12rem; color: var(--muted); max-width: 46ch; }
.today { padding: 22px; display: grid; gap: 10px; }
.today__word { font-size: clamp(2.2rem, 9vw, 3.6rem); }
.today__meta { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
@media (min-width: 860px) {
  .hero { grid-template-columns: 1.1fr 1fr; align-items: center; padding-top: 48px; }
}

.years { display: grid; gap: 16px; margin-top: 28px; }
@media (min-width: 720px) { .years { grid-template-columns: 1fr 1fr; } }
.year { padding: 22px; text-decoration: none; color: inherit; display: grid; gap: 12px; transition: transform 120ms ease, border-color 120ms ease; }
.year:hover { transform: translateY(-2px); border-color: var(--accent); }
.year h2 { font-size: 1.6rem; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.shortcuts { display: grid; gap: 12px; margin-top: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.shortcut { padding: 16px 18px; text-decoration: none; color: inherit; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.shortcut strong { font-family: var(--f-display); }
.shortcut svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.steps { margin-top: 40px; }
.steps ol { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 12px; counter-reset: s; }
@media (min-width: 720px) { .steps ol { grid-template-columns: repeat(4, 1fr); } }
.steps li { counter-increment: s; padding: 16px; border-radius: var(--r); background: var(--surface-2); }
.steps li::before { content: counter(s); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); font-weight: 800; font-size: 0.85rem; margin-bottom: 8px; }
.steps strong { display: block; font-family: var(--f-display); }

/* ---- Lists of chapters ------------------------------------------------- */
.pagehead { display: grid; gap: 6px; margin-bottom: 20px; }
.pagehead h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); }
.chapters { display: grid; gap: 12px; }
.chapter { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; padding: 16px; text-decoration: none; color: inherit; }
.chapter:hover { border-color: var(--accent); }
.chapter__num { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-family: var(--f-display); font-weight: 700; background: var(--accent-soft); color: var(--accent-strong); }
.chapter--locked { opacity: 0.6; }
.chapter--locked .chapter__num { background: var(--surface-2); color: var(--muted); }
.chapter h2 { font-size: 1.08rem; }
.chapter .pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.phases { display: grid; gap: 12px; margin-top: 8px; }
@media (min-width: 720px) { .phases { grid-template-columns: repeat(3, 1fr); } }
.phase { padding: 18px; display: grid; gap: 10px; align-content: start; }
.phase h2 { font-size: 1.15rem; }
.wordchips { display: flex; flex-wrap: wrap; gap: 6px; }
.wordchips span { background: var(--surface-2); border-radius: 8px; padding: 2px 10px; font-weight: 600; }

/* ---- Study ------------------------------------------------------------- */
.studylist { display: grid; gap: 14px; }
.wordcard { padding: 16px; display: grid; gap: 14px; grid-template-columns: 112px 1fr; align-items: start; }
@media (min-width: 720px) { .wordcard { grid-template-columns: 150px 1fr; padding: 20px; } }
.wordcard__word { font-size: clamp(1.6rem, 6vw, 2.2rem); }
.wordcard__body { display: grid; gap: 8px; min-width: 0; }
.wordcard__line { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.example { font-style: italic; color: var(--muted); }
.example b { font-style: normal; color: var(--text); }

.pic { width: 100%; aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: var(--accent-soft); position: relative; }
.pic img { width: 100%; height: 100%; object-fit: cover; }
.pic__ph { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--accent-strong); }
.pic__ph b { font-family: var(--f-display); font-size: 3.2rem; line-height: 1; }
.pic__ph span { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.pic__ph svg { width: 46%; fill: none; stroke: currentColor; stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.55; }
.pic--blur img, .pic--blur .pic__ph { filter: blur(var(--blur, 20px)) saturate(1.2); transition: filter 350ms ease-out; transform: scale(1.12); }
@media (prefers-reduced-motion: reduce) {
  .pic--blur img, .pic--blur .pic__ph { visibility: hidden; transition: none; }
}

/* ---- Spell aloud ------------------------------------------------------- */
.spell { padding: 22px; display: grid; gap: 18px; justify-items: center; text-align: center; }
.spell .pic { max-width: 220px; }
.spell__word { font-size: clamp(2.6rem, 12vw, 4.4rem); }

/* ---- Play (hangman) ---------------------------------------------------- */
.play { display: grid; gap: 14px; }
.play__top { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; }
@media (min-width: 720px) { .play__top { grid-template-columns: 220px 1fr; } }
.play__top .pic { max-width: 220px; }
.gallows { width: 100%; max-height: 240px; }
.gallows .g { fill: none; stroke: var(--stroke); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity 200ms ease; }
.gallows .g.on { opacity: 1; }
.gallows .g--base { opacity: 1; stroke: var(--line); }
.gallows .head { fill: var(--amber); stroke: none; }
.status { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; }
.lives { display: inline-flex; gap: 5px; }
.lives i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.lives i.lost { background: var(--line); }

.blanks { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; font-family: var(--f-display); font-weight: 700; font-size: clamp(1.5rem, 7vw, 2.4rem); min-height: 1.6em; }
.blanks span { width: 1.05em; text-align: center; border-bottom: 4px solid var(--line); line-height: 1.25; }
.blanks span.got { border-color: var(--accent); }
.blanks span.missed { color: var(--bad); border-color: var(--bad); }

details.hint { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
details.hint summary { cursor: pointer; padding: 12px 16px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; }
details.hint summary::-webkit-details-marker { display: none; }
details.hint summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--muted); }
details.hint[open] summary::after { content: "–"; }
details.hint .hint__body { padding: 0 16px 14px; display: grid; gap: 6px; }

.keyboard { display: flex; flex-direction: column; gap: 7px; align-items: center; width: 100%; user-select: none; -webkit-user-select: none; }
.keyboard-row { display: flex; flex-wrap: nowrap; gap: 5px; justify-content: center; width: 100%; }
.key {
  flex: 0 1 auto; width: clamp(27px, 8.4vw, 46px); height: clamp(42px, 12vw, 54px); min-width: 0; padding: 0;
  border-radius: 9px; border: 1px solid var(--line); background: var(--key-bg); color: var(--text);
  font-family: var(--f-display); font-weight: 600; font-size: clamp(0.9rem, 3.6vw, 1.1rem); cursor: pointer;
  box-shadow: 0 2px 0 var(--line); transition: background-color 120ms ease, transform 80ms ease;
}
.key:hover:not(:disabled) { border-color: var(--accent); }
.key:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.key.hit { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: none; }
.key.miss { background: var(--surface-2); color: var(--muted); text-decoration: line-through; box-shadow: none; }
.key:disabled { cursor: default; }

.result { padding: 20px; display: grid; gap: 12px; }
.result--good { border-color: var(--good); }
.result--bad { border-color: var(--bad); }
.result h2 { font-size: 1.3rem; }
.result__head { display: flex; align-items: center; gap: 10px; }
.result__badge { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; }
.result--good .result__badge { background: var(--good); }
.result--bad .result__badge { background: var(--bad); }
.result__grid { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: start; }

/* ---- Test -------------------------------------------------------------- */
.testcard { padding: 20px; display: grid; gap: 14px; }
.answer { width: 100%; font: 700 1.6rem var(--f-display); padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--text); letter-spacing: 0.03em; }
.answer:focus { outline: none; border-color: var(--accent); }
.progressline { font-weight: 700; color: var(--muted); font-size: 0.9rem; }

/* ---- Pick words -------------------------------------------------------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
:root[data-theme="dark"] .tab[aria-selected="true"] { background: var(--text); color: var(--bg); }
.picker { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: 52vh; overflow: auto; padding: 4px; }
.picker label { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; cursor: pointer; }
.picker input { width: 18px; height: 18px; accent-color: var(--teal); }
.field { width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.stickybar { position: sticky; bottom: 0; padding: 12px 0; background: var(--bg); border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; }

/* ---- Tables / misc ---------------------------------------------------- */
.list { display: grid; gap: 8px; }
.listrow { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.listrow strong { font-family: var(--f-display); font-size: 1.1rem; }
.empty { padding: 28px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.prose { max-width: 66ch; }
.prose h2 { font-size: 1.25rem; margin-top: 28px; }
.prose p { margin-top: 10px; }
.settings { display: grid; gap: 12px; }
.setting { padding: 16px; display: grid; gap: 10px; }
.radios { display: flex; gap: 8px; flex-wrap: wrap; }
.radios label { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }

.foot { border-top: 1px solid var(--line); padding: 20px 0 28px; margin-top: 24px; }
.foot__inner { display: grid; gap: 6px; font-size: 0.92rem; }
.foot__small { color: var(--muted); font-size: 0.8rem; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 40px); opacity: 0; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-weight: 600; transition: all 200ms ease; pointer-events: none; z-index: 40; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
.result__word { font-size: clamp(2rem, 9vw, 2.8rem); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.page > .btnrow, .page > .stack, .page > .phases, .page > .muted { margin-top: 18px; }
.page > .pagehead + .btnrow { margin-top: 0; margin-bottom: 14px; }
main:focus, main:focus-visible { outline: none; }
@media (max-width: 480px) { .wordcard { grid-template-columns: 84px 1fr; } .pic__ph b { font-size: 2.4rem; } }
