/* Data-Driven Athletics book site: the book page (index.html) and the reader (read.html).
   Colours follow the cover: navy band, cover blue, pale blue sky. */
:root {
  --bg: #f4f8fc; --surface: #ffffff; --surface-2: #eaf2fa; --border: #d3e0ec;
  --text: #0f1b2b; --text-soft: #3d4f63; --text-faint: #6b7d90;
  --accent: #0b6aa2; --accent-2: #084f7a; --accent-soft: #dcecf8; --on-accent: #ffffff;
  --navy: #0f1b2b; --on-navy: #e7eef6;
  --shadow: 0 1px 2px rgba(15, 27, 43, 0.06), 0 8px 24px -12px rgba(15, 27, 43, 0.25);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1420; --surface: #121e2d; --surface-2: #17263a; --border: #24364c;
    --text: #e6eef7; --text-soft: #b5c4d4; --text-faint: #8597aa;
    --accent: #4fa8de; --accent-2: #7cc0ea; --accent-soft: #15324a; --on-accent: #06121e;
    --navy: #070e17; --on-navy: #e7eef6;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px -12px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1420; --surface: #121e2d; --surface-2: #17263a; --border: #24364c;
  --text: #e6eef7; --text-soft: #b5c4d4; --text-faint: #8597aa;
  --accent: #4fa8de; --accent-2: #7cc0ea; --accent-soft: #15324a; --on-accent: #06121e;
  --navy: #070e17; --on-navy: #e7eef6;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); }
a:hover { color: var(--accent-2); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ buttons -- */
.act { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 0.9rem;
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.act:hover { border-color: var(--accent); color: var(--accent); }
.act.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.act.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent); }
.act .sz { font-weight: 400; color: var(--text-faint); font-size: 0.82rem; }
.act.primary .sz { color: inherit; opacity: 0.85; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.acts.big .act { min-height: 44px; padding: 9px 18px; font-size: 0.98rem; }
.chip { display: inline-flex; align-items: center; min-height: 30px; padding: 3px 11px; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent-2); border: 1px solid transparent; font: inherit; font-size: 0.82rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }

/* ------------------------------------------------------------ top bar -- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 20px; background: var(--navy); color: var(--on-navy); }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--on-navy); text-decoration: none; font-weight: 700; }
.brand:hover { color: #fff; }
.brand img { width: 32px; height: 32px; border-radius: 6px; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.top nav a { color: var(--on-navy); text-decoration: none; font-size: 0.92rem; padding: 6px 10px; border-radius: 8px; }
.top nav a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* --------------------------------------------------------------- hero -- */
main { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.hero { display: grid; grid-template-columns: minmax(200px, 330px) 1fr; gap: 44px; align-items: center; padding: 44px 0 36px; }
.cover img { display: block; width: 100%; height: auto; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,.15), 0 22px 44px -18px rgba(15, 27, 43, 0.6); }
.kicker { margin: 0; color: var(--accent); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.hero h1 { margin: 6px 0 4px; font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.05; letter-spacing: -0.02em; }
.hero .sub { margin: 0 0 14px; font-size: 1.2rem; color: var(--text-soft); line-height: 1.4; }
.hero .by { margin: 0 0 16px; color: var(--text-soft); }
.hero .blurb { margin: 0 0 10px; max-width: 46rem; }

/* ----------------------------------------------------------- contents -- */
.part { padding: 26px 0 6px; border-top: 1px solid var(--border); }
.part h2 { margin: 0 0 16px; font-size: 1.45rem; letter-spacing: -0.01em; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.part h2 .pn { color: var(--accent); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; }
.part h2 .pr { color: var(--text-faint); font-size: 0.9rem; font-weight: 500; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; padding-bottom: 18px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; scroll-margin-top: 70px; }
.card .art { display: block; width: 100%; height: auto; aspect-ratio: 5 / 2; object-fit: cover; background: #e8f3fb; }
.cbody { padding: 14px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.card h3 { margin: 3px 0 6px; font-size: 1.2rem; line-height: 1.25; }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a:hover { color: var(--accent); }
.question { margin: 0 0 8px; color: var(--text-soft); font-style: italic; }
details { margin: 2px 0 0; font-size: 0.92rem; color: var(--text-soft); }
details summary { cursor: pointer; color: var(--text-faint); font-weight: 600; }
details ul { margin: 6px 0 0; padding-left: 20px; }
.method { border-top: 1px solid var(--border); margin-top: 8px; }
.method summary { padding: 7px 0; color: var(--accent-2); }
.method figure { margin: 0 0 6px; }
.method img { display: block; width: 100%; height: auto; border-radius: 8px; }
.method figcaption { margin-top: 7px; }
.card .acts { margin-top: auto; padding-top: 12px; }
.appx { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.appx li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; scroll-margin-top: 70px; }
.appx .atitle { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.appx .atitle:hover { color: var(--accent); }
.appx .al { display: block; color: var(--accent); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.appx p { margin: 6px 0 0; color: var(--text-soft); font-size: 0.92rem; overflow-wrap: anywhere; }
.card, .appx li, .app { min-width: 0; }

/* --------------------------------------------------------------- apps -- */
.apps, .cite { padding: 28px 0 10px; border-top: 1px solid var(--border); }
.apps h2, .cite h2 { margin: 0 0 8px; font-size: 1.45rem; }
.lead { margin: 0 0 16px; color: var(--text-soft); max-width: 50rem; }
.applist { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; }
.app { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.app .an a { font-weight: 700; color: var(--text); text-decoration: none; }
.app .an a:hover { color: var(--accent); }
.app .av { display: block; color: var(--text-faint); font-size: 0.85rem; }
.app .ac { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.app .also { color: var(--text-faint); font-size: 0.85rem; }
.app .also a { margin-left: 3px; }
.app > .act { grid-row: 1; grid-column: 2; }
.ref { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 16px; max-width: 60rem; }

.foot { margin-top: 30px; padding: 24px 20px 34px; background: var(--navy); color: var(--on-navy); font-size: 0.9rem; text-align: center; }
.foot p { margin: 4px auto; max-width: 60rem; }
.foot a { color: #9fd0f2; }

/* ------------------------------------------------------- cite dialog -- */
.citebox { width: min(680px, calc(100vw - 24px)); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.citebox::backdrop { background: rgba(8, 15, 25, 0.55); }
.citebox h2 { margin: 0 0 8px; font-size: 1.15rem; }
.citebox .how { margin: 0 0 12px; color: var(--text-soft); font-size: 0.93rem; }
.citebox .tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.citebox pre { margin: 0; max-height: 42vh; overflow: auto; padding: 12px; background: var(--surface-2); border-radius: 8px; font-size: 0.8rem; white-space: pre-wrap; word-break: break-word; }
.dacts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

@media (max-width: 760px) {
  .top { padding: 8px 16px; }
  .top nav a:not(:last-child) { display: none; }
  main { padding: 0 16px; }
  .hero { grid-template-columns: 1fr; gap: 22px; padding-top: 26px; }
  .cover { max-width: 220px; }
  .cards, .appx, .applist { grid-template-columns: minmax(0, 1fr); }
  .act { white-space: normal; }
}

/* ============================================================ reader === */
body.reader main { max-width: none; margin: 0; padding: 0; }
body.reader { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.rbar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--navy); color: var(--on-navy); flex: none; min-height: 54px; }
.rbar .brand span { display: none; }
.ibtn { display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding: 0 8px; border-radius: 9px; border: 0; background: transparent;
  color: var(--on-navy); font: inherit; font-size: 0.85rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.ibtn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.ibtn[aria-disabled="true"] { opacity: 0.35; pointer-events: none; }
.rhead { min-width: 0; flex: 1; }
.rcrumb { font-size: 0.75rem; color: #9db1c6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rcrumb a { color: #b9d6ee; text-decoration: none; }
.rcrumb a:hover { text-decoration: underline; color: #fff; }
.rhead h1 { margin: 0; font-size: 1rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rtools { display: flex; align-items: center; gap: 4px; flex: none; }
.grp { display: inline-flex; align-items: center; }
.pageno { display: inline-flex; align-items: center; gap: 5px; font-size: 0.85rem; color: #c7d6e5; padding: 0 4px; }
.pageno input { width: 3.2em; height: 30px; border-radius: 7px; border: 1px solid #36506d; background: #13243a; color: #fff; text-align: center; font: inherit; }
.rbar .act { min-height: 34px; padding: 5px 12px; background: var(--accent); border-color: var(--accent); color: #fff; }
.rbar .act:hover { background: #1381c2; color: #fff; }
.rbody { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px 1fr; }
body.side-closed .rbody { grid-template-columns: 0 1fr; }
body.side-closed #side { visibility: hidden; }
#side { min-height: 0; overflow: auto; border-right: 1px solid var(--border); background: var(--surface); padding: 12px 10px 20px; }
.side-h { margin: 14px 6px 6px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); }
.side-h:first-child { margin-top: 2px; }
.chlist { list-style: none; margin: 0; padding: 0; }
.chlist a { display: grid; grid-template-columns: 2.1em 1fr; gap: 4px; padding: 6px 8px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 0.9rem; line-height: 1.3; }
.chlist a:hover { background: var(--surface-2); }
.chlist a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-2); font-weight: 700; }
.chlist .n { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.chlist .grp-h { margin: 10px 8px 2px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.inapp { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.inapp a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 0.88rem; }
.inapp a:hover { border-color: var(--accent); color: var(--accent); }
.inapp .ext { color: var(--text-faint); font-size: 0.8rem; }
.qbox { margin: 4px 6px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--text-soft); font-size: 0.88rem; font-style: italic; }
.side-foot { margin: 16px 6px 0; font-size: 0.82rem; color: var(--text-faint); }
.scrim { position: fixed; inset: 0; background: rgba(8, 15, 25, 0.5); z-index: 19; }

#view { min-height: 0; overflow: auto; overscroll-behavior: contain; position: relative; outline: none;
  background: color-mix(in srgb, var(--bg) 82%, #808894); }
#pages { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px 12px 40px; width: max-content; min-width: 100%; }
.page { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18), 0 6px 20px -8px rgba(0, 0, 0, 0.3); flex: none;
  --user-unit: 1; --scale-round-x: 1px; --scale-round-y: 1px; }
.page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.page .links { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.page .links a { position: absolute; pointer-events: auto; border-radius: 2px; }
.page .links a:hover { background: rgba(37, 99, 235, 0.12); outline: 1px solid rgba(37, 99, 235, 0.4); }
.page .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #8a94a6; font-size: 0.9rem; }
.rnote { max-width: 34rem; margin: 12vh auto 0; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); }
.rnote h2 { margin: 0 0 6px; font-size: 1.1rem; }
.rnote p { margin: 0 0 10px; color: var(--text-soft); }

/* pdf.js text layer (from pdfjs-dist web/pdf_viewer.css, trimmed): transparent
   text over the canvas so a reader can select, copy and find words. */
.textLayer { position: absolute; text-align: initial; inset: 0; overflow: clip; opacity: 1; line-height: 1; z-index: 1;
  -webkit-text-size-adjust: none; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText;
  --min-font-size: 1; --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); --min-font-size-inv: calc(1 / var(--min-font-size)); }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; user-select: text; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; --font-height: 0;
  font-size: calc(var(--text-scale-factor) * var(--font-height)); --scale-x: 1; --rotate: 0deg;
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv)); }
.textLayer .markedContent { display: contents; }
.textLayer ::selection { background: rgba(0, 0, 255, 0.25); color: transparent; }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }

@media (max-width: 860px) {
  .rbody { grid-template-columns: 1fr; }
  #side { position: fixed; z-index: 20; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); transform: translateX(-102%); transition: transform 0.2s; }
  body.side-open #side { transform: none; }
  body.side-closed #side { visibility: visible; }
  .rbar { gap: 4px; padding: 6px 6px; }
  .rcrumb, .zoom, .rbar .act .lg, .rbar .brand { display: none; }
  .pageno span:last-child { display: none; }
  #pages { padding: 10px 6px 30px; gap: 10px; }
}
.cite-line { font-size: .8rem; color: var(--muted, #5b6b85); margin: 6px 0 0; }
