/* Academy — base stylesheet
   See docs/brandbook.md for the design system this implements.
   Plain CSS, no build step, no external font/CDN dependency. */

:root {
  /* Color — light theme (default) */
  --color-bg: #faf8f5;
  --color-surface: #ffffff;
  --color-surface-raised: #faf8f5;
  --color-ink: #1c1a17;
  --color-ink-muted: #5c574e;
  --color-border: #e8e2d8;
  --color-accent: #8a5a35;
  --color-accent-hover: #6e4629;
  --color-optional: #7a6b8f;
  --color-focus-ring: rgba(138, 90, 53, 0.55);

  /* Typography */
  --font-heading: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;

  /* Base font-size scale (controlled by the A-/A+ control via
     [data-font-size] on <html>; --fs-* below are derived from this so the
     whole type scale rescales together, not just body text). */
  --fs-scale: 1;
  --fs-sm: calc(0.875rem * var(--fs-scale));
  --fs-base: calc(1.0625rem * var(--fs-scale));
  --fs-lg: calc(1.25rem * var(--fs-scale));
  --fs-xl: calc(1.75rem * var(--fs-scale));
  --fs-2xl: calc(2.25rem * var(--fs-scale));
  --fs-3xl: calc(2.75rem * var(--fs-scale));

  /* Spacing (8px base unit) */
  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --space-7: 4rem;
  --space-8: 5rem;

  --radius-sm: 4px;
  --measure: 68ch;
}

/* ---------- Theme system ----------
   Three states, set via data-theme="auto|light|dark" on <html> (server-
   rendered from the user's saved preference, no flash-of-wrong-theme).
   "auto" has no explicit override block below — it simply falls through to
   the prefers-color-scheme media query further down. "light" is the :root
   default above. "dark" is explicit so it applies regardless of OS setting. */

[data-theme="dark"] {
  --color-bg: #171512;
  --color-surface: #211e1a;
  --color-surface-raised: #2b271f;
  --color-ink: #f2ede4;
  --color-ink-muted: #b3aa9c;
  --color-border: #3a352d;
  --color-accent: #d8a878;
  --color-accent-hover: #eec095;
  --color-optional: #b3a4cf;
  --color-focus-ring: rgba(216, 168, 120, 0.6);
}

/* "auto" (or no data-theme attribute at all, e.g. JS-disabled fallback):
   follow the OS-level preference. Scoped so it never fights an explicit
   data-theme="light" choice. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) {
    --color-bg: #171512;
    --color-surface: #211e1a;
    --color-surface-raised: #2b271f;
    --color-ink: #f2ede4;
    --color-ink-muted: #b3aa9c;
    --color-border: #3a352d;
    --color-accent: #d8a878;
    --color-accent-hover: #eec095;
    --color-optional: #b3a4cf;
    --color-focus-ring: rgba(216, 168, 120, 0.6);
  }
}

* {
  box-sizing: border-box;
}

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

html[data-theme="dark"] {
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
  }
}

/* Font-size control: three steps, cycled by the A-/A+ control, persisted
   server-side (theme_preference/font_size_preference on the user) and
   applied here on <html> so it scales the whole type system via
   --fs-scale above. Default (no attribute, or "medium") is 1. */
html[data-font-size="small"] { --fs-scale: 0.9; }
html[data-font-size="large"] { --fs-scale: 1.15; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s ease, color 0.15s ease;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  line-height: 1.25;
  margin: 0 0 var(--space-3);
  color: var(--color-ink);
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }

p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Layout shell ---------- */

.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.site-header__inner {
  max-width: 46rem;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.site-header__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ---------- Preference controls (theme + font size) ----------
   Present in the header on every logged-in template. Buttons rather than a
   <select> so state is visible at a glance and touch targets stay large.
   Preferences persist to the user's account via PATCH /api/preferences
   (see static/js/preferences.js) — never localStorage-only, so they follow
   the user across devices. */

.pref-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pref-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.pref-btn {
  appearance: none;
  border: none;
  background: var(--color-surface);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  line-height: 1;
  cursor: pointer;
  padding: 0.55rem 0.7rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--color-border);
}

.pref-group .pref-btn:last-child {
  border-right: none;
}

.pref-btn:hover {
  background: var(--color-bg);
  color: var(--color-accent);
  text-decoration: none;
}

.pref-btn[aria-pressed="true"] {
  background: var(--color-accent);
  color: var(--color-surface);
}

.pref-btn[aria-pressed="true"]:hover {
  color: var(--color-surface);
}

.pref-btn--font-small { font-size: 0.8em; }
.pref-btn--font-large { font-size: 1.15em; }

.theme-toggle {
  appearance: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  cursor: pointer;
  padding: 0.55rem 0.75rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.theme-toggle:hover {
  background: var(--color-bg);
  color: var(--color-accent);
}

.theme-toggle__icon {
  font-size: 1em;
  line-height: 1;
}

/* ---------- Header brand lockup (compact) ----------
   Simplified per client feedback ("you don't have to have the logo AND the
   text" — redundant brand elements read as busy). The header's job is
   navigation, not a hero/brand moment, so this is now just the real logo
   (no chip hack — sits on the header's own --color-surface pill so the
   white-fill SVG stays legible in both themes without a mismatched light
   box) plus the "Academy" wordmark once. No kicker text here — the kicker
   text lived redundantly next to the logo in the old lockup; the logo
   itself is now the Iron Mind AI signal, "Academy" is the product name. */
.site-header__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
}

.site-header__brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-ink);
  border-radius: var(--radius-sm);
  padding: 0.35em 0.55em;
  line-height: 0;
}

[data-theme="dark"] .site-header__brand-mark {
  /* Same fixed-dark-backdrop exception as the auth hero panel — see that
     section below for the full rationale. Kept intentionally small/quiet
     here since this is a nav element, not a brand moment. */
  background: #1c1a17;
}

.site-header__brand-mark img {
  display: block;
  height: 0.85rem;
  width: auto;
}

.site-header__brand-name {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--color-ink);
}

.site-header__brand:hover .site-header__brand-name {
  color: var(--color-accent);
}

/* ---------- Forms & buttons (signup) ---------- */

.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-ink);
  margin-bottom: var(--space-1);
}

/* De-emphasized label variant for optional fields (e.g. signup extras:
   company/linkedin_url/social_url) — lighter weight + muted color than
   required-field labels, paired with an explicit "(optional)" text suffix
   so the optional/required distinction is never color-only. Keeps optional
   fields from reading as "job application" weight next to name/email. */
.form-label--optional {
  font-weight: 400;
  color: var(--color-ink-muted);
}

.form-label__hint {
  font-weight: 400;
  color: var(--color-ink-muted);
}

/* Optional-fields group (company/linkedin/social on signup.html) — extra
   top spacing + a hairline rule separates it from the required name/email
   block above, so the required fields read as "the actual form" and the
   optional block reads as a lower-friction, skippable add-on beneath it. */
.form-fieldset--optional {
  border: 0;
  padding: var(--space-3) 0 0;
  margin: var(--space-2) 0 0;
  border-top: 1px solid var(--color-border);
  min-width: 0;
}

.form-fieldset--optional legend {
  display: none;
}

.form-fieldset--optional .form-input {
  min-height: 2.5rem;
}

.form-input {
  display: block;
  width: 100%;
  max-width: 24rem;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--color-ink);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-2);
  margin-bottom: var(--space-3);
  min-height: 2.75rem;
}

.form-input:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 1px;
  border-color: var(--color-accent);
}

.form-error {
  color: #b3261e;
  font-size: var(--fs-sm);
  margin-bottom: var(--space-3);
}

[data-theme="dark"] .form-error {
  color: #ff8a80;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  min-height: 2.75rem;
}

.btn--primary {
  background: var(--color-accent);
  color: var(--color-surface);
}

.btn--primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

.signup-form {
  max-width: 24rem;
}

.site-header__meta {
  font-size: var(--fs-sm);
  color: var(--color-ink-muted);
}

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-8);
}

/* ---------- TOC / chapters list ---------- */

.page-intro {
  margin-bottom: var(--space-6);
}

.page-intro p {
  color: var(--color-ink-muted);
  max-width: var(--measure);
}

.act-group {
  margin-bottom: var(--space-6);
}

.act-label {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-2);
}

.act-label__num {
  color: var(--color-accent);
  font-weight: 700;
}

.act-label--optional .act-label__num {
  color: var(--color-optional);
}

.act-label__badge {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--color-optional);
  text-transform: none;
  letter-spacing: normal;
  border: 1px solid var(--color-optional);
  border-radius: var(--radius-sm);
  padding: 0.05rem 0.4rem;
}

.act-label__progress {
  margin-left: auto;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--color-ink-muted);
}

.overall-progress {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.overall-progress__bar {
  flex: 1 1 auto;
  max-width: 20rem;
  height: 0.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.overall-progress__fill {
  height: 100%;
  background: var(--color-accent);
}

.overall-progress__label {
  font-size: var(--fs-sm);
  color: var(--color-ink-muted);
  white-space: nowrap;
}

/* ---------- Continue reading card (resume-where-left-off) ----------
   course-ui.md item #12. Prominent callout above the act-group list, not
   just another list row — reuses .chapter-link for the inner link markup
   (title styling stays consistent with the rest of the TOC) but the outer
   .continue-reading-card wrapper gives it CTA-level visual weight: tinted
   surface, accent-colored left border (same "callout" language as
   .core-idea/.predict-reveal on the chapter detail page), and a small
   uppercase eyebrow label so it reads as "pick up where you left off"
   rather than a regular chapter entry. */

.continue-reading-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-4);
  margin-bottom: var(--space-6);
}

.continue-reading-card .chapter-link {
  border-bottom: none;
  padding: var(--space-3) var(--space-1);
  gap: var(--space-2);
}

.continue-reading-card .chapter-link:hover {
  background: transparent;
}

.continue-reading-card .chapter-link .chapter-link__title {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  color: var(--color-ink);
}

.continue-reading-card .chapter-link:hover .chapter-link__title {
  color: var(--color-accent);
}

.continue-reading-card__label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-accent);
  margin-bottom: 0.2rem;
}

.chapter-link__check {
  flex: 0 0 auto;
  color: var(--color-accent);
  font-weight: 700;
}

.chapter-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chapter-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-1);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-ink);
  text-decoration: none;
}

.chapter-link:hover {
  color: var(--color-accent);
  text-decoration: none;
  background: var(--color-surface);
}

.chapter-link__title {
  flex: 1 1 auto;
  font-size: var(--fs-base);
}

.status-pill {
  flex: 0 0 auto;
  font-size: var(--fs-sm);
  color: var(--color-ink-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.5rem;
  white-space: nowrap;
}

.status-pill--published {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* ---------- Chapter detail ---------- */

.chapter-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4em;
  font-size: var(--fs-sm);
  color: var(--color-ink-muted);
  margin-bottom: var(--space-2);
}

.chapter-meta__sep {
  color: var(--color-border);
}

.reading-time {
  color: var(--color-ink-muted);
}

.chapter-header {
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.core-idea {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-5) 0;
}

.core-idea h2 {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-muted);
  margin-bottom: var(--space-1);
}

.core-idea .prose {
  margin: 0;
}

.prose {
  max-width: var(--measure);
  font-size: var(--fs-base);
  line-height: 1.7;
}

.prose p {
  margin: 0 0 var(--space-4);
}

.prose h2, .prose h3 {
  margin-top: var(--space-6);
}

.last-updated {
  color: var(--color-ink-muted);
}

/* ---------- Jargon-collision callout ----------
   Collapsible <details>/<summary> flagging terms that mean something
   different in this chapter than readers may expect elsewhere. Styled as a
   distinct callout (left accent + tinted surface), same visual language as
   .core-idea but using --color-optional so it reads as "heads up" rather
   than "primary takeaway". */

.jargon-collision {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-optional);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-5) 0;
}

.jargon-collision__summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--color-optional);
  list-style: none;
}

.jargon-collision__summary::-webkit-details-marker {
  display: none;
}

.jargon-collision__summary::before {
  content: "\25B8"; /* ▸ */
  display: inline-block;
  margin-right: 0.4em;
  transition: transform 0.15s ease;
}

.jargon-collision[open] .jargon-collision__summary::before {
  transform: rotate(90deg);
}

.jargon-collision__note {
  margin: var(--space-3) 0 0;
  max-width: var(--measure);
  color: var(--color-ink);
}

/* ---------- Predict-then-reveal ----------
   Primes the reader before the main body. Same card language as
   .core-idea/.jargon-collision but with an accent-colored border to signal
   "do this before reading on". */

.predict-reveal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-5) 0;
}

.predict-reveal__label {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-muted);
  margin-bottom: var(--space-1);
}

.predict-reveal__prompt {
  max-width: var(--measure);
}

.predict-reveal__answer {
  max-width: var(--measure);
  margin: var(--space-3) 0 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

/* ---------- Chapter diagrams ----------
   Static inline SVGs authored as trusted content in course.yaml. Wrapped in
   <figure> for semantic correctness; the SVG itself scales responsively
   since it ships with a viewBox but no fixed pixel dimensions. */

.chapter-diagrams {
  margin: var(--space-6) 0;
}

.diagram {
  margin: 0 0 var(--space-6);
}

.diagram__title {
  font-size: var(--fs-lg);
  margin-bottom: var(--space-2);
}

.diagram__svg-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
}

.diagram__svg-wrap svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.diagram__caption {
  font-size: var(--fs-sm);
  color: var(--color-ink-muted);
  margin-top: var(--space-2);
  max-width: var(--measure);
}

/* ---------- Chapter quiz ----------
   Multiple choice, immediate feedback, no pass/fail, no submit-and-lock
   (course-ui.md Phase 4, items #8/#9). Each question is a native
   <fieldset>/<legend> radio group — no custom ARIA roles needed since the
   native semantics already cover grouping/labeling. Selecting an option
   immediately reveals feedback via JS (see chapter-interactive.js); the
   learner can change their answer at any time, indefinitely — inputs are
   never disabled and there is no scoring/percentage anywhere in this
   block. Correct/incorrect states reuse the same red as .form-error (the
   documented error-semantics exception to the core palette) plus a
   matching green, both paired with a ::before glyph and a text label so
   nothing is color-only. */

.chapter-quiz {
  margin: var(--space-7) 0;
}

.chapter-quiz__heading {
  margin-bottom: var(--space-4);
}

.quiz-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  margin: 0 0 var(--space-5);
  /* <fieldset> has a UA-default min-inline-size: min-content (unlike a
     plain <div>, which defaults to min-width: auto/0 in a block context).
     That special sizing rule is the actual root cause of the mobile
     horizontal-scroll bug: a long <legend>/question or answer string could
     hold the fieldset open wider than the viewport instead of wrapping.
     Overriding min-width to 0 restores normal shrink-to-fit behavior. */
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.quiz-item__question {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  line-height: 1.4;
  color: var(--color-ink);
  padding: 0;
  max-width: var(--measure);
  /* <legend> gets the same special UA sizing treatment as its parent
     fieldset in some browsers; force it to wrap and respect the container
     width rather than sizing to its longest unbroken run of text. */
  width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

.quiz-item__options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
  min-width: 0;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  /* Prevent the row from growing past its container when the label text
     below can't otherwise shrink (flex items default to min-width: auto,
     which ignores the parent's width when content has no wrap opportunity). */
  min-width: 0;
  box-sizing: border-box;
}

.quiz-option__input {
  /* Native radio, kept visible (not visually-hidden) — this is a reading
     course, not a form-heavy product; the default control is legible and
     touch-friendly, in keeping with "no icon dependency" elsewhere. */
  margin-top: 0.35em;
  min-width: 1.15rem;
  min-height: 1.15rem;
  flex-shrink: 0;
}

.quiz-option__label {
  font-size: var(--fs-base);
  color: var(--color-ink);
  cursor: pointer;
  padding: 0.15em 0;
  /* Comfortable tap target on touch devices without changing visual
     density on desktop. */
  min-height: 1.5rem;
  /* Flex-item default min-width is `auto`, which lets long unbreakable
     answer text (URLs, code identifiers, etc.) force this label — and
     therefore .quiz-option/.quiz-item/the page — wider than the viewport.
     min-width: 0 + wrap rules let it shrink to the container and wrap
     normally instead, which was the direct cause of the mobile horizontal
     scroll indicator. */
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: break-word;
  word-break: break-word;
}

.quiz-option--correct {
  border-color: #2e7d32;
  background: rgba(46, 125, 50, 0.08);
}

.quiz-option--correct .quiz-option__label::after {
  content: " \2713 Correct"; /* ✓ Correct */
  font-weight: 600;
  color: #2e7d32;
}

.quiz-option--incorrect {
  border-color: #b3261e;
  background: rgba(179, 38, 30, 0.08);
}

.quiz-option--incorrect .quiz-option__label::after {
  content: " \2715 Not quite"; /* ✕ Not quite */
  font-weight: 600;
  color: #b3261e;
}

[data-theme="dark"] .quiz-option--correct {
  border-color: #7fd88a;
  background: rgba(127, 216, 138, 0.12);
}

[data-theme="dark"] .quiz-option--correct .quiz-option__label::after {
  color: #7fd88a;
}

[data-theme="dark"] .quiz-option--incorrect {
  border-color: #ff8a80;
  background: rgba(255, 138, 128, 0.12);
}

[data-theme="dark"] .quiz-option--incorrect .quiz-option__label::after {
  color: #ff8a80;
}

.quiz-item__feedback {
  margin: var(--space-3) 0 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  max-width: var(--measure);
  font-size: var(--fs-sm);
  color: var(--color-ink-muted);
}

.quiz-item__feedback:empty {
  display: none;
}

.quiz-item__feedback--correct {
  color: #2e7d32;
}

.quiz-item__feedback--incorrect {
  color: #b3261e;
}

[data-theme="dark"] .quiz-item__feedback--correct {
  color: #7fd88a;
}

[data-theme="dark"] .quiz-item__feedback--incorrect {
  color: #ff8a80;
}

.chapter-nav {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-7);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.chapter-nav__link {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  color: var(--color-ink);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
}

.chapter-nav__link:hover {
  background: var(--color-surface);
  text-decoration: none;
  color: var(--color-accent);
}

.chapter-nav__link--next {
  text-align: right;
  align-items: flex-end;
}

.chapter-nav__label {
  font-size: var(--fs-sm);
  color: var(--color-ink-muted);
}

.chapter-nav__title {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
}

.chapter-nav__toc {
  text-align: center;
  margin-top: var(--space-5);
}

/* ---------- Certificate link (chapters list, 100% complete) ----------
   course-ui.md item #13/14. Small polished callout shown only at
   overall_pct == 100, same "flat card, accent left border" callout
   language as .continue-reading-card, but sits inline in .page-intro (a
   single line, not a full card row) since it's a secondary CTA rather than
   the primary "what to read next" prompt. */

.certificate-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  margin-top: var(--space-3);
  font-size: var(--fs-sm);
}

.certificate-link__icon {
  font-size: 1.1em;
  line-height: 1;
}

.certificate-link a {
  font-weight: 600;
}

/* ---------- Certificate of completion (public, shareable page) ----------
   course-ui.md item #13/14, GET /certificate/{user_id}. No-auth, public
   page meant to be linked/screenshotted (e.g. LinkedIn) — deliberately
   more "designed object" than the rest of the reader UI, but still built
   entirely from existing tokens (color/spacing/type) so it stays on-brand
   and inherits dark mode automatically. Centered card with a double rule
   and generous padding reads as a formal certificate without resorting to
   gradients, drop shadows, or imagery. */

.certificate-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: var(--space-6);
}

.certificate {
  width: 100%;
  max-width: 40rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-7) var(--space-6);
  text-align: center;
  position: relative;
}

.certificate::before {
  content: "";
  position: absolute;
  inset: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.certificate__mark {
  font-size: var(--fs-2xl);
  margin: 0 0 var(--space-2);
  line-height: 1;
}

.certificate__kicker {
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}

.certificate__heading {
  font-size: var(--fs-2xl);
  margin-bottom: var(--space-4);
}

.certificate__rule {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-4) auto;
  max-width: 12rem;
}

.certificate__eyebrow {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-muted);
  margin-bottom: var(--space-1);
}

.certificate__name {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  color: var(--color-ink);
  margin-bottom: var(--space-3);
}

.certificate__body {
  max-width: var(--measure);
  margin: 0 auto var(--space-2);
  color: var(--color-ink);
}

.certificate__stats {
  display: flex;
  justify-content: center;
  gap: var(--space-7);
  margin: var(--space-5) 0 var(--space-2);
}

.certificate__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.certificate__stat dt {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-muted);
  margin-bottom: 0.2rem;
}

.certificate__stat dd {
  font-family: var(--font-heading);
  font-size: var(--fs-2xl);
  color: var(--color-accent);
  margin: 0;
}

.certificate__footer {
  font-size: var(--fs-sm);
  color: var(--color-ink-muted);
  margin: 0;
}

.certificate__url {
  word-break: break-all;
}

.certificate-page__note {
  font-size: var(--fs-sm);
  color: var(--color-ink-muted);
  text-align: center;
  max-width: 30rem;
  margin-top: var(--space-4);
}

@media (max-width: 40rem) {
  .certificate {
    padding: var(--space-5) var(--space-4);
  }

  .certificate__stats {
    gap: var(--space-5);
  }
}

/* ---------- Auth flow (signup / check-email / verify-failed) ----------
   REDO of the previous pass. Client feedback (verbatim, see task brief):
   fonts not aligned, logo treatment "wonky" (a pale chip behind a
   white-fill SVG looked like a bug — especially in dark mode, a cream box
   floating on a dark card), and the whole stacked-center arrangement
   (chip -> kicker -> wordmark -> card, all centered in one column) read as
   busy/disconnected rather than "one clean brand moment." Requested
   reference class: Linear/Stripe/Vercel-style two-column split auth
   screens — hero on one side, form on the other.

   Fix: `.auth-shell` is now a two-column CSS Grid at desktop widths.
   LEFT = `.auth-hero`, a dedicated dark brand panel (full block-height,
   fine to depart from Academy's cream palette here specifically since this
   is a hero/brand surface, not a reading surface — see brandbook "Auth
   Hero" section). RIGHT = `.auth-panel`, Academy's own light
   `--color-surface`/serif identity, unchanged, containing the actual form
   card. At <=48rem the grid collapses to a single column and the hero
   shrinks to a compact top band (logo + "Academy" only, no tagline) so the
   form stays reachable without excessive scrolling.

   Logo: no more `.brand-mark` chip hack. `iron-mind-logo.svg` is a solid-
   white wordmark literally designed for dark backgrounds — placed directly
   on `.auth-hero`'s dark background it needs no backdrop treatment at all.
   No kicker text repeating "Iron Mind AI" next to it either (client:
   "you don't have to have the logo that says Iron Mind and the text") —
   the logo alone on its native dark panel already reads as one confident,
   correct brand signal. "Academy" appears exactly once, as the page's
   serif `<h1>`/title on the form side — not repeated in the hero. */

.auth-shell {
  /* Override the global `main { max-width / margin: 0 auto / padding }`
     rule (base.css, meant for chapter reading pages) — .auth-shell is
     also a <main> element but needs to be a genuine full-bleed two-column
     split, not a centered, padded, width-capped box. Without this, the
     hero/form grid below renders correctly but squeezed into a narrow
     centered column with dead space on both sides. */
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 48rem) {
  .auth-shell {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------- Hero panel (left column, desktop / top band, mobile) ----------
   Intentionally NOT built from Academy's cream/light tokens — this is a
   scoped exception (see brandbook "Auth Hero"): a near-black brand surface
   closer to iron-mind.ai's own hero treatment, since it's a brand moment,
   not a reading surface. Academy's own --color-bg/--color-surface/
   --color-ink are untouched everywhere else in the app, including
   `.auth-panel` on the right. */
.auth-hero {
  --hero-bg: #14120f;
  --hero-ink: #f2ede4;
  --hero-ink-muted: rgba(242, 237, 228, 0.62);
  --hero-accent: #c17a45;

  background: var(--hero-bg);
  color: var(--hero-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6) var(--space-5);
  gap: var(--space-5);
}

.auth-hero__logo {
  display: block;
  height: 3.25rem;
  width: auto;
}

.auth-hero__rule {
  width: 2.5rem;
  height: 2px;
  background: var(--hero-accent);
}

.auth-hero__tagline {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  line-height: 1.3;
  color: var(--hero-ink);
  max-width: 24ch;
  margin: 0;
}

.auth-hero__sub {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--hero-ink-muted);
  max-width: 32ch;
  margin: 0;
}

/* Mobile: compact top band — logo + rule only, no tagline/sub, so the form
   is reached with minimal scrolling (per task brief item #2). */
@media (max-width: 47.9375rem) {
  .auth-hero {
    padding: var(--space-5) var(--space-4);
    gap: var(--space-3);
  }

  .auth-hero__logo {
    height: 2.25rem;
  }

  .auth-hero__tagline,
  .auth-hero__sub {
    display: none;
  }
}

/* ---------- Form panel (right column, desktop / bottom, mobile) ----------
   Academy's own light surface — unchanged palette, vertically centered
   within its own column so it doesn't compete visually with the hero. */
.auth-panel {
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
}

.auth-card {
  width: 100%;
  max-width: 26rem;
  text-align: left;
}

.auth-card .page-intro {
  margin-bottom: var(--space-5);
  text-align: left;
}

.auth-card .page-intro h1 {
  font-size: var(--fs-2xl);
  text-align: left;
}

.auth-card .page-intro p {
  margin: 0;
  max-width: 34ch;
  text-align: left;
}

.auth-card .form-error {
  text-align: left;
}

.auth-form {
  max-width: none;
  text-align: left;
}

.auth-form .form-input {
  max-width: none;
}

.auth-form .btn {
  width: 100%;
}

.auth-card__icon {
  font-size: var(--fs-2xl);
  line-height: 1;
  margin-bottom: var(--space-3);
  color: var(--color-accent);
  text-align: left;
}

.auth-card__footer {
  margin-top: var(--space-5);
  font-size: var(--fs-sm);
  color: var(--color-ink-muted);
  text-align: left;
}

@media (max-width: 30rem) {
  .auth-panel {
    padding: var(--space-5) var(--space-4);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 40rem) {
  h1 { font-size: var(--fs-2xl); }

  .site-header__inner {
    padding: var(--space-3);
  }

  .site-header__right {
    width: 100%;
    justify-content: space-between;
  }

  main {
    padding: var(--space-5) var(--space-3) var(--space-7);
  }

  /* Chapter list rows: bump vertical padding so the tap target clears the
     ~44px touch-target guideline even though visual density stays tight. */
  .chapter-link {
    padding: var(--space-3) var(--space-1);
    gap: var(--space-2);
  }

  .continue-reading-card {
    padding: var(--space-1) var(--space-3);
  }

  .status-pill {
    font-size: 0.75rem;
  }

  .chapter-nav {
    flex-direction: column;
  }

  .chapter-nav__link {
    padding: var(--space-3) var(--space-2);
  }

  .chapter-nav__link--next {
    text-align: left;
    align-items: flex-start;
  }

  /* Quiz option cards: match the comfortable-touch-target treatment
     already applied to .chapter-link / .chapter-nav__link at this
     breakpoint, and give the fieldset a little less side padding so the
     option cards don't read as cramped against the viewport edge on
     narrow phones. Visual design (colors, borders, radio control) is
     unchanged — spacing only. */
  .quiz-item {
    padding: var(--space-3);
  }

  .quiz-option {
    padding: var(--space-3) var(--space-2);
  }
}

@media (max-width: 30rem) {
  /* Narrowest phones: prevent the chapter title / status pill row from
     feeling cramped, and don't force text edge-to-edge. */
  .chapter-link {
    flex-wrap: wrap;
  }

  .prose {
    font-size: var(--fs-base);
  }

  .pref-controls {
    gap: var(--space-1);
  }

  .theme-toggle span:not(.theme-toggle__icon) {
    display: none;
  }
}
