/* ==========================================================================
   COMP9085 - Machine Learning and Foundation Models for Biology,
   Healthcare and Nutrition
   Design system.

   The visual language pairs a biological register (a deep specimen green,
   warm nucleus amber) with a data register (a cool slate ink, a clinical
   blue). It is meant to read as a university module, not as a product.

   Sections
     1. Tokens
     2. Reset and base
     3. Typography
     4. Layout
     5. Header and navigation
     6. Components
     7. Visualisation chrome
     8. Footer
     9. Utilities
   ========================================================================== */

/* --- 1. Tokens ---------------------------------------------------------- */
:root {
  /* Ink and ground */
  --ink:            #12181c;
  --ink-2:          #2f3a41;
  --ink-3:          #5b6b75;
  --ink-4:          #8798a3;
  --rule:           #dde4e8;
  --rule-soft:      #eaeff2;
  --ground:         #ffffff;
  --ground-2:       #f6f8f9;
  --ground-3:       #eef2f4;

  /* Biological register */
  --specimen:       #1f5f4b;   /* deep green: biology, life science */
  --specimen-soft:  #e6f1ed;
  --nucleus:        #b5762a;   /* warm amber: stained nuclei */
  --nucleus-soft:   #fbf1e3;

  /* Data register */
  --clinical:       #1f4e79;   /* clinical blue: measurement, evidence */
  --clinical-soft:  #e7eff6;
  --signal:         #7b3f8f;   /* violet: learned representation */
  --signal-soft:    #f2eaf5;

  /* Semantic */
  --warn:           #9a5b12;
  --warn-soft:      #fdf3e4;
  --warn-rule:      #e3b980;
  --danger:         #9b2c2c;
  --danger-soft:    #fceded;
  --ok:             #1f6f4a;
  --ok-soft:        #e6f3ec;

  /* Class colours, used consistently across every visualisation.
     Chosen to remain distinguishable in the common forms of colour vision
     deficiency, and always paired with a shape or a text label so that
     colour is never the only channel. */
  --cat-1: #1f4e79;   /* benign / class A */
  --cat-2: #b5762a;   /* malignant / class B */
  --cat-3: #1f5f4b;   /* class C */
  --cat-4: #7b3f8f;   /* class D */
  --cat-5: #5b6b75;   /* other / noise */

  /* Journey stages */
  --stage-1: #1f4e79;
  --stage-2: #2b6f8c;
  --stage-3: #7b3f8f;
  --stage-4: #b5762a;
  --stage-5: #1f5f4b;

  /* Type */
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --serif: "Charter", "Bitstream Charter", "Iowan Old Style", Georgia,
           "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  /* Spacing scale */
  --s1: 0.25rem; --s2: 0.5rem;  --s3: 0.75rem; --s4: 1rem;
  --s5: 1.5rem;  --s6: 2rem;    --s7: 3rem;    --s8: 4rem;   --s9: 6rem;

  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 2px rgba(18, 24, 28, .05), 0 4px 12px rgba(18, 24, 28, .05);
  --shadow-lg: 0 2px 4px rgba(18, 24, 28, .06), 0 12px 32px rgba(18, 24, 28, .09);

  --measure: 68ch;
  --wide: 1180px;
  --header-h: 60px;
}

/* --- 2. Reset and base -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, canvas { max-width: 100%; }
img { height: auto; }

/* Visible focus for every interactive element. */
:focus-visible {
  outline: 3px solid var(--clinical);
  outline-offset: 2px;
  border-radius: 3px;
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--clinical);
  color: #fff;
  padding: var(--s3) var(--s5);
  font-weight: 600;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* --- 3. Typography ------------------------------------------------------ */
h1, h2, h3, h4, h5 {
  margin: 0 0 var(--s4);
  line-height: 1.22;
  font-weight: 650;
  letter-spacing: -0.011em;
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: clamp(1.85rem, 1.3rem + 2.2vw, 2.9rem); letter-spacing: -0.022em; }
h2 { font-size: clamp(1.4rem, 1.15rem + 1.05vw, 1.95rem); margin-top: var(--s7); }
h3 { font-size: clamp(1.12rem, 1.02rem + 0.45vw, 1.35rem); margin-top: var(--s6); }
h4 { font-size: 1.02rem; margin-top: var(--s5); }

h2:first-child, h3:first-child, h4:first-child { margin-top: 0; }

p { margin: 0 0 var(--s4); max-width: var(--measure); }
p:last-child { margin-bottom: 0; }

a { color: var(--clinical); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }

ul, ol { margin: 0 0 var(--s4); padding-left: 1.3em; max-width: var(--measure); }
li { margin-bottom: var(--s2); }
li:last-child { margin-bottom: 0; }

strong { font-weight: 640; }

code, kbd, samp {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--ground-3);
  padding: 0.12em 0.36em;
  border-radius: 3px;
}
pre {
  font-family: var(--mono);
  font-size: 0.83rem;
  line-height: 1.6;
  background: #16202a;
  color: #dbe6ef;
  padding: var(--s5);
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 0 0 var(--s5);
  -webkit-overflow-scrolling: touch;
}
pre code { background: none; padding: 0; color: inherit; font-size: inherit; }

.lede {
  font-size: clamp(1.02rem, 0.98rem + 0.35vw, 1.18rem);
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 62ch;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--s3);
  display: block;
}

blockquote {
  margin: 0 0 var(--s5);
  padding-left: var(--s5);
  border-left: 3px solid var(--specimen);
  color: var(--ink-2);
  font-style: italic;
  max-width: var(--measure);
}

/* --- 4. Layout ---------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--wide);
  margin-inline: auto;
  padding-inline: var(--s5);
}
.wrap-narrow { max-width: 780px; }

main { display: block; min-height: 60vh; }

section { margin-bottom: var(--s8); }
.section-pad { padding-block: var(--s8); }

.grid { display: grid; gap: var(--s5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--s7) 0;
}

/* --- 5. Header and navigation ------------------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.94);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: var(--s5);
  height: var(--header-h);
  max-width: var(--wide);
  margin-inline: auto;
  padding-inline: var(--s5);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}
.brand:hover { color: var(--ink); }
.brand-mark { flex-shrink: 0; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-code { font-weight: 700; font-size: 0.92rem; letter-spacing: -0.01em; }
.brand-sub  { font-size: 0.68rem; color: var(--ink-3); letter-spacing: 0.02em; }

.site-nav { margin-left: auto; }
.site-nav ul {
  display: flex;
  align-items: center;
  gap: var(--s1);
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: none;
}
.site-nav li { margin: 0; }
.site-nav a {
  display: block;
  padding: var(--s2) var(--s3);
  font-size: 0.85rem;
  font-weight: 520;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: var(--radius);
  white-space: nowrap;
}
.site-nav a:hover { background: var(--ground-3); color: var(--ink); }
.site-nav a[aria-current="page"] {
  color: var(--clinical);
  font-weight: 640;
  background: var(--clinical-soft);
}

.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s2) var(--s3);
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  align-items: center;
  gap: var(--s2);
}

/* --- 6. Components ------------------------------------------------------ */

/* Page hero */
.page-hero {
  background: linear-gradient(180deg, var(--ground-2) 0%, var(--ground) 100%);
  border-bottom: 1px solid var(--rule);
  padding-block: var(--s7) var(--s6);
  margin-bottom: var(--s7);
}
.page-hero h1 { margin-bottom: var(--s3); }

/* Card */
.card {
  background: var(--ground);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: var(--s5);
}
.card h3, .card h4 { margin-top: 0; }
.card p:last-child, .card ul:last-child { margin-bottom: 0; }

a.card, .card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.card:hover, .card-link:hover {
  border-color: var(--clinical);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  color: inherit;
}

/* Week card */
.week-card { position: relative; padding-top: var(--s5); }
.week-card .week-num {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  display: block;
  margin-bottom: var(--s2);
}
.week-card h3 { font-size: 1.05rem; margin-bottom: var(--s2); }
.week-card p { font-size: 0.9rem; color: var(--ink-3); margin-bottom: var(--s4); }
.week-card .strand-bar {
  position: absolute; inset: 0 0 auto 0; height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Pills and tags */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: 0.7rem;
  font-weight: 620;
  letter-spacing: 0.02em;
  padding: 0.2em 0.62em;
  border-radius: 100px;
  background: var(--ground-3);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill-lo       { background: var(--clinical-soft); color: var(--clinical); }
.pill-fm       { background: var(--signal-soft);   color: var(--signal); }
.pill-bio      { background: var(--specimen-soft); color: var(--specimen); }
.pill-classic  { background: var(--nucleus-soft);  color: var(--nucleus); }
.pill-sim      { background: var(--warn-soft);     color: var(--warn); }
.pill-real     { background: var(--ok-soft);       color: var(--ok); }
.pill-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s4); }

/* Callouts */
.callout {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink-4);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--ground-2);
  padding: var(--s5);
  margin: 0 0 var(--s5);
}
.callout > :last-child { margin-bottom: 0; }
.callout-title {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: var(--s3);
  display: flex; align-items: center; gap: var(--s2);
}
.callout-fm      { border-left-color: var(--signal);   background: var(--signal-soft); }
.callout-fm .callout-title { color: var(--signal); }
.callout-key     { border-left-color: var(--specimen); background: var(--specimen-soft); }
.callout-key .callout-title { color: var(--specimen); }
.callout-warn    { border-left-color: var(--warn-rule); background: var(--warn-soft); }
.callout-warn .callout-title { color: var(--warn); }
.callout-bio     { border-left-color: var(--specimen); background: var(--ground-2); }
.callout-bio .callout-title { color: var(--specimen); }
.callout-sci     { border-left-color: var(--nucleus);  background: var(--nucleus-soft); }
.callout-sci .callout-title { color: var(--nucleus); }

/* Concept list */
.concept-list { list-style: none; padding: 0; margin: 0; max-width: none; }
.concept-list > li {
  border-top: 1px solid var(--rule-soft);
  padding: var(--s4) 0;
  margin: 0;
}
.concept-list > li:first-child { border-top: 0; padding-top: 0; }
.concept-term {
  font-weight: 640;
  color: var(--ink);
  margin-bottom: var(--s1);
}
.concept-body { color: var(--ink-2); font-size: 0.945rem; margin: 0; max-width: var(--measure); }

/* Objectives */
.objectives { counter-reset: obj; list-style: none; padding: 0; max-width: none; }
.objectives li {
  counter-increment: obj;
  position: relative;
  padding-left: 2.2rem;
  margin-bottom: var(--s3);
  max-width: var(--measure);
}
.objectives li::before {
  content: counter(obj);
  position: absolute; left: 0; top: 0.1em;
  width: 1.5rem; height: 1.5rem;
  display: grid; place-items: center;
  background: var(--clinical-soft);
  color: var(--clinical);
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--mono);
}

/* Tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: var(--s5); }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
  min-width: 520px;
}
caption {
  caption-side: top;
  text-align: left;
  font-size: 0.82rem;
  color: var(--ink-3);
  padding-bottom: var(--s3);
}
th, td {
  text-align: left;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
}
th {
  font-weight: 640;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
tbody tr:hover { background: var(--ground-2); }
td.num, th.num { text-align: right; font-family: var(--mono); font-size: 0.85em; }
.table-compact th, .table-compact td { padding: var(--s2) var(--s3); }

/* Buttons and controls */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 570;
  padding: var(--s2) var(--s4);
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--ground);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background .13s, border-color .13s;
}
.btn:hover { background: var(--ground-3); border-color: var(--ink-4); color: var(--ink); }
.btn-primary {
  background: var(--clinical); border-color: var(--clinical); color: #fff;
}
.btn-primary:hover { background: #17395a; border-color: #17395a; color: #fff; }
.btn-sm { font-size: 0.8rem; padding: var(--s1) var(--s3); }
.btn[aria-pressed="true"] {
  background: var(--clinical); border-color: var(--clinical); color: #fff;
}

/* Quiz */
.quiz { border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; }
.quiz-q { border-top: 1px solid var(--rule-soft); padding: var(--s5); }
.quiz-q:first-child { border-top: 0; }
.quiz-stem { font-weight: 570; margin-bottom: var(--s4); max-width: var(--measure); }
.quiz-opts { list-style: none; padding: 0; margin: 0 0 var(--s3); max-width: none; }
.quiz-opts li { margin-bottom: var(--s2); }
.quiz-opt {
  display: flex;
  gap: var(--s3);
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.9rem;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--ground);
  cursor: pointer;
  transition: border-color .13s, background .13s;
}
.quiz-opt:hover:not([disabled]) { border-color: var(--ink-4); background: var(--ground-2); }
.quiz-opt[disabled] { cursor: default; }
.quiz-opt .marker {
  flex-shrink: 0; font-family: var(--mono); font-weight: 700;
  color: var(--ink-4); font-size: 0.82rem; padding-top: 0.05em;
}
.quiz-opt.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.quiz-opt.is-correct .marker { color: var(--ok); }
.quiz-opt.is-wrong   { border-color: var(--danger); background: var(--danger-soft); }
.quiz-opt.is-wrong .marker { color: var(--danger); }
.quiz-why {
  font-size: 0.88rem; color: var(--ink-2);
  background: var(--ground-2);
  border-left: 3px solid var(--ink-4);
  padding: var(--s3) var(--s4);
  border-radius: 0 var(--radius) var(--radius) 0;
  max-width: var(--measure);
}
.quiz-why.ok { border-left-color: var(--ok); }
.quiz-why.no { border-left-color: var(--danger); }

/* Feedback form */
.feedback { background: var(--ground-2); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: var(--s6); }
.confidence-scale { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s2); }
.confidence-scale button {
  flex: 1 1 3.5rem; min-width: 3.5rem;
  font: inherit; font-size: 0.9rem; font-weight: 600;
  padding: var(--s3); cursor: pointer;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--ground); color: var(--ink-2);
}
.confidence-scale button:hover { border-color: var(--clinical); }
.confidence-scale button[aria-pressed="true"] {
  background: var(--clinical); border-color: var(--clinical); color: #fff;
}
.scale-ends { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--ink-3); margin-bottom: var(--s5); }

.field { margin-bottom: var(--s5); }
.field label { display: block; font-size: 0.88rem; font-weight: 570; margin-bottom: var(--s2); }
.field textarea, .field input[type="text"], .field select {
  width: 100%; font: inherit; font-size: 0.9rem;
  padding: var(--s3);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--ground);
  color: var(--ink);
}
.field textarea { min-height: 4.5rem; resize: vertical; }
.field-hint { font-size: 0.8rem; color: var(--ink-3); margin-top: var(--s1); }

.privacy-note {
  font-size: 0.8rem; color: var(--ink-3);
  border-top: 1px solid var(--rule);
  padding-top: var(--s3); margin-top: var(--s5);
}

/* Progress */
.progress-track {
  height: 5px; background: var(--ground-3);
  border-radius: 100px; overflow: hidden; margin-bottom: var(--s2);
}
.progress-fill { height: 100%; background: var(--specimen); border-radius: 100px; transition: width .35s ease; }
.progress-label { font-size: 0.78rem; color: var(--ink-3); }

/* Reference panel */
.refs { list-style: none; padding: 0; margin: 0; max-width: none; counter-reset: r; }
.refs li {
  counter-increment: r;
  position: relative;
  padding: var(--s3) 0 var(--s3) 2.4rem;
  border-top: 1px solid var(--rule-soft);
  font-size: 0.88rem;
  margin: 0;
}
.refs li:first-child { border-top: 0; }
.refs li::before {
  content: "[" counter(r) "]";
  position: absolute; left: 0; top: var(--s3);
  font-family: var(--mono); font-size: 0.75rem; color: var(--ink-4);
}
.refs .ref-cite { color: var(--ink-2); }
.refs .ref-note { color: var(--ink-3); font-size: 0.85rem; margin-top: var(--s1); }
.refs a { word-break: break-word; }

/* Inline citation marker */
.cite {
  font-family: var(--mono);
  font-size: 0.72em;
  vertical-align: 0.28em;
  color: var(--clinical);
  text-decoration: none;
  padding: 0 0.1em;
  font-weight: 600;
}
.cite:hover { text-decoration: underline; }

/* Data provenance badge */
.provenance {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-size: 0.74rem; font-weight: 600;
  padding: 0.25em 0.7em; border-radius: 100px;
}
.provenance-real { background: var(--ok-soft); color: var(--ok); }
.provenance-sim  { background: var(--warn-soft); color: var(--warn); }

/* Step / pipeline */
.pipeline { display: grid; gap: var(--s3); }
.pipeline-step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s4);
  align-items: start;
  padding: var(--s4);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--ground);
  cursor: pointer;
  text-align: left;
  font: inherit;
  width: 100%;
  transition: border-color .13s, background .13s;
}
.pipeline-step:hover { border-color: var(--ink-4); }
.pipeline-step[aria-expanded="true"] { border-color: var(--clinical); background: var(--clinical-soft); }
.pipeline-step .idx {
  width: 1.7rem; height: 1.7rem; display: grid; place-items: center;
  border-radius: 50%; background: var(--ground-3); color: var(--ink-2);
  font-family: var(--mono); font-size: 0.75rem; font-weight: 700;
}
.pipeline-step[aria-expanded="true"] .idx { background: var(--clinical); color: #fff; }
.pipeline-step .label { font-weight: 600; font-size: 0.95rem; }
.pipeline-step .body  { font-size: 0.87rem; color: var(--ink-3); margin-top: var(--s1); }
.pipeline-detail {
  font-size: 0.88rem;
  padding: var(--s4);
  margin: calc(-1 * var(--s2)) 0 var(--s2) 2.5rem;
  background: var(--ground-2);
  border-left: 2px solid var(--clinical);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* Definition grid for dataset cards */
.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s5); margin: 0 0 var(--s5); font-size: 0.89rem; }
.dl-grid dt { font-weight: 620; color: var(--ink-3); }
.dl-grid dd { margin: 0; }

/* --- 7. Visualisation chrome ------------------------------------------- */
.viz {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--ground);
  overflow: hidden;
  margin-bottom: var(--s6);
}
.viz-head {
  padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 1px solid var(--rule-soft);
  background: var(--ground-2);
}
.viz-head h3 { margin: 0 0 var(--s2); font-size: 1.05rem; }
.viz-head p  { margin: 0; font-size: 0.89rem; color: var(--ink-3); }

.viz-controls {
  display: flex; flex-wrap: wrap; gap: var(--s4) var(--s5);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--rule-soft);
  background: var(--ground-2);
  align-items: flex-end;
}
.control { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.control > label, .control > .control-label {
  font-size: 0.76rem; font-weight: 620; color: var(--ink-3);
  letter-spacing: 0.02em;
}
.control input[type="range"] { width: 100%; min-width: 130px; accent-color: var(--clinical); }
.control select, .control input[type="number"] {
  font: inherit; font-size: 0.85rem; padding: var(--s2) var(--s3);
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--ground); color: var(--ink); min-width: 110px;
}
.control .val { font-family: var(--mono); font-size: 0.8rem; color: var(--ink); font-weight: 600; }
.control-inline { flex-direction: row; align-items: center; gap: var(--s2); }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.seg button {
  font: inherit; font-size: 0.82rem; padding: var(--s2) var(--s3);
  background: var(--ground); border: 0; border-right: 1px solid var(--rule);
  cursor: pointer; color: var(--ink-2);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--clinical); color: #fff; }
.viz-controls .spacer { flex: 1 1 auto; }

.viz-body { padding: var(--s5); }
.viz-stage { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.viz-stage svg { display: block; }

.viz-readout {
  display: flex; flex-wrap: wrap; gap: var(--s5);
  padding: var(--s4) var(--s5);
  background: var(--ground-2);
  border-top: 1px solid var(--rule-soft);
}
.metric { min-width: 5.5rem; }
.metric .m-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); font-weight: 620; }
.metric .m-value { font-family: var(--mono); font-size: 1.15rem; font-weight: 640; color: var(--ink); line-height: 1.3; }
.metric .m-note  { font-size: 0.74rem; color: var(--ink-4); }
.metric.is-good .m-value { color: var(--ok); }
.metric.is-bad  .m-value { color: var(--danger); }

.viz-explain {
  padding: var(--s5);
  border-top: 1px solid var(--rule-soft);
  font-size: 0.9rem;
  color: var(--ink-2);
}
.viz-explain > :last-child { margin-bottom: 0; }

/* Text alternative for every chart, for screen readers and for anyone who
   would simply rather read the numbers. */
.viz-alt { border-top: 1px solid var(--rule-soft); }
.viz-alt > summary {
  padding: var(--s3) var(--s5);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 570;
  color: var(--clinical);
  background: var(--ground-2);
  list-style: none;
}
.viz-alt > summary::-webkit-details-marker { display: none; }
.viz-alt > summary::before { content: "▸ "; font-size: 0.8em; }
.viz-alt[open] > summary::before { content: "▾ "; }
.viz-alt > summary:hover { background: var(--ground-3); }
.viz-alt .alt-body { padding: var(--s5); font-size: 0.86rem; background: var(--ground); }
.viz-alt .alt-body table { min-width: 0; }

/* SVG defaults */
.axis text  { font-size: 11px; fill: var(--ink-3); font-family: var(--sans); }
.axis path, .axis line { stroke: var(--rule); shape-rendering: crispEdges; }
.axis-label { font-size: 11.5px; fill: var(--ink-2); font-weight: 600; }
.grid-line  { stroke: var(--rule-soft); shape-rendering: crispEdges; }
.chart-title { font-size: 12.5px; font-weight: 640; fill: var(--ink); }

.legend { display: flex; flex-wrap: wrap; gap: var(--s4); font-size: 0.8rem; color: var(--ink-2); margin-top: var(--s3); }
.legend-item { display: inline-flex; align-items: center; gap: var(--s2); }
.legend-swatch { width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0; }

/* Tooltip */
.viz-tip {
  position: fixed;
  pointer-events: none;
  z-index: 150;
  background: var(--ink);
  color: #fff;
  font-size: 0.78rem;
  line-height: 1.45;
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
  max-width: 260px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .1s;
}
.viz-tip.on { opacity: 1; }
.viz-tip strong { color: #fff; }

/* --- 8. Footer ---------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--rule);
  background: var(--ground-2);
  padding-block: var(--s7) var(--s6);
  margin-top: var(--s9);
  font-size: 0.87rem;
  color: var(--ink-3);
}
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s6); margin-bottom: var(--s6); }
.footer-grid h4 { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: var(--s3); }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: var(--s2); }
.footer-grid a { color: var(--ink-2); text-decoration: none; }
.footer-grid a:hover { color: var(--clinical); text-decoration: underline; }
.footer-base { border-top: 1px solid var(--rule); padding-top: var(--s5); font-size: 0.82rem; }
.footer-base p { max-width: none; }

/* Week pager */
.pager { display: flex; justify-content: space-between; gap: var(--s4); border-top: 1px solid var(--rule); padding-top: var(--s5); margin-top: var(--s7); }
.pager a { text-decoration: none; font-size: 0.9rem; max-width: 46%; }
.pager .dir { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-4); font-weight: 650; }
.pager .ttl { color: var(--ink); font-weight: 570; }
.pager a:hover .ttl { color: var(--clinical); }
.pager .next { text-align: right; margin-left: auto; }

/* --- 9. Utilities ------------------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.muted { color: var(--ink-3); }
.small { font-size: 0.85rem; }
.tiny  { font-size: 0.78rem; }
.mono  { font-family: var(--mono); }
.center { text-align: center; }
.mb0 { margin-bottom: 0; }
.mt0 { margin-top: 0; }
.mb4 { margin-bottom: var(--s4); }
.mb5 { margin-bottom: var(--s5); }
.mb6 { margin-bottom: var(--s6); }
.mt5 { margin-top: var(--s5); }
.mt6 { margin-top: var(--s6); }
.full { max-width: none; }
.flex { display: flex; gap: var(--s4); flex-wrap: wrap; align-items: center; }
.stack > * + * { margin-top: var(--s4); }

.noscript-note {
  background: var(--warn-soft);
  border: 1px solid var(--warn-rule);
  border-radius: var(--radius);
  padding: var(--s5);
  margin-bottom: var(--s6);
}

/* --- 10. Video, slides and orientation ---------------------------------
   Added for the Week 1 rebuild. Video embeds are responsive and are never
   the only place a piece of teaching content appears.
   --------------------------------------------------------------------- */

.video-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--ground);
  margin-bottom: var(--s6);
}
.video-head { padding: var(--s5) var(--s5) var(--s4); background: var(--ground-2); border-bottom: 1px solid var(--rule-soft); }
.video-head h3 { margin: 0 0 var(--s2); font-size: 1.05rem; }
.video-meta { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: 0.8rem; color: var(--ink-3); }
.video-meta span { display: inline-flex; align-items: center; gap: 0.3em; }

/* 16:9 responsive frame that works without aspect-ratio support. */
.video-frame { position: relative; width: 100%; padding-top: 56.25%; background: #12181c; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.video-body { padding: var(--s5); }
.video-body > :last-child { margin-bottom: 0; }
.video-purpose { font-size: 0.92rem; }
.video-question {
  background: var(--nucleus-soft);
  border-left: 3px solid var(--nucleus);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--s3) var(--s4);
  font-size: 0.9rem;
  margin-top: var(--s4);
}
.video-question strong { color: var(--nucleus); }
.video-actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s4); }

/* Placeholder shown when a video ID has not been supplied yet. */
.video-placeholder {
  background: var(--warn-soft);
  border: 2px dashed var(--warn-rule);
  border-radius: var(--radius);
  padding: var(--s6);
  text-align: left;
}
.video-placeholder h4 { margin-top: 0; color: var(--warn); }


/* "No lab this week" notice */
.no-lab-notice {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--clinical);
  background: var(--clinical-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--s5);
}
.no-lab-notice h3 { margin-top: 0; color: var(--clinical); }

/* Orientation blocks on the Week 1 page */
.orient-list { list-style: none; padding: 0; margin: 0; }
.orient-list > li {
  display: grid; grid-template-columns: 10.5rem 1fr; gap: var(--s4);
  padding: var(--s3) 0; border-top: 1px solid var(--rule-soft);
  margin: 0;
}
.orient-list > li:first-child { border-top: 0; }
.orient-list .what { font-weight: 620; color: var(--ink-2); font-size: 0.92rem; }
.orient-list .body { font-size: 0.92rem; color: var(--ink-2); }
@media (max-width: 640px) {
  .orient-list > li { grid-template-columns: 1fr; gap: var(--s1); }
}

/* Generic-to-biological parallel table */
.parallel-table td:first-child { color: var(--ink-3); }
.parallel-table td:last-child { color: var(--ink); font-weight: 520; }

/* Placeholder link marker, used in the footer for unconfigured URLs */
.link-placeholder {
  color: var(--ink-4);
  border-bottom: 1px dashed var(--ink-4);
  cursor: help;
}

/* ==========================================================================
   11. Model inspection and deployment (Week 2)
   Shared by the tree builder's node inspector, the decision-path panel, and
   the deployment demonstration. Reused by later weeks' model explorers.
   ========================================================================== */

.viz-panel {
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--rule);
}
.viz-panel h4 {
  margin: 0 0 var(--s3);
  font-size: .85rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.inspect-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.inspect-table th,
.inspect-table td {
  padding: .3rem .5rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}
.inspect-table th { width: 42%; font-weight: 600; color: var(--ink-3); }

/* ---- Decision path ----------------------------------------------------- */
.decision-path { list-style: none; margin: 0; padding: 0; }
.decision-path li {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem var(--s4);
  align-items: baseline;
  justify-content: space-between;
  padding: .42rem .6rem;
  margin-bottom: .3rem;
  border-left: 4px solid var(--ink-4);
  background: var(--ground-2);
  font-size: .88rem;
}
.decision-path .dp-test { font-weight: 600; }
.decision-path .dp-answer { color: var(--ink-3); font-size: .82rem; }
.decision-path .dp-true { border-left-color: var(--cat-1); }
.decision-path .dp-false { border-left-color: var(--cat-3); }
.decision-path .dp-leaf { border-left-width: 5px; background: var(--ground-3); }
.decision-path .dp-benign { border-left-color: var(--cat-1); }
.decision-path .dp-malignant { border-left-color: var(--cat-2); }
.dp-note { margin-top: var(--s3); }

/* ---- Deployment form --------------------------------------------------- */
.deploy {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: var(--s4);
  margin-bottom: var(--s5);
  background: var(--ground);
}
.deploy-head h4 { margin: 0 0 .2rem; font-size: 1rem; }
.deploy-head p { margin: 0 0 var(--s4); }
.deploy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s4);
}
.deploy-field { display: flex; flex-direction: column; gap: .18rem; }
.deploy-field label { font-size: .84rem; font-weight: 600; }
.deploy-field input {
  padding: .35rem .5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font: inherit;
  font-size: .9rem;
  background: var(--ground);
  color: var(--ink);
  min-width: 0;
}
.deploy-field input:focus-visible { outline: 2px solid var(--cat-1); outline-offset: 1px; }
.deploy-field input[aria-invalid="true"] { border-color: var(--danger); }
.deploy-hint { font-size: .74rem; color: var(--ink-4); }
.deploy-msg { font-size: .76rem; min-height: 0; }
.deploy-msg-warn { color: var(--warn); }
.deploy-msg-error { color: var(--danger); font-weight: 600; }
.deploy-actions {
  margin-top: var(--s4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
}
.deploy-invalid { color: var(--danger); font-weight: 600; }

/* ---- Deployment result ------------------------------------------------- */
.deploy-result {
  border-left: 5px solid var(--ink-4);
  padding: var(--s4);
  background: var(--ground-2);
  margin-bottom: var(--s4);
}
.deploy-result h4 { margin: 0 0 var(--s3); font-size: .95rem; }
.deploy-result h5 {
  margin: var(--s4) 0 var(--s3);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-3);
}
.deploy-benign { border-left-color: var(--cat-1); }
.deploy-malignant { border-left-color: var(--cat-2); }
.deploy-pred { margin: 0; font-size: 1.05rem; }
.deploy-compare,
.deploy-info { margin-bottom: var(--s4); }
.deploy-compare h4,
.deploy-info h4 { margin: 0 0 var(--s3); font-size: .95rem; }
.deploy-trust { margin-bottom: var(--s4); }
.deploy-trust dt { font-weight: 600; margin-top: var(--s3); }
.deploy-trust dd { margin: .15rem 0 0; color: var(--ink-2); font-size: .9rem; }
.deploy-warning {
  border: 1px solid var(--danger);
  border-left-width: 5px;
  padding: var(--s3) var(--s4);
  color: var(--ink);
  font-size: .9rem;
}

@media (max-width: 600px) {
  .deploy-grid { grid-template-columns: 1fr; }
  .decision-path li { flex-direction: column; gap: .15rem; }
}

/* ---- Week 3: pipeline builder ----------------------------------------- */
.ppl { display: grid; grid-template-columns: 1fr 1.3fr; gap: var(--s4); margin-bottom: var(--s4); }
.ppl-lane { border: 1px dashed var(--rule); border-radius: 8px; padding: var(--s3); min-height: 7rem; }
.ppl-lane h4 { margin: 0 0 var(--s3); font-size: .8rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-3); }
.ppl-lane-out { background: var(--danger-soft); border-color: var(--danger); }
.ppl-lane-in { background: var(--ok-soft); border-color: var(--ok); }
.ppl-step { display: block; width: 100%; text-align: left; margin-bottom: var(--s2);
  background: var(--ground); border: 1px solid var(--rule); border-left: 5px solid var(--ok);
  border-radius: 6px; padding: var(--s2) var(--s3); cursor: pointer; font: inherit; color: var(--ink); }
.ppl-step:hover:not([disabled]) { border-color: var(--ink-4); }
.ppl-step:focus-visible { outline: 2px solid var(--clinical); outline-offset: 2px; }
.ppl-step[disabled] { cursor: default; }
.ppl-step.ppl-out { border-left-color: var(--danger); }
.ppl-name { display: block; font-weight: 650; font-size: .9rem; }
.ppl-what, .ppl-hint { display: block; font-size: .8rem; color: var(--ink-3); }
.ppl-hint { color: var(--clinical); margin-top: 2px; }
.ppl-warn, .ppl-ok { border-left: 5px solid var(--danger); background: var(--danger-soft);
  padding: var(--s3) var(--s4); margin-bottom: var(--s3); font-size: .9rem; }
.ppl-ok { border-left-color: var(--ok); background: var(--ok-soft); }
.ppl-code { font-size: .78rem; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- Week 3: end-to-end stepper ---------------------------------------- */
.e2e-steps { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s2);
  padding: 0; margin: 0 0 var(--s4); }
.e2e-steps li { margin: 0; }
.e2e-steps button { font: inherit; font-size: .8rem; background: var(--ground-2);
  border: 1px solid var(--rule); border-radius: 999px; padding: 4px 10px 4px 4px;
  cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.e2e-steps .n { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem;
  border-radius: 50%; background: var(--rule); font-weight: 650; font-size: .75rem; }
.e2e-steps .is-done button { border-color: var(--ok); }
.e2e-steps .is-done .n { background: var(--ok); color: #fff; }
.e2e-steps .is-current button { border-color: var(--clinical); background: var(--clinical-soft);
  color: var(--ink); font-weight: 620; }
.e2e-steps .is-current .n { background: var(--clinical); color: #fff; }
.e2e h4 { margin-top: 0; }

/* ---- Interactive index page -------------------------------------------- */
.ix-week { margin-bottom: var(--s6, 2.5rem); }
.ix-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }
.ix-item { border: 1px solid var(--rule); border-radius: 8px; padding: var(--s3) var(--s4); }
.ix-item h4 { margin: 0 0 var(--s1); font-size: 1rem; }
.ix-item p { margin: 0 0 var(--s2); font-size: .9rem; }
.ix-meta { font-size: .8rem; color: var(--ink-3); }

@media (max-width: 700px) {
  .ppl { grid-template-columns: 1fr; }
}
