/* AI Imaging Lab: shared styles for the landing page, the teacher guide and the credits page.
   Plain CSS. No web fonts, no images, no external requests, so it also works from file://.
   scripts/build-credits.ts copies this whole file into credits.html and into the marked block
   of teachers.html, which keeps those two pages self-contained inside the downloaded demo. */

/* ---- Tokens ------------------------------------------------------------------------------ */
:root {
  --bg: #f3f7f9;
  --surface: #ffffff;
  --surface-2: #e6eff3;
  --text: #14232b;
  --muted: #455a64;
  --line: #c5d5dc;
  --accent: #0b6a82;
  --accent-ink: #ffffff;
  --accent-soft: #d3e9ef;
  --violet: #6a43a8;
  --violet-bg: #efe9f8;
  --amber: #8a5a12;
  --amber-bg: #f8eed9;
  --film: #0a1318;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Bahnschrift SemiCondensed", "Arial Narrow", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --radius: 14px;
  --measure: 62ch;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1a20;
    --surface: #16252d;
    --surface-2: #1d303a;
    --text: #e6eef2;
    --muted: #a9bcc6;
    --line: #2e4553;
    --accent: #5bc2db;
    --accent-ink: #06222b;
    --accent-soft: #1c3c47;
    --violet: #b9a0ea;
    --violet-bg: #2a2140;
    --amber: #dcae62;
    --amber-bg: #3a2c12;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1a20;
  --surface: #16252d;
  --surface-2: #1d303a;
  --text: #e6eef2;
  --muted: #a9bcc6;
  --line: #2e4553;
  --accent: #5bc2db;
  --accent-ink: #06222b;
  --accent-soft: #1c3c47;
  --violet: #b9a0ea;
  --violet-bg: #2a2140;
  --amber: #dcae62;
  --amber-bg: #3a2c12;
  color-scheme: dark;
}

/* ---- Base -------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.125rem/1.6 var(--font-body);
}

h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; margin: 0; text-wrap: balance; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
ul, ol { padding-inline-start: 1.3rem; }
li + li { margin-top: 0.3rem; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap { width: min(100% - 2rem, 70rem); margin-inline: auto; }

.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  border-radius: 0 0 10px 10px;
}
.skip-link:focus { top: 0; }

/* ---- Header and footer ------------------------------------------------------------------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.75rem; padding-block: 0.7rem; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font: 700 1.5rem/1 var(--font-head);
  text-decoration: none;
}
.brand svg { width: 1.9rem; height: 1.9rem; color: var(--accent); flex: none; }

.site-header nav { margin-inline-start: auto; }
.nav { display: flex; flex-wrap: wrap; gap: 0.1rem 1.4rem; margin: 0; padding: 0; list-style: none; }
.nav li + li { margin-top: 0; }
.nav a { display: inline-block; padding: 0.55rem 0; color: var(--text); font-weight: 600; text-decoration: none; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--accent); text-decoration: underline; text-decoration-thickness: 2px; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.4rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font: 600 0.95rem/1 var(--font-body);
  cursor: pointer;
}
.theme-toggle svg { width: 1.15rem; height: 1.15rem; }
.theme-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

.site-footer { margin-top: 3rem; padding-block: 1.75rem 2.5rem; background: var(--surface); border-top: 1px solid var(--line); color: var(--muted); font-size: 0.97rem; }
.site-footer p { max-width: var(--measure); }
.footer-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; margin: 0; padding: 0; list-style: none; }
.footer-nav li + li { margin-top: 0; }

/* ---- Buttons ----------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3.25rem;
  padding: 0.7rem 1.6rem;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: 700 1.1rem/1.2 var(--font-body);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--accent-soft); text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.btn-big { min-height: 4.25rem; padding-inline: 2.4rem; font-size: 1.3rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; margin-top: 1.75rem; }

/* ---- Landing: hero ----------------------------------------------------------------------- */
.hero { padding-block: clamp(2rem, 6vw, 4.5rem); }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr); gap: clamp(1.5rem, 5vw, 4rem); align-items: center; }
.hero h1 { margin-bottom: 1.1rem; font-size: clamp(2.6rem, 6.6vw, 4.6rem); line-height: 1.02; letter-spacing: -0.01em; }
.lede { max-width: 33em; font-size: 1.3rem; line-height: 1.55; }
.hero-note { margin: 1.1rem 0 0; color: var(--muted); font-size: 1rem; }

.film { margin: 0; padding: 0.9rem; border: 1px solid #22404c; border-radius: 22px; background: var(--film); }
.film svg { display: block; width: 100%; height: auto; border-radius: 14px; }
.film figcaption { padding: 0.65rem 0.4rem 0.15rem; color: #b8cbd4; font-size: 0.92rem; line-height: 1.45; }
.film .bones { fill: rgba(207, 232, 240, 0.16); stroke: #cfe8f0; stroke-width: 1.6; }
.film .carpal { fill: rgba(207, 232, 240, 0.22); }
.film .haze { fill: none; stroke: #cfe8f0; stroke-width: 22; stroke-linecap: round; opacity: 0.1; }
.film .finding rect { fill: rgba(220, 174, 98, 0.1); stroke: #dcae62; stroke-width: 2.2; stroke-dasharray: 7 5; }
.film .finding text { fill: #dcae62; font: 700 15px var(--font-body); }
.film .sweep { opacity: 0; }

@media (prefers-reduced-motion: no-preference) {
  .film .sweep { animation: sweep 3.8s ease-in-out 0.6s 1 both; }
  .film .finding { opacity: 0; animation: appear 0.7s ease-out 4.6s 1 forwards; }
}
@keyframes sweep {
  0% { transform: translateY(-30px); opacity: 0; }
  12%, 88% { opacity: 1; }
  100% { transform: translateY(500px); opacity: 0; }
}
@keyframes appear { to { opacity: 1; } }

/* ---- Landing: sections ------------------------------------------------------------------- */
.section { padding-block: clamp(2.25rem, 5vw, 4rem); }
.section.band { background: var(--surface); border-block: 1px solid var(--line); }
.section h2 { margin-bottom: 0.7rem; font-size: clamp(1.9rem, 3.8vw, 2.7rem); line-height: 1.08; }
.section-intro { max-width: var(--measure); margin-bottom: 2rem; color: var(--muted); }

.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { margin: 0; padding-top: 0.9rem; border-top: 3px solid var(--accent); counter-increment: step; }
.steps li::before { display: block; content: counter(step); color: var(--accent); font: 700 2.4rem/1 var(--font-head); }
.steps h3 { margin: 0.25rem 0 0.3rem; font-size: 1.5rem; }
.steps p { margin: 0; color: var(--muted); }

.machines { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; margin: 0; padding: 0; list-style: none; }
.machine { display: flex; flex-direction: column; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.machine .art { display: grid; place-items: center; padding: 1.25rem; background: var(--surface-2); color: var(--accent); }
.machine .art svg { width: min(100%, 15rem); height: auto; }
.machine .body { padding: 1.1rem 1.35rem 1.5rem; }
.machine h3 { margin-bottom: 0.35rem; font-size: 1.75rem; line-height: 1.1; }
.machine .idea { font-weight: 700; }
.machine p:last-child { margin-bottom: 0; color: var(--muted); }

.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.compare > div { padding: 1.35rem 1.5rem 1.2rem; border: 1px solid var(--line); border-top-width: 6px; border-radius: var(--radius); background: var(--bg); }
.compare .ai { border-top-color: var(--accent); }
.compare .doctor { border-top-color: var(--text); }
.compare h3 { margin-bottom: 0.6rem; font-size: 1.6rem; }
.compare ul { margin: 0; }

.voices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; margin: 2.25rem 0 0; }
.voice { margin: 0; padding: 1rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.voice figcaption { margin-bottom: 0.4rem; font-weight: 700; }
.voice blockquote { margin: 0; }
.voice.kid { border-color: var(--violet); background: var(--violet-bg); }
.voice.kid figcaption { color: var(--violet); }
.voices-note { margin: 0.9rem 0 0; color: var(--muted); font-size: 0.97rem; }

.callout { margin: 1.5rem 0 0; padding: 0.95rem 1.2rem; border-left: 6px solid var(--amber); border-radius: 0 var(--radius) var(--radius) 0; background: var(--amber-bg); }
.callout > :last-child { margin-bottom: 0; }
.callout strong { color: var(--amber); }

.kit { display: grid; gap: 0.5rem; padding: clamp(1.25rem, 3vw, 2rem); border: 1px solid var(--line); border-radius: 22px; background: var(--surface); }
.kit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem 1.75rem; }
.kit-info { min-width: 0; flex: 1 1 18rem; }
.kit-info p { margin: 0; }
.kit-meta { font-weight: 600; }
.kit-sha { margin-top: 0.3rem; color: var(--muted); font: 0.85rem/1.4 var(--font-mono); overflow-wrap: anywhere; user-select: all; }
.kit-missing { margin: 0; padding: 0.9rem 1.2rem; border-left: 6px solid var(--amber); border-radius: 0 var(--radius) var(--radius) 0; background: var(--amber-bg); font-weight: 600; }
.kit-promise { margin: 0.75rem 0 0; color: var(--muted); }

.os-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; margin: 1.75rem 0 0; }
.os { padding-top: 0.8rem; border-top: 3px solid var(--accent); }
.os h3 { margin-bottom: 0.4rem; font-size: 1.5rem; }
.os p { margin: 0; }

.two-col { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3rem); align-items: start; }
.two-col > :last-child { margin-top: 0; }
.checklist { margin: 0 0 1.25rem; padding-inline-start: 1.2rem; }

/* ---- Teacher guide and credits ----------------------------------------------------------- */
.page-head { padding-block: clamp(1.75rem, 4vw, 3rem) 0.5rem; }
.page-head h1 { margin-bottom: 0.7rem; font-size: clamp(2.2rem, 5.2vw, 3.6rem); line-height: 1.04; }
.page-head .lede { margin-bottom: 1rem; }
.page-head h1.long { max-width: 30ch; font-size: clamp(1.9rem, 4.2vw, 2.8rem); line-height: 1.12; }

.toc { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.25rem 0 0; padding: 0; list-style: none; }
.toc li + li { margin-top: 0; }
.toc a { display: inline-block; padding: 0.4rem 0.95rem; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 0.97rem; font-weight: 600; text-decoration: none; }
.toc a:hover { border-color: var(--accent); color: var(--accent); }

.doc-section { padding-block: clamp(1.5rem, 3vw, 2.25rem); border-top: 1px solid var(--line); }
.doc-section:first-of-type { margin-top: 1.5rem; }
.doc-section h2 { margin-bottom: 0.6rem; font-size: clamp(1.7rem, 3.4vw, 2.3rem); line-height: 1.1; }
.doc-section h3 { margin: 1.4rem 0 0.4rem; font-size: 1.4rem; }
.prose .wrap > p, .prose .wrap > ul, .prose .wrap > ol { max-width: var(--measure); }

.terms { display: grid; grid-template-columns: minmax(7rem, max-content) minmax(0, 1fr); gap: 0.55rem 1.75rem; max-width: 52rem; margin: 0; }
.terms dt { font-weight: 700; }
.terms dd { margin: 0; }

.table-wrap { margin: 0 0 1rem; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 1rem; }
table.grid caption { padding: 0 0 0.5rem; text-align: left; font-weight: 700; }
table.grid th, table.grid td { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid thead th { border-bottom: 2px solid var(--text); font-weight: 700; white-space: nowrap; }
table.grid td:first-child { white-space: nowrap; font-weight: 600; }

details.qa { margin: 0.6rem 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
details.qa summary { padding: 0.8rem 1.1rem; font-weight: 700; cursor: pointer; }
details.qa[open] summary { border-bottom: 1px solid var(--line); }
details.qa > div { padding: 0.8rem 1.1rem 0.2rem; max-width: var(--measure); }

code { padding: 0.08em 0.35em; border-radius: 5px; background: var(--surface-2); font: 0.92em var(--font-mono); overflow-wrap: anywhere; }
kbd { padding: 0.05em 0.45em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); font: 0.9em var(--font-mono); }

.note { margin: 1rem 0; padding: 0.85rem 1.1rem; border-left: 6px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; background: var(--accent-soft); max-width: 48rem; }
.note > :last-child { margin-bottom: 0; }

.credit-case { padding-block: 1.5rem; border-top: 1px solid var(--line); }
.credit-case h2 { margin-bottom: 0.2rem; font-size: 1.9rem; }
.credit-case .case-meta { margin-bottom: 1rem; color: var(--muted); }
.image-credit { margin: 0 0 1rem; padding: 1rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.image-credit h3 { margin-bottom: 0.5rem; font-size: 1.25rem; }
.image-credit dl { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0.3rem 1.25rem; margin: 0; }
.image-credit dt { color: var(--muted); font-weight: 600; }
.image-credit dd { margin: 0; overflow-wrap: anywhere; }
.empty { padding: 1rem 1.25rem; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); max-width: 40rem; }

/* ---- Worksheet --------------------------------------------------------------------------- */
.worksheet { padding: clamp(1.1rem, 3vw, 1.75rem); border: 2px solid var(--text); border-radius: var(--radius); background: var(--surface); }
.ws-title { flex: 1 1 100%; margin: 0; font: 700 2rem/1.1 var(--font-head); }
.ws-top { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem 1.5rem; margin-bottom: 0.5rem; }
.ws-fill { display: flex; flex: 1 1 12rem; gap: 0.5rem; align-items: end; }
.ws-fill span.line { flex: 1; min-height: 1.6rem; border-bottom: 1.5px solid currentColor; }
.ws-q { margin-top: 1.4rem; break-inside: avoid; }
.ws-q h4 { margin: 0 0 0.5rem; font-size: 1.3rem; }
.ws-q p { margin: 0 0 0.5rem; }
.match { display: flex; flex-wrap: wrap; gap: 0.5rem 2.25rem; margin: 0 0 0.9rem; padding: 0; list-style: none; }
.match li { display: flex; align-items: center; gap: 0.6rem; margin: 0; }
.match b { font: 700 1.3rem var(--font-head); }
.match .box { display: inline-block; width: 2.2rem; height: 2.2rem; border: 1.5px solid currentColor; }
.options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem 1rem; margin: 0 0 0.5rem; padding: 0; list-style: none; }
.options li { margin: 0; padding: 0.5rem 0.8rem; border: 1.5px solid currentColor; border-radius: 10px; }
.break-art { display: block; width: min(100%, 30rem); height: auto; margin: 0.25rem 0 0.5rem; color: var(--text); }
.choices { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; margin: 0 0 0.6rem; padding: 0; list-style: none; }
.choices li { margin: 0; padding: 0.3rem 1.1rem; border: 1.5px solid currentColor; border-radius: 999px; }
.lines span { display: block; height: 2.1rem; border-bottom: 1px solid var(--muted); }
.ws-foot { margin: 1.25rem 0 0; color: var(--muted); font-size: 0.9rem; }
.print-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin: 0 0 1rem; }
.print-row p { margin: 0; color: var(--muted); }

.kit-only { display: none; }
.is-kit .kit-only { display: list-item; }
.is-kit .hosted-only { display: none; }

/* ---- Small screens ----------------------------------------------------------------------- */
@media (max-width: 52rem) {
  .hero .wrap, .two-col { grid-template-columns: minmax(0, 1fr); }
  .steps, .machines, .os-grid { grid-template-columns: minmax(0, 1fr); }
  .compare, .voices { grid-template-columns: minmax(0, 1fr); }
  .site-header nav { order: 3; flex-basis: 100%; margin-inline-start: 0; }
  .theme-toggle { margin-inline-start: auto; }
  .machine .art svg { width: min(100%, 12rem); }
}
@media (max-width: 34rem) {
  body { font-size: 1.0625rem; }
  .terms { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; }
  .terms dd { margin-bottom: 0.7rem; }
  .image-credit dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .image-credit dd { margin-bottom: 0.45rem; }
  .btn { width: 100%; }
  .options { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Print: the whole guide, or only the worksheet --------------------------------------- */
@media print {
  @page { margin: 14mm; }
  /* :not(#print) raises specificity so the paper colours win over the dark theme tokens. */
  :root:not(#print) {
    --bg: #ffffff; --surface: #ffffff; --surface-2: #ffffff; --text: #000000; --muted: #222222;
    --line: #888888; --accent: #000000; --accent-ink: #ffffff; --accent-soft: #ffffff;
    --violet: #000000; --violet-bg: #ffffff; --amber: #000000; --amber-bg: #ffffff;
    color-scheme: light;
  }
  body { font-size: 11pt; line-height: 1.45; }
  .skip-link, .site-header, .site-footer, .toc, .actions, .theme-toggle, .print-row, .no-print { display: none !important; }
  .doc-section { break-inside: auto; }
  .worksheet { break-before: page; border: none; padding: 0; }
  body.print-worksheet .doc-section { padding: 0; border: none; }
  .ws-q, table.grid tr, details.qa, .image-credit { break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  body.print-worksheet main > :not(#worksheet), body.print-worksheet .page-head { display: none !important; }
  body.print-worksheet .worksheet { break-before: auto; }
  /* No script needed: opening the guide at #worksheet and printing prints only the worksheet. */
  body:has(#worksheet:target) main > :not(#worksheet), body:has(#worksheet:target) .page-head { display: none !important; }
  body:has(#worksheet:target) .worksheet { break-before: auto; }
}
