:root {
  --paper: #f6f1e7;
  --paper2: #efe8d8;
  --ink: #1c1812;
  --muted: #6f6754;
  --line: #d8cfba;
  --accent: #b3541e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;
  --sans: -apple-system, "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { background: var(--paper); color: var(--ink); font-family: var(--serif); line-height: 1.5; }
::selection { background: #ffd9b3; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.site-head { }
.masthead { display: flex; gap: 40px; padding: 42px 40px 26px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; max-width: 1280px; margin: 0 auto; }
.kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
h1 { font-size: clamp(34px, 5vw, 58px); font-weight: 600; line-height: 1.02; letter-spacing: -.01em; max-width: 640px; }
h1 .accent { color: var(--accent); font-style: italic; }
.standfirst { margin-top: 18px; max-width: 640px; font-size: 17px; color: #3d382c; }
.mast-right { min-width: 300px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--ink); border: 1.5px solid var(--ink); }
.stat { background: var(--paper2); padding: 16px 12px; text-align: center; }
.stat b { display: block; font-size: 30px; line-height: 1; color: var(--ink); }
.stat span { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.standmore { display: none; }

.tabs { display: flex; gap: 0; max-width: 1280px; margin: 0 auto; padding: 0 40px; flex-wrap: wrap; }
.tabs-wrap { position: sticky; top: 0; z-index: 30; background: var(--paper); border-bottom: 2px solid var(--ink); }
.tabs-scroll-hint { display: none; }
.tabs a { font-family: var(--mono); font-size: 13.5px; padding: 12px 20px; border: none; border-right: 1px solid var(--line); cursor: pointer; color: var(--muted); text-decoration: none; display: block; touch-action: manipulation; }
.tabs a:first-child { border-left: 1px solid var(--line); }
.tabs a.active { color: var(--paper); background: var(--ink); }

/* ---------- layout ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 34px 40px 80px; }
.view { display: none; }
.view.active { display: block; animation: fadein .16s var(--ease-out); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

h2.view-title { font-size: 30px; margin-bottom: 6px; }
.view-sub { color: var(--muted); font-size: 16px; margin-bottom: 26px; max-width: 760px; }

/* ---------- overview ---------- */
.ov-grid { display: grid; grid-template-columns: 1.25fr .9fr; gap: 34px; align-items: start; }
@media (max-width: 980px) { .ov-grid { grid-template-columns: 1fr; } }
.card { background: #fffdf7; border: 1.5px solid var(--ink); box-shadow: 4px 4px 0 rgba(28,24,18,.14); padding: 22px; margin-bottom: 22px; }
.card h3 { font-size: 19px; margin-bottom: 10px; }
.card p { margin-bottom: 10px; font-size: 15.5px; }
.card .mono-tag { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-bottom: 6px; }
.anatomy { list-style: none; }
.anatomy li { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.anatomy li:last-child { border-bottom: none; }
.anatomy .n { font-family: var(--mono); color: var(--accent); font-weight: 700; flex-shrink: 0; }
.domain-legend { display: flex; flex-wrap: wrap; gap: 8px; }
.dom-chip { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 12px; padding: 5px 10px; border: 1px solid var(--line); background: #fffdf7; cursor: pointer; }
.dom-chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.dom-chip b { font-weight: 400; }
.obs-list { list-style: none; }
.obs-list li { padding: 12px 0 12px 26px; border-bottom: 1px dashed var(--line); position: relative; font-size: 15.5px; }
.obs-list li:last-child { border-bottom: none; }
.obs-list li::before { content: "§"; position: absolute; left: 0; color: var(--accent); font-family: var(--mono); }
.obs-list li b { display: block; font-size: 16.5px; }

/* ---------- timeline ---------- */
.tl-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.tl-controls .label { font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.arc-toggle { font-family: var(--mono); font-size: 12.5px; padding: 6px 12px; border: 1.5px solid var(--line); background: #fffdf7; cursor: pointer; color: var(--ink); }
.arc-toggle.on { color: #fff; border-color: currentColor; }
#tl-wrap { position: relative; background: #fffdf7; border: 1.5px solid var(--ink); box-shadow: 4px 4px 0 rgba(28,24,18,.14); overflow-x: auto; }
#tl-svg { display: block; min-width: 1000px; }
.tl-hint { font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 8px 12px 0; }
.arc-cards { margin-top: 30px; }
.arc-cards h2.view-title { margin-top: 12px; }
.arc-card { border: 1.5px solid var(--ink); background: #fffdf7; box-shadow: 4px 4px 0 rgba(28,24,18,.14); margin-bottom: 20px; overflow: hidden; }
.arc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 16px 22px; cursor: pointer; border-left: 7px solid var(--accent); background: var(--paper2); }
.arc-head h3 { font-size: 21px; }
.arc-head .count { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.arc-body { padding: 18px 22px 20px; display: none; }
.arc-card.open .arc-body {
  display: block; opacity: 1; transform: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(-6px); }
}
.arc-thesis { font-style: italic; font-size: 16.5px; margin-bottom: 12px; color: #3d382c; }
.arc-body p { font-size: 15px; margin-bottom: 12px; }
.arc-body .lbl { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); display: block; margin: 12px 0 4px; }
.arc-docs { display: flex; flex-wrap: wrap; gap: 7px; margin: 6px 0 2px; }
.doc-chip { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); background: var(--paper); padding: 4px 9px; cursor: pointer; display: inline-flex; gap: 7px; align-items: center; }
.doc-chip .yr { color: var(--muted); }
.pred-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.pred-chip { font-family: var(--mono); font-size: 12px; padding: 4px 9px; border: 1px solid var(--accent); color: var(--accent); cursor: pointer; background: transparent; }
/* hover is for pointers — touch taps must not leave a stuck hover state */
@media (hover: hover) and (pointer: fine) {
  .tabs a:hover { color: var(--ink); background: rgba(0,0,0,.03); }
  .dom-chip:hover { border-color: var(--ink); }
  .doc-chip:hover { border-color: var(--ink); background: #fff; }
  .pred-chip:hover { background: var(--accent); color: #fff; }
  .doc-card:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 rgba(28,24,18,.18); }
}

/* tactile press feedback — better-ui: always scale(0.96) */
.tabs a, .dom-chip, .doc-chip, .pred-chip, .arc-toggle, .drawer-close, .standmore, .tabs-scroll-hint { transition: transform 140ms var(--ease-out); }
.tabs a:active, .dom-chip:active, .doc-chip:active, .pred-chip:active, .arc-toggle:active, .doc-card:active, .drawer-close:active, .standmore:active, .tabs-scroll-hint:active { transform: scale(0.96); }

/* ---------- predictions ---------- */
.pred-controls { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.pred-controls .label { font-family: var(--mono); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
#pred-sort { font-family: var(--mono); font-size: 13px; padding: 6px 10px; border: 1.5px solid var(--ink); background: #fffdf7; }
.pred-card { border: 1.5px solid var(--ink); background: #fffdf7; box-shadow: 4px 4px 0 rgba(28,24,18,.14); margin-bottom: 18px; padding: 20px 22px; position: relative; }
.pred-card .pred-id { position: absolute; top: 18px; right: 20px; font-family: var(--mono); font-size: 26px; font-weight: 700; color: rgba(28,24,18,.16); }
.pred-card h3 { font-size: 20px; max-width: 82%; margin-bottom: 10px; }
.conviction-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.conv-bar { flex: 1; max-width: 340px; height: 14px; background: var(--paper2); border: 1px solid var(--line); position: relative; }
.conv-fill { position: absolute; inset: 0; width: 100%; background: linear-gradient(90deg, #d9a05b, var(--accent)); transform: scaleX(0); transform-origin: left; transition: transform .8s var(--ease-out); }
.conv-num { font-family: var(--mono); font-size: 20px; font-weight: 700; }
.conv-label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.horizon { font-family: var(--mono); font-size: 12.5px; color: var(--accent); border: 1px solid var(--accent); padding: 2px 8px; white-space: nowrap; }
.pred-card .statement { font-size: 15.5px; margin-bottom: 14px; }
.pred-card .lbl { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); display: block; margin: 12px 0 5px; }
.counter-note { font-size: 14.5px; color: #4a4436; font-style: italic; }
.pursue-box { background: var(--paper2); border-left: 4px solid var(--accent); padding: 10px 14px; font-size: 15px; }

/* ---------- pursuits ---------- */
.pursuit { display: grid; grid-template-columns: 70px 1fr; gap: 0; border: 1.5px solid var(--ink); background: #fffdf7; box-shadow: 4px 4px 0 rgba(28,24,18,.14); margin-bottom: 16px; }
.pursuit .rank { display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 30px; font-weight: 700; color: var(--paper); background: var(--ink); }
.pursuit:nth-child(odd) .rank { background: var(--accent); }
.pursuit .pbody { padding: 18px 22px; }
.pursuit h3 { font-size: 20px; margin-bottom: 8px; }
.pursuit p { font-size: 15px; margin-bottom: 10px; }
.pursuit .links { display: flex; gap: 7px; flex-wrap: wrap; }

/* ---------- library ---------- */
.lib-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 6px; }
.lib-controls select, .lib-controls input { font-family: var(--mono); font-size: 13px; padding: 7px 10px; border: 1.5px solid var(--ink); background: #fffdf7; }
.lib-controls input { flex: 1; min-width: 220px; }
.lib-count { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.doc-card { border: 1.5px solid var(--ink); background: #fffdf7; padding: 16px 18px; cursor: pointer; position: relative; transition: transform 140ms var(--ease-out), box-shadow .12s ease; display: flex; flex-direction: column; gap: 8px; }
.doc-card .top { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11.5px; }
.doc-card .yr { font-weight: 700; }
.doc-card h4 { font-size: 17.5px; line-height: 1.2; }
.doc-card .author { font-size: 13.5px; color: var(--muted); font-style: italic; }
.doc-card .abs { font-size: 14px; color: #3d382c; }
.doc-card .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; }
.doc-card .tag { font-family: var(--mono); font-size: 10.5px; padding: 2px 7px; border: 1px solid var(--line); color: var(--muted); }
.receipt-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.receipt-dot.strict { background: var(--ink); }
.receipt-dot.cultural { background: none; border: 1.5px solid var(--ink); }

/* ---------- drawer ---------- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(28,24,18,.45); z-index: 40; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 220ms var(--ease-out), visibility 0s linear 220ms; }
.drawer-overlay.open { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 220ms var(--ease-out), visibility 0s; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 92vw); background: var(--paper); border-left: 2px solid var(--ink); z-index: 50; overflow-y: auto; padding: 30px 30px 60px; transform: translateX(100%); opacity: 0; visibility: hidden; transition: transform 200ms var(--ease-out), opacity 160ms var(--ease-out), visibility 0s linear 200ms; }
.drawer.open { transform: none; opacity: 1; visibility: visible; transition: transform 320ms var(--ease-drawer), opacity 200ms var(--ease-out), visibility 0s; }
.drawer:focus { outline: none; }
.drawer-close { position: absolute; top: 14px; right: 16px; font-size: 18px; background: var(--paper2); border: 1.5px solid var(--ink); width: 34px; height: 34px; cursor: pointer; font-family: var(--mono); }
.drawer .d-kicker { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); margin-bottom: 8px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.drawer h2 { font-size: 26px; line-height: 1.1; margin-bottom: 6px; }
.drawer .d-author { font-style: italic; color: var(--muted); font-size: 16px; margin-bottom: 14px; }
.drawer .d-quote { border-left: 4px solid var(--accent); padding: 10px 16px; font-size: 17px; font-style: italic; margin: 14px 0; background: var(--paper2); }
.drawer .d-sec { margin: 14px 0; }
.drawer .d-lbl { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); display: block; margin-bottom: 4px; }
.drawer .d-sec p { font-size: 15px; }
.drawer .d-signal { font-family: var(--mono); font-size: 12.5px; color: #4a4436; background: var(--paper2); border: 1px dashed var(--line); padding: 10px 12px; }
.drawer .d-src { font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* ---------- method ---------- */
.method-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
@media (max-width: 900px) { .method-grid { grid-template-columns: 1fr; } }
.method-grid .card p { font-size: 15px; }
.method-grid ul { padding-left: 20px; font-size: 15px; }
.method-grid li { margin-bottom: 6px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--paper2); padding: 1px 5px; }

/* ---------- footer (colophon receipt style) ---------- */
footer { background: var(--paper); border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); padding: 9px 40px; text-align: center; }
footer p { margin: 0; font-family: var(--mono); font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* tooltip */
#tl-tip { position: fixed; z-index: 60; background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 12px; padding: 7px 10px; pointer-events: none; max-width: 320px; box-shadow: 3px 3px 0 rgba(28,24,18,.3); transform-origin: top left; opacity: 0; visibility: hidden; transform: translateY(4px) scale(.97); transition: opacity 140ms var(--ease-out), transform 140ms var(--ease-out), visibility 0s linear 140ms; }
#tl-tip.show { opacity: 1; visibility: visible; transform: none; transition: opacity 140ms var(--ease-out), transform 140ms var(--ease-out), visibility 0s; }

/* Netlify-injected "Powered by Netlify" badge */
#nl-badge-frame { display: none !important; }

/* ---------- mobile ---------- */
@media (max-width: 768px) {
  .masthead { padding: 18px 16px 12px; gap: 14px; }
  h1 { font-size: clamp(26px, 7.5vw, 34px); }
  .standfirst { font-size: 14.5px; margin-top: 10px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .standmore { display: inline-block; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); background: none; border: 1px dashed var(--line); padding: 4px 10px; margin-top: 8px; cursor: pointer; }
  .standfirst.expanded { -webkit-line-clamp: unset; display: block; }
  .mast-right { display: none; }
  .tabs { padding: 0 12px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { padding: 13px 13px; font-size: 12.5px; white-space: nowrap; flex-shrink: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .tabs-wrap { display: flex; align-items: stretch; }
  .tabs-wrap .tabs { flex: 1 1 auto; min-width: 0; margin: 0; max-width: none; }
  .tabs-scroll-hint { display: flex; align-items: center; justify-content: center; flex: 0 0 46px; position: static; transform: none; font-family: var(--mono); font-size: 22px; line-height: 1; color: var(--muted); background: var(--paper); border: none; border-left: 1px solid var(--line); cursor: pointer; padding: 0; transition: opacity .25s, transform 140ms var(--ease-out); }
  .tabs-scroll-hint.at-end { opacity: 0; pointer-events: none; }
  main { padding: 22px 16px 60px; }
  .view-sub { font-size: 14.5px; margin-bottom: 18px; }
  .card { padding: 16px; }
  .pred-card { padding: 16px; }
  .pred-card h3 { max-width: 100%; font-size: 18px; }
  .pred-card .pred-id { font-size: 20px; }
  .conviction-row { flex-wrap: wrap; gap: 8px 10px; }
  .arc-head { padding: 13px 16px; }
  .arc-head h3 { font-size: 19px; }
  .arc-body { padding: 14px 16px 16px; }
  .pursuit { grid-template-columns: 52px 1fr; }
  .pursuit .pbody { padding: 14px 16px; }
  .pursuit .rank { font-size: 22px; align-items: flex-start; padding-top: 14px; }
  .lib-controls { gap: 8px; }
  .lib-controls input { min-width: 160px; }
  .drawer { padding: 24px 20px 50px; width: min(560px, 100vw); }
  footer { padding: 9px 14px; }
  footer p { font-size: 10px; letter-spacing: .1em; }
  #tl-svg { min-width: 840px; }
  #tl-wrap::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 26px; background: linear-gradient(to right, transparent, #fffdf7); pointer-events: none; }
  /* timeline view: visualization leads on mobile
     (.active is required: a bare #id outranks .view { display: none } and pins the timeline on screen) */
  #view-timeline.active { display: flex; flex-direction: column; }
  #view-timeline > .view-title { order: 0; }
  #view-timeline #tl-wrap { order: 1; }
  #view-timeline .tl-controls { order: 2; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 6px; }
  #view-timeline .view-sub { order: 3; }
  #view-timeline .tl-hint { order: 4; }
  #view-timeline .arc-cards { order: 5; }
  /* compact expandable prediction context */
  details.pred-extra summary { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); padding: 10px 0 2px; cursor: pointer; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tabs a, .dom-chip, .doc-chip, .pred-chip, .arc-toggle, .doc-card, .drawer-close, .standmore, .tabs-scroll-hint { transition: none; }
  .tabs a:active, .dom-chip:active, .doc-chip:active, .pred-chip:active, .arc-toggle:active, .doc-card:active, .drawer-close:active, .standmore:active, .tabs-scroll-hint:active,
  .doc-card:hover { transform: none; }
  .conv-fill { transition: none; }
  .arc-card.open .arc-body { transition: opacity 180ms var(--ease-out); @starting-style { opacity: 0; } }
  .drawer, .drawer.open { transform: none; transition: opacity 150ms ease, visibility 0s; }
  .drawer-overlay, .drawer-overlay.open { transition: opacity 150ms ease, visibility 0s; }
  #tl-tip, #tl-tip.show { transform: none; }
}
