/* paper.fun early access. Paper look from the app (app/src/tokens.css): cream paper, ink, one ink blue.
   Everything scales from one fluid headline size (--h1) so the page holds together from a phone to a 5120 px ultrawide. */
@font-face { font-family: 'Geist'; src: url('/assets/fonts/Geist.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('/assets/fonts/GeistMono.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  --bg: #F1EFE9;
  --card: #FCFBF8;
  --inset: #EBE8E0;
  --ink: #16150F;
  --ink-2: #57534A;
  --ink-3: #6C685E;
  --line: rgba(33, 30, 22, 0.09);
  --line-2: rgba(33, 30, 22, 0.16);
  --blue: #2B47E3;
  --blue-2: #233CC9;
  --blue-soft: rgba(43, 71, 227, 0.10);
  --flap: #A3B2F8;
  --font: 'Geist', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --shadow-float: 0 1px 0 rgba(33, 30, 22, 0.04), 0 12px 32px -10px rgba(33, 30, 22, 0.22), 0 32px 64px -28px rgba(33, 30, 22, 0.20);

  /* the fluid scale */
  --h1: clamp(42px, min(5.5vw, 9.6svh), 150px);
  --u: clamp(16px, calc(var(--h1) * .205), 27px);          /* UI text: buttons, card, labels */
  --body: clamp(16px, calc(var(--h1) * .19), 25px);
  --g: clamp(20px, 3.4vw, 72px);                           /* side gutter */
  --maxw: 2960px;
  --wm: clamp(22px, calc(var(--h1) * .3), 40px);           /* wordmark */
  --top-pad: clamp(16px, 2.4svh, 40px);
  --top-h: calc(var(--wm) * 1.2 + 2 * var(--top-pad));
  --race-h: clamp(84px, 13svh, 220px);
  --hero-pad: clamp(12px, 2.4svh, 40px);
  --film: min(44vw, calc(100svh - var(--top-h) - var(--race-h) - 2 * var(--hero-pad)), 1080px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
  background: var(--bg) url('/assets/doodles.svg') repeat; background-size: 420px 420px;
  color: var(--ink); font-family: var(--font); font-size: var(--body); line-height: 1.45;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
img, svg, video { display: block; max-width: 100%; }
h1, h2, h3, p, ol, dl, dd, figure { margin: 0; }
ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
::selection { background: var(--blue-soft); }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -100px; z-index: 50; padding: 10px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 15px; font-weight: 600; }
.skip:focus-visible { top: 12px; outline-color: var(--blue); }

.frame { width: min(100% - 2 * var(--g), var(--maxw)); margin-inline: auto; }

/* ---------- wordmark: "paper" + the folded ink-blue dot + "fun" ---------- */
.wm { display: inline-flex; align-items: baseline; font-size: var(--wm); font-weight: 600; letter-spacing: -0.05em; line-height: 1.2; color: var(--ink); border-radius: 6px; }
.wm-dot {
  display: inline-block; width: .162em; height: .162em; margin: 0 -.012em 0 .066em; position: relative; top: .004em;
  background: var(--blue); clip-path: polygon(0 0, 62% 0, 100% 38%, 100% 100%, 0 100%);
}
.wm-dot::after { content: ''; position: absolute; left: 62%; top: 0; width: 38%; height: 38%; background: var(--flap); clip-path: polygon(0 0, 100% 100%, 0 100%); }

/* ---------- top ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding-block: var(--top-pad); }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--film); column-gap: clamp(48px, 6vw, 240px); align-items: center;
  min-height: calc(100svh - var(--top-h) - var(--race-h)); padding-block: var(--hero-pad);
}
.hero-copy { min-width: 0; }
.h1 { font-size: var(--h1); line-height: .98; font-weight: 600; letter-spacing: -0.045em; color: var(--ink); }
.h1-a, .h1-b { display: block; text-wrap: balance; }
.h1-b { color: var(--blue); }
.sub { margin-top: calc(var(--h1) * .3); font-size: clamp(18px, calc(var(--h1) * .25), var(--sub-max, 34px)); line-height: 1.35; letter-spacing: -0.012em; color: var(--ink-2); max-width: 30em; text-wrap: balance; }
.cta { margin-top: calc(var(--h1) * .5); }
.joined { margin-top: calc(var(--h1) * .42); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em; height: 3em; padding: 0 1.3em;
  border-radius: 999px; font-size: var(--u); font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; line-height: 1;
  transition: background-color .18s ease, box-shadow .18s ease, transform .25s var(--ease-out); -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(.985); }
.btn-primary { background: var(--blue); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 1px 2px rgba(22, 21, 15, .16), 0 10px 24px -10px rgba(43, 71, 227, .6); }
.btn-primary:hover { background: var(--blue-2); }
.btn.is-off { opacity: .5; pointer-events: none; box-shadow: none; }
.btn-ghost { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 2px rgba(22, 21, 15, .05); }
.btn-ghost:hover { background: #fff; box-shadow: inset 0 0 0 1px rgba(33, 30, 22, .26), 0 1px 2px rgba(22, 21, 15, .06); }
.btn-lg { height: 3.35em; padding: 0 1.6em; font-size: calc(var(--u) * 1.06); }
.btn-sm { height: 2.4em; padding: 0 1em; font-size: 14px; }
.btn[aria-disabled="true"], .btn:disabled { opacity: .6; pointer-events: none; }
.x-logo { width: .95em; height: .95em; fill: currentColor; flex: none; }
.ico { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.count { display: flex; align-items: center; gap: .6em; margin-top: 1.15em; font-size: calc(var(--u) * .9); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.live { position: relative; width: .5em; height: .5em; border-radius: 50%; background: var(--blue); flex: none; }
.live::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--blue); animation: live 2.4s ease-out infinite; }
@keyframes live { 0% { transform: scale(1); opacity: .5; } 70%, 100% { transform: scale(2.8); opacity: 0; } }
.notice { margin-top: .8em; font-size: calc(var(--u) * .875); color: var(--ink-2); }
.notice:empty { display: none; }

/* ---------- after sign-up: the ticket (a sheet of paper with its corner folded, like the dot) ---------- */
body[data-state="out"] .joined { display: none; }
body[data-state="in"] .cta { display: none; }
.joined {
  --fold: calc(var(--u) * 1.9);
  position: relative; max-width: 31em; font-size: var(--u);
  filter: drop-shadow(0 1px 1px rgba(33, 30, 22, .07)) drop-shadow(0 14px 22px rgba(33, 30, 22, .10));
}
.joined.is-entering { animation: ticketIn .7s var(--ease-out) both; }
@keyframes ticketIn { from { opacity: 0; transform: translateY(14px) rotate(-.6deg); } to { opacity: 1; transform: none; } }
.ticket {
  background: var(--card); border-radius: 1.1em; padding: 1.5em 1.6em 1.35em;
  -webkit-mask: linear-gradient(225deg, transparent calc(var(--fold) * .7071), #000 calc(var(--fold) * .7071));
  mask: linear-gradient(225deg, transparent calc(var(--fold) * .7071), #000 calc(var(--fold) * .7071));
}
.fold {
  position: absolute; top: 0; right: 0; width: var(--fold); height: var(--fold);
  background: linear-gradient(225deg, #E9E3D6, #D6CEBD); clip-path: polygon(0 0, 100% 100%, 0 100%);
  border-bottom-left-radius: .2em;
}
.ticket-h { font-size: 1.5em; font-weight: 600; letter-spacing: -0.025em; line-height: 1.1; outline: none; }
.who { display: flex; align-items: center; gap: .65em; margin-top: .85em; min-width: 0; }
.av {
  position: relative; display: inline-grid; place-items: center; width: 2.3em; height: 2.3em; border-radius: 50%; flex: none; overflow: hidden;
  font-weight: 600; font-size: 1em; color: #3A3830; box-shadow: inset 0 0 0 1px var(--line);
}
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.av-0 { background: #DCE2EE; } .av-1 { background: #E9E1D2; } .av-2 { background: #D9E6DD; } .av-3 { background: #EEDCDF; }
.av-4 { background: #DFE3EA; } .av-5 { background: #ECE2CF; } .av-6 { background: #D6E4E6; } .av-7 { background: #E4DDEA; }
.who-handle { font-weight: 600; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pos { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: .35em; margin-top: 1.05em; padding-top: 1em; border-top: 1px solid var(--line); }
.pos-n { font-size: 3.1em; font-weight: 600; letter-spacing: -0.045em; line-height: 1; color: var(--blue); font-variant-numeric: tabular-nums; }
.pos-l { font-size: 1.15em; font-weight: 500; color: var(--ink-2); letter-spacing: -0.01em; }
.boost { margin-top: .7em; color: var(--ink); line-height: 1.4; text-wrap: pretty; }
.share { display: flex; flex-wrap: wrap; gap: .6em; margin-top: 1.15em; }
.share .btn { font-size: 1em; }
.meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2em .55em; margin-top: 1em; font-size: .86em; color: var(--ink-3); }
.link-text { font-family: var(--mono); font-size: .95em; color: var(--ink-2); overflow-wrap: anywhere; }
.dot-sep { color: var(--ink-3); }

/* ---------- film ---------- */
.hero-film { display: flex; justify-content: flex-end; }
.film {
  position: relative; width: var(--film); aspect-ratio: 1 / 1; border-radius: clamp(14px, calc(var(--film) * .028), 30px); overflow: hidden;
  background: #ECE9E1; box-shadow: 0 1px 0 rgba(33, 30, 22, .04), 0 2px 6px rgba(33, 30, 22, .05), 0 28px 56px -28px rgba(33, 30, 22, .30);
  isolation: isolate;
}
.film::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(33, 30, 22, .07); pointer-events: none; z-index: 2; }
.film-poster, .film-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.film-video { opacity: 0; transition: opacity .6s ease; }
.film.is-playing .film-video { opacity: 1; }

/* ---------- the race (the hour's chart race, edge to edge) ---------- */
.race { position: relative; height: var(--race-h); overflow: hidden; pointer-events: none; }
.race svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.race .lead { stroke-dasharray: 1; stroke-dashoffset: 0; }
.race.will-draw .lead { stroke-dashoffset: 1; }
.race.will-draw .end { opacity: 0; }
.race.is-drawn .lead { stroke-dashoffset: 0; transition: stroke-dashoffset 2.2s cubic-bezier(.45, 0, .2, 1); }
.race.is-drawn .end { opacity: 1; transition: opacity .5s ease 2s; }
.race-label { font-family: var(--font); font-weight: 600; letter-spacing: -0.02em; fill: var(--blue); }

/* ---------- how it works ---------- */
.how { padding-top: clamp(56px, 9svh, 168px); }
.kicker { font-family: var(--mono); font-size: calc(var(--u) * .9); font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-bottom: 1.5em; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(24px, 3.2vw, 112px); }
.step { border-top: 1px solid var(--line-2); padding-top: calc(var(--u) * 1.25); }
.step-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: calc(var(--u) * 1.2); }
.step-n { display: block; font-family: var(--mono); font-size: calc(var(--u) * .82); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.step-ico { width: calc(var(--u) * 2.6); height: calc(var(--u) * 2.6); fill: none; stroke: var(--blue); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; margin-top: calc(var(--u) * -.35); }
.step-t { font-size: clamp(22px, calc(var(--h1) * .33), 52px); font-weight: 600; letter-spacing: -0.03em; line-height: 1.12; text-wrap: balance; max-width: 14em; }

/* ---------- FAQ ---------- */
.faq { padding-top: clamp(64px, 10svh, 184px); padding-bottom: clamp(88px, 14svh, 240px); }
.qa { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(24px, 3.2vw, 112px); }
.qa-item { border-top: 1px solid var(--line-2); padding-top: calc(var(--u) * 1.25); }
.qa dt { font-size: calc(var(--u) * 1.12); font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.qa dd { margin-top: .55em; font-size: var(--body); color: var(--ink-2); line-height: 1.5; max-width: 26em; text-wrap: pretty; }

/* ---------- closing ---------- */
.end { display: flex; flex-direction: column; align-items: center; text-align: center; padding-bottom: clamp(72px, 12svh, 200px); }
.end-h { display: inline-flex; align-items: center; gap: .42em; font-size: clamp(30px, calc(var(--h1) * .52), 92px); font-weight: 600; letter-spacing: -0.04em; line-height: 1.05; font-variant-numeric: tabular-nums; text-wrap: balance; }
.end-h .live { width: .2em; height: .2em; }
.end .btn { margin-top: calc(var(--h1) * .4); }
body[data-state="in"] .end { display: none; }

/* ---------- footer ---------- */
.foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  border-top: 1px solid var(--line-2); padding-block: clamp(20px, 3svh, 40px) max(clamp(24px, 4svh, 56px), env(safe-area-inset-bottom));
  font-size: calc(var(--u) * .85); color: var(--ink-3);
}
.foot-nav { display: flex; gap: clamp(18px, 2vw, 40px); }
.foot-nav a { color: var(--ink-2); border-radius: 4px; }
.foot-nav a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: .2em; }

/* ---------- demo sheet ---------- */
.sheet {
  width: min(440px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 22px; background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-float); overflow: visible;
}
.sheet[open] { animation: sheetIn .38s var(--ease-out) both; }
.sheet::backdrop { background: rgba(22, 21, 15, .32); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.sheet-form { padding: 26px 26px 24px; font-size: 16px; }
.sheet-grip { display: none; }
.sheet-h { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.sheet-sub { margin-top: 6px; font-size: 14.5px; color: var(--ink-2); line-height: 1.45; }
.field-label { display: block; margin-top: 20px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field {
  display: flex; align-items: center; gap: 2px; height: 52px; margin-top: 8px; padding: 0 14px; border-radius: 12px;
  background: var(--inset); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .15s ease, background-color .15s ease;
}
.field:focus-within { background: #fff; box-shadow: inset 0 0 0 2px var(--blue); }
.field-at { color: var(--ink-3); font-size: 17px; }
.field input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font-size: 17px; outline: none; }
.field input:focus-visible { outline: none; }
.field-err { min-height: 20px; margin-top: 8px; font-size: 13.5px; color: #B42318; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.sheet-actions .btn { font-size: 16px; height: 46px; }

/* ---------- plain pages: privacy, notes, admin ---------- */
body.plain { font-size: 17px; }
.note { width: min(100% - 40px, 640px); margin: 0 auto; padding: 48px 0 80px; }
.note .wm { font-size: 26px; }
.note h1 { margin-top: 48px; font-size: clamp(30px, 5vw, 44px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.05; }
.note h2 { margin-top: 36px; font-size: 19px; font-weight: 600; letter-spacing: -0.015em; }
.note p, .note ul { margin-top: 12px; color: var(--ink-2); line-height: 1.6; }
.note ul { padding-left: 1.2em; }
.note li + li { margin-top: 6px; }
.note .updated { margin-top: 10px; font-size: 14px; color: var(--ink-3); }
.link { color: var(--blue); text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 1px; border-radius: 3px; }
.note-foot { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line-2); font-size: 14px; color: var(--ink-3); display: flex; gap: 20px; flex-wrap: wrap; }

body.admin { font-size: 14px; }
.admin-wrap { width: min(100% - 32px, 1400px); margin: 0 auto; padding: 28px 0 60px; }
.admin-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; margin-bottom: 20px; }
.admin-head .wm { font-size: 24px; }
.admin-head p { color: var(--ink-2); flex: 1; }
.table-wrap { overflow-x: auto; background: var(--card); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px rgba(33, 30, 22, .04); }
.admin table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.admin th, .admin td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin th { font-size: 12px; font-weight: 600; color: var(--ink-3); background: rgba(235, 232, 224, .5); position: sticky; top: 0; }
.admin td.n, .admin th:nth-child(1), .admin th:nth-child(3), .admin th:nth-child(4), .admin th:nth-child(5), .admin th:nth-child(8) { text-align: right; }
.admin tr.pri td { background: rgba(43, 71, 227, .04); }
.admin td a { color: var(--ink); font-weight: 600; }
.admin td a:hover { color: var(--blue); }
.dim { color: var(--ink-3); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--inset); color: var(--ink-2); }
.tag-blue { background: var(--blue-soft); color: var(--blue); }

/* ---------- responsive ---------- */
@media (max-width: 899px) {
  :root { --h1: clamp(40px, 9.4vw, 72px); --u: clamp(16px, 2.35vw, 20px); --race-h: clamp(96px, 24vw, 150px); }
  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; padding-top: clamp(12px, 4vw, 32px); padding-bottom: 0; }
  .hero-film { justify-content: flex-start; margin-top: clamp(36px, 8vw, 56px); }
  .film { width: 100%; }
  .step-t { font-size: clamp(21px, 2.9vw, 26px); }
  .how { padding-top: clamp(48px, 12vw, 80px); }
  .faq { padding-top: clamp(40px, 10vw, 72px); }
}
@media (max-width: 699px) {
  .steps, .qa { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .step, .qa-item { padding-bottom: calc(var(--u) * 1.6); }
  .step-t { max-width: 18em; }
  .step-top { margin-bottom: calc(var(--u) * .7); }
  .step-ico { width: calc(var(--u) * 2.1); height: calc(var(--u) * 2.1); margin-top: calc(var(--u) * -.25); }
}
@media (max-width: 640px) {
  .btn-lg { width: 100%; }
  .joined { max-width: none; }
  .ticket { padding: 1.3em 1.25em 1.2em; }
  .share .btn { flex: 1 1 0; padding: 0 1em; }
  .pos-n { font-size: 2.7em; }
  .meta { flex-direction: column; gap: .3em; }
  .meta .dot-sep { display: none; }
  .sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  .sheet[open] { animation-name: sheetUp; }
  .sheet-form { padding: 10px 20px max(20px, env(safe-area-inset-bottom)); }
  .sheet-grip { display: block; width: 40px; height: 4px; margin: 0 auto 16px; border-radius: 4px; background: var(--line-2); }
  .sheet-actions .btn { flex: 1; }
  .foot { font-size: 14px; }
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }

/* wide and ultrawide: the hero holds the first screen with the race at its foot */
@media (min-width: 2400px) and (min-aspect-ratio: 2/1) {
  :root {
    --h1: clamp(42px, 12.2svh, 176px);
    --u: clamp(16px, calc(var(--h1) * .17), 30px);
    --body: clamp(16px, calc(var(--h1) * .15), 27px);
    --sub-max: 40px;
    --maxw: 3200px;
  }
  .hero { column-gap: 160px; }
  .joined { font-size: min(var(--u), 26px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; transition-delay: 0ms !important; }
  .film-video { display: none; }
  .live::after { display: none; }
}
