/* ─── tokens ─────────────────────────────────────────────── */
:root {
  --ink: #fdf6ea;
  --ink-2: rgba(253, 246, 234, .80);
  --ink-3: rgba(253, 246, 234, .52);
  --line: rgba(253, 246, 234, .30);
  --amber: #ffd166;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Manrope', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --gutter: clamp(22px, 5.5vw, 92px);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: #2f86e0; color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
em { font-style: italic; }
::selection { background: var(--amber); color: #2a1a08; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; border-radius: 4px; }

.world { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; touch-action: none; }
#scroller { position: relative; z-index: 1; pointer-events: none; }

/* while the first shot is up, the whole page is a handle for the concha */
body.is-first { cursor: grab; }
body.is-turning { cursor: grabbing; }

/* ─── loader ─────────────────────────────────────────────── */
.loader {
  position: fixed; inset: 0; z-index: 120; background: #2f86e0;
  display: grid; place-items: center; text-align: center;
  transition: opacity 1s var(--ease), visibility 1s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader__k { font-family: var(--mono); font-size: 10px; letter-spacing: .38em; text-transform: uppercase; color: var(--amber); }
.loader__t { font-family: var(--serif); font-weight: 200; font-size: clamp(58px, 11vw, 132px); line-height: 1; margin: 16px 0 8px; }
.loader__t i { font-style: normal; font-size: .24em; color: var(--ink-3); margin-left: .12em; }
.loader__n { font-family: var(--mono); font-size: 10px; letter-spacing: .26em; text-transform: uppercase; color: var(--ink-3); }

/* ─── chrome ─────────────────────────────────────────────── */
.chrome {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: clamp(18px, 2.6vw, 34px) var(--gutter);
  opacity: 0; transition: opacity 1.1s var(--ease) .3s;
  mix-blend-mode: difference;
}
.is-ready .chrome { opacity: 1; }
.mark { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: clamp(17px, 1.5vw, 21px); letter-spacing: .01em; }
.mark__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.frame { font-family: var(--mono); font-size: 11px; letter-spacing: .2em; color: var(--ink-2); }
.frame i { font-style: normal; color: var(--ink-3); margin: 0 6px; }

.chrome__right { display: flex; align-items: center; gap: clamp(14px, 2.4vw, 28px); }
.snd {
  display: inline-flex; align-items: center; gap: 9px; padding: 7px 13px 7px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-3); transition: color .3s, border-color .3s, background .3s;
}
.snd:hover { color: var(--ink); border-color: var(--ink-3); }
.snd.is-on { color: var(--ink); border-color: var(--amber); }
.snd__bars { display: flex; align-items: flex-end; gap: 2px; height: 11px; }
.snd__bars b { display: block; width: 2px; height: 3px; background: currentColor; border-radius: 1px; }
.snd.is-on .snd__bars b { animation: bars 1.1s ease-in-out infinite; }
.snd.is-on .snd__bars b:nth-child(2) { animation-delay: .16s }
.snd.is-on .snd__bars b:nth-child(3) { animation-delay: .32s }
.snd.is-on .snd__bars b:nth-child(4) { animation-delay: .48s }
@keyframes bars { 0%, 100% { height: 3px } 50% { height: 11px } }

/* ─── beats ──────────────────────────────────────────────── */
.beats { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
/* type always needs something to sit on, however bright the shot gets */
.beats::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to top, rgba(14,22,40,.62) 0%, rgba(14,22,40,.24) 36%, rgba(14,22,40,0) 64%),
    linear-gradient(100deg, rgba(14,22,40,.42) 0%, rgba(14,22,40,.12) 44%, rgba(14,22,40,0) 72%);
}
.beat { position: absolute; }
.beat {
  position: absolute; left: 0; right: 0; bottom: clamp(74px, 13vh, 132px);
  padding: 0 var(--gutter);
  max-width: min(1080px, 94vw);
  opacity: 0; visibility: hidden;
}
/* the opening shot puts its words lower and wider, under the held concha */
.beat.is-hold { bottom: clamp(82px, 15vh, 150px); }

.kick {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .3em; text-transform: uppercase;
  color: var(--amber); margin-bottom: clamp(14px, 2vh, 22px);
}
.rule { display: block; width: clamp(34px, 6vw, 84px); height: 1px; background: currentColor; transform-origin: left center; }

.disp {
  font-family: var(--serif); font-weight: 200;
  font-size: clamp(40px, 7.4vw, 108px); line-height: .96; letter-spacing: -.032em;
  margin: 0 0 clamp(16px, 2.4vh, 26px);
  text-shadow: 0 2px 26px rgba(12,20,38,.55), 0 1px 3px rgba(12,20,38,.35);
}
.disp .ln { display: block; }
.disp .ln.in { padding-left: clamp(20px, 6vw, 108px); }
.mask { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: .08em; }
.word { display: inline-block; will-change: transform; }
.disp em.word { font-style: italic; color: var(--amber); }

.body {
  font-size: clamp(14.5px, 1.2vw, 17.5px); line-height: 1.66;
  color: var(--ink); max-width: 40ch;
  text-shadow: 0 2px 18px rgba(12,20,38,.6);
}

/* the box: a small caption plate that wipes open */
.plate {
  display: inline-flex; align-items: baseline; gap: 12px;
  margin-top: clamp(20px, 3vh, 34px);
  padding: 11px 18px; border: 1px solid var(--line); border-radius: 2px;
  background: rgba(16, 26, 48, .30); backdrop-filter: blur(10px);
}
.plate b { font-family: var(--serif); font-weight: 400; font-size: 17px; letter-spacing: -.01em; }
.plate span { font-family: var(--mono); font-size: 9.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-3); }
/* the drag prompt only matters until you have actually dragged */
.beat.is-hold .plate { transition: opacity .6s var(--ease); }
.has-turned .beat.is-hold .plate { opacity: .28; }

/* ─── cue + progress ─────────────────────────────────────── */
.cue {
  position: fixed; z-index: 40; right: var(--gutter); bottom: clamp(26px, 4vh, 44px);
  display: flex; align-items: center; gap: 12px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .26em; text-transform: uppercase; color: var(--ink-3);
  opacity: 0; transition: opacity .7s var(--ease) 1.2s;
}
.is-ready .cue { opacity: 1; }
.is-ready .cue.is-hidden { opacity: 0; transition-delay: 0s; }
.cue i { display: block; width: 28px; height: 1px; background: var(--line); position: relative; overflow: hidden; }
.cue i::after { content: ''; position: absolute; inset: 0; background: var(--amber); transform: translateX(-100%); animation: sweep 2.1s var(--ease) infinite; }
@keyframes sweep { 0% { transform: translateX(-100%) } 60%, 100% { transform: translateX(100%) } }

.progress { position: fixed; left: 0; right: 0; bottom: 0; height: 2px; z-index: 40; background: rgba(253,246,234,.10); }
.progress i { display: block; height: 100%; background: var(--amber); transform-origin: left center; transform: scaleX(0); }

/* ─── end card ───────────────────────────────────────────── */
.end {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-content: center; justify-items: center; gap: 18px; text-align: center;
  background: radial-gradient(62% 62% at 50% 50%, rgba(18,30,56,.78), rgba(18,30,56,.94));
  opacity: 0; visibility: hidden; transition: opacity .9s var(--ease), visibility .9s;
}
.end.is-in { opacity: 1; visibility: visible; }
.end__t { font-family: var(--serif); font-weight: 200; font-size: clamp(46px, 9vw, 104px); line-height: 1; letter-spacing: -.03em; }
.end__c { font-family: var(--mono); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); max-width: 46ch; line-height: 2; }
.end__again { margin-top: 10px; padding: 13px 26px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; font-weight: 600; transition: background .25s, border-color .25s, color .25s; }
.end__again:hover { background: var(--amber); border-color: var(--amber); color: #2a1a08; }

/* ─── responsive ─────────────────────────────────────────── */
@media (max-width: 820px) {
  .beat { bottom: clamp(64px, 11vh, 96px); max-width: 100%; }
  .disp { font-size: clamp(34px, 10vw, 54px); }
  .disp .ln.in { padding-left: 7vw; }
  .body { max-width: 30ch; font-size: 14px; }
  .cue { display: none; }
  .plate { padding: 9px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .cue i::after, .snd.is-on .snd__bars b, .dot.is-grab .dot__r { animation: none; }
}

/* ─── the pigeon that follows your hand ──────────────────── */
body.has-crit, body.has-crit button, body.has-crit a { cursor: none; }

.dot {
  position: fixed; left: 0; top: 0; z-index: 95;
  width: 0; height: 0; pointer-events: none; will-change: transform;
}
/* the ring reads the state: idle, over a piece you can turn, over a control */
.dot__r, .dot__p { position: absolute; left: 0; top: 0; border-radius: 50%; }
.dot__r {
  width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border: 1px solid var(--cur, var(--amber)); opacity: .5;
  box-shadow: 0 0 0 1px rgba(16, 24, 46, .18) inset;
  transition: width .32s var(--ease), height .32s var(--ease),
              margin .32s var(--ease), opacity .3s, border-style .2s, background .3s;
}
.dot__p {
  width: 4px; height: 4px; margin: -2px 0 0 -2px;
  background: var(--cur, var(--amber));
  box-shadow: 0 0 8px var(--cur, var(--amber));
  transition: width .3s var(--ease), height .3s var(--ease), margin .3s var(--ease);
}
/* over a piece: a slow dashed ring — the thing under you can be turned */
.dot.is-grab .dot__r {
  width: 52px; height: 52px; margin: -26px 0 0 -26px; opacity: .95;
  border-style: dashed; animation: ringspin 7s linear infinite;
}
.dot.is-hot .dot__r { width: 40px; height: 40px; margin: -20px 0 0 -20px; opacity: .9; background: rgba(253, 246, 234, .14); }
.dot.is-hot .dot__p, .dot.is-down .dot__p { width: 0; height: 0; margin: 0; }
.dot.is-down .dot__r { width: 19px; height: 19px; margin: -9.5px 0 0 -9.5px; opacity: 1; background: color-mix(in srgb, var(--cur, #ffd166) 26%, transparent); }
@keyframes ringspin { to { transform: rotate(360deg) } }

/* the ribbon your hand drags behind it */
.ribbon {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: 93;
  pointer-events: none; overflow: visible;
}
.ribbon path {
  fill: var(--cur, var(--amber));
  /* a hairline of shadow so the ribbon still reads when it is the same colour
     as the piece it is being dragged across */
  stroke: rgba(18, 26, 48, .22); stroke-width: 1;
  opacity: .78;
  filter: drop-shadow(0 1px 8px color-mix(in srgb, var(--cur, #ffd166) 65%, transparent));
}

.crit {
  position: fixed; left: 0; top: 0; z-index: 90;
  width: 72px; height: 62px; pointer-events: none; will-change: transform;
  opacity: 0; transition: opacity .8s var(--ease);
}
.is-ready .crit { opacity: 1; }
/* she has been fed enough to shine a little herself */
.crit__halo {
  position: absolute; left: 50%; top: 42%;
  width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 140, .46), rgba(255, 190, 120, 0) 64%);
  opacity: calc(.34 + var(--plump, 0) * .52);
  transition: opacity .4s linear;
}
.crit__sh {
  position: absolute; left: 50%; bottom: 3px; width: 42px; height: 9px; margin-left: -21px;
  border-radius: 50%; background: rgba(16, 24, 46, .34); filter: blur(3.5px);
  transform: scale(calc(1 - var(--lift, 0) * .42));
  opacity: calc(.6 - var(--lift, 0) * .34);
}
.crit__b { position: absolute; inset: 0; transform-origin: 50% 88%; will-change: transform; }
.crit__b svg { display: block; overflow: visible; filter: drop-shadow(0 3px 7px rgba(16, 24, 46, .34)); }
#cbHead, #cbWing, #cbTail { transform-box: view-box; }
#cbHead { transform-origin: 46px 27px; }
#cbWing { transform-origin: 25px 32px; }
#cbTail { transform-origin: 16px 35px; }
.crit.is-full .crit__b svg { filter: drop-shadow(0 3px 7px rgba(16,24,46,.34)) drop-shadow(0 0 14px rgba(255, 209, 102, .85)); }

.crit__n {
  position: absolute; left: 100%; top: 4px; margin-left: 1px;
  font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .14em;
  color: var(--amber); opacity: 0; white-space: nowrap;
  text-shadow: 0 1px 6px rgba(16, 24, 46, .7);
}

.crumbs { position: fixed; inset: 0; z-index: 88; pointer-events: none; }
.crumb {
  position: absolute; left: 0; top: 0; width: 8px; height: 8px; margin: -4px 0 0 -4px;
  border-radius: 2.5px; box-shadow: 0 0 12px rgba(255, 209, 102, .55);
  transition: opacity .4s var(--ease);
  animation: crumbdrop .42s var(--ease) both;
}
.crumb.is-gone { --cs: 0; opacity: 0; transition: opacity .38s var(--ease), --cs .38s; }
@keyframes crumbdrop { 0% { --cs: 1.9; opacity: 0 } 60% { opacity: 1 } 100% { --cs: 1; opacity: 1 } }
@property --cs { syntax: '<number>'; initial-value: 1; inherits: false; }

@media (pointer: coarse) { .crit, .dot, .ribbon, .crumbs { display: none; } }
@media (prefers-reduced-motion: reduce) { .crumb { animation: none; } }

/* the trail your hand draws, and the hearts she gives you back */
.heart {
  position: absolute; left: 50%; top: -8px; margin-left: -9px;
  filter: drop-shadow(0 2px 5px rgba(16, 24, 46, .45));
  animation: heartUp 1.25s var(--ease) both;
  pointer-events: none;
}
@keyframes heartUp {
  0%   { transform: translate(var(--hx), 8px) scale(.25); opacity: 0 }
  22%  { transform: translate(var(--hx), -6px) scale(1.12); opacity: 1 }
  100% { transform: translate(calc(var(--hx) + var(--hd)), -54px) scale(.8); opacity: 0 }
}
@media (pointer: coarse) { .ribbon, .heart { display: none; } }
@media (prefers-reduced-motion: reduce) { .heart { animation-duration: .9s; } }
