/* Page styles; the game's own styles live in game/game.css (tokens too). */
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--ink); font: 500 17px/1.55 var(--text); }
a { color: inherit; }
.wrap { padding-inline: clamp(16px, 4vw, 56px); }
img, svg, canvas { display: block; max-width: 100%; }

/* bar */
.bar { display: flex; justify-content: space-between; align-items: center; padding-block: 20px; }
.bar b { font: 800 1.3rem var(--display); letter-spacing: -0.03em; }
.bar nav { display: flex; gap: 22px; font-weight: 600; }
.bar nav a { text-decoration: none; transition: color .2s; }
.bar nav a:hover { color: var(--blue); }

/* hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); align-items: center; min-height: calc(100svh - 72px); padding-bottom: 6svh; }
.hero h1 { font: 800 clamp(3.2rem, 0.6rem + 7vw, 8.5rem)/0.88 var(--display); letter-spacing: -0.055em; }
.hero h1 span { display: block; color: var(--blue); }
.hero .lead { font-size: clamp(1.2rem, 1rem + .7vw, 1.6rem); line-height: 1.35; margin-top: 26px; max-width: 30ch; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; margin-top: 32px; }
.btn { display: inline-block; background: var(--blue); color: #fff; text-decoration: none; font-weight: 700; padding: 16px 30px; border-radius: 999px; transition: transform .3s var(--spring), background .2s; }
.btn:hover { transform: translateY(-2px); background: var(--ink); }
.cta a:not(.btn) { font-weight: 700; }
#heroBoard { width: 100%; aspect-ratio: 1; background: var(--paper); border-radius: 28px; }

/* sections */
section.chapter { padding-top: clamp(110px, 13vw, 190px); }
.chapter > h2 { font: 800 clamp(2.4rem, 1.2rem + 4vw, 5rem)/0.95 var(--display); letter-spacing: -0.045em; max-width: 16ch; }
.chapter > .lead { font-size: clamp(1.15rem, 1rem + .5vw, 1.45rem); line-height: 1.4; margin-top: 18px; max-width: 46ch; }

/* try being one agent */
.one { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: clamp(24px, 4vw, 64px); align-items: center; margin-top: 40px; }
.one .card { background: var(--paper); border-radius: 26px; padding: clamp(20px, 3vw, 34px); display: grid; gap: 18px; }
#oneBoard { width: 100%; height: 170px; touch-action: manipulation; }
.one .say { font-size: 15px; font-weight: 600; color: var(--muted); min-height: 2.9em; margin-top: -8px; }
.one label:not(.toggle) { display: grid; gap: 8px; font-weight: 700; }
.one input[type=range] { width: 100%; accent-color: var(--blue); height: 32px; }
.toggle { display: flex; gap: 10px; align-items: center; font-weight: 600; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--blue); }
.readouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.readouts div { background: var(--bg); border-radius: 16px; padding: 14px; }
.readouts b { display: block; font: 800 clamp(1.6rem, 1.2rem + 1vw, 2.2rem)/1 var(--display); letter-spacing: -0.03em; transition: color .3s; }
.readouts span { font-size: 14px; color: var(--muted); }
.one .text p + p { margin-top: 14px; }
.one .text p { font-size: 1.1rem; max-width: 40ch; }

/* the game section */
#game .gamewrap { margin-top: 34px; }

/* findings */
.finding { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: clamp(24px, 4vw, 64px); align-items: start; margin-top: clamp(64px, 8vw, 110px); }
.finding:nth-of-type(even) .chart { order: -1; }
.finding h3 { font: 800 clamp(1.7rem, 1.1rem + 1.8vw, 2.6rem)/1.02 var(--display); letter-spacing: -0.035em; margin-bottom: 14px; }
.finding p { max-width: 44ch; font-size: 1.08rem; }
.finding p + p { margin-top: 12px; color: var(--muted); font-size: 15px; }
.chart { background: var(--paper); border-radius: 26px; padding: clamp(18px, 2.6vw, 30px); }
.ctlbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 20px; }
.cmp-next { border: 0; background: none; padding: 8px 4px; font: 700 14px var(--text); color: var(--blue); cursor: pointer; transition: opacity .4s; }
.cmp-next:hover { text-decoration: underline; text-underline-offset: 3px; }
.ctlbar.used .cmp-next { opacity: 0; pointer-events: none; }
.ctl { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--bg); padding: 5px; border-radius: 22px; outline: 2px solid transparent; outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .chart.live .ctlbar:not(.used) .ctl { animation: nudge 1.6s ease-in-out .6s 3; }
  @keyframes nudge { 50% { outline-color: var(--blue); } }
}
.ctl:empty { display: none; }
.ctl button { border: 0; background: transparent; font: 700 15px var(--text); color: var(--ink); padding: 11px 18px; border-radius: 999px; cursor: pointer; transition: background .2s, color .2s, transform .3s var(--spring); }
.ctl button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.ctl button:hover { background: var(--paper); }
.ctl button[aria-pressed="true"]:hover { background: var(--ink); color: var(--paper); }
.rows { display: grid; gap: 12px; }
.row, .col { cursor: pointer; border-radius: 12px; outline: none; transition: opacity .25s; }
.row.dim, .col.dim { opacity: .38; }
.row:focus-visible, .col:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
.row { display: grid; grid-template-columns: minmax(96px, 10.5em) minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.row .lab { font-weight: 600; font-size: 15px; line-height: 1.2; }
.row .val { font-weight: 800; font-size: 15px; min-width: 4.2em; white-space: nowrap; transition: color .3s; }
.track { position: relative; height: 28px; background: var(--bg); border-radius: 9px; overflow: hidden; }
.track .fill { position: absolute; top: 0; bottom: 0; border-radius: 9px; transition: width .9s cubic-bezier(.2,.8,.2,1), left .9s cubic-bezier(.2,.8,.2,1), background .3s; }
.track .zero { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1px; background: var(--ink); z-index: 1; }
.row:hover .lab { color: var(--blue); }
.cols { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; height: 260px; padding-top: 26px; }
.cols .best { display: none; }
.ctrack::before { content: ""; position: absolute; left: -16px; right: -16px; bottom: calc(100% / 1.05); border-top: 2px dashed #c9c6be; }
.col { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: 8px; min-height: 0; }
.col .val { font: 800 clamp(1.4rem, 1rem + 1vw, 2rem) var(--display); letter-spacing: -0.03em; }
.ctrack { position: relative; width: min(120px, 70%); height: 100%; display: flex; align-items: flex-end; }
.ctrack .fill { width: 100%; border-radius: 12px 12px 6px 6px; transition: height .9s cubic-bezier(.2,.8,.2,1); }
.col .lab { font-weight: 700; }
.chart .why { display: grid; margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: var(--bg); font-size: 15px; line-height: 1.45; color: var(--muted); transition: color .2s; }
.chart .why > span { grid-area: 1 / 1; visibility: hidden; }
.chart .why > span.cur { visibility: visible; }
.chart .why.on { color: var(--ink); }
.chart .why b { color: var(--ink); }
.finding .try { display: inline-block; margin-top: 18px; font-weight: 700; color: var(--blue); text-decoration: none; border-bottom: 2px solid currentColor; padding-bottom: 2px; }
.finding .try::after { content: "→"; margin-left: 6px; display: inline-block; transition: transform .3s var(--spring); }
.finding .try:hover::after { transform: translateX(4px); }
.chart .note { font-size: 14px; color: var(--muted); margin-top: 16px; max-width: 60ch; }
@media (prefers-reduced-motion: reduce) { .track .fill, .ctrack .fill { transition: none; } }

/* how it was kept honest */
.honest { background: var(--ink); color: var(--paper); margin-top: clamp(110px, 13vw, 190px); padding-block: clamp(90px, 10vw, 150px); }
.honest h2 { font: 800 clamp(2.4rem, 1.2rem + 4vw, 5rem)/0.95 var(--display); letter-spacing: -0.045em; max-width: 14ch; }
.honest .lead { color: #d8d5cc; font-size: clamp(1.15rem, 1rem + .5vw, 1.45rem); margin-top: 18px; max-width: 46ch; }
.nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; margin-top: 56px; }
.nums b { display: block; font: 800 clamp(2.6rem, 1.4rem + 3.2vw, 5rem)/1 var(--display); letter-spacing: -0.04em; color: #8fb0ff; }
.nums span { color: #d8d5cc; }
.timeline { list-style: none; padding: 0; margin: 72px 0 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.timeline li { background: #2a2923; border-radius: 18px; padding: 18px; display: grid; grid-template-rows: auto 1fr auto; gap: 6px; }
.timeline li a { margin-top: 8px; }
.timeline b { font: 800 1.25rem var(--display); }
.timeline a { color: #8fb0ff; font-weight: 600; text-decoration: none; }
.timeline a:hover { text-decoration: underline; }
.timeline small { color: #bdbab1; font-size: 14px; }
.failed { margin-top: 72px; display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(24px, 4vw, 64px); }
.failed h3 { font: 800 clamp(1.7rem, 1.1rem + 1.8vw, 2.6rem)/1.02 var(--display); letter-spacing: -0.035em; }
.failed ul { list-style: none; padding: 0; display: grid; gap: 10px; }
.failed li { background: #2a2923; border-radius: 14px; padding: 14px 16px; color: #ececea; }
.failed li b { color: #ff8f7d; margin-right: 6px; }

/* footer */
footer.end { padding-block: clamp(80px, 10vw, 140px) 40px; }
footer.end .name { font: 800 clamp(3.6rem, 1rem + 11vw, 12rem)/0.86 var(--display); letter-spacing: -0.06em; }
footer.end .name span { color: var(--blue); }
footer.end .links { display: flex; flex-wrap: wrap; gap: 14px 30px; margin-top: 34px; font-weight: 700; font-size: 1.1rem; }
footer.end .credit { margin-top: 40px; font-weight: 600; }
footer.end .credit a { text-underline-offset: 3px; }
footer.end .credit a:hover { color: var(--blue); }
footer.end .small { margin-top: 10px; color: var(--muted); font-size: 14px; max-width: 80ch; }

/* entrances */
@media (prefers-reduced-motion: no-preference) {
  .rise { opacity: 0; transform: translateY(26px); transition: opacity .7s cubic-bezier(.2,.7,.2,1), transform .7s cubic-bezier(.2,.7,.2,1); }
  .rise.in { opacity: 1; transform: none; }
  .hero h1, .hero h1 span { animation: up 1s cubic-bezier(.2,.7,.2,1) both; }
  .hero h1 span { animation-delay: .12s; }
  @keyframes up { from { opacity: 0; transform: translateY(34px); } }
}

@media (max-width: 900px) {
  .bar nav a:not(:last-child) { display: none; }
  .hero, .one, .finding, .failed { grid-template-columns: 1fr; }
  .hero { min-height: 0; padding-top: 4svh; }
  .finding:nth-of-type(even) .chart { order: 0; }
  .readouts { grid-template-columns: 1fr 1fr 1fr; }
  .readouts div { padding: 10px; }
  .nums { grid-template-columns: 1fr 1fr; }
  .timeline { grid-template-columns: 1fr; }
}


/* phones: the bar label sits above its bar, so the bar gets the full width */
@media (max-width: 560px) {
  .row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .row .lab { grid-column: 1 / -1; }
  .rows { gap: 14px; }
}
