/**
 * Outbreak Simulator styles.
 *
 * Page-local palette per the house lab convention (see
 * chemical-and-physical-changes.css), with a dark variant. Dark mode follows
 * the site theme (html[data-theme], set from the usaws_theme cookie by a tiny
 * script in the view) and falls back to the OS preference.
 *
 * Meaning-carrying colors: PURPLE = virus, GREEN = bacterium. Neither is the
 * only signal: names are always printed, and every student state in the
 * school grid has its own shape as well as its own color.
 *
 * WCAG 2.1 AA: 0.75rem minimum font size, 44px touch targets on every
 * control, :focus-visible rings, reduced motion respected (main.js jumps to
 * the final day instead of animating), correctness never conveyed by color
 * alone (feedback carries a check or cross plus words).
 */
:root {
  --bg: #eef2f7;
  --paper: #ffffff;
  --paper-2: #f5f7fb;
  --ink: #17222e;
  --muted: #4d5d6c;
  --line: #d3dce6;

  --virus: #6b2fa8;
  --virus-bg: #f3ecfb;
  --bact: #14693d;
  --bact-bg: #e8f6ee;
  --accent: #1d4e89;
  --accent-bg: #eaf1fa;
  --good: #1a7f4b;
  --good-bg: #e9f8ef;
  --bad: #b42323;
  --bad-bg: #fff1f1;

  --m-s: #ffffff; --m-e: #e0a100; --m-i: #c92a2a; --m-r: #0f766e; --m-v: #1d4e89;
  --shadow: rgba(23, 34, 46, .05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1722; --paper: #17212e; --paper-2: #1d2937; --ink: #e8eef5; --muted: #a9b8c8; --line: #2e3d4f;
    --virus: #c9a2ee; --virus-bg: #281a3b; --bact: #7fd8a6; --bact-bg: #12301f;
    --accent: #8cb8f0; --accent-bg: #172a42; --good: #6fd69c; --good-bg: #12301f; --bad: #ff9a9a; --bad-bg: #3a1a1a;
    --m-s: #17212e; --m-e: #f0b400; --m-i: #ff6b6b; --m-r: #3cc5b8; --m-v: #7fb2f5;
    --shadow: rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1722; --paper: #17212e; --paper-2: #1d2937; --ink: #e8eef5; --muted: #a9b8c8; --line: #2e3d4f;
  --virus: #c9a2ee; --virus-bg: #281a3b; --bact: #7fd8a6; --bact-bg: #12301f;
  --accent: #8cb8f0; --accent-bg: #172a42; --good: #6fd69c; --good-bg: #12301f; --bad: #ff9a9a; --bad-bg: #3a1a1a;
  --m-s: #17212e; --m-e: #f0b400; --m-i: #ff6b6b; --m-r: #3cc5b8; --m-v: #7fb2f5;
  --shadow: rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body { background: var(--bg); color: var(--ink); }
.os-wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px 28px; }
.os-wrap, .os-wrap * { font-family: 'Inter', system-ui, sans-serif; }
.os-wrap h1, .os-wrap h2, .os-wrap h3, .os-eyebrow, .os-part, .os-btn, .os-chip-n {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
}
.os-sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.os-wrap :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* HERO ------------------------------------------------------------------ */
.os-hero { padding: 18px 8px 6px; text-align: center; }
.os-hero-title { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.os-hero h1 { font-weight: 700; font-size: clamp(1.7rem, 4.4vw, 2.5rem); line-height: 1.05; letter-spacing: -.02em; }
.os-eyebrow {
  font-weight: 600; letter-spacing: .14em; text-transform: uppercase; font-size: .75rem;
  color: #fff; background: linear-gradient(90deg, #6b2fa8 0 50%, #14693d 50% 100%);
  padding: 5px 12px; border-radius: 6px;
}
.os-sub { max-width: 720px; margin: 8px auto 0; color: var(--muted); font-size: 1rem; font-weight: 500; line-height: 1.5; }
.os-standard {
  display: inline-block; margin-top: 10px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); font-size: .8rem; font-weight: 600; color: var(--muted);
}
.os-note { max-width: 720px; margin: 8px auto 0; color: var(--muted); font-size: .85rem; line-height: 1.45; }
.os-preview {
  margin: 12px 0; padding: 10px 14px; border-radius: 10px; background: var(--accent-bg);
  border: 1px solid var(--line); font-weight: 600; font-size: .9rem;
}

/* PANELS ---------------------------------------------------------------- */
.os-panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; margin: 16px 0; box-shadow: 0 6px 20px var(--shadow);
}
.os-panel h2 { font-weight: 700; font-size: 1.35rem; margin-bottom: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.os-part {
  font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--bg); background: var(--ink); padding: 4px 10px; border-radius: 6px;
}
.os-panel-sub { color: var(--muted); font-size: .95rem; line-height: 1.5; margin-bottom: 14px; }
.os-h3 { font-size: 1.05rem; font-weight: 700; margin: 14px 0 8px; }
.os-next { margin-top: 12px; color: var(--muted); font-size: .9rem; font-style: italic; }

/* PROGRESS STRIP -------------------------------------------------------- */
.os-progress {
  display: flex; align-items: center; gap: 12px; margin: 12px 0; position: sticky; top: 0; z-index: 5;
  padding: 8px 10px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.os-chips { list-style: none; display: flex; gap: 8px; flex-wrap: wrap; }
.os-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 44px; min-height: 44px; padding: 4px 12px;
  border-radius: 999px; border: 2px solid var(--line); background: var(--paper); color: var(--ink); text-decoration: none; font-weight: 700;
}
.os-chip-done { border-color: var(--good); background: var(--good-bg); }
.os-chip-check { color: var(--good); font-weight: 700; }
.os-prog-count { font-size: .85rem; font-weight: 600; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* TASK LIST ------------------------------------------------------------- */
.os-tasklist { list-style: none; display: grid; gap: 10px; counter-reset: task; }
.os-task { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--paper-2); }
.os-task-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.os-task p { font-size: .9rem; color: var(--muted); line-height: 1.5; margin-top: 4px; }
.os-status { font-size: .8rem; font-weight: 700; color: var(--muted); }
.os-task-done { border-color: var(--good); background: var(--good-bg); }
.os-task-done .os-status { color: var(--good); }
.os-done-banner { margin-top: 12px; padding: 10px 14px; border-radius: 10px; border: 2px solid var(--good); background: var(--good-bg); font-weight: 700; }

/* CARDS ----------------------------------------------------------------- */
.os-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; margin: 14px 0; }
.os-cardbox { border-radius: 14px; padding: 16px; border: 2px solid; }
.os-cardbox h3 { font-size: 1.15rem; font-weight: 700; }
.os-kind { font-size: .85rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.os-cardbox-virus { border-color: var(--virus); background: var(--virus-bg); }
.os-cardbox-virus h3 { color: var(--virus); }
.os-cardbox-bacterium { border-color: var(--bact); background: var(--bact-bg); }
.os-cardbox-bacterium h3 { color: var(--bact); }
.os-card dt { font-weight: 700; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.os-card dd { font-size: .95rem; line-height: 1.5; }

/* SORT ------------------------------------------------------------------ */
.os-sort { display: grid; gap: 10px; }
.os-sortitem { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px; background: var(--paper-2); }
.os-sortitem legend { font-size: .97rem; font-weight: 600; padding: 0 6px; line-height: 1.45; }
.os-sortnum { color: var(--muted); }
.os-sortopts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.os-sortfb { font-size: .9rem; margin-top: 6px; min-height: 1.2em; }
.os-ok { border-color: var(--good); background: var(--good-bg); }
.os-ok .os-sortfb { color: var(--good); font-weight: 600; }
.os-bad { border-color: var(--bad); background: var(--bad-bg); }
.os-bad .os-sortfb { color: var(--bad); font-weight: 600; }

.os-pill { position: relative; display: inline-flex; }
.os-pill input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.os-pill > span {
  display: inline-flex; flex-direction: column; justify-content: center; min-height: 44px; padding: 8px 18px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--paper); font-weight: 600; font-size: .95rem; pointer-events: none;
}
.os-pill input:checked + span { border-color: var(--accent); background: var(--accent-bg); box-shadow: inset 0 0 0 1px var(--accent); }
.os-pill input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.os-pill input:disabled { cursor: default; }
.os-pill input:disabled + span { opacity: .75; }
.os-pill-big > span { border-radius: 12px; align-items: flex-start; }
.os-pill-big small { font-weight: 500; color: var(--muted); font-size: .8rem; }

/* BUTTONS + FEEDBACK ---------------------------------------------------- */
.os-btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.os-btn {
  min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 2px solid var(--ink); background: var(--paper);
  color: var(--ink); font-weight: 600; font-size: .95rem; cursor: pointer;
}
.os-btn:hover:not(:disabled) { background: var(--paper-2); }
.os-btn:disabled { opacity: .5; cursor: not-allowed; }
.os-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .os-btn-primary { color: #0f1722; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .os-btn-primary { color: #0f1722; } }
.os-btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.os-btn-quiet { border-color: var(--line); font-weight: 500; }
.os-feedback { margin-top: 10px; font-size: .95rem; font-weight: 600; }
.os-fb-good { color: var(--good); }
.os-fb-bad { color: var(--bad); }

/* SIMULATOR LAYOUT ------------------------------------------------------ */
.os-sim-grid { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 20px; align-items: start; }
.os-fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 14px; margin-bottom: 12px; background: var(--paper-2); min-width: 0; }
.os-fieldset legend { font-weight: 700; font-size: .95rem; padding: 0 6px; }
.os-pick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.os-card-live { max-height: 260px; overflow-y: auto; padding-right: 4px; }
.os-card-live dd { font-size: .85rem; }
.os-lock { font-size: .9rem; font-weight: 600; color: var(--bad); margin-bottom: 8px; }

.os-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px; cursor: pointer; border-top: 1px solid var(--line); }
.os-fieldset .os-opt:first-of-type { border-top: 0; }
.os-opt input[type="checkbox"] { width: 24px; height: 24px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.os-opt > span { display: flex; flex-direction: column; font-size: .95rem; }
.os-opt small, .os-opt-range small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.4; font-weight: 400; }
.os-opt-range, .os-opt-abx { display: block; cursor: default; }
.os-opt-range label { display: block; }
.os-range-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.os-range-row input[type="range"] { flex: 1; min-height: 44px; accent-color: var(--accent); }
.os-range-row output { min-width: 3.2em; font-weight: 700; font-family: 'JetBrains Mono', ui-monospace, monospace; text-align: right; }
.os-abx-main { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.os-abx-main input { width: 24px; height: 24px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.os-abx-main span { display: flex; flex-direction: column; font-size: .95rem; }
.os-abx-use { margin: 8px 0 0 34px; }
.os-abx-use label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.os-abx-use select {
  width: 100%; min-height: 44px; padding: 8px 10px; font-size: .9rem; border-radius: 8px; border: 2px solid var(--line);
  background: var(--paper); color: var(--ink);
}
.os-inline-note { font-size: .8rem; color: var(--muted); line-height: 1.45; margin-top: 6px; }
.os-budget { margin-top: 10px; font-size: .9rem; font-weight: 700; }
.os-budget-over { color: var(--bad); }

/* STAGE ----------------------------------------------------------------- */
.os-stage { min-width: 0; }
.os-stage .os-h3:first-child { margin-top: 0; }
.os-school-wrap { background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.os-school { display: block; width: 100%; max-width: 560px; margin: 0 auto; height: auto; min-height: 120px; }
.os-m * { stroke-width: 2; }
.os-m-S circle { fill: var(--m-s); stroke: var(--muted); }
.os-m-E circle:first-child { fill: var(--m-e); stroke: var(--ink); }
.os-m-I circle { fill: var(--m-i); stroke: var(--ink); }
.os-m-H circle:first-child { fill: var(--m-i); stroke: var(--ink); opacity: .45; }
.os-m-R rect { fill: var(--m-r); stroke: var(--ink); }
.os-m-V rect { fill: var(--m-v); stroke: var(--ink); }
.os-ring { fill: none; stroke: var(--ink); stroke-dasharray: 3 3; stroke-width: 1.5; }
.os-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0; font-size: .85rem; }
.os-legend li { display: inline-flex; align-items: center; gap: 4px; }
.os-legend-mark { width: 26px; height: 26px; }
.os-legend-mark .os-m * { stroke-width: 2.5; }

.os-play { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.os-play input[type="range"] { flex: 1; min-height: 44px; accent-color: var(--accent); }
.os-daylabel { min-width: 4.5em; font-weight: 700; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .9rem; }
.os-counts { font-size: .9rem; color: var(--muted); min-height: 2.8em; line-height: 1.4; }

.os-chart-wrap { width: 100%; background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; overflow: hidden; }
.os-chart { display: block; max-width: 100%; }
.os-grid { stroke: var(--line); stroke-width: 1; }
.os-tick, .os-axis { fill: var(--muted); font-size: 12px; font-family: 'Inter', sans-serif; }
.os-axis { font-weight: 600; }
.os-line { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.os-line-now { stroke: var(--m-i); stroke-width: 3.5; }
.os-line-total { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 2 4; }
.os-line-base { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 8 5; opacity: .8; }
.os-dayline { stroke: var(--ink); stroke-width: 1; opacity: .35; }
.os-dot-now { fill: var(--m-i); stroke: var(--ink); stroke-width: 2; }
.os-chart-key { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0; font-size: .85rem; }
.os-chart-key li { display: inline-flex; align-items: center; gap: 6px; }
.os-key { display: inline-block; width: 30px; height: 0; border-top: 4px solid; }
.os-key-now { border-color: var(--m-i); }
.os-key-total { border-color: var(--accent); border-top-style: dotted; }
.os-key-base { border-color: var(--muted); border-top-style: dashed; }
.os-readout { font-weight: 600; font-size: 1rem; line-height: 1.5; margin-top: 8px; }
.os-sub-readout { font-size: .9rem; color: var(--muted); line-height: 1.5; margin-top: 4px; min-height: 1.4em; }

/* DETAILS + TABLES ------------------------------------------------------ */
.os-details { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 12px; background: var(--paper-2); }
.os-details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700; font-size: .95rem; }
.os-details ul { margin: 0 0 8px 22px; }
.os-details li { font-size: .9rem; line-height: 1.55; margin-bottom: 4px; }
.os-tablewrap { overflow-x: auto; max-height: 360px; overflow-y: auto; }
.os-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.os-table th, .os-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.os-table thead th { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); position: sticky; top: 0; background: var(--paper); }
.os-table tbody th { font-weight: 700; }
.os-runs td:nth-child(3) { white-space: normal; min-width: 180px; }
.os-runs td:nth-child(n+4), .os-runs th:nth-child(n+4) { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.os-over { color: var(--muted); font-style: italic; }
.os-empty { color: var(--muted); font-size: .9rem; margin: 8px 0; }
.os-export-status { font-size: .85rem; color: var(--muted); }

/* LAB NOTEBOOK ---------------------------------------------------------- */
.labnb--os {
  --labnb-surface: var(--paper); --labnb-border: var(--line); --labnb-ink: var(--ink);
  --labnb-muted: var(--muted); --labnb-accent: var(--accent);
  margin-top: 0; border-top: 0; padding-top: 0;
}
.os-nb-label { font-family: 'Space Grotesk', sans-serif; font-size: .8rem; }
.os-nb-h { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; }
.os-nb-props a { color: var(--accent); font-weight: 600; }
.os-nb-field textarea { min-height: 96px; font-size: .97rem; line-height: 1.5; background: var(--paper-2); color: var(--ink); }
.labnb--os .labnb-log { max-height: 220px; overflow-y: auto; }

.os-copyright { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 20px; }

@media (max-width: 860px) {
  .os-sim-grid { grid-template-columns: 1fr; }
  .os-card-live { max-height: none; }
}
@media (max-width: 560px) {
  .os-panel { padding: 14px; border-radius: 14px; }
  .os-progress { gap: 6px; padding: 6px; }
  .os-chip { padding: 4px 8px; }
  .os-prog-count { font-size: .75rem; }
  .os-sortopts .os-pill { flex: 1 1 28%; }
  .os-sortopts .os-pill > span { width: 100%; align-items: center; padding: 8px 6px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
