@font-face { font-family: 'Fraunces'; src: url('fonts/fraunces-latin-full-normal.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Fraunces'; src: url('fonts/fraunces-latin-full-italic.woff2') format('woff2'); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: 'Manrope'; src: url('fonts/manrope-latin-wght-normal.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }

:root {
  --night: #0b1426;
  --night-2: #142340;
  --ink: #fbf3e4;
  --ink-soft: #c9c2b4;
  --ink-mute: #8f94a3;
  --gold: #f2c46d;
  --gold-deep: #d79a3e;
  --ember: #e8894a;
  --wood: #7a2331;
  --wood-dark: #561622;
  --line: rgba(242, 196, 109, .28);
  --glass: rgba(20, 35, 64, .55);
  --town: #070c18;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Manrope', system-ui, sans-serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-door: cubic-bezier(.55, 0, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--night);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- atmosphere ---------- */
.sky {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 60% at 50% 115%, rgba(232, 137, 74, .32), transparent 60%),
    radial-gradient(80% 50% at 50% 38%, rgba(242, 196, 109, .10), transparent 70%),
    linear-gradient(180deg, #070d1a 0%, var(--night) 45%, var(--night-2) 100%);
  transition: background .8s;
}
body.is-open .sky {
  background:
    radial-gradient(120% 60% at 50% 115%, rgba(232, 137, 74, .38), transparent 60%),
    radial-gradient(90% 55% at 50% 32%, rgba(242, 196, 109, .22), transparent 70%),
    linear-gradient(180deg, #070d1a 0%, var(--night) 45%, var(--night-2) 100%);
}
#snow { position: fixed; inset: 0; z-index: 1; pointer-events: none; width: 100%; height: 100%; }
/* skyline sits on top of the footer band, full bleed */
.town { display: block; width: 100%; height: clamp(150px, 16vw, 230px); pointer-events: none; }
.town-back { fill: #12203a; }
.town-front { fill: var(--town); }
.lights > * { fill: #ffc874; }
/* windows switch on/off at random (app.js) */
.lights rect { opacity: .75; transition: opacity 3s ease; }
.lights rect:nth-child(4n) { opacity: .5; }
.lights rect.off { opacity: .05; }
.lights rect.warm { opacity: .9; fill: #ffd98f; }
/* Hundertwasser golden balls: core + breathing halo */
.ball .core { fill: #ffd47a; }
.ball .halo { fill: url(#ballGlow); opacity: .7; transform-box: fill-box; transform-origin: center; animation: halo-pulse 6s ease-in-out infinite; animation-delay: var(--d, 0s); }
.ball .core { transform-box: fill-box; transform-origin: center; animation: core-pulse 6s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes halo-pulse { 0%, 100% { opacity: .6; transform: scale(.9); } 50% { opacity: .85; transform: scale(1); } }
@keyframes core-pulse { 0%, 100% { fill: #f2c46d; } 50% { fill: #ffdf98; } }
/* train crosses the town every ~32s */
.rail { fill: #1c2a45; }
.train { animation: train 32s linear infinite; animation-delay: -24s; }
.train-body { fill: #1f3050; }
.train-roof { fill: #5d7299; }
.train-stripe { fill: #b5343f; }
.train-win { fill: #ffe7a8; }
.train-door { fill: #16233d; }
.train-cab { fill: #9fb6d9; opacity: .55; }
.train-panto { fill: none; stroke: #5d7299; stroke-width: 1.2; }
.train-wheel { fill: #0d1628; }
.train-head { fill: #fff; filter: drop-shadow(0 0 4px #fff3c4); }
.train-beam { fill: url(#beam); }
@keyframes train { 0% { transform: translateX(-380px); } 60%, 100% { transform: translateX(1420px); } }

/* ---------- layout ---------- */
.app {
  position: relative; z-index: 2;
  width: min(100%, 480px);
  margin: 0 auto;
  min-height: 100svh;
  padding: max(20px, env(safe-area-inset-top)) 20px 0;
  display: flex; flex-direction: column;
}
.top { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.brand { margin: 0; white-space: nowrap; font: 700 15px/1.2 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.brand-star { display: inline-block; margin-right: 6px; font-size: 1.15em; animation: twinkle 3s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .45; transform: scale(.85) rotate(20deg); } }
.today { margin: 0; font-size: 14px; color: var(--ink-mute); }

/* ---------- stage ---------- */
.stage {
  position: relative;
  margin: clamp(20px, 5vh, 44px) 0 0;
  display: grid; place-items: center;
}

/* door */
.door-wrap { grid-area: 1 / 1; position: relative; width: min(84vw, 340px); aspect-ratio: 4 / 5; transition: transform .9s var(--ease-out), opacity .6s; }
.door {
  position: absolute; inset: 0;
  border: 0; padding: 0; margin: 0; background: none; cursor: pointer;
  perspective: 1100px;
  border-radius: 150px 150px 14px 14px; /* arched window */
  -webkit-tap-highlight-color: transparent;
}
.door::before { /* stone frame */
  content: ''; position: absolute; inset: -12px;
  border-radius: 162px 162px 20px 20px;
  background: linear-gradient(160deg, #2a3958, #18243d 60%, #121c31);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .08);
  z-index: -1;
}
.door::after { /* gold trim */
  content: ''; position: absolute; inset: -5px;
  border-radius: 155px 155px 17px 17px;
  border: 1px solid var(--line);
  pointer-events: none; z-index: 3;
}
.door:focus-visible { outline: none; }
.door:focus-visible::after { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 196, 109, .35); }

.door-light {
  position: absolute; inset: 0; border-radius: inherit; overflow: hidden;
  background:
    radial-gradient(60% 50% at 50% 55%, #fff6d8 0%, var(--gold) 35%, var(--ember) 75%, #b4532c 100%);
  box-shadow: inset 0 0 40px rgba(120, 40, 10, .5);
}
.door-light::after { /* light rays */
  content: ''; position: absolute; inset: -40%;
  background: repeating-conic-gradient(from 0deg at 50% 55%, rgba(255, 255, 255, .22) 0 6deg, transparent 6deg 18deg);
  animation: spin 24s linear infinite; mix-blend-mode: soft-light;
}
@keyframes spin { to { transform: rotate(360deg); } }

.shutter {
  position: absolute; top: 0; bottom: 0; width: 50%;
  display: flex; flex-direction: column; gap: 8px; padding: 14px 12px;
  background: linear-gradient(180deg, #8e2b3b, var(--wood) 50%, var(--wood-dark));
  transition: transform 1.25s var(--ease-door);
  transform-style: preserve-3d;
  backface-visibility: hidden;
  z-index: 2;
}
.shutter-l { left: 0; transform-origin: left center; border-radius: 150px 0 0 14px; padding-top: 70px; box-shadow: inset -1px 0 0 rgba(0, 0, 0, .35); }
.shutter-r { right: 0; transform-origin: right center; border-radius: 0 150px 14px 0; padding-top: 70px; box-shadow: inset 1px 0 0 rgba(255, 255, 255, .06); }
.shutter-panel {
  flex: 1; border-radius: 6px;
  border: 1px solid rgba(242, 196, 109, .22);
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(0, 0, 0, .12));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), inset 0 -2px 6px rgba(0, 0, 0, .25);
}
.shutter-l .shutter-panel:first-child { border-top-left-radius: 90px; }
.shutter-r .shutter-panel:first-child { border-top-right-radius: 90px; }

.seal {
  position: absolute; left: 50%; top: 52%; z-index: 4;
  width: 46%; aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 50%;
  display: grid; place-content: center; text-align: center;
  background: radial-gradient(circle at 35% 30%, #ffe9b0, var(--gold) 45%, var(--gold-deep) 100%);
  color: var(--wood-dark);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45), inset 0 -4px 10px rgba(140, 80, 10, .35), inset 0 3px 6px rgba(255, 255, 255, .5);
  transition: transform .5s var(--ease-out), opacity .4s;
}
.seal::before { content: ''; position: absolute; inset: 7px; border-radius: 50%; border: 1px dashed rgba(86, 22, 34, .35); }
.seal-label { font: 700 10px/1 var(--sans); letter-spacing: .3em; text-transform: uppercase; margin-bottom: 2px; padding-left: .3em; }
.seal-num { font: 600 clamp(46px, 15vw, 64px)/.9 var(--serif); font-variation-settings: 'SOFT' 100, 'WONK' 1; }

/* idle invitation: gentle breathing glow */
.door-wrap.is-ready .door::before { animation: halo 2.6s ease-in-out infinite; }
@keyframes halo {
  0%, 100% { box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7), 0 0 0 0 rgba(242, 196, 109, 0), inset 0 1px 0 rgba(255, 255, 255, .08); }
  50% { box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7), 0 0 50px 4px rgba(242, 196, 109, .28), inset 0 1px 0 rgba(255, 255, 255, .08); }
}
.door-wrap.is-ready .seal { animation: seal-bob 2.6s ease-in-out infinite; }
@keyframes seal-bob { 50% { transform: translate(-50%, -52%) scale(1.04); } }

/* locked: tap feedback */
.door-wrap.is-locked .seal { filter: saturate(.55) brightness(.85); }
.door-wrap.shake { animation: shake .5s; }
@keyframes shake { 20% { transform: translateX(-7px) rotate(-1deg); } 40% { transform: translateX(6px) rotate(1deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }

/* opening sequence */
.door-wrap.is-opening .seal { transform: translate(-50%, -50%) scale(1.25); opacity: 0; transition-duration: .45s; }
.door-wrap.is-opening .shutter-l { transform: rotateY(-112deg); }
.door-wrap.is-opening .shutter-r { transform: rotateY(112deg); }
.door-wrap.is-gone { transform: scale(1.35); opacity: 0; pointer-events: none; transition: transform 1.1s var(--ease-out), opacity .9s ease; }

.sparks { position: absolute; inset: -60%; width: 220%; height: 220%; pointer-events: none; z-index: 5; }

/* player */
.player { grid-area: 1 / 1; --pw: min(100vw - 16px, 640px); margin: 0 calc((100% - var(--pw)) / 2); width: var(--pw); position: relative; z-index: 6; }
.player.rise { animation: rise .9s var(--ease-out) both; }
.player-frame {
  position: relative; clip-path: circle(100% at 50% 50%); border-radius: 18px; overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px var(--line), 0 30px 80px -20px rgba(232, 137, 74, .55), 0 20px 50px -10px rgba(0, 0, 0, .8);
}
.player video { display: block; width: 100%; max-height: 72svh; background: #000; }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.94); filter: blur(6px); } }

/* iris reveal: the door's light opens up into the video */
.stage { transition: height .9s var(--ease-out); }
.player-frame { transition: clip-path 1.15s cubic-bezier(.7, 0, .2, 1), filter 1.6s ease, transform 1.15s var(--ease-out); }
.player-frame::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, #fff7df 0%, rgba(242, 196, 109, .85) 40%, rgba(232, 137, 74, .4) 75%, transparent 100%);
  opacity: 0; transition: opacity 1.5s ease .15s;
}
.player.iris .player-frame { clip-path: circle(0% at 50% 50%); filter: brightness(1.8) saturate(.6); transform: scale(.96); transition: none; }
.player.iris .player-frame::after { opacity: 1; transition: none; }


/* ---------- info ---------- */
.info { text-align: center; margin-top: clamp(22px, 4vh, 34px); }
.eyebrow { margin: 0 0 6px; font: 700 12px/1.2 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.title {
  margin: 0; font: italic 500 clamp(30px, 8.6vw, 40px)/1.08 var(--serif);
  font-variation-settings: 'SOFT' 100, 'WONK' 1, 'opsz' 72;
  letter-spacing: -.01em; text-wrap: balance;
}
.lead { margin: 10px auto 0; max-width: 32ch; color: var(--ink-soft); font-size: 15px; text-wrap: pretty; }
.info.reveal > * { animation: rise .8s var(--ease-out) both; }
.info.reveal > :nth-child(2) { animation-delay: .08s; }
.info.reveal > :nth-child(3) { animation-delay: .16s; }
.info.reveal > :nth-child(4) { animation-delay: .24s; }
.info.reveal > :nth-child(5) { animation-delay: .32s; }

.countdown {
  margin: 22px auto 0; padding: 14px 18px 16px; max-width: 320px;
  border-radius: 18px; border: 1px solid var(--line);
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.countdown-label { margin: 0; font-size: 13px; color: var(--ink-soft); }
.countdown-time {
  margin: 2px 0 0; font: 500 38px/1.1 var(--serif); font-variant-numeric: tabular-nums;
  font-variation-settings: 'SOFT' 50; color: var(--ink); letter-spacing: .02em;
}
.countdown-time small { font: 600 11px var(--sans); letter-spacing: .12em; color: var(--ink-mute); text-transform: uppercase; margin: 0 6px 0 2px; }
.countdown.is-small { padding: 10px 16px; }
.countdown.is-small .countdown-time { font-size: 24px; }

.cta-row { margin-top: 22px; display: flex; justify-content: center; }
.btn {
  border: 0; cursor: pointer; min-height: 52px; padding: 0 28px; border-radius: 999px;
  font: 700 16px/1 var(--sans); letter-spacing: .01em;
  transition: transform .2s var(--ease-out), box-shadow .3s;
}
.btn-primary {
  color: var(--wood-dark);
  background: linear-gradient(180deg, #ffe2a0, var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 10px 30px -8px rgba(242, 196, 109, .7), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.btn:active { transform: scale(.96); }
.btn:focus-visible, .chip:focus-visible, .demo button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.actions { margin-top: 22px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--glass);
  font: 600 14px/1 var(--sans);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background .2s, transform .2s;
}
.chip svg { width: 18px; height: 18px; fill: var(--gold); }
.chip:active { transform: scale(.96); }
@media (hover: hover) { .chip:hover { background: rgba(242, 196, 109, .12); } }

.foot { margin: auto calc(50% - 50vw) 0; padding-top: 36px; width: 100vw; text-align: center; font-size: 13px; color: var(--ink-mute); }
.foot-band { margin-top: -1px; padding: 6px 20px max(22px, env(safe-area-inset-bottom)); background: var(--town); }
.foot p { margin: 0 0 8px; text-wrap: balance; }
body.has-demo .foot-band { padding-bottom: 72px; }
.foot strong { color: var(--ink-soft); font-weight: 600; }
.foot nav { display: flex; justify-content: center; gap: 18px; }
.foot a { color: var(--ink-mute); text-underline-offset: 3px; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 30;
  transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 14px;
  background: #fbf3e4; color: var(--night); font-weight: 600; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  animation: rise .4s var(--ease-out) both;
}

/* ---------- demo panel ---------- */
.demo { position: fixed; left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 40; display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 8px; }
.demo-toggle {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  min-height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px dashed rgba(255, 255, 255, .35); background: rgba(5, 10, 20, .8);
  font: 600 12px/1 var(--sans); font-variant-numeric: tabular-nums; color: #fff;
}
.demo-dot { width: 8px; height: 8px; border-radius: 50%; background: #5bd38a; box-shadow: 0 0 8px #5bd38a; }
.demo-panel {
  width: min(300px, calc(100vw - 24px)); padding: 16px; border-radius: 16px;
  background: rgba(8, 14, 28, .96); border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .6); font-size: 13px;
}
.demo-h { margin: 0 0 12px; font-weight: 700; }
.demo-field { display: grid; gap: 6px; margin: 0 0 12px; padding: 0; border: 0; }
.demo-field legend { padding: 0; margin-bottom: 6px; color: var(--ink-mute); }
.demo-field label { display: flex; gap: 8px; align-items: center; }
.demo-field input[type=range] { width: 100%; accent-color: var(--gold); }
.demo-group { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.demo-group button, .demo-reset {
  cursor: pointer; padding: 7px 10px; border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .06);
  font: 600 12px/1 var(--sans); font-variant-numeric: tabular-nums;
}
.demo-reset { width: 100%; }
.demo-note { margin: 12px 0 0; color: var(--ink-mute); font-size: 11.5px; line-height: 1.45; }

/* ---------- larger screens ---------- */
@media (min-width: 720px) {
  .door-wrap { width: 360px; }
  .stage { margin-top: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .2s !important; }
  .door-light::after { animation: none; }
}
