/* public_html/assets/css/pages.css
 *
 * WHY (step 4.2): component and view styling for the SPA shell — cards, the
 * course/chapter lists, access badges, forms (login/register/onboarding),
 * notices, and buttons. site.css supplies tokens + the header/main/footer
 * shell and the a11y primitives; this file styles what the router renders into
 * <main>. It REPLACES the disposable step-1.6 placeholder styles.
 *
 * HOW: plain CSS, token-driven (var(--*) from site.css). Selector specificity
 * is kept flat (single classes) so rules don't silently cancel each other out.
 */

/* ======================================================================
 * View scaffolding
 * ==================================================================== */

/* An "eyebrow": a small-caps, letter-spaced label above a heading. This is the
 * restrained scholarly accent (brief §11.6) — it encodes the section's kind
 * (e.g. "Course", "Chapter"), not mere decoration. */
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--fs-eyebrow);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 .35rem;
}

.lead { color: var(--muted); font-size: 1.05rem; max-width: 46rem; }

/* A neutral card surface for grouped content. */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
}

/* The narrower column used by auth/onboarding forms. */
.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.5rem 1.6rem;
  max-width: 30rem;
}

.muted { color: var(--muted); }
.stack > * + * { margin-top: 1rem; }   /* vertical rhythm helper */

/* ======================================================================
 * Catalog: language → course → chapter lists
 * ==================================================================== */

.lang-group { margin: 0 0 2rem; }
.lang-group__name { margin-top: 0; }

/* A list of courses or chapters. Each item is a card-like link block. We use a
 * real <ul>/<li> with an <a> inside so it is a navigable list to a screen
 * reader and keyboard-operable for free. */
.tile-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  text-decoration: none;
  color: var(--ink);
}
.tile:hover { border-color: var(--accent); background: var(--accent-tint); color: var(--ink); }
.tile__title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.tile__meta  { color: var(--muted); font-size: var(--fs-small); margin-top: .2rem; }
.tile__row   { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }

/* A "locked" tile is rendered as a non-link block (no destination) so keyboard
 * users don't tab onto a dead control; the badge explains why. */
.tile.is-locked { background: var(--page); border-style: dashed; cursor: default; }
.tile.is-locked:hover { border-color: var(--hairline); background: var(--page); }

/* ======================================================================
 * Access badges (free / premium / licensed / locked)
 * Colour PLUS a word — never colour alone.
 * ==================================================================== */
.badge {
  display: inline-block;
  font-size: var(--fs-eyebrow);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .12rem .5rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  vertical-align: middle;
}
.badge--free     { color: var(--ok);   background: var(--ok-bg); }
.badge--premium  { color: var(--warn); background: var(--warn-bg); }
.badge--licensed { color: var(--accent); background: var(--accent-tint); }
.badge--locked   { color: var(--muted); background: var(--page); }

/* ======================================================================
 * Forms (login / register / onboarding)
 * ==================================================================== */
.field { margin: 0 0 1.1rem; }
.field > label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  padding: .55rem .65rem;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface);
  color: var(--ink);
}
/* An input flagged invalid gets a red border AND is wired via aria-describedby
 * to its .field-error (set in JS), so the error is announced and associated —
 * not signalled by colour alone. */
.field input[aria-invalid="true"] { border-color: var(--bad); }
.field-hint  { color: var(--muted); font-size: var(--fs-small); margin-top: .25rem; }
.field-error {
  color: var(--bad);
  font-size: var(--fs-small);
  margin-top: .3rem;
  display: none;            /* shown by adding .is-shown in JS */
}
.field-error.is-shown { display: block; }

/* A grid of selectable chips for multi-select choices (study goals). Each chip
 * is a real <label> wrapping a checkbox, so it is keyboard-operable and the
 * checked state is conveyed natively. */
.chip-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .4rem .7rem;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}
.chip input { margin: 0; }
/* :has lets the chip reflect its checkbox state without JS; where unsupported
 * the checkbox itself still shows state, so this is purely an enhancement. */
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); color: var(--accent-strong); }
.chip:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.consent { font-size: var(--fs-small); color: var(--muted); margin: 1rem 0; display: flex; gap: .5rem; }
.consent input { margin-top: .15rem; }

/* ======================================================================
 * Buttons
 * ==================================================================== */
.btn {
  font: inherit;
  display: inline-block;
  padding: .55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-strong); color: #fff; }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--hairline-strong); }
.btn--secondary:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }

/* ======================================================================
 * Notices / messages / inline status
 * role="status" or role="alert" is set in markup; these just style it.
 * ==================================================================== */
.notice {
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  margin: 1rem 0;
  background: var(--accent-tint);
}
.notice--warn { background: var(--warn-bg); border-color: #ead9b0; }
.notice--bad  { background: var(--bad-bg);  border-color: #eccccc; }

.form-msg { margin: 1rem 0 0; min-height: 1.3em; }
.form-msg.is-ok  { color: var(--ok); }
.form-msg.is-bad { color: var(--bad); }

/* The empty/placeholder state for a stub chapter or an empty list — an
 * invitation, not an apology (per design copy guidance). */
.empty {
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: var(--muted);
  text-align: center;
}

/* A simple definition-style list for chapter "at a glance" facts. */
.facts { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Monospace inline for content keys shown in dev/scholarly contexts. */
.code { font-family: var(--font-mono); font-size: .9em; }

/* A read-only rendering of chapter prose sections (4.3 turns these interactive). */
.section-block { margin: 0 0 1.25rem; }
.section-block h3 { margin-top: 0; }

/* Back link above a detail view. */
.back-link { display: inline-block; margin-bottom: 1rem; font-size: var(--fs-small); }

/* Wider layout breathing room on small screens. */
@media (max-width: 36rem) {
  .site-main { padding: 1.25rem 1rem 2.5rem; }
  .panel { padding: 1.25rem; }
}

/* ── Recall ("Review") activity (4.3) ────────────────────────────────────
   The card is deliberately calm: a large prompt, a reveal, then the rating
   row. The answer side uses the accent tint so the reveal reads as a state
   change without relying on colour alone (it also moves focus). */
.recall-prompt {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  line-height: 1.15;
  margin: .25rem 0 1rem;
}
.recall-answer {
  border-left: 3px solid var(--accent);
  background: var(--accent-tint);
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  margin: .25rem 0 1rem;
}
.recall-answer__text {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  margin: .15rem 0 0;
}
/* The keyboard-shortcut hint sits quietly beneath the controls. */
.recall-hint { font-size: var(--fs-small); margin: .5rem 0 0; }
/* An inline retry notice keeps the card visible (see renderInlineNotice). */
.recall-notice { margin-top: 1rem; }

/* ======================================================================
 * Standalone pages (.page) — privacy, terms, and the help pages (11.3).
 * These documents are a single <main class="card page"> with no app shell,
 * so unlike the SPA's <main> they had no width cap or centring and ran
 * edge-to-edge. Give them a comfortable, centred reading column. Class-scoped
 * to `.page`, so SPA views (which never carry the class) are untouched.
 * ==================================================================== */
.page {
  max-width: 44rem;        /* a touch narrower than --maxw: prose, not app chrome */
  margin: 2rem auto;
}
.page > h1 { margin-top: .25rem; }
.page h2 { margin-top: 1.6rem; }   /* breathing room between help sections */

/* ======================================================================
 * Registration prompt modal + catalog "sample" link (step 13.1)
 * A lightweight dialog shown after an anonymous visitor reads a public sample.
 * Built from design tokens; honours prefers-reduced-motion via the global rule
 * in site.css (the fade is a plain opacity transition that rule disables).
 * ==================================================================== */
.modal__backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(27, 31, 36, .45);   /* --ink at low alpha */
}
.modal__card {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
  border-top: 3px solid var(--gold);   /* the same quiet signature as the header */
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(27, 31, 36, .18);
  max-width: 30rem;
  width: 100%;
  padding: 1.5rem 1.5rem 1.25rem;
}
.modal__card h2 { margin-top: 0; }
.modal__card .btn-row { margin-top: 1.25rem; }

/* The quiet "Try the sample →" link under a course tile in the catalog. Not a
 * button — a low-key text affordance so it never competes with the tile. */
.tile-sample-link {
  display: inline-block;
  margin: .35rem 0 .25rem .15rem;
  font-size: var(--fs-small);
  color: var(--accent);
  text-decoration: none;
}
.tile-sample-link:hover { color: var(--accent-strong); text-decoration: underline; }

/* ======================================================================
 * Exercise player (step 13.5)
 * Reuses .panel/.btn/.notice/.chip; these rules only add the option layout,
 * the right/wrong states, and the answer inputs. Color states pair a border
 * change WITH the existing ok/bad notice text, so color is never the only
 * signal (a11y 11.1 discipline).
 * ==================================================================== */
.ex-card .ex-prompt { font-size: 1.06rem; }

.ex-options {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: stretch;
  max-width: 28rem;
}
.ex-option { text-align: left; }
.ex-option--right {
  border-color: var(--ok, #2e7d32);
  box-shadow: inset 3px 0 0 var(--ok, #2e7d32);
}
.ex-option--wrong {
  border-color: var(--bad, #b3261e);
  box-shadow: inset 3px 0 0 var(--bad, #b3261e);
}

/* parse-drill checkboxes: comfortable touch targets, one per line */
.ex-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .6rem;
  border: 1px solid var(--hairline, #d9d5cc);
  border-radius: var(--radius, 6px);
  cursor: pointer;
}
.ex-check input { margin: 0; }

.ex-input {
  font: inherit;
  padding: .5rem .65rem;
  border: 1px solid var(--hairline-strong, #b9b3a6);
  border-radius: var(--radius, 6px);
  min-width: 14rem;
  flex: 1 1 14rem;
}
textarea.ex-input { width: 100%; resize: vertical; }

.ex-feedback { margin-top: .75rem; }
