/* app.css — INHSA Spelling Trainer brand tokens + components (SPEC §1.5). Tokens copied from the INHSA Wix kit
   (wix-sites/inhsa/_shared/shared-block.html v1.2). Self-hosted fonts (SIL OFL, see /fonts/OFL-*.txt).
   No inline styles anywhere (CSP style-src 'self'): pages use these classes only. Light theme only. */

/* ---------- Fonts (variable woff2, latin + latin-ext subsets) ---------- */
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 700 800; font-display: swap;
  src: url(/fonts/bricolage-grotesque-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 700 800; font-display: swap;
  src: url(/fonts/bricolage-grotesque-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito Sans"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(/fonts/nunito-sans-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Nunito Sans"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(/fonts/nunito-sans-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- Tokens ---------- */
:root {
  --forest: #1f4a3a; --forest-2: #2b6450; --pine: #173a2d; --ink: #1d2a24; --muted: #5d6b64;
  --cream: #fbf6ec; --cream-2: #f4ecdc; --sage: #ebf2ec; --mint: #e3efe8;
  --sun: #f4b740; --sun-deep: #c98f17; --sun-soft: #fdeec9;
  --berry: #d4573b; --berry-ink: #b23f25;
  --card: #fff; --line: #e7dfcd; --line-strong: #7b8c82;
  --r-sm: 12px; --r: 16px; --r-lg: 24px;
  --tile-shadow: 0 3px 0 rgba(23, 58, 45, .18);
  --max: 1040px; --gutter: clamp(16px, 4vw, 24px);
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --text: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--cream); }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--cream);
  font-family: var(--text); font-size: 1.0625rem; line-height: 1.6; color: var(--ink); }
body.kid { font-size: 1.125rem; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--forest); font-weight: 700; text-underline-offset: 2px; }
a:hover { color: var(--pine); }
h1, h2, h3 { font-family: var(--display); color: var(--pine); margin: 0 0 .5em; letter-spacing: -.015em; text-wrap: balance; }
h1 { font-size: clamp(2rem, 1.3rem + 2.6vw, 2.75rem); font-weight: 800; line-height: 1.08; }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.85rem); font-weight: 800; line-height: 1.12; }
h3, .h3 { font-size: 1.25rem; font-weight: 700; line-height: 1.22; }
p, li { text-wrap: pretty; }
p { margin: 0 0 1em; }
.lede { font-size: 1.2rem; color: var(--muted); max-width: 60ch; }
.muted { color: var(--muted); }
.small { font-size: .92rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nw { white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 10; padding: 10px 16px; border-radius: var(--r-sm); background: var(--pine); color: #fff; }
.skip:focus { top: 12px; color: #fff; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .02em; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--forest); outline-offset: 3px; }
.on-dark :focus-visible { outline-color: var(--sun); }

.eyebrow { display: inline-flex; align-items: center; gap: .6em; margin: 0 0 .75rem; font-size: .78rem; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase; color: var(--forest-2); }
.eyebrow::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--sun); transform: rotate(8deg); }
.hl { -webkit-box-decoration-break: clone; box-decoration-break: clone; background: linear-gradient(transparent 56%, var(--sun) 56% 88%, transparent 88%); padding: 0 .06em; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding-inline: var(--gutter); }
.wrap.narrow { max-width: 640px; }
.wrap.mid { max-width: 820px; }
main { flex: 1 0 auto; padding-block: clamp(24px, 5vw, 48px); }
.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 1.75rem; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }

/* ---------- Header / footer ---------- */
.app-header { background: var(--cream); border-bottom: 1px solid var(--line); }
.app-header .wrap { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--pine); }
.brand img { width: 32px; height: 36px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-org { font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--forest-2); }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 1.2rem; letter-spacing: -.01em; }
.user-menu { display: flex; align-items: center; gap: 10px; font-size: .95rem; }
.user-menu .who { color: var(--muted); font-weight: 700; }
.app-footer { border-top: 1px solid var(--line); background: var(--cream-2); color: var(--muted); font-size: .92rem; }
.app-footer .wrap { padding-block: 20px; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.app-footer a { color: var(--forest); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 48px; padding: .7em 1.3em;
  border: 2px solid transparent; border-radius: var(--r-sm); font-family: var(--text); font-weight: 800; font-size: 1rem;
  line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s, background-color .15s; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn[aria-disabled="true"], .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sun { background: var(--sun); color: var(--pine); box-shadow: 0 4px 0 var(--sun-deep); }
.btn-sun:hover { box-shadow: 0 5px 0 var(--sun-deep); color: var(--pine); }
.btn-forest { background: var(--forest); color: #fff; box-shadow: 0 4px 0 var(--pine); }
.btn-forest:hover { box-shadow: 0 5px 0 var(--pine); color: #fff; }
.btn-line { background: transparent; color: var(--pine); border-color: var(--line-strong); }
.btn-line:hover { border-color: var(--forest); background: rgba(255, 255, 255, .7); color: var(--pine); }
.btn-danger { background: #fff; color: var(--berry-ink); border-color: var(--berry); }
.btn-small { min-height: 38px; padding: .4em .9em; font-size: .92rem; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--forest); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.btn-block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 24px; }
@media (max-width: 480px) { .actions .btn { flex: 1 1 100%; } }
.actions + .hint, .actions + p { margin-top: 18px; }

/* ---------- Cards, chips, banners ---------- */
.card { padding: clamp(20px, 3vw, 30px); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); }
.card.sage { background: var(--sage); border-color: #d6e4d9; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.chip { display: inline-block; padding: .15em .7em; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .82rem; font-weight: 800; color: var(--ink); white-space: nowrap; }
.chip.ok { background: var(--mint); border-color: #c5ddcd; color: var(--pine); }
.chip.wait { background: var(--sun-soft); border-color: #f1d796; color: #6b4b06; }
.chip.stop { background: #fbe4dd; border-color: #f0c0b2; color: var(--berry-ink); }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-radius: var(--r); border: 1px solid var(--line); background: #fff; }
.banner::before { content: ""; flex: none; width: 10px; height: 10px; margin-top: .55em; border-radius: 3px; background: var(--forest-2); transform: rotate(8deg); }
.banner.info { background: var(--sage); border-color: #d6e4d9; }
.banner.wait { background: var(--sun-soft); border-color: #f1d796; }
.banner.wait::before { background: var(--sun-deep); }
.banner.stop { background: #fbe4dd; border-color: #f0c0b2; }
.banner.stop::before { background: var(--berry); }
.banner p { margin: 0; }
.tile-hex { display: grid; place-items: center; width: 46px; height: 52px; border-radius: var(--r-sm); background: #fff; color: var(--pine); font: 800 1.5rem/1 var(--display); box-shadow: var(--tile-shadow); }

/* ---------- Forms ---------- */
form { margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field, .field + .check, .check + .field, .check + .check { margin-top: 16px; }
.field-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.field-row + .field, .field + .field-row, .field-row + .field-row { margin-top: 16px; }
.field-row > .field + .field { margin-top: 0; }
label, .label { font-weight: 800; color: var(--pine); }
.optional { font-weight: 600; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 2px solid var(--line-strong); border-radius: var(--r-sm);
  background: #fff; color: var(--ink); font: inherit; font-size: 1.0625rem; }
input:focus, select:focus, textarea:focus { border-color: var(--forest); outline: 3px solid rgba(31, 74, 58, .25); outline-offset: 0; }
/* Edge's built-in reveal "eye" would sit next to our own Show button: keep only ours. */
input[type="password"]::-ms-reveal, input[type="password"]::-ms-clear { display: none; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--berry); }
.hint { font-size: .92rem; color: var(--muted); margin: 0; }
.field-error { font-size: .92rem; font-weight: 700; color: var(--berry-ink); margin: 0; }
.check { display: flex; gap: 12px; align-items: flex-start; }
.check input { flex: none; width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--forest); }
.check label { font-weight: 600; color: var(--ink); }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { padding-right: 84px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--sage); color: var(--pine); font: inherit; font-size: .88rem; font-weight: 800; cursor: pointer; }
.caps-warn { font-size: .88rem; font-weight: 800; color: #6b4b06; margin: 0; }
.form-error { padding: 12px 16px; border-radius: var(--r-sm); background: #fbe4dd; border: 1px solid #f0c0b2; color: var(--berry-ink); font-weight: 700; }
.form-ok { padding: 12px 16px; border-radius: var(--r-sm); background: var(--mint); border: 1px solid #c5ddcd; color: var(--pine); font-weight: 700; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; } /* honeypot */
.rules { list-style: none; padding: 0; margin: 8px 0 0; font-size: .92rem; }
.rules li { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.rules li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line-strong); }
.rules li.met { color: var(--pine); font-weight: 700; }
.rules li.met::before { background: var(--forest); border-color: var(--forest); }

/* ---------- Tabs and steps ---------- */
.tabs { display: flex; gap: 6px; padding: 6px; border-radius: var(--r); background: var(--cream-2); border: 1px solid var(--line); }
.tab { flex: 1; min-height: 48px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--pine); font: inherit; font-weight: 800; cursor: pointer; }
.tab[aria-selected="true"] { background: #fff; box-shadow: var(--tile-shadow); }
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 24px; counter-reset: step; }
.steps li { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: .82rem; font-weight: 800; color: var(--muted); }
.steps li::before { content: ""; height: 6px; border-radius: 3px; background: var(--line); }
.steps li.done::before, .steps li.current::before { background: var(--forest); }
.steps li.current { color: var(--pine); }
@media (max-width: 520px) { .steps li span { display: none; } }

/* ---------- Tables (admin) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
table.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--cream); }
.table tr:last-child td { border-bottom: 0; }
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 16px; margin: 0; }
.kv dt { font-weight: 800; color: var(--pine); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv + .hint, .kv + p { margin-top: 14px; }

.rule-list { margin: 0; padding-left: 1.2em; }
.rule-list li + li { margin-top: 8px; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset > h2 { margin-bottom: .75em; }
.radio-group { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Speller cards (parent) ---------- */
.speller { display: flex; flex-direction: column; gap: 10px; }
.speller-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; }
.speller-name { font-family: var(--display); font-weight: 800; font-size: 1.35rem; color: var(--pine); }

/* ---------- Dialogs ---------- */
dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; color: var(--ink); box-shadow: 0 20px 60px rgba(23, 58, 45, .25); }
dialog::backdrop { background: rgba(23, 58, 45, .45); }
.dialog-body { padding: clamp(20px, 4vw, 28px); }
.dialog-body h2 { font-size: 1.5rem; }
.secret-box { padding: 14px 16px; border-radius: var(--r-sm); background: var(--cream); border: 1px dashed var(--line-strong); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.05rem; overflow-wrap: anywhere; }
.codes { columns: 2; padding-left: 1.2em; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* ---------- Welcome ---------- */
.hero { display: grid; gap: clamp(24px, 5vw, 48px); grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); align-items: center; }
.hero-mark { width: clamp(120px, 22vw, 200px); margin-inline: auto; }
.welcome-points { margin-top: clamp(32px, 6vw, 56px); }
.welcome-points .card p { margin: 0; }
.choice { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Documents (privacy, help) ---------- */
.doc h2 { margin-top: 1.6em; }
.doc h3 { margin-top: 1.2em; margin-bottom: .3em; }
.doc ul { padding-left: 1.2em; }

/* ---------- Admin ---------- */
.admin-nav { background: var(--pine); }
.admin-nav .wrap { display: flex; flex-wrap: wrap; gap: 4px; padding-block: 6px; }
.admin-nav a { padding: 8px 14px; border-radius: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: .95rem; }
.admin-nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.admin-nav a[aria-current="page"] { background: var(--sun); color: var(--pine); }
.admin-nav :focus-visible { outline-color: var(--sun); }
.stat { display: flex; flex-direction: column; gap: 2px; text-decoration: none; transition: border-color .15s, transform .15s; }
a.stat:hover { border-color: var(--forest); transform: translateY(-1px); }
.stat-num { font-family: var(--display); font-weight: 800; font-size: 2.2rem; line-height: 1; color: var(--pine); }
.stat-label { font-size: .92rem; color: var(--muted); font-weight: 700; }
.msg { display: flex; flex-direction: column; gap: 8px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { min-width: 180px; }

/* ---------- Clue block (Learning mode; admin "student preview") ---------- */
.clues { display: flex; flex-direction: column; gap: 10px; }
.clues p { margin: 0; }
.clue-meta { font-weight: 800; color: var(--forest-2); }
.clue-pos { font-style: italic; }
.clue-def { font-size: 1.08rem; }
.clue-sentence { padding: 12px 14px; border-radius: var(--r-sm); background: var(--sage); }
.clue-blank { display: inline-block; min-width: 4.5em; border-bottom: 3px solid var(--pine); color: transparent; line-height: 1; }

/* ---------- Parent area ---------- */
.speller-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.danger-zone { border-color: #f0c0b2; }
.danger-zone h2 { color: var(--berry-ink); }
.placeholder-note { border-style: dashed; background: var(--cream-2); }

/* ---------- Print: login cards and Word Explorer lists (only while body.printing-cards is set) ---------- */
.print-only { display: none; }
.print-root { display: none; }
@media print {
  body.printing-cards > *:not(.print-root) { display: none !important; }
  body.printing-cards .print-root, .print-only { display: block !important; }
  .login-card { border: 2px dashed #000; border-radius: 12px; padding: 16px; margin: 0 0 16px; break-inside: avoid; }
  .print-list { color: #000; background: #fff; font-size: 10pt; }
  .print-list h1 { font-size: 14pt; margin: 0 0 4pt; }
  .print-list p { margin: 0 0 8pt; }
  .print-list table { width: 100%; border-collapse: collapse; }
  .print-list th, .print-list td { border: 1px solid #000; padding: 3pt 5pt; text-align: left; vertical-align: top; }
  .print-list thead { display: table-header-group; }
  .print-list tr { break-inside: avoid; }
  .print-list .pl-word { font-weight: 800; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .btn:hover, .btn:active { transform: none; }
}
@media (forced-colors: active) {
  .btn, .tab, .chip, .card, .banner { border: 2px solid ButtonText; }
  .hl { background: none; text-decoration: underline; }
}
