:root {
  --paper: #f5f0e7;
  --paper-bright: #fffdf8;
  --ink: #162635;
  --muted: #5f6d73;
  --hair: #c8c0b4;
  --teal: #1d6d78;
  --teal-dark: #104b56;
  --teal-soft: #d8e9e6;
  --coral: #c95642;
  --coral-dark: #8d3528;
  --coral-soft: #f2d9cf;
  --gold: #d7b447;
  --gold-soft: #f5e9ae;
  --shadow: none;
  --radius: .25rem;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.55; }
button, input { font: inherit; }
button { min-height: 44px; }
a { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: .6rem;
  left: .6rem;
  padding: .7rem 1rem;
  background: var(--ink);
  color: white;
  transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem clamp(1.2rem, 4vw, 4rem);
  color: #fff;
  font-size: .73rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.site-header p { margin: 0; opacity: .7; }
.wordmark { text-decoration: none; font-weight: 800; }

.hero {
  min-height: 720px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr);
  gap: clamp(2rem, 6vw, 7rem);
  align-items: center;
  padding: 7.4rem clamp(1.2rem, 5vw, 5rem) 4.3rem;
  color: white;
  background:
    radial-gradient(circle at 78% 15%, rgba(215, 180, 71, .22), transparent 28%),
    linear-gradient(135deg, #132838 0%, #173945 55%, #102934 100%);
  overflow: hidden;
}

.hero-copy { max-width: 760px; min-width: 0; }
.eyebrow {
  margin: 0 0 .85rem;
  color: var(--coral);
  font-size: .77rem;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.hero .eyebrow { color: #f5c3ac; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.03; letter-spacing: -.028em; }
h1 { margin: 0; font-size: clamp(3.5rem, 6.8vw, 7.3rem); font-weight: 600; }
.standfirst { max-width: 720px; margin: 1.5rem 0 1.65rem; font-size: clamp(1.05rem, 1.55vw, 1.34rem); color: rgba(255,255,255,.84); }
.standfirst strong { color: white; }
.scope-note { max-width: 570px; margin: .9rem 0 0; font-size: .86rem; color: rgba(255,255,255,.68); }

.primary-action, .secondary-action, .milestones button, .step-button {
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
}
.primary-action { padding: .83rem 1.3rem; background: var(--gold); color: var(--ink); font-weight: 800; }
.primary-action:hover, .primary-action:focus-visible { background: #efd267; }
.secondary-action { padding: .78rem 1.15rem; background: var(--ink); color: white; font-weight: 750; }
.secondary-action:hover, .secondary-action:focus-visible { background: var(--teal-dark); }
button:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.hero-comparison {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: clamp(1.3rem, 3vw, 2.5rem);
  border-top: 1px solid rgba(255,255,255,.35);
  border-bottom: 1px solid rgba(255,255,255,.35);
}
.hero-period { min-width: 0; }
.hero-period p { margin: .25rem 0; }
.hero-period > p:last-child { color: rgba(255,255,255,.64); font-size: .8rem; }
.hero-period.faded { opacity: .68; }
.period-label { color: #f5c3ac; font-size: .68rem; font-weight: 800; letter-spacing: .08em; }
.hero-value { font-family: Georgia, serif; font-size: clamp(3rem, 5vw, 5.5rem); line-height: 1; }
.hero-arrow { font-size: 2rem; color: var(--gold); }
.hero-dots { position: absolute; left: 1.8rem; right: 1.8rem; bottom: 1rem; display: flex; justify-content: space-between; }
.hero-dots span { width: .38rem; height: .38rem; border-radius: 50%; background: rgba(255,255,255,.34); }

.section {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(5rem, 9vw, 9rem) clamp(1.2rem, 5vw, 5rem);
}
.section + .section { border-top: 1px solid var(--hair); }
.section-number { display: none; }
.section-heading { max-width: 880px; margin-bottom: 3rem; }
h2 { margin: 0 0 1.1rem; font-size: clamp(2.8rem, 5.4vw, 5.8rem); font-weight: 600; }
h3 { font-size: 1.65rem; }
.section-heading > p:last-child { max-width: 760px; color: var(--muted); font-size: 1.04rem; }
.small-copy { margin: .4rem 0 0; color: var(--muted); font-size: .78rem; }

.search-panel { padding: clamp(1.2rem, 3vw, 2.5rem); border: 1px solid var(--hair); border-top: 4px solid var(--teal); border-radius: var(--radius); background: var(--paper-bright); }
.range-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .8rem; }
.range-row label { text-align: center; font-weight: 750; }
.step-button { width: 46px; padding: 0; border-color: var(--hair); background: white; color: var(--ink); font-size: 1.35rem; }
.step-button:hover { border-color: var(--teal); }
input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--coral); }
.milestones { display: flex; flex-wrap: wrap; gap: .55rem; margin: 1rem 0 1.4rem; }
.milestones button { min-height: 38px; padding: .45rem .8rem; border-color: var(--hair); background: transparent; color: var(--muted); font-size: .78rem; }
.milestones button:hover { border-color: var(--teal); color: var(--teal-dark); }
.search-wall-wrap { overflow: hidden; border-radius: 2px; background: var(--ink); }
.search-wall { display: block; width: 100%; height: 116px; }
.record-readout { margin: 1.2rem 0; padding: 1.2rem 1.35rem; border-left: 5px solid var(--coral); background: var(--coral-soft); }
.record-readout p { margin: .25rem 0; }
.readout-label { color: var(--coral-dark); font-size: .72rem; font-weight: 800; letter-spacing: .09em; }
.readout-value { font-family: Georgia, serif; font-size: 2.4rem; line-height: 1; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
caption { padding: .5rem 0; text-align: left; font-weight: 750; }
th, td { padding: .72rem .55rem; border-bottom: 1px solid var(--hair); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; }
#record-table tr[hidden] { display: none; }
.search-panel > .secondary-action { margin-top: 1.2rem; }

.curtain-section { max-width: none; background: #e9e3d8; }
.curtain-section > * { max-width: 1340px; margin-left: auto; margin-right: auto; }
.curtain-controls { display: grid; grid-template-columns: minmax(240px, 1fr) 2fr auto; gap: 1rem; align-items: center; margin-bottom: 1.5rem; }
.curtain-controls label { font-weight: 750; }
.chart-pair { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1.2rem; }
.scatter-card { position: relative; margin: 0; padding: 1rem; border: 1px solid var(--hair); border-radius: var(--radius); background: var(--paper-bright); overflow: hidden; }
.scatter-card figcaption { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; padding: .3rem .35rem .8rem; }
.scatter-card figcaption span { color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .08em; }
.scatter-card figcaption strong { font-family: Georgia, serif; font-size: 1.4rem; }
.scatter-card svg { display: block; width: 100%; height: auto; }
.time-curtain { position: absolute; inset: 3.3rem 0 0; display: grid; place-items: center; background: var(--gold-soft); border-left: 3px solid var(--gold); transition: width .28s ease; }
.time-curtain[hidden] { display: none; }
.time-curtain span { writing-mode: vertical-rl; color: #715d13; font-size: .72rem; font-weight: 850; letter-spacing: .13em; }
.scatter-table { max-width: 980px; margin-top: 1.2rem; }
.result-box { margin-top: 1.2rem; padding: 1.4rem 1.6rem; border-radius: 2px; background: var(--ink); color: white; }
.result-box h3 { margin: .2rem 0 .7rem; font-size: clamp(2rem, 4vw, 3.6rem); }
.result-box p:last-child { max-width: 770px; color: rgba(255,255,255,.75); }

.paired-plot { display: grid; gap: .6rem; margin: 2rem 0; }
.pair-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(260px, 3fr) 92px; gap: 1rem; align-items: center; }
.pair-label { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pair-track { position: relative; height: 28px; border-radius: 2px; background: linear-gradient(to right, rgba(29,109,120,.12), rgba(201,86,66,.12)); }
.pair-track::before { content: ""; position: absolute; top: 50%; left: var(--holdout); width: calc(var(--training) - var(--holdout)); height: 1px; background: var(--hair); }
.pair-dot { position: absolute; top: 50%; transform: translate(-50%,-50%); }
.pair-dot.training { left: var(--training); width: 13px; height: 13px; border-radius: 50%; background: var(--teal); }
.pair-dot.holdout { left: var(--holdout); width: 11px; height: 11px; background: var(--coral); transform: translate(-50%,-50%) rotate(45deg); }
.pair-values { font-variant-numeric: tabular-nums; font-size: .78rem; color: var(--muted); }
details { border-top: 1px solid var(--hair); padding-top: 1rem; }
summary { cursor: pointer; font-weight: 750; }

.shuffle-section { background: var(--ink); color: white; max-width: none; }
.shuffle-section > * { max-width: 1340px; margin-left: auto; margin-right: auto; }
.shuffle-section .section-number { color: rgba(255,255,255,.07); }
.shuffle-section .section-heading > p:last-child, .shuffle-section .qualification { color: rgba(255,255,255,.68); }
.shuffle-grid { display: grid; grid-template-columns: repeat(20, 1fr); gap: clamp(.25rem, .55vw, .5rem); margin: 2rem 0; }
.shuffle-dot { aspect-ratio: 1; border-radius: 50%; background: rgba(255,255,255,.15); }
.shuffle-dot.meets { background: var(--gold); }
.qualification { max-width: 850px; }

.limits-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.limits-grid article { padding: 1.4rem 1.5rem; border-top: 4px solid var(--teal); background: var(--paper-bright); }
.limits-grid article:nth-child(even) { border-color: var(--coral); }
.limits-grid h3 { margin: 0 0 .7rem; }
.limits-grid p { color: var(--muted); }

footer { display: flex; justify-content: space-between; gap: 2rem; padding: 2rem clamp(1.2rem,5vw,5rem); border-top: 1px solid var(--hair); color: var(--muted); font-size: .75rem; }
footer p { max-width: 620px; }

@media (max-width: 920px) {
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .hero-comparison { max-width: 680px; }
  .curtain-controls { grid-template-columns: 1fr; }
  .chart-pair { grid-template-columns: 1fr; }
  .limits-grid { grid-template-columns: 1fr; }
  .pair-row { grid-template-columns: 1fr; gap: .35rem; }
  .pair-values { text-align: right; }
}

@media (max-width: 560px) {
  .site-header { position: absolute; align-items: flex-start; }
  .site-header p { max-width: 145px; text-align: right; }
  .hero { padding-top: 6.8rem; }
  h1 { font-size: clamp(2.8rem, 13.2vw, 3.6rem); overflow-wrap: anywhere; }
  .hero .eyebrow { font-size: .7rem; overflow-wrap: anywhere; }
  .hero-comparison { grid-template-columns: 1fr; }
  .hero-arrow { transform: rotate(90deg); justify-self: center; }
  .range-row { grid-template-columns: auto 1fr auto; }
  .section-number { top: 3.3rem; }
  .section { padding-top: 5.4rem; }
  .shuffle-grid { grid-template-columns: repeat(10, 1fr); }
  footer { flex-direction: column; }
}

@media (max-width: 340px) {
  h1 { font-size: 2.15rem; overflow-wrap: normal; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
