/* Braille Practice – styles. No external fonts or requests, so everything works offline. */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f9;
  --border: #d3d9e8;
  --border-strong: #7c87a3;
  --text: #17202f;
  --muted: #526078;
  --primary: #2f3fa8;
  --primary-hover: #26348c;
  --on-primary: #ffffff;
  --dot-on: #17202f;
  --on-dot: #ffffff;
  --ok: #14633a;
  --ok-bg: #e4f4ea;
  --bad: #a3231f;
  --bad-bg: #fdebea;
  --focus: #0b57d0;
  --shadow: 0 1px 2px rgba(23, 32, 47, .06), 0 4px 14px rgba(23, 32, 47, .07);
  --radius: 14px;
  --dot: 48px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (min-width: 820px) { :root { --dot: 56px; } }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1320; --surface: #171e30; --surface-2: #1f2840; --border: #2c3754; --border-strong: #8591b1;
    --text: #e8ecf6; --muted: #a9b3ca; --primary: #94a6ff; --primary-hover: #b0bdff; --on-primary: #0e1320;
    --dot-on: #f1f4ff; --on-dot: #0e1320;
    --ok: #7ad69f; --ok-bg: #12301f; --bad: #ff9b95; --bad-bg: #3a1716; --focus: #ffd24a; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1320; --surface: #171e30; --surface-2: #1f2840; --border: #2c3754; --border-strong: #8591b1;
  --text: #e8ecf6; --muted: #a9b3ca; --primary: #94a6ff; --primary-hover: #b0bdff; --on-primary: #0e1320;
  --dot-on: #f1f4ff; --on-dot: #0e1320;
  --ok: #7ad69f; --ok-bg: #12301f; --bad: #ff9b95; --bad-bg: #3a1716; --focus: #ffd24a; --shadow: none;
}
:root[data-dots="large"] { --dot: 64px; }
@media (min-width: 820px) { :root[data-dots="large"] { --dot: 72px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 1.0625rem; line-height: 1.5; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
main { flex: 1; padding-top: 24px; padding-bottom: 40px; outline: none; }
.wrap { width: 100%; max-width: 940px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
main:not(.wide) > * { max-width: 760px; }

h1 { font-size: clamp(1.6rem, 5.2vw, 2.1rem); line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 1.6em 0 .5em; }
p { margin: 0 0 1em; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.lead { font-size: 1.15rem; color: var(--muted); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
h1:focus, h2:focus, main:focus { outline: none; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--primary); color: var(--on-primary);
  padding: 10px 16px; border-radius: 8px; text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 8px; }

/* Header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--primary); text-decoration: none; font-weight: 700; }
.brand-name { color: var(--text); font-size: 1.1rem; white-space: nowrap; }
.brand-mark { flex: none; }
@media (max-width: 380px) { .brand-name { font-size: 1rem; } .nav-link { padding: 10px 8px; } }
.nav-list { list-style: none; display: flex; gap: 2px; margin: 0; padding: 0; }
.nav-link {
  font: inherit; font-weight: 600; color: var(--primary); background: none; border: 0; cursor: pointer;
  padding: 10px 12px; min-height: 44px; border-radius: 10px; text-decoration: none; display: inline-flex; align-items: center;
}
.nav-link:hover { background: var(--surface-2); }
.site-footer { color: var(--muted); font-size: .9rem; padding: 18px 0 calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.site-footer p { margin: 0; }

.update-banner { background: var(--primary); color: var(--on-primary); }
.update-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; padding-bottom: 8px; }
.update-banner .btn { background: var(--on-primary); color: var(--primary); border-color: var(--on-primary); }

.resume { margin: 0 0 20px; }

/* Breadcrumbs */
.crumbs { margin: 0 0 14px; font-size: .95rem; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 0; padding: 0; }
.crumbs li + li::before { content: "›"; color: var(--muted); margin-right: 8px; }
.crumbs a { padding: 4px 0; }
.crumbs [aria-current] { color: var(--muted); }

/* Cards */
.cards { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .cards.grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.card {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px; min-height: 72px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card:hover { border-color: var(--primary); }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-title { font-weight: 700; font-size: 1.1rem; }
.card-meta { color: var(--muted); font-size: .95rem; }
.card-chev { color: var(--primary); font-size: 1.6rem; line-height: 1; }
.badge { display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-right: 6px; }
.badge.done { background: var(--ok-bg); color: var(--ok); }

.mode-card { flex-direction: column; align-items: flex-start; gap: 6px; padding: 20px; }
.mode-card .card-title { font-size: 1.25rem; }
.mode-demo { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }

/* Buttons */
.btn {
  font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 22px; border-radius: 12px; border: 2px solid var(--primary);
  background: var(--primary); color: var(--on-primary); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.secondary { background: transparent; color: var(--primary); }
.btn.secondary:hover { background: var(--surface-2); }
.btn-small { min-height: 40px; padding: 6px 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.actions .btn { flex: 1 1 160px; }
@media (min-width: 560px) { .actions .btn { flex: 0 1 auto; } }

/* Practice screen */
.progress-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; color: var(--muted); font-weight: 600; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }

.prompt-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); text-align: center; }
.prompt-label { color: var(--muted); font-weight: 600; margin: 0 0 6px; }
.prompt-word { font-size: clamp(2rem, 9vw, 3.2rem); font-weight: 750; line-height: 1.15; margin: 0; overflow-wrap: anywhere; }
.q-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 12px; color: var(--muted); }

/* Braille cells */
.cells {
  --cols: var(--cols-narrow, 3);
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, calc(var(--dot) * 2 + 10px + 12px)));
  justify-content: center; gap: 12px; margin: 22px 0 6px; padding: 0;
}
@media (min-width: 820px) { .cells { --cols: var(--cols-wide, 6); gap: 16px; } }
.cell-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.cell {
  width: 100%; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, auto); grid-auto-flow: column;
  gap: 6px; padding: 6px; border-radius: 16px; background: var(--surface-2); border: 2px solid var(--border);
  border-inline: 2px solid var(--border);
}
.cell.current { border-color: var(--primary); }
.cell.wrong { border-color: var(--bad); }
.cell.right { border-color: var(--ok); }
.cell-caption { font-size: .85rem; color: var(--muted); text-align: center; min-height: 1.2em; }
.dot {
  position: relative; width: 100%; max-width: var(--dot); aspect-ratio: 1; justify-self: center; border-radius: 50%; padding: 0; margin: 0;
  display: grid; place-items: center; font: inherit; font-weight: 700; font-size: clamp(.85rem, 3.4vw, 1.1rem);
  background: var(--surface); color: var(--muted); border: 2px solid var(--border-strong); touch-action: manipulation;
}
button.dot { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button.dot:hover:not([disabled]) { border-color: var(--primary); }
.dot[aria-pressed="true"], .dot.on { background: var(--dot-on); color: var(--on-dot); border-color: var(--dot-on); }
.dot.static { cursor: default; }
.dot.static:not(.on) { background: transparent; border-style: dashed; border-color: var(--border); color: transparent; }
.dot.static.on { color: transparent; }
.show-nums .dot.static { color: var(--muted); }
.show-nums .dot.static.on { color: var(--on-dot); }
.dot[disabled] { cursor: default; }
.dot[aria-pressed="true"]::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--dot-on); opacity: .25; }

.kb-entry { margin-top: 18px; }
.kb-entry label { display: block; font-weight: 600; margin-bottom: 6px; }
.kb-entry .hint { font-size: .92rem; color: var(--muted); margin: 6px 0 0; }
@media (hover: none) and (pointer: coarse) { .kb-entry { display: none; } }

.field { width: 100%; font: inherit; font-size: 1.25rem; padding: 12px 14px; min-height: 52px; border-radius: 12px; border: 2px solid var(--border-strong); background: var(--surface); color: var(--text); }
.field:focus-visible { outline-offset: 2px; border-color: var(--focus); }
.answer-field { margin-top: 20px; }
.answer-field label { display: block; font-weight: 700; margin-bottom: 6px; }

/* Multiple choice */
.choice-set { border: 0; margin: 0; padding: 0; min-width: 0; }
.choice-set legend { font-weight: 700; padding: 0; margin-bottom: 10px; }
/* One column on a phone; as many columns as fit on wider screens. Every choice in a row is the same height. */
.choice-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.choice-grid.compact { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); }
.choice {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px; cursor: pointer;
  font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; hyphens: auto;
  background: var(--surface); border: 2px solid var(--border-strong); border-radius: 12px; touch-action: manipulation;
}
.answer-field .choice { display: flex; margin-bottom: 0; }   /* beats the generic ".answer-field label" rule */
.choice:hover { border-color: var(--primary); }
.choice input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--primary); }
.choice.selected { border-color: var(--primary); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--primary); }
.choice:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice input:focus-visible { outline: none; }

/* Feedback */
.feedback { margin-top: 22px; padding: 18px 20px; border-radius: var(--radius); border: 2px solid; }
.feedback.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--text); }
.feedback.bad { background: var(--bad-bg); border-color: var(--bad); color: var(--text); }
.feedback h2 { margin: 0 0 6px; font-size: 1.35rem; }
.feedback.ok h2 { color: var(--ok); }
.feedback.bad h2 { color: var(--bad); }
.feedback p:last-child { margin-bottom: 0; }
.review { margin: 14px 0 0; padding-left: 1.2em; }
.compare { display: grid; gap: 18px; margin-top: 8px; }
@media (min-width: 820px) { .compare.two { grid-template-columns: 1fr 1fr; } }
.compare h3 { font-size: 1rem; margin: 0 0 4px; text-align: center; color: var(--muted); }
.compare .cells { margin-top: 6px; }

/* Results */
.score { font-size: clamp(2.4rem, 12vw, 3.6rem); font-weight: 800; margin: 0; line-height: 1.1; }
.missed { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.missed li { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.missed .cells { margin: 10px 0 0; }

/* Settings & help */
.setting { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.setting label { display: flex; align-items: flex-start; gap: 12px; font-weight: 600; cursor: pointer; }
.setting input[type="checkbox"] { width: 24px; height: 24px; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
.setting .hint { margin: 4px 0 0 36px; font-weight: 400; color: var(--muted); font-size: .95rem; }
.setting select { font: inherit; padding: 8px 10px; min-height: 44px; border-radius: 10px; border: 2px solid var(--border-strong); background: var(--surface); color: var(--text); margin-top: 6px; }
.setting .select-label { font-weight: 600; display: block; }
.help-demo { display: flex; justify-content: center; margin: 12px 0; }
.help-demo .cells { margin: 0; --cols: 1; }
kbd { font-family: ui-monospace, Consolas, monospace; font-size: .95em; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border-strong); }
.keymap { border-collapse: collapse; margin: 8px 0 16px; }
.keymap th, .keymap td { text-align: left; padding: 6px 18px 6px 0; border-bottom: 1px solid var(--border); }

@media (forced-colors: active) {
  .dot[aria-pressed="true"], .dot.on { background: Highlight; color: HighlightText; border-color: Highlight; forced-color-adjust: none; }
  .dot { border-color: ButtonText; }
  .cell.current { border-color: Highlight; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .card, .dot { transition: background-color .12s, border-color .12s; }
}
@media print { .site-header, .site-footer, .actions { display: none; } }
