/* ============================================================================
   course-theme.css — the shared component framework for every course page.

   This is the third and last stylesheet on the site, loaded after style.css
   (tokens, buttons, containers) and topic.css (page furniture). It wins ties by
   source order, so it is where a component's *look* is decided.

   It deliberately introduces NO new class vocabulary. Every selector below is a
   class the live course pages and the self-marking engine already emit:
   .rd-hero / .syllabus-header / .rd-eyebrow / .rd-block / .rd-q / .qmeta /
   .qtext / .rd-ms / .score / .rd-reveal. Earlier drafts of this file were
   written against a greenfield vocabulary (.course-container, .exam-question-card,
   .question-text, .student-answer-input, .grading-feedback-box, .mark-scheme-toggle)
   that matched zero elements on the site, so linking it changed nothing a student
   could see. The mapping used instead is:

       .course-container      -> .rd-hero .container / .rd-wrap
       .syllabus-header       -> header.syllabus-header inside .rd-hero
       .syllabus-badge        -> .syllabus-header .rd-eyebrow
       .course-topic-title    -> .syllabus-header h1
       .exam-question-card    -> .rd-q
       .question-meta         -> .rd-q .qmeta
       .question-text         -> .rd-q .qtext
       .student-answer-input  -> .rd-q textarea
       .grading-feedback-box  -> .rd-q .qrow .score.is-full / .is-part / .is-zero
       .mark-scheme-toggle    -> .rd-q .qrow .rd-reveal
       .grading-feedback-box  -> .rd-ms (the revealed mark scheme panel)

   The three .score state classes replace the inline `style.color` that engine.js
   used to write on every tally, so one file now owns the marking feedback look.

   hcdn caches static files for 7 days. This file is linked through build.py's
   asset() hash helper (`/assets/course-theme.css?v=<hash>`); never hardcode a
   bare URL for it in a page, or an edit will not reach a student for a week.
   ========================================================================== */


/* ---------------------------------------------------------------------------
   1. Page header block
   The title block of every course page: the qualification badge, the page
   <h1>, and the one-line summary. Wrapped in a real <header> by build.py so the
   document outline is header > h1 rather than a bare h1 in a bare section.
   --------------------------------------------------------------------------- */
.rd-hero .syllabus-header {
  border-bottom: 2px solid var(--line);
  padding-bottom: 16px;
}

/* The badge. Was plain teal text; now a pill, using the same token pair as the
   .chip-cmd pills on the question cards so the two read as one family. */
.rd-hero .syllabus-header .rd-eyebrow {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 9999px;
}

.rd-hero .syllabus-header h1 {
  margin: 12px 0 12px;
  line-height: 1.15;
}

/* The summary sits inside the header, so it must not push the rule away. */
.rd-hero .syllabus-header .rd-sum {
  margin: 0;
}

/* The progress control follows the rule, so its own top margin is the gap. */
.rd-hero .syllabus-header + .rd-mastery {
  margin-top: 22px;
}

/* The hub and the syllabus page carry the same header block but use the
   .page-hero / .kicker vocabulary rather than .rd-hero / .rd-eyebrow, so the
   same treatment is repeated against those names. Two rules, one look. */
.page-hero .syllabus-header {
  border-bottom: 2px solid var(--line);
  padding-bottom: 16px;
}

.page-hero .syllabus-header .kicker {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 9999px;
}

.page-hero .syllabus-header p:last-child {
  margin-bottom: 0;
}


/* ---------------------------------------------------------------------------
   2. The exam-practice region
   build.py wraps each page's exam-style question block in
   <section class="rd-station" aria-label="Exam Practice Station">.

   `display: contents` is the whole point: the section is a real, labelled region
   in the accessibility tree, but it generates no box, so .rd-blocks stays a flex
   column whose items are the .rd-block cards exactly as before. Without this the
   section would become the flex item and the 22px gap between cards would move
   to the wrong edge.
   --------------------------------------------------------------------------- */
.rd-blocks > .rd-station {
  display: contents;
}

/* The region label itself is for screen readers, not the page: the visible
   heading is the block's own <h2>Exam-style questions</h2>. */
.rd-station > .rd-block > h2:first-child {
  scroll-margin-top: 92px;
}


/* ---------------------------------------------------------------------------
   3. The self-marking question card
   --------------------------------------------------------------------------- */
.rd-q {
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease;
}

.rd-q:hover,
.rd-q:focus-within {
  box-shadow: var(--shadow-md);
}

/* .question-meta — the chip row. topic.css already lays it out; nothing to
   change beyond keeping the chips from wrapping onto the question text. */
.rd-q .qmeta {
  margin-bottom: 10px;
}

/* .question-text — a touch larger and given a readable measure, because these
   are the lines a student re-reads most. */
.rd-q .qtext {
  font-size: 17px;
  line-height: 1.55;
  margin-bottom: 12px;
}

/* .student-answer-input — the box a student actually types into. The focus ring
   is the real change: topic.css only recoloured the border on focus, which is
   invisible at a glance and invisible entirely to a keyboard user on a busy
   page. */
.rd-q textarea {
  min-height: 104px;
  padding: 13px 15px;
  line-height: 1.55;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rd-q textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 163, 0.18);
}

/* The action row. .rd-reveal is the primary action on the card and keeps its
   solid .btn-accent look; .mark-scheme-toggle's underlined-text treatment from
   the original framework was a weaker affordance than the button already here. */
.rd-q .qrow {
  align-items: center;
}

.rd-q .qrow .rd-reveal:disabled {
  opacity: 1;
  cursor: default;
  transform: none;
  box-shadow: none;
}


/* ---------------------------------------------------------------------------
   4. Grading feedback
   engine.js used to write `scoreEl.style.color = ...` on every tally — one of
   ~7,100 inline style attributes across the site, and the single most repeated
   one on the question cards. It now toggles .is-full / .is-part / .is-zero and
   the three states are defined once, here.

   The empty span is hidden: it carries the padding now, so an unmarked question
   would otherwise show a blank grey pill next to the reveal button.
   --------------------------------------------------------------------------- */
.rd-q .qrow .score {
  margin-left: auto;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.2;
  color: var(--ink);
  padding: 6px 14px;
  border-radius: 9999px;
  opacity: 0;
  transition: opacity 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.rd-q .qrow .score.is-full,
.rd-q .qrow .score.is-part,
.rd-q .qrow .score.is-zero {
  opacity: 1;
}

.rd-q .qrow .score.is-full {
  background-color: #f0fff4;
  color: #276749;
  box-shadow: inset 0 0 0 1px #c6f6d5;
}

.rd-q .qrow .score.is-part {
  background-color: #fffaf0;
  color: #7b341e;
  box-shadow: inset 0 0 0 1px #fbd38d;
}

.rd-q .qrow .score.is-zero {
  background-color: #fff5f5;
  color: #7f1d1d;
  box-shadow: inset 0 0 0 1px #feb2b2;
}

/* .grading-feedback-box, revealed: the mark-scheme panel. The revealed panel
   eases in so a student sees that the card grew rather than the page jumping. */
.rd-ms.show {
  animation: rd-ms-in 0.18s ease both;
}

@keyframes rd-ms-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* A ticked point is the correct-state treatment from the original framework:
   green tint plus a left bar. `inset` box-shadow rather than border-left so the
   row does not change width (and re-wrap) the moment it is ticked. */
.rd-ms li.ticked {
  background: #f0fff4;
  box-shadow: inset 3px 0 0 #38a169;
}

.rd-ms li.ticked label {
  color: #276749;
  font-weight: 500;
}

@media (prefers-reduced-motion: reduce) {
  .rd-ms.show { animation: none; }
  .rd-q { transition: none; }
  .rd-q .qrow .score { transition: none; }
}


/* ---------------------------------------------------------------------------
   5. Inline styles that moved out of engine.js
   Five static style="" attributes the bank and progress screens wrote on every
   render. The two `width:` values that remain inline are computed data, not
   styling, and stay where they are.
   --------------------------------------------------------------------------- */
.rd-filters strong {
  font-family: var(--font-display);
  color: var(--ink);
}

.rd-filters .rd-muted {
  margin-left: auto;
}

/* "Show my score report" / "Start again" — sibling buttons, so the gap is the
   second button's own left margin, not a style attribute. */
.rd-tally + .rd-clear {
  margin-left: 10px;
}

/* The percentage beside the big score, in the score report. */
.rd-report .big span {
  font-size: 22px;
  color: #fff;
}

/* Progress page: its own score banner and course headings. */
#rd-progress-host > .rd-report.show {
  margin-top: 0;
}

#rd-progress-host > h2.rd-mt {
  font-size: 22px;
}


/* ---------------------------------------------------------------------------
   6. Small screens
   The reveal button becomes the full-width primary action and the score pill
   moves under it, so a thumb does not have to hit a 90px target on the right
   edge of a 360px screen.
   --------------------------------------------------------------------------- */
@media (max-width: 520px) {
  .rd-q .qrow {
    gap: 8px;
  }

  .rd-q .qrow .rd-reveal {
    width: 100%;
    justify-content: center;
  }

  .rd-q .qrow .score {
    margin-left: 0;
    order: 2;
  }
}

/* ============================================================================
   7. Layout helpers hoisted out of the page generator

   build.py used to emit 57 inline `style=` attributes across 13 page emitters -
   7,127 of them on the built site, and the only layout values on the site that
   no stylesheet owned. Every one is now a class defined here, so a course page
   inherits its layout from the central stylesheets and never from a value
   written into its own markup.

   Specificity: each rule below is written at least as specific as the rule it
   replaces, and this file loads last, so none of them depends on source order
   against style.css or topic.css.
   ========================================================================== */


/* --- Section rhythm -------------------------------------------------------
   `.section` is `padding: 80px 0`. A practice page pulls its top padding in to
   26px, a course section to 40px, the hub's first block to 44px. */

.section.rd-practice, main.rd-practice { padding-top: 26px; }
.section.rd-sec { padding-top: 40px; }
.section.rd-sec-lg { padding-top: 44px; }
.rd-sec-flush { padding: 0; }


/* --- The two-column tool grid --------------------------------------------
   `.rd-tools` declares three columns at one-class weight and already drops to
   two at 900px and one at 800px. The inline this replaces set two columns at
   EVERY width, so a phone got a two-column grid it could not escape. */

.rd-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rd-tools.rd-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 800px) {
  .rd-grid-2,
  .rd-tools.rd-grid-2 { grid-template-columns: 1fr; }
}


/* --- Left-aligned section heads ------------------------------------------
   `.sec-head` is centred at 640px. Every course page's own head is left
   aligned, and four widths are in use; the width is a class, not a value
   written onto the page. */

.sec-head.rd-head { text-align: left; margin: 0; }
.sec-head.rd-head.rd-head-w820 { max-width: 820px; }
.sec-head.rd-head.rd-head-w760 { max-width: 760px; }
.sec-head.rd-head.rd-head-w720 { max-width: 720px; }
.sec-head.rd-head.rd-head-w860 { max-width: 860px; }
.sec-head.rd-head.rd-head-gap { margin-top: 30px; }

.sec-head.rd-head h1 { margin: 14px 0 12px; }
.sec-head.rd-head h2 { margin: 10px 0 8px; }
.sec-head.rd-head h3 { margin: 0 0 6px; }
.sec-head.rd-head p:not(.rd-hero-cta) { margin: 0; }


/* --- The mastery bar's capped variant ------------------------------------ */

.rd-mastery.rd-mastery-cap { max-width: 640px; }


/* --- Table wrappers ------------------------------------------------------
   `.rd-tablesec` had no stylesheet rule at all: every page carried its own
   margin inline. */

.rd-tablesec { margin-top: 22px; }
.rd-tablesec.rd-tablesec-sm { margin-top: 16px; }


/* --- Course-page content blocks ------------------------------------------
   Each block owns its own rhythm, and the margins of the heading and the lead
   paragraph inside it. */

.rd-block.rd-block-list { margin-top: 26px; }
.rd-block.rd-block-list > h3 { margin: 0 0 4px; }
.rd-block.rd-block-list > p.rd-muted { margin: 0 0 12px; }

.rd-block.rd-block-brief { margin-top: 24px; }
.rd-block.rd-block-brief > h3 { margin: 0 0 6px; font-size: 19px; }
.rd-block.rd-block-brief > p.rd-muted { margin: 0 0 14px; }

.rd-block.rd-block-plan { margin-top: 34px; }


/* --- One-off rhythms, named for the element they sit on ------------------ */

.rd-tools.rd-tools-tight { margin-top: 18px; }
.rd-muted.rd-note { margin-top: 12px; font-size: 14px; }
.rd-muted.rd-ao-note { margin-top: 14px; }
ul.rd-list.rd-ao-list { margin-top: 14px; }
p.rd-syl-note { margin-top: 26px; }
p.rd-hero-cta { margin: 20px 0 0; }


/* --- The last mistake row has no rule above it ---------------------------
   The closing "Revise this topic" row reuses the .why block, so it needed the
   divider and the red label switched off inline. */

.rd-mistake .why.why-last { border-bottom: none; }
.rd-mistake .why.why-last .lbl { color: var(--ink-soft); }

/* --- SVG figures ----------------------------------------------------------
   Every figure module put `max-width:100%;height:auto` on the SVG root as an
   inline attribute. It is a class now, so the rule travels with the element
   wherever a figure is placed instead of depending on a wrapper. */

.rd-svg { max-width: 100%; height: auto; }

/* --- Hand-authored page helpers ------------------------------------------
   index, contact, policies and account are written by hand, so each of them
   carried its own inline layout as well. Same rule: the value lives in the
   stylesheet. Every class below carries exactly the declaration it replaced. */

.section.rd-sec-sm { padding-top: 32px; }

/* contact.html - the icon tile beside each info-card heading */
.info-card .dot {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}

p.rd-p-sm { font-size: 15px; }
p.rd-p-mb { margin-bottom: 16px; }
p.rd-p-mb-sm { margin-bottom: 12px; }
p.rd-p-mt { margin-top: 14px; }
h3.rd-h3-sub { font-size: 17px; margin: 18px 0 10px; }
.rd-tablewrap.rd-tablewrap-flush { margin: 0; }
.note.rd-note-gap { margin-top: 18px; }
