/* Spanish Tutor — hand-written, mobile first.  No CDN, no build step.
   Ben mostly uses a phone: big tap targets, no hover-only affordances. */

:root {
  --bg: #fbf9f6;
  --surface: #ffffff;
  --surface-2: #f3efe9;
  --text: #22201d;
  --muted: #6b6560;
  --line: #e2dbd2;
  --accent: #b4462c;
  --on-accent: #fff;
  --accent-soft: #fdeee9;
  --ok: #2c6b45;
  --ok-soft: #e7f4ec;
  --warn: #8a6414;
  --warn-soft: #fbf1d9;
  --bad: #a32f22;
  --bad-soft: #fbe9e6;
  --radius: 14px;
  --tap: 48px;
  --wrap: 46rem;          /* a phone-width reading column, for the student */
}

/* The teacher reads dense tables on a laptop, not a phone.  Both the top bar and
   the page use var(--wrap), so widening it here widens the whole teacher side. */
body.wide { --wrap: 76rem; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --surface: #201f24;
    --surface-2: #2a282f;
    --text: #eceaf0;
    --muted: #a8a2ad;
    --line: #3a3742;
    --accent: #ef8a6b;
    --on-accent: #201209;
    --accent-soft: #3a2119;
    --ok: #7fd6a0;
    --ok-soft: #1d3629;
    --warn: #e2c27a;
    --warn-soft: #352c14;
    --bad: #f28d80;
    --bad-soft: #3a1e1b;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible,
select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 1rem 1rem 5rem; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: var(--wrap); margin: 0 auto; padding: .5rem 1rem;
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); margin-right: auto; }
.brand small { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); }
nav.main { display: flex; gap: .25rem; flex-wrap: wrap; }
nav.main a, nav.main button {
  display: inline-flex; align-items: center; min-height: 40px;
  padding: .25rem .6rem; border-radius: 999px; text-decoration: none;
  color: var(--text); font-size: .95rem;
}
nav.main a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.streak-chip {
  background: var(--warn-soft); color: var(--warn); border-radius: 999px;
  padding: .15rem .6rem; font-size: .85rem; font-weight: 600; white-space: nowrap;
}

/* ------------------------------------------------------------------ blocks */
h1 { font-size: 1.5rem; line-height: 1.25; margin: .2rem 0 .1rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 .5rem; }
h3 { font-size: 1.02rem; margin: 1.2rem 0 .4rem; }
.eyebrow { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; margin: 0; }
.lede { color: var(--muted); margin: .2rem 0 1rem; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; margin: .75rem 0;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card.done { border-color: var(--ok); background: var(--ok-soft); }
.card h2 { display: flex; align-items: center; gap: .5rem; margin: 0 0 .35rem; font-size: 1.08rem; }
.card .meta { color: var(--muted); font-size: .9rem; }

.tag {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted);
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

/* ----------------------------------------------------------------- buttons */
.btn, button, input[type="submit"] {
  font: inherit; font-weight: 600;
  min-height: var(--tap); padding: .6rem 1.1rem;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.ghost, button.ghost { background: transparent; }
.btn.small, button.small { min-height: 38px; padding: .3rem .7rem; font-size: .9rem; }
.btn.wide { width: 100%; }
button[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .75rem; }

/* ------------------------------------------------------------------ forms */
label { display: block; font-weight: 600; margin: .9rem 0 .3rem; }
label.inline { display: flex; align-items: center; gap: .6rem; font-weight: 500; min-height: var(--tap); }
input[type="text"], input[type="password"], input[type="date"], input[type="number"],
input[type="search"], textarea, select {
  font: inherit; width: 100%; padding: .65rem .7rem; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
textarea { min-height: 9rem; line-height: 1.5; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; accent-color: var(--accent); }
.hint { color: var(--muted); font-size: .9rem; }
.error {
  background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad);
  border-radius: 10px; padding: .6rem .8rem; margin: .75rem 0;
}
.notice {
  background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok);
  border-radius: 10px; padding: .6rem .8rem; margin: .75rem 0;
}

/* --------------------------------------------------------------- exercises */
.prompt { font-size: 1.15rem; line-height: 2.1; margin: .5rem 0 1rem; }
input.blank {
  display: inline-block; width: 8.5rem; min-height: 44px; margin: 0 .15rem;
  padding: .25rem .5rem; text-align: center;
  border: 0; border-bottom: 2px solid var(--accent); border-radius: 6px 6px 0 0;
  background: var(--accent-soft); font-size: 1.05rem;
}
input.blank.wide { display: block; width: 100%; text-align: left; margin: .6rem 0; }
input.blank.right { border: 2px solid var(--ok); background: var(--ok-soft); }
input.blank.wrong { border: 2px solid var(--bad); background: var(--bad-soft); }
.blank-slot { color: var(--accent); font-weight: 700; letter-spacing: .05em; }
.choices { display: grid; gap: .5rem; margin: .5rem 0; }
.choice {
  display: flex; align-items: center; gap: .7rem; min-height: var(--tap);
  padding: .5rem .8rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); font-weight: 500; cursor: pointer;
}
.choice.picked { border-color: var(--accent); background: var(--accent-soft); }
.choice.right { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }

.feedback { border-radius: var(--radius); padding: .9rem 1rem; margin: 1rem 0; border: 1px solid; }
.feedback.right { background: var(--ok-soft); border-color: var(--ok); }
.feedback.wrong { background: var(--bad-soft); border-color: var(--bad); }
.feedback.flag { background: var(--warn-soft); border-color: var(--warn); }
.feedback.review { background: var(--surface-2); border-color: var(--line); }
.feedback h2 { margin: 0 0 .3rem; font-size: 1.05rem; }
.feedback .answer { font-size: 1.1rem; font-weight: 700; }
.progressbar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: .5rem 0 1rem; }
.progressbar > span { display: block; height: 100%; background: var(--accent); }

/* ------------------------------------------------------------------ tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: .5rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:nth-child(odd) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.prose table { margin: 1rem 0; }
.prose th, .prose td { white-space: nowrap; }
.prose { overflow-wrap: break-word; }
.prose ul { padding-left: 1.2rem; }
.prose code { background: var(--surface-2); padding: .1rem .3rem; border-radius: 6px; }

/* ------------------------------------------------------------------- lists */
.stack { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.row {
  display: flex; gap: .75rem; align-items: center; justify-content: space-between;
  padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); text-decoration: none; color: inherit; min-height: var(--tap);
}
.row .grow { flex: 1; min-width: 0; }
.row small { color: var(--muted); display: block; }
.calendar { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; margin: .5rem 0 1rem; }
.calendar .cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  font-size: .85rem; font-weight: 600; color: var(--muted); text-decoration: none;
}
.calendar .cell.done { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.calendar .cell.locked { opacity: .4; }
.calendar .cell.current { outline: 2px solid var(--accent); }

.bar { background: var(--surface-2); border-radius: 999px; height: 10px; min-width: 70px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); }
.bar.low > span { background: var(--bad); }
.bar.mid > span { background: var(--warn); }

audio { width: 100%; margin: .4rem 0; }
.recorder { text-align: center; padding: 1rem 0; }
.recorder .timer { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.recorder .state { color: var(--muted); min-height: 1.5rem; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--bad); display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  .recording .rec-dot { animation: pulse 1.2s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: .25; } }

details.help { border: 1px solid var(--line); border-radius: 12px; padding: .6rem .8rem; margin: .6rem 0; background: var(--surface); }
details.help summary { font-weight: 600; cursor: pointer; min-height: 36px; display: flex; align-items: center; }

footer.foot { color: var(--muted); font-size: .85rem; text-align: center; padding: 2rem 1rem; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 1rem; top: .5rem; background: var(--surface); padding: .5rem .8rem; border-radius: 8px; z-index: 50; }
.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;
}

@media (min-width: 40rem) {
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
  .calendar { grid-template-columns: repeat(10, 1fr); }
}

/* Laptop first (CLAUDE.md §3).  Ben works on a MacBook, so a day's four blocks sit
   side by side instead of stacking into a long scroll, and a conjugation table fits
   on screen without swiping. */
@media (min-width: 60rem) {
  body:not(.wide) { --wrap: 64rem; }
  .blocks {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem; align-items: start;
  }
  .blocks > .card { margin: 0; }
  .stack.two-col { grid-template-columns: 1fr 1fr; }
}

/* A trackpad doesn't need thumb-sized controls; a touch screen still does. */
@media (pointer: fine) {
  :root { --tap: 40px; }
}

/* Lesson prose keeps a readable measure on a wide screen — but the tables inside it,
   which are the point of most lessons, are free to use the whole column. */
.prose p, .prose ul, .prose ol, .prose blockquote { max-width: 46rem; }
