/* ===================================================================
   DNA Inheritance — "How it really works" (page 2) — modern theme
   Accent blue from the esfh.org.uk header (#006EC7). Self-contained copy;
   page 1 never depends on this file.
   =================================================================== */

:root {
  --c-red:#e6394a; --c-blue:#2f7be6; --c-green:#2fb84a; --c-yellow:#f2c31c;
  --c-purple:#8b3fd1; --c-orange:#f2802b; --c-turquoise:#1ec8c8; --c-pink:#f25fa8;

  --blue:#006ec7;
  --blue-600:#005aa3;
  --blue-700:#01467c;
  --blue-050:#eaf3fc;
  --blue-100:#d5e7f8;

  --ink:#14212e;
  --ink-2:#42536a;
  --ink-3:#6d7d90;
  --bg:#eef3f8;
  --surface:#ffffff;
  --surface-2:#f3f6fa;
  --line:#dbe3ec;
  --danger:#e5484d;

  --radius:16px;
  --shadow-sm:0 1px 2px rgba(20,33,46,.06);
  --shadow:0 1px 2px rgba(20,33,46,.05), 0 10px 26px rgba(20,33,46,.08);

  --anim-scale:1;

  /* special inheritance lines — high contrast against the blue fan */
  --mt:#0ca678;   /* mitochondrial (green) */
  --yy:#f08c00;   /* Y (amber) */
  --xx:#e64980;   /* X (magenta) */
}

* { box-sizing:border-box; }
html { scroll-behavior:smooth; }
body {
  margin:0;
  font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color:var(--ink-2);
  background:radial-gradient(1200px 600px at 50% -10%, var(--blue-050), transparent 60%), var(--bg);
  min-height:100vh;
  -webkit-font-smoothing:antialiased;
}

/* ---- banner ---- */
.banner {
  text-align:center; padding:30px 16px 22px;
  background:linear-gradient(135deg, var(--blue) 0%, var(--blue-600) 55%, var(--blue-700) 100%);
  color:#fff; box-shadow:0 6px 22px rgba(0,90,163,.28);
}
.banner h1 { margin:0; font-size:clamp(24px,3.8vw,42px); font-weight:800; letter-spacing:-0.5px; color:#fff; }
.subtitle { margin:8px auto 18px; max-width:880px; color:rgba(255,255,255,.9); font-size:clamp(13px,1.6vw,17px); line-height:1.5; }
.subtitle em { color:#fff; font-style:normal; font-weight:700; }

/* ---- buttons ---- */
button, .btnlink {
  font-family:inherit; cursor:pointer; font-weight:600; border:none; border-radius:10px;
  transition:transform .12s ease, box-shadow .15s ease, background .15s ease, filter .12s ease;
  text-decoration:none; display:inline-block; color:#fff;
}
button:active { transform:translateY(1px); }
button:disabled { cursor:not-allowed; opacity:.5; }
button:focus-visible { outline:3px solid var(--blue-100); outline-offset:2px; }

.toolbar { display:flex; gap:10px; justify-content:center; align-items:center; flex-wrap:wrap; }
.toolbar .spacer { flex:0 0 20px; }
.toggle { background:rgba(255,255,255,.16); color:#fff; padding:9px 15px; font-size:14px; border:1px solid rgba(255,255,255,.45); }
.toggle:hover { background:rgba(255,255,255,.26); }
.toggle[aria-pressed="true"] { background:#fff; color:var(--blue-600); border-color:#fff; box-shadow:0 2px 8px rgba(0,0,0,.15); }
.ctrl { background:#fff; color:var(--blue-600); padding:9px 17px; font-size:14px; box-shadow:0 2px 8px rgba(0,0,0,.14); }
.ctrl:hover { filter:brightness(.97); }
.ctrl.danger { background:rgba(255,255,255,.14); color:#fff; border:1px solid rgba(255,255,255,.5); }
.ctrl.danger:hover { background:var(--danger); border-color:var(--danger); }

.crank {
  font-size:clamp(15px,2vw,19px); font-weight:700; padding:12px 26px; color:#fff;
  background:var(--blue); border-radius:999px; box-shadow:0 6px 16px rgba(0,110,199,.32); letter-spacing:.1px;
}
.crank:not(:disabled):hover { background:var(--blue-600); transform:translateY(-1px); box-shadow:0 8px 20px rgba(0,110,199,.4); }
.crank.ready { animation:crankPulse 1.5s ease-in-out infinite; }
@keyframes crankPulse {
  0%,100%{ box-shadow:0 6px 16px rgba(0,110,199,.32); }
  50%{ box-shadow:0 6px 16px rgba(0,110,199,.32), 0 0 0 6px rgba(0,110,199,.16); }
}

/* ---- the crank itself: a handle that really turns ----
   Self-contained copy of the page-1 treatment; page 1 never depends on this. */
.crank.has-crank { display:inline-flex; align-items:center; gap:11px; }
.crank-icon { width:1.6em; height:1.6em; flex:none; }
.ck-plate { fill:rgba(255,255,255,.14); stroke:rgba(255,255,255,.5); stroke-width:1.7; }
.ck-bar, .ck-knob, .ck-hub { fill:#fff; }
.ck-tail { fill:rgba(255,255,255,.7); }
.ck-knob { stroke:rgba(0,54,99,.18); stroke-width:1; }
.ck-pin  { fill:#0b5ea3; }
.ck-arm  { transform-box:view-box; transform-origin:20px 20px; }

@keyframes crankIdle {
  0%,70%,100% { transform:rotate(0deg); }
  78%         { transform:rotate(-18deg); }
  88%         { transform:rotate(12deg); }
}
@keyframes crankSpin { from { transform:rotate(0deg); } to { transform:rotate(360deg); } }

.crank.ready .ck-arm                { animation:crankIdle 2.6s ease-in-out infinite; }
.crank:not(:disabled):hover .ck-arm { animation:crankSpin 1.5s linear infinite; }
.crank.turning .ck-arm              { animation:crankSpin calc(var(--anim-scale) * 620ms) linear infinite; }
/* a crank that is mid-turn is busy, not unavailable — keep it bright */
.crank.turning:disabled { opacity:1; cursor:progress; }

/* ---- layout ---- */
.machine { max-width:1500px; margin:0 auto; padding:22px 18px 48px; }
.stage {
  margin:16px 0; padding:22px; border-radius:var(--radius);
  background:var(--surface); border:1px solid var(--line); box-shadow:var(--shadow);
}
.stage-head { text-align:center; margin-bottom:16px; }
.stage-head h2 { margin:0; font-size:clamp(19px,2.4vw,27px); font-weight:800; letter-spacing:-0.3px; color:var(--ink); }
.stage-head h2::after { content:""; display:block; width:48px; height:3px; margin:9px auto 0; background:var(--blue); border-radius:2px; }
.stage-note { margin:8px auto 0; max-width:880px; color:var(--ink-3); font-size:14px; line-height:1.5; }
.stage-note em { color:var(--ink-2); font-style:normal; font-weight:600; }

/* ---- caption cards ---- */
.caption {
  background:var(--blue-050); border:1px solid var(--blue-100); border-left:4px solid var(--blue);
  border-radius:10px; padding:12px 15px; margin:12px auto; max-width:940px; color:var(--ink-2);
  font-size:13.5px; line-height:1.55;
}
.caption b { color:var(--ink); }
.tag {
  display:inline-block; font-size:11px; font-weight:700; letter-spacing:.4px;
  background:var(--blue); color:#fff; padding:2px 9px; border-radius:20px; margin-right:6px; text-transform:uppercase;
}

/* ---- tabs ---- */
.tabs { display:flex; gap:8px; justify-content:center; flex-wrap:wrap; margin:16px 0 2px; }
.tab {
  padding:11px 22px; font-size:15px; border-radius:12px; background:var(--surface);
  color:var(--ink-2); border:1px solid var(--line); font-weight:700;
}
.tab:hover { border-color:var(--blue-100); }
.tab[aria-selected="true"] { background:var(--blue); color:#fff; border-color:var(--blue); box-shadow:0 6px 16px rgba(0,110,199,.28); }
.view[hidden] { display:none; }

/* ---- chip ---- */
.chip {
  display:inline-flex; align-items:center; gap:6px; background:#fff; border:1px solid var(--line);
  border-radius:20px; padding:4px 12px; font-size:12.5px; font-weight:600; color:var(--ink-2);
}
.chip .sw { width:14px; height:14px; border-radius:50%; box-shadow:inset 0 0 0 1px rgba(0,0,0,.1); }

/* =================================================================
   VIEW A — pedigree of karyotype people
   ================================================================= */
.pedigree { display:flex; flex-direction:column; gap:14px; }
.gen-row { display:grid; gap:12px; align-items:start; justify-content:center; }
.gen-8 { grid-template-columns:repeat(4,minmax(150px,1fr)); }
.gen-4 { grid-template-columns:repeat(4,minmax(150px,1fr)); max-width:1100px; margin:0 auto; }
.gen-2 { grid-template-columns:repeat(2,minmax(180px,1fr)); max-width:760px; margin:0 auto; }
.gen-1 { grid-template-columns:minmax(220px,520px); justify-content:center; }

.person {
  position:relative; border-radius:12px; padding:10px 12px 12px;
  background:var(--surface); border:1px solid var(--line); box-shadow:var(--shadow-sm);
}
.person::before, .person::after { display:none; }
.person .who { text-align:center; font-size:12.5px; font-weight:700; color:var(--ink); margin:0 0 8px; letter-spacing:.2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.person.you { border-color:var(--blue-100); box-shadow:0 0 0 2px var(--blue-100), var(--shadow); }
.person.you .who { color:var(--blue-600); font-size:16px; }
.person.founder { cursor:pointer; transition:box-shadow .15s ease, transform .1s ease; }
.person.founder:hover { box-shadow:0 0 0 2px var(--blue), var(--shadow); transform:translateY(-1px); }

/* karyotype */
.karyo { display:flex; flex-direction:column; gap:5px; }
.chrom { display:flex; flex-direction:column; gap:2px; }
.copy { position:relative; height:9px; border-radius:5px; overflow:hidden; background:#e7edf4; box-shadow:inset 0 0 0 1px rgba(20,33,46,.05); }
.you .copy { height:12px; }
.seg { position:absolute; top:0; bottom:0; }
.cut { position:absolute; top:-2px; bottom:-2px; width:2px; background:var(--ink); box-shadow:0 0 4px 1px rgba(20,33,46,.5); opacity:0; z-index:3; }
.copy.building .seg { animation:wipeIn calc(var(--anim-scale)*520ms) ease-out both; }
.copy.building .cut { animation:cutFlash calc(var(--anim-scale)*600ms) ease-out both; }
@keyframes wipeIn { from{ clip-path:inset(0 100% 0 0); } to{ clip-path:inset(0 0 0 0); } }
@keyframes cutFlash { 0%{opacity:0} 30%{opacity:1} 100%{opacity:0} }

.tracing .seg { opacity:.16; }
.tracing .seg.traced { opacity:1; box-shadow:0 0 0 1px rgba(20,33,46,.35); }

.legend { display:flex; flex-wrap:wrap; gap:8px 12px; justify-content:center; margin-top:14px; }
.legend .chip { cursor:pointer; }
.legend .chip:hover { border-color:var(--blue-100); }
.legend .chip.dim { opacity:.4; }

.breakdown { display:flex; flex-wrap:wrap; gap:6px 10px; justify-content:center; margin-top:12px; }
.trace-readout { text-align:center; margin-top:12px; font-size:15px; color:var(--ink); min-height:22px; }
.trace-readout b { color:var(--blue-600); }

/* =================================================================
   VIEW B — fan chart
   ================================================================= */
.vb-controls { display:flex; gap:14px; justify-content:center; align-items:center; flex-wrap:wrap; margin-bottom:8px; }
.vb-controls label { font-size:14px; color:var(--ink-2); font-weight:700; }
.vb-controls input[type=range] { width:min(320px,60vw); accent-color:var(--blue); }
.depth-val { color:var(--blue-600); font-variant-numeric:tabular-nums; }

/* sex of the simulated person — decides the Y and X inheritance patterns */
.sex-picker { display:inline-flex; align-items:center; gap:6px; }
.sex-label { font-size:14px; color:var(--ink-2); font-weight:700; }
.toggle.sex { background:#fff; color:var(--ink-2); border:1px solid var(--line); padding:7px 14px; font-size:13px; }
.toggle.sex[aria-pressed="true"] { background:var(--blue); color:#fff; border-color:var(--blue); box-shadow:0 4px 12px rgba(0,110,199,.26); }

/* ---- key ---- */
.fan-key { display:flex; gap:10px 20px; justify-content:center; flex-wrap:wrap; margin:10px 0 4px; font-size:13px; color:var(--ink-2); }
.key-item { display:inline-flex; align-items:center; gap:7px; font-weight:600; }
.key-sw { width:22px; height:14px; border-radius:3px; box-shadow:inset 0 0 0 1px rgba(20,33,46,.25); }
.key-sw.sw-dna  { background:linear-gradient(90deg, rgba(0,110,199,.28), rgba(0,110,199,1)); }
/* must match the SVG <pattern id="noDna"> used for zero-contribution cells */
.key-sw.sw-none { background:repeating-linear-gradient(45deg, #69757f 0 3px, #9aa6b2 3px 7px); box-shadow:inset 0 0 0 1px #5b6670; }

/* ---- reconciliation table ---- */
.recon { max-width:640px; margin:18px auto 0; }
.recon h3 { margin:0 0 4px; text-align:center; font-size:16px; font-weight:800; color:var(--ink); }
.recon-note { margin:0 auto 10px; max-width:600px; text-align:center; font-size:12.5px; color:var(--ink-3); line-height:1.45; }
.gen-table { width:100%; border-collapse:collapse; font-size:13px; background:var(--surface); border:1px solid var(--line); border-radius:10px; overflow:hidden; }
.gen-table th, .gen-table td { padding:6px 10px; text-align:right; border-bottom:1px solid var(--line); font-variant-numeric:tabular-nums; }
.gen-table th:first-child, .gen-table td:first-child { text-align:left; }
.gen-table tr.head th { background:var(--surface-2); color:var(--ink); font-weight:700; font-size:12px; }
.gen-table tr:last-child td { border-bottom:none; }
.gen-table tr.outer td { background:var(--blue-050); font-weight:700; color:var(--ink); }
.gen-table tr.totals td { background:var(--blue); color:#fff; font-weight:800; border-top:2px solid var(--blue-600); }
.tagsm { display:inline-block; font-size:10.5px; font-weight:700; letter-spacing:.3px; background:var(--blue); color:#fff; padding:1px 7px; border-radius:20px; text-transform:uppercase; }
.tagsm-alt { background:#fff; color:var(--blue-600); }

.headline { text-align:center; font-size:clamp(16px,2.4vw,24px); color:var(--ink); margin:8px auto 4px; max-width:1000px; line-height:1.45; font-weight:600; }
.headline b { color:var(--blue-600); font-variant-numeric:tabular-nums; }
.headline .drop { color:#e8590c; font-weight:800; }

.fan-wrap { display:flex; justify-content:center; }
#fanChart { width:min(760px,94vw); height:auto; }
#fanChart text { font-family:inherit; }
/* percentage labels: dark text with a white halo so they read on any sector */
#fanChart .fan-lbl { fill:var(--ink); paint-order:stroke; stroke:#fff; stroke-width:2.6px; stroke-linejoin:round; }
.fan-sector { transition:opacity .25s ease; }
.fan-sector.no-dna { stroke-width:.8; }
.fan-sector.hl-mt { stroke:var(--mt); stroke-width:2.6; }
.fan-sector.hl-y  { stroke:var(--yy); stroke-width:2.6; }
.fan-sector.hl-x  { stroke:var(--xx); stroke-width:2.2; stroke-dasharray:3 2; }

.line-toggles { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; margin:12px 0 4px; }
.line-toggles .toggle { font-size:13px; padding:7px 13px; background:#fff; color:var(--ink-2); border:1px solid var(--line); }
.line-toggles .toggle[data-line="mt"][aria-pressed="true"] { background:var(--mt); color:#fff; border-color:var(--mt); }
.line-toggles .toggle[data-line="y"][aria-pressed="true"]  { background:var(--yy); color:#fff; border-color:var(--yy); }
.line-toggles .toggle[data-line="x"][aria-pressed="true"]  { background:var(--xx); color:#fff; border-color:var(--xx); }

.special-caps { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:10px; max-width:1100px; margin:12px auto 0; }
.special-caps .caption { margin:0; background:var(--surface-2); border-color:var(--line); border-left-color:var(--blue); }
.dot { display:inline-block; width:11px; height:11px; border-radius:50%; vertical-align:middle; margin-right:5px; }

/* ---- nav / foot ---- */
.foot { text-align:center; padding:28px 16px; color:var(--ink-3); font-size:13px; }
.page-nav { margin-bottom:16px; }

/* ---- reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior:auto; }
  .crank.ready { animation:none; }
  .ck-arm { animation:none !important; }
  .copy.building .seg, .copy.building .cut { animation:none; }
  .fan-sector { transition:none; }
}
@media (max-width:720px){ .gen-8, .gen-4 { grid-template-columns:repeat(2,minmax(140px,1fr)); } }
