/* ─────────────────────────────────────────────────────────────
   khoa.ch — tokens
   ───────────────────────────────────────────────────────────── */
:root {
  --chalk:   #f1f2f4;   /* cool near-white base            */
  --chalk-2: #e7e8ec;   /* slightly deeper panel           */
  --ink:     #14141a;   /* foreground / type               */
  --ink-soft:#5c5d68;   /* muted labels                    */
  --gules:   #ff3b1d;   /* vermilion — "gules" red accent  */
  --volt:    #2b4dff;   /* electric blue                   */
  --sun:     #ffc400;   /* sunflower                       */
  --mint:    #00c2a8;   /* teal pop                        */

  --accent:  var(--gules);

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --mono:    "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);   /* overshoot   */
  --ease-out:    cubic-bezier(.16, 1, .3, 1);

  --edge: clamp(1.25rem, 5vw, 4rem);
}

/* ─── reset-ish ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
  /* no CSS scroll-snap: it yanks small swipes back to the section start.
     free native scrolling stays smooth on mobile. */
}
body {
  margin: 0;
  background: var(--chalk);
  color: var(--ink);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, p { margin: 0; }
a { color: inherit; }

/* film grain + progress bar ─────────────────────────────────── */
.grain {
  position: fixed; inset: 0; z-index: 9; pointer-events: none;
  opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
}
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 20;
  background: transparent; pointer-events: none;
}
.progress i {
  display: block; height: 100%; width: 100%;
  transform: scaleX(var(--p, 0)); transform-origin: 0 50%;
  background: var(--accent); transition: background .5s var(--ease-out);
}

/* ─── shared section frame ──────────────────────────────────── */
section {
  position: relative;
  min-height: 100svh;      /* fallback for browsers without dvh */
  min-height: 100dvh;      /* tracks the live mobile viewport → clean snapping */
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: clamp(3rem, 9vh, 7rem) var(--edge);
  text-align: center;
  overflow: hidden;   /* clip any per-scene decoration from widening the page */
}

.eyebrow, .tag {
  font-family: var(--mono);
  font-size: clamp(.7rem, 1.6vw, .82rem);
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-soft);
}
.tag { color: var(--accent); }
.wink { color: var(--accent); }
.light { color: rgba(255,255,255,.85) !important; }

/* shared mid-size display headline (candidates) --------------- */
.mid {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(2.1rem, 8vw, 5.5rem); line-height: .98;
  letter-spacing: -.025em; max-width: 16ch;
}

/* ─── Scene 1 · hero ────────────────────────────────────────── */
.hero .eyebrow { margin-bottom: clamp(1.2rem, 4vh, 2.4rem); }

.wordmark {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3.4rem, 22vw, 15rem);
  line-height: .82;
  letter-spacing: -.03em;
}
.kinetic { display: inline-flex; flex-wrap: nowrap; }
.ch {
  display: inline-block;
  will-change: transform;
  transition: transform .9s var(--ease-spring);
  transform: translate3d(0,0,0);
}
.ch.dot { color: var(--gules); }

.hero .sub {
  max-width: 34ch;
  margin: clamp(1.6rem, 4vh, 2.6rem) auto 0;
  font-size: clamp(.9rem, 2.2vw, 1.05rem);
  line-height: 1.5; color: var(--ink-soft);
}

.scrollcue {
  position: absolute; bottom: clamp(1.4rem, 4vh, 2.6rem);
  display: inline-flex; flex-direction: column; align-items: center; gap: .5rem;
  font-family: var(--mono); font-size: .7rem; letter-spacing: .2em;
  text-transform: uppercase; text-decoration: none; color: var(--ink-soft);
}
.scrollcue svg { animation: bob 1.8s var(--ease-out) infinite; }
@keyframes bob { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(5px);} }

/* ═══ CANDIDATE A · toss playground ═════════════════════════ */
.toss { overflow: hidden; }
.toss-head { position: relative; z-index: 3; pointer-events: none; }
.toss-head .eyebrow { margin-bottom: 1rem; }
.arena { position: absolute; inset: 0; z-index: 1; }
.chip {
  position: absolute; top: 0; left: 0;
  display: grid; place-items: center;
  width: clamp(52px, 12vmin, 104px); height: clamp(52px, 12vmin, 104px);
  border-radius: 24px;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(1.5rem, 5vmin, 3rem);
  color: var(--chalk); user-select: none; cursor: grab;
  touch-action: none; will-change: transform;
  box-shadow: 0 10px 30px rgba(20,20,26,.16);
}
.chip:active { cursor: grabbing; }
.chip.c0 { background: var(--gules); }
.chip.c1 { background: var(--volt); }
.chip.c2 { background: var(--sun); color: var(--ink); }
.chip.c3 { background: var(--mint); color: var(--ink); }
.chip.c4 { background: var(--ink); }

/* ═══ CANDIDATE B · clock ═══════════════════════════════════ */
.clock .eyebrow { margin-bottom: clamp(1rem, 3vh, 2rem); }
.time {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(3.4rem, 18vw, 13rem); line-height: .9;
  letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: baseline;
}
.time .colon { color: var(--mint); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.clock-sub {
  margin-top: clamp(1rem, 3vh, 1.8rem);
  font-family: var(--mono); font-size: clamp(.8rem, 2vw, 1rem);
  letter-spacing: .08em; color: var(--ink-soft);
}

/* ═══ CANDIDATE D · statement (slow timed fill) ═════════════ */
@property --fill { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
.scrub { background: var(--chalk-2); }
.scrub-text {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(2rem, 8.5vw, 6rem); line-height: 1.02;
  letter-spacing: -.02em; max-width: 18ch;
  display: flex; flex-direction: column; gap: .1em;
}
.scrub-text span {
  --fill: 0%;
  background-image: linear-gradient(90deg, var(--ink) 0 var(--fill), rgba(20,20,26,.16) var(--fill) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  transition: --fill 2s var(--ease-out);
  transform-origin: center;
}
.scrub-text .hot {
  background-image: linear-gradient(90deg, var(--gules) 0 var(--fill), rgba(20,20,26,.16) var(--fill) 100%);
}
.scrub-text.in span { --fill: 100%; }
.scrub-text.in span:nth-child(2) { transition-delay: .6s; }
.scrub-text.in span:nth-child(3) { transition-delay: 1.2s; }
/* when the reveal reaches "respect." — punch it big, then settle */
.scrub-text.in .hot { animation: respectPop 1.3s var(--ease-out) 2.4s both; }
@keyframes respectPop {
  0%   { transform: scale(1); }
  38%  { transform: scale(1.62); }
  66%  { transform: scale(.93); }
  100% { transform: scale(1); }
}

/* ─── Scene · spectrum (continuous colour cycle) ────────────── */
.spectrum { overflow: hidden; }
.spectrum::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: hsl(212 86% 55%);
  animation: spectrumHue 14s linear infinite;
}
@keyframes spectrumHue { to { filter: hue-rotate(360deg); } }
.shout {
  position: relative; z-index: 1;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(4rem, 26vw, 18rem); line-height: .8;
  letter-spacing: -.04em; color: var(--chalk);
  display: flex; flex-direction: column;
}
.shout .line { display: block; }

/* ─── Scene · contact ───────────────────────────────────────── */
.contact .tag { margin-bottom: clamp(1.5rem, 5vh, 2.6rem); }
.email {
  display: inline-flex; flex-wrap: wrap; justify-content: center;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(1.9rem, 9vw, 6rem); line-height: 1;
  letter-spacing: -.02em; text-decoration: none; color: var(--ink);
}
.scatter {
  display: inline-block; will-change: transform, opacity;
  transition: transform 1s var(--ease-spring), opacity .7s var(--ease-out);
}
.scatter.at  { color: var(--gules); }
.scatter.dot { color: var(--gules); }
.email:hover .scatter { transform: translateY(-6px) rotate(-3deg); }

.actions {
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center;
  margin-top: clamp(2.2rem, 6vh, 3.4rem);
}
.btn {
  font-family: var(--mono); font-size: .95rem; font-weight: 700;
  letter-spacing: .02em; text-decoration: none;
  padding: .95em 1.6em; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--ink);
  transition: transform .3s var(--ease-spring), background .25s, color .25s;
}
.btn.copy { background: var(--ink); color: var(--chalk); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn:hover { transform: translateY(-3px); }
.btn:active { transform: translateY(0) scale(.97); }
.btn.copy.done { background: var(--mint); border-color: var(--mint); color: var(--ink); }

/* ─── footer (pinned inside the last section) ───────────────── */
.contact-inner { display: flex; flex-direction: column; align-items: center; }
footer {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center;
  padding: 1.4rem var(--edge) calc(1.4rem + env(safe-area-inset-bottom));
  font-family: var(--mono); font-size: .78rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-soft);
  background: transparent;
}

/* ─── reveal-on-scroll ──────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .8s var(--ease-out), transform .8s var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }

/* ─── focus visibility ──────────────────────────────────────── */
:focus-visible { outline: 3px solid var(--gules); outline-offset: 4px; border-radius: 4px; }

/* ─── reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .ch, .scatter, .reveal { transform: none !important; opacity: 1 !important; }
  .scrub-text span { --fill: 100% !important; }
}
