/* Foundations of Science II — Midterm 2 study guide */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --fg: #1d1c1a;
  --muted: #5d5a54;
  --line: #d6d2c8;
  --strong-line: #8a857a;
  --link: #1f5fa8;
  /* Diagram accents: A = DNA / CRISPR, B = RNA / RNAi, C = warning / foreign */
  --accent-a: #1f5fa8;
  --accent-a-soft: #e3edf9;
  --accent-b: #b4561a;
  --accent-b-soft: #fbeadf;
  --accent-c: #6b4fa0;
  --accent-c-soft: #eee8f7;
  --ok: #2c7a4b;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161614;
    --surface: #1f1f1c;
    --surface-2: #2a2a26;
    --fg: #ebe8e1;
    --muted: #a9a59c;
    --line: #3d3c37;
    --strong-line: #7d796f;
    --link: #8cb8ec;
    --accent-a: #8cb8ec;
    --accent-a-soft: #1d2b3c;
    --accent-b: #f0a46e;
    --accent-b-soft: #3a2619;
    --accent-c: #c2aef0;
    --accent-c-soft: #2d2540;
    --ok: #79c99a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #161614;
  --surface: #1f1f1c;
  --surface-2: #2a2a26;
  --fg: #ebe8e1;
  --muted: #a9a59c;
  --line: #3d3c37;
  --strong-line: #7d796f;
  --link: #8cb8ec;
  --accent-a: #8cb8ec;
  --accent-a-soft: #1d2b3c;
  --accent-b: #f0a46e;
  --accent-b-soft: #3a2619;
  --accent-c: #c2aef0;
  --accent-c-soft: #2d2540;
  --ok: #79c99a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
[id] { scroll-margin-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
}

h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.85rem; margin: 1.25rem 0 1.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; margin: 2.5rem 0 1rem; padding-top: 0.5rem; border-top: 1px solid var(--line); }
h3 { font-size: 1.1rem; margin: 1.75rem 0 0.5rem; }
a { color: var(--link); }
p, ul, ol { margin: 0 0 1.15rem; }
li { margin-bottom: 0.65rem; padding-left: 0.2rem; }
li::marker { color: var(--muted); }
ul { padding-left: 1.4rem; }
strong { font-weight: 700; }
.lede { font-size: 1.15em; margin-bottom: 2rem; color: var(--fg); }
.lead-in { font-weight: 700; margin-bottom: 0.6rem; }

/* Each subsection is its own card, so the page reads as a stack of distinct topics. */
.block {
  margin: 2rem 0;
  padding: 1.4rem 1.6rem 0.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.block > h2 { margin: 0 0 1rem; padding: 0; border: 0; }
.block.check { border-left: 4px solid var(--accent-a); }
.block figure.diagram { background: var(--bg); }
.block .table-wrap { margin-bottom: 1.25rem; }

@media (min-width: 768px) {
  body { font-size: 1.125rem; line-height: 1.75; }
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Diagrams ---------- */

figure.diagram {
  margin: 1.75rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
figure.diagram svg { display: block; width: 100%; height: auto; max-width: 560px; margin: 0 auto; color: var(--fg); }
figure.diagram figcaption { margin-top: 0.75rem; font-size: 0.95rem; color: var(--fg); }
figure.diagram figcaption strong { display: block; }

.d-box { fill: var(--surface-2); stroke: var(--strong-line); stroke-width: 1.5; }
.d-card { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.d-line { stroke: var(--strong-line); stroke-width: 2; fill: none; }
.d-dash { stroke: var(--strong-line); stroke-width: 1.5; stroke-dasharray: 5 5; fill: none; }
.d-head { fill: var(--strong-line); }
.d-text { fill: currentColor; }
.d-muted { fill: var(--muted); }
.d-a { fill: var(--accent-a); }
.d-b { fill: var(--accent-b); }
.d-c { fill: var(--accent-c); }
.d-a-line { stroke: var(--accent-a); stroke-width: 2.5; fill: none; }
.d-b-line { stroke: var(--accent-b); stroke-width: 2.5; fill: none; }
.d-a-box { fill: var(--accent-a-soft); stroke: var(--accent-a); stroke-width: 2; }
.d-b-box { fill: var(--accent-b-soft); stroke: var(--accent-b); stroke-width: 2; }
.d-c-box { fill: var(--accent-c-soft); stroke: var(--accent-c); stroke-width: 1.5; }
.d-chip { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; }

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

.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.site-title { font-weight: 700; color: var(--fg); text-decoration: none; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn, .theme-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  min-height: 44px; padding: 0 12px; cursor: pointer; font-size: 0.95rem;
}

.layout { display: block; }
main { max-width: 72ch; margin: 0 auto; padding: 0.5rem 16px 4rem; min-width: 0; }

.sidebar {
  position: fixed; z-index: 40; top: 0; bottom: 0; left: 0;
  width: min(86vw, 320px);
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 1rem 0.75rem 2rem;
  display: none;
}
.menu-open .sidebar { display: block; }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.45); }
.scrim[hidden] { display: none; }

.sidebar-head { font-size: 0.85rem; color: var(--muted); margin: 0 0.5rem 0.75rem; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list li { margin: 0; }
.nav-list a {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 6px 8px; border-radius: 8px;
  color: var(--fg); text-decoration: none; line-height: 1.3; font-size: 0.97rem;
}
.nav-list a:hover { background: var(--surface-2); }
.nav-list a[aria-current="page"] { background: var(--accent-a-soft); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent-a); }
.nav-num {
  flex: none; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; border: 1px solid var(--line); color: var(--muted);
}
.nav-label { flex: 1; }

@media (min-width: 768px) {
  .layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); }
  .sidebar-hidden .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar-hidden .sidebar { display: none; }
  .sidebar {
    position: sticky; top: 61px; height: calc(100vh - 61px);
    display: block; width: auto;
    background: var(--bg);
  }
  .scrim { display: none; }
  main { max-width: 50rem; padding: 0.75rem 40px 5rem; }
  figure.diagram svg { max-width: 640px; }
}

/* ---------- Pager ---------- */

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0.75rem 0; }
.pager a {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 56px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--fg); text-decoration: none; line-height: 1.3;
}
.pager a:hover { border-color: var(--strong-line); }
.pager-next { text-align: right; }
.pager-dir { font-size: 0.8rem; color: var(--muted); }
.pager-title { font-size: 0.92rem; font-weight: 600; color: var(--link); }
.pager-bottom { margin-top: 3rem; }
.keys-hint { font-size: 0.85rem; color: var(--muted); text-align: center; }
@media (hover: none) { .keys-hint { display: none; } }

/* ---------- Tables ---------- */

.table-wrap { margin: 1rem 0 1.5rem; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; line-height: 1.5; }
th, td { text-align: left; vertical-align: top; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--line); }
thead th { font-size: 0.85rem; color: var(--muted); background: var(--surface-2); border-bottom: 2px solid var(--strong-line); }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
tbody th { font-weight: 600; }

@media (max-width: 640px) {
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack, table.stack tbody, table.stack tr, table.stack th, table.stack td { display: block; width: 100%; }
  table.stack tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 0.75rem; background: var(--surface); padding: 0.25rem 0; }
  table.stack th, table.stack td { border: 0; padding: 0.3rem 0.8rem; }
  table.stack tbody th { font-size: 1.02rem; padding-top: 0.5rem; }
  table.stack td::before { content: attr(data-label); display: block; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
  table.stack td[data-label=""]::before { display: none; }
}

table.pairs.covered td { cursor: pointer; }
table.pairs.covered td:not(.revealed) { color: transparent; background: var(--surface-2); user-select: none; position: relative; }
table.pairs.covered td:not(.revealed)::after {
  content: "Tap to reveal"; position: absolute; left: 0.6rem; top: 0.55rem; color: var(--muted); font-size: 0.85rem;
}
.cover-btn, .reset-checks, .fc-bar button, .fc-actions button {
  min-height: 44px; padding: 0 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--strong-line); background: var(--surface);
}

/* ---------- Schedule checklist ---------- */

.checklist { list-style: none; padding: 0; }
.checklist li { margin: 0; border-bottom: 1px solid var(--line); }
.checklist label { display: flex; gap: 12px; align-items: flex-start; padding: 0.6rem 0; cursor: pointer; }
.checklist input { flex: none; width: 22px; height: 22px; margin-top: 0.15rem; accent-color: var(--ok); }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; }
.reset-row { margin-top: 2rem; }

/* ---------- Practice questions ---------- */

.question { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 0.9rem 1rem; margin: 0 0 1rem; }
.q-text { margin: 0 0 0.6rem; font-weight: 500; }
.q-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.8rem; height: 1.8rem; margin-right: 0.35rem; border-radius: 50%;
  background: var(--accent-a-soft); color: var(--accent-a); font-weight: 700; font-size: 0.9rem;
}
.question summary {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--strong-line); border-radius: 8px; cursor: pointer; list-style: none; user-select: none;
}
.question summary::-webkit-details-marker { display: none; }
.question details[open] summary { background: var(--surface-2); }
.question summary .hide, .question details[open] summary .show { display: none; }
.question details[open] summary .hide { display: inline; }
.question details p { margin: 0.75rem 0 0; padding: 0.75rem 0.9rem; border-left: 3px solid var(--ok); background: var(--surface-2); border-radius: 0 8px 8px 0; }

/* ---------- Plain-language card (lecture pages) ---------- */

.plain {
  margin: 0 0 2rem;
  padding: 1.1rem 1.4rem 0.2rem;
  background: var(--accent-a-soft);
  border-left: 4px solid var(--accent-a);
  border-radius: 0 12px 12px 0;
}
.plain h2 { margin: 0 0 0.5rem; padding: 0; border: 0; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-a); }

/* ---------- Further reading ---------- */

.src-intro { font-size: 0.95em; color: var(--muted); }
.source-list { list-style: none; padding: 0; }
.source-list li { padding: 0.75rem 0; margin: 0; border-top: 1px solid var(--line); }
.source-list li:first-child { border-top: 0; padding-top: 0; }
.source-list a { font-weight: 600; }
.source-list a::after { content: " ↗"; font-weight: 400; }
.src-pub { display: block; font-size: 0.85em; color: var(--muted); }
.src-note { display: block; font-size: 0.95em; margin-top: 0.15rem; }

/* ---------- Answer template ---------- */

.template .steps { padding-left: 1.6rem; }
.template .steps li { margin-bottom: 0.75rem; }
.template .steps li::marker { font-weight: 700; color: var(--accent-a); }
.template .avoid { padding: 0.7rem 0.9rem; border-radius: 8px; background: var(--accent-b-soft); color: var(--fg); }

/* ---------- Role-play scenarios ---------- */

.scenario-meta { margin: 0 0 0.2rem; font-size: 0.85rem; color: var(--muted); }
.block.scenario > h2 { margin-bottom: 0.75rem; }
.patient {
  margin: 0 0 1.25rem; padding: 0.9rem 1.1rem;
  background: var(--surface-2); border-radius: 12px 12px 12px 2px;
  font-size: 1.08em; font-style: italic;
}
.draft-label { display: block; font-size: 0.85rem; font-weight: 700; color: var(--muted); margin-bottom: 0.35rem; }
.scenario textarea {
  display: block; width: 100%; min-height: 7rem; margin-bottom: 1rem; padding: 0.7rem 0.85rem;
  font: inherit; font-size: 0.97em; line-height: 1.6; color: var(--fg);
  background: var(--bg); border: 1px solid var(--strong-line); border-radius: 8px; resize: vertical;
}
.model { margin-bottom: 1.2rem; }
.model summary {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--strong-line); border-radius: 8px; cursor: pointer; list-style: none; user-select: none;
}
.model summary::-webkit-details-marker { display: none; }
.model[open] summary { background: var(--surface-2); }
.model summary .hide, .model[open] summary .show { display: none; }
.model[open] summary .hide { display: inline; }
.model-body { margin-top: 1rem; padding: 1rem 1.2rem 0.2rem; border-left: 3px solid var(--ok); background: var(--bg); border-radius: 0 8px 8px 0; }
.covers-head { font-weight: 700; margin-bottom: 0.4rem; }
.covers { margin-bottom: 1rem; }

/* ---------- Flashcards ---------- */

.flashcards { margin: 1rem 0 2rem; }
.fc-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin-bottom: 0.75rem; }
.fc-mode { display: flex; gap: 6px; flex-wrap: wrap; }
.fc-bar button[aria-pressed="true"] { background: var(--accent-a-soft); border-color: var(--accent-a); font-weight: 700; }
.fc-card {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 0.75rem;
  width: 100%; min-height: 220px; padding: 1.25rem; text-align: center;
  border: 2px solid var(--strong-line); border-radius: 14px; background: var(--surface); cursor: pointer;
}
.fc-card.back { border-color: var(--accent-a); background: var(--accent-a-soft); }
.fc-side { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.fc-text { font-size: 1.3rem; font-weight: 600; line-height: 1.4; }
.fc-card.back .fc-text { font-size: 1.08rem; font-weight: 400; }
.fc-hint { font-size: 0.85rem; color: var(--muted); }
.fc-pos { text-align: center; color: var(--muted); font-size: 0.9rem; margin: 0.5rem 0; min-height: 1.4em; }
.fc-actions { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
.fc-actions .fc-mark { border-color: var(--accent-b); }
.fc-actions .fc-got { border-color: var(--ok); }
button:disabled { opacity: 0.45; cursor: default; }
