/* =========================================================
   Rawan — the temperature arc
   Cold and distant at the start, candlelit at the reveal.
   Every screen advances one stop along the ramp.
   ========================================================= */

/* The stage tokens below are plain custom properties on purpose.
   Registered (@property) custom properties are parsed by more engines
   than actually animate them, so transitioning the variables directly
   is unreliable. Instead every element paints with background-color —
   which animates everywhere — and shapes itself with a static mask. */

:root {
  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;

  --tx: rgba(238,240,247,.94);
  --tx-dim: rgba(238,240,247,.52);

  --glass: rgba(255,255,255,.045);
  --edge: rgba(255,255,255,.11);

  /* one shared motion vocabulary */
  --fast: 180ms;
  --mid: 340ms;
  --slow: 620ms;
  --ease: cubic-bezier(.32,.72,0,1);
  --ease-soft: cubic-bezier(.22,1,.36,1);

  --arc: 1400ms; /* how long the room takes to change temperature */

  /* pulses with the music; sound.js drives it */
  --pulse: 1;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* The `hidden` attribute is only a UA `display:none`, so ANY author display
   rule silently defeats it. .gifwrap (grid) and .reveal (flex) both did —
   leaving invisible full-screen overlays that swallowed every click. */
[hidden] { display: none !important; }

html { height: 100%; }
body {
  min-height: 100dvh; height: 100dvh; overflow: hidden;
  font-family: var(--sans);
  color: var(--tx);
  background: #05070E;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

/* ---------- the ramp ---------- */
body[data-stage="0"] { --c1:#05070E; --c2:#0B1020; --oa:#1B2747; --ob:#16203A; --key:#47597E; }
body[data-stage="1"] { --c1:#070B16; --c2:#101832; --oa:#25355C; --ob:#1B2747; --key:#546892; }
body[data-stage="2"] { --c1:#0A0E1B; --c2:#161E38; --oa:#3A4468; --ob:#2A2F4E; --key:#6B7399; }
body[data-stage="3"] { --c1:#100F1B; --c2:#241E32; --oa:#5A4A5C; --ob:#3D3348; --key:#8A6A63; }
body[data-stage="4"] { --c1:#150F14; --c2:#2E2224; --oa:#7A5340; --ob:#573A33; --key:#B0764A; }
body[data-stage="5"] { --c1:#140F09; --c2:#33230F; --oa:#9C6524; --ob:#6E4519; --key:#C4762E; }

/* ---------- ambient ---------- */
/* base tone, plus a masked sheet of the second tone over it —
   two flat colours instead of a gradient, so both can animate */
.bg {
  position: fixed; inset: 0; z-index: 0;
  background-color: var(--c1);
  transition: background-color var(--arc) var(--ease);
}
.bg::after {
  content: ''; position: absolute; inset: 0;
  background-color: var(--c2);
  -webkit-mask-image: linear-gradient(168deg, transparent 0%, #000 55%, transparent 100%);
  mask-image: linear-gradient(168deg, transparent 0%, #000 55%, transparent 100%);
  transition: background-color var(--arc) var(--ease);
}

.orb {
  position: fixed; border-radius: 50%; z-index: 1; pointer-events: none;
  filter: blur(72px); opacity: .5;
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 68%);
  mask-image: radial-gradient(circle, #000 0%, transparent 68%);
  transition: background-color var(--arc) var(--ease);
  will-change: transform;
}
.orb-a {
  width: 46vmax; height: 46vmax; top: -14%; left: -10%;
  background-color: var(--oa);
}
.orb-b {
  width: 38vmax; height: 38vmax; bottom: -16%; right: -10%;
  background-color: var(--ob);
}

/* static grain — no repaint loop, just a still texture */
.grain {
  position: fixed; inset: 0; z-index: 2; pointer-events: none; opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
}

.vignette {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse 76% 66% at 50% 48%, transparent 46%, rgba(0,0,0,.62) 100%);
}

.cursor-glow {
  position: fixed; top: 0; left: 0; width: 320px; height: 320px; border-radius: 50%;
  margin: -160px 0 0 -160px; z-index: 3; pointer-events: none;
  background-color: var(--key);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 68%);
  mask-image: radial-gradient(circle, #000 0%, transparent 68%);
  opacity: 0;
  transition: opacity var(--slow) var(--ease), background-color var(--arc) var(--ease);
  will-change: transform;
}
body.has-pointer .cursor-glow { opacity: .22; }
/* ---------- now playing ---------- */
.nowplaying {
  position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); z-index: 120;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px 9px 14px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--edge);
  backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px);
  font-family: var(--sans); max-width: min(78vw, 300px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--slow) var(--ease), border-color var(--fast), background var(--fast);
}
/* display only — never intercepts a tap, so it can't be muted by accident */
.nowplaying.ready { opacity: .62; }
/* during the reveal, 'again?' takes the bottom-centre slot, so step up out of it */
body.revealing .nowplaying { transform: translateX(-50%) translateY(-44px); }
.track {
  font-size: 12.5px; letter-spacing: .04em; color: var(--tx-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* when nothing is actually coming out, stop pretending */
.nowplaying.silent { opacity: .8; border-color: rgba(217,138,61,.4); }
.nowplaying.silent .eq i { animation-play-state: paused; transform: scaleY(.2); }
.nowplaying.silent .track { color: rgba(224,164,92,.95); }

.eq { display: flex; align-items: center; gap: 2px; height: 14px; flex: 0 0 auto; }
.eq i {
  display: block; width: 2px; border-radius: 2px; height: 100%;
  background: color-mix(in srgb, var(--key) 80%, white);
  transform-origin: center;
  animation: eq .9s ease-in-out infinite;
}
.eq i:nth-child(2) { animation-delay: .12s; }
.eq i:nth-child(3) { animation-delay: .24s; }
.eq i:nth-child(4) { animation-delay: .08s; }
@keyframes eq { 0%,100% { transform: scaleY(.28); } 50% { transform: scaleY(1); } }
.nowplaying[aria-pressed="true"] .eq i { animation-play-state: paused; transform: scaleY(.22); }

/* the opening nudge about sound */
.hint {
  font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--tx-dim); opacity: 0;
  animation: hintIn 1.1s var(--ease) 1.6s forwards;
}
@keyframes hintIn { to { opacity: .5; } }

/* ---------- screens ---------- */
.stage {
  position: relative; z-index: 10;
  height: 100dvh; display: grid; place-items: center;
  padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
}
.screen {
  grid-area: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(30px, 6vh, 52px);
  text-align: center;
  opacity: 0; transform: translateY(14px) scale(.985);
  pointer-events: none;
  transition: opacity var(--slow) var(--ease), transform var(--slow) var(--ease);
}
.screen.is-active { opacity: 1; transform: none; pointer-events: auto; }
.screen.is-leaving { opacity: 0; transform: translateY(-12px) scale(.99); }

.whisper {
  font-size: 12.5px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--tx-dim); font-weight: 500;
}

.ask {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(26px, 5.2vw, 46px);
  line-height: 1.24; letter-spacing: -.02em;
  max-width: 18ch; text-wrap: balance;
  text-shadow: 0 2px 40px rgba(0,0,0,.5);
}
.ask-name {
  font-style: italic;
  font-size: clamp(30px, 7vw, 58px);
  max-width: 14ch;
}

.row {
  display: flex; gap: 18px; flex-wrap: wrap;
  align-items: center; justify-content: center;
  position: relative; min-height: 58px;
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--sans); font-size: 17px; font-weight: 500;
  color: var(--tx); cursor: pointer;
  padding: 15px 32px; min-width: 132px; min-height: 50px;
  border-radius: 15px;
  border: 1px solid var(--edge);
  background: var(--glass);
  backdrop-filter: saturate(170%) blur(22px); -webkit-backdrop-filter: saturate(170%) blur(22px);
  /* background/border carry the temperature, so they ride the slow arc;
     transform stays snappy so presses still feel immediate */
  transition: background-color var(--arc) var(--ease), border-color var(--arc) var(--ease),
              transform var(--fast) var(--ease-soft), box-shadow var(--mid) var(--ease);
  user-select: none; -webkit-user-select: none;
}
.btn:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.2); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.985); }
.btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--key) 90%, white); outline-offset: 4px; }

.btn-yes {
  border-color: color-mix(in srgb, var(--key) 42%, transparent);
  background: color-mix(in srgb, var(--key) 13%, transparent);
}
.btn-yes:hover { background: color-mix(in srgb, var(--key) 22%, transparent); }

/* the invitation + the turn — the only two that glow */
.btn-key {
  font-weight: 600; letter-spacing: .02em;
  border-color: color-mix(in srgb, var(--key) 55%, transparent);
  background: color-mix(in srgb, var(--key) 16%, transparent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--key) 40%, transparent);
  animation: breathe 3.4s var(--ease) infinite;
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 22px -4px color-mix(in srgb, var(--key) 55%, transparent); }
  50% { box-shadow: 0 0 46px 2px color-mix(in srgb, var(--key) 72%, transparent); }
}
.btn-key:hover { background: color-mix(in srgb, var(--key) 26%, transparent); }

/* The one that runs. pointer-events:none makes it genuinely uncatchable —
   the dodge is driven by cursor proximity, not by hovering the button, so
   it can never be clicked no matter how close she gets. */
.btn-no {
  will-change: transform; position: relative; z-index: 4;
  pointer-events: none;
  /* the later taunts are long sentences; keep them on one readable line
     and never wider than the phone it's running on */
  max-width: 78vw; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 430px) {
  .btn-no { font-size: 15px; padding-left: 18px; padding-right: 18px; min-width: 0; }
}

/* ---------- GIF card ---------- */
.gifwrap {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; gap: 18px;
  grid-auto-flow: row;
  background: rgba(4,5,10,.58);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity var(--mid) var(--ease);
  cursor: pointer; padding: 22px;
}
.gifwrap.in { opacity: 1; }

.gifcard {
  position: relative;
  width: min(70vw, 340px);
  aspect-ratio: 4 / 3;               /* replaced from the real GIF on load */
  border-radius: 20px; overflow: hidden;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
  transform: scale(.86); opacity: 0;
  transition: transform var(--slow) var(--ease-soft), opacity var(--mid) var(--ease), aspect-ratio var(--mid) var(--ease);
  will-change: transform;
}
.gifwrap.in .gifcard { transform: scale(1); opacity: 1; }
.gifcard img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* No progress ring — it read as a loading spinner. The card simply
   arrives, plays, and leaves; tapping anywhere still skips ahead. */

/* ---------- the reveal ---------- */
.reveal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; background: #06040A;
  opacity: 0; pointer-events: none;
  transition: opacity var(--slow) var(--ease), background 2.2s var(--ease);
  overflow: hidden;
  /* clear the 'again?' control pinned to the bottom */
  padding: 22px 22px calc(64px + env(safe-area-inset-bottom));
}
.reveal.on { opacity: 1; pointer-events: auto; }
.reveal.warm { background: #0D0A07; }

.ember {
  position: absolute; top: 46%; left: 50%;
  width: min(70vmin, 520px); aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%,-50%) scale(calc(.2 * var(--pulse)));
  background: radial-gradient(circle, rgba(224,164,92,.5), rgba(196,118,46,.16) 42%, transparent 70%);
  filter: blur(48px); opacity: 0; z-index: 0; pointer-events: none;
  transition: opacity 1.4s var(--ease), transform 2.4s var(--ease-soft);
}
.reveal.lit .ember { opacity: 1; transform: translate(-50%,-50%) scale(calc(1 * var(--pulse))); }

.frame {
  position: relative; z-index: 3;
  /* --ph is the photo's real width/height, set by motion.js on load, so the
     frame takes the picture's own shape instead of cropping it to 3:4.
     height = width / ratio, so bounding width at (46dvh x ratio) caps height. */
  aspect-ratio: var(--ph, .75);
  width: min(340px, 74vw, calc(46dvh * var(--ph, .75)));
  flex: 0 0 auto;
  border-radius: 22px; overflow: hidden;
  box-shadow: 0 40px 90px -24px rgba(0,0,0,.85);
  opacity: 0; transform: scale(1.06); filter: blur(20px);
  transition: opacity 1.2s var(--ease), transform 1.4s var(--ease-soft), filter 1.4s var(--ease);
}
.reveal.shown .frame { opacity: 1; transform: scale(1); filter: blur(0); }
.frame::after {
  content: ''; position: absolute; inset: 0; border-radius: 22px; z-index: 5;
  border: 1px solid rgba(255,255,255,.13);
  box-shadow: inset 0 0 60px -20px rgba(224,164,92,.3);
  pointer-events: none;
}
.reveal.shown .frame::after { animation: frameGlow 6s var(--ease) 2s infinite; }
@keyframes frameGlow {
  0%, 100% { border-color: rgba(255,255,255,.13); box-shadow: inset 0 0 60px -20px rgba(224,164,92,.3); }
  50%      { border-color: rgba(255,255,255,.22); box-shadow: inset 0 0 74px -18px rgba(224,164,92,.46); }
}

/* the glossy light sweep — translate, not `left`, so it stays off the
   layout path and rides the compositor */
.frame::before {
  content: ''; position: absolute; top: -12%; left: 0; z-index: 4;
  width: 58%; height: 124%; pointer-events: none;
  background: linear-gradient(105deg,
    transparent 18%,
    rgba(255,255,255,.05) 40%,
    rgba(255,255,255,.14) 50%,
    rgba(255,255,255,.05) 60%,
    transparent 82%);
  transform: translate3d(-220%, 0, 0) rotate(4deg);
  opacity: 0;
}
.reveal.shown .frame::before { animation: sweep 7s var(--ease-soft) 2.4s infinite; }
@keyframes sweep {
  0%       { transform: translate3d(-220%,0,0) rotate(4deg); opacity: 0; }
  6%       { opacity: 1; }
  34%      { opacity: 1; }
  42%,100% { transform: translate3d(330%,0,0) rotate(4deg); opacity: 0; }
}

.frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  will-change: transform;
}
/* it breathes, so the reveal never reads as a frozen screenshot */
.reveal.shown .frame img { animation: breathe-photo 11s var(--ease-soft) 1.8s infinite; }
@keyframes breathe-photo {
  0%, 100% { transform: scale(1.006) translate3d(0, 0, 0); }
  50%      { transform: scale(1.026) translate3d(0, -5px, 0); }
}

.line {
  position: relative; z-index: 4;
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: clamp(19px, 3vw, 25px);
  color: rgba(245,235,222,.9);
  margin-top: clamp(14px, 3vh, 26px); min-height: 1.6em; text-align: center;
  letter-spacing: -.01em; flex: 0 0 auto;
}
.line span {
  display: inline-block; opacity: 0; transform: translateY(8px);
  animation: word .7s var(--ease-soft) forwards;
}
@keyframes word { to { opacity: 1; transform: none; } }

.pill {
  position: relative; z-index: 5;
  /* same height guard: at 16:9, 25dvh wide ≈ 14dvh tall */
  width: min(230px, 56vw, 25dvh); aspect-ratio: 16 / 9;
  margin-top: clamp(10px, 2vh, 18px); border-radius: 18px; overflow: hidden;
  flex: 0 0 auto;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.13);
  backdrop-filter: saturate(170%) blur(30px); -webkit-backdrop-filter: saturate(170%) blur(30px);
  box-shadow: 0 20px 50px -16px rgba(0,0,0,.7);
  opacity: 0; transform: translateY(22px);
  transition: opacity var(--slow) var(--ease), transform var(--slow) var(--ease-soft), aspect-ratio var(--mid) var(--ease);
}
.reveal.pilled .pill { opacity: 1; transform: none; }
.pill img { width: 100%; height: 100%; object-fit: cover; display: block; }

.bokeh { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 2s var(--ease); }
.reveal.drift .bokeh { opacity: 1; }
.bokeh i {
  position: absolute; bottom: -12%; border-radius: 50%;
  background: radial-gradient(circle, rgba(232,180,116,.5), transparent 68%);
  filter: blur(5px);
  animation: rise linear infinite;
}
@keyframes rise {
  from { transform: translate3d(0, 0, 0) scale(.6); opacity: 0; }
  12%  { opacity: .55; }
  88%  { opacity: .35; }
  to   { transform: translate3d(var(--dx, 20px), -118vh, 0) scale(1.1); opacity: 0; }
}

.again {
  position: absolute; bottom: max(22px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  font-family: var(--sans); font-size: 12.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--tx-dim); background: none; border: 0; cursor: pointer;
  padding: 10px 16px; z-index: 8;
  opacity: 0; transition: opacity 1.2s var(--ease), color var(--fast);
}
.reveal.drift .again { opacity: .55; }
.again:hover { color: var(--tx); }
.again:focus-visible { outline: 2px solid rgba(224,164,92,.9); outline-offset: 3px; border-radius: 6px; }

/* ---------- small screens ---------- */
@media (max-width: 600px) {
  .btn { padding: 14px 26px; min-width: 118px; font-size: 16px; }
  .row { gap: 14px; }
  .ask { max-width: 15ch; }
}

/* ---------- motion off ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .orb, .cursor-glow, .bokeh { display: none; }
  .screen { transform: none; }
  /* the runaway button stops running and stays clickable */
  .btn-no { transform: none !important; opacity: .55; }
}
