/* ---------- Theme tokens (JS swaps these per edit; @property lets them animate) ---------- */
@property --bg      { syntax: "<color>"; inherits: true; initial-value: #0a0a10; }
@property --text    { syntax: "<color>"; inherits: true; initial-value: #f4f4f8; }
@property --accent  { syntax: "<color>"; inherits: true; initial-value: #b9a8ff; }
@property --accent2 { syntax: "<color>"; inherits: true; initial-value: #ffc2dc; }

:root {
  --bg: #0a0a10;
  --text: #f4f4f8;
  --accent: #b9a8ff;
  --accent2: #ffc2dc;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.76, 0, .24, 1);
  transition: --bg 1.4s ease, --text 1.4s ease, --accent 1.4s ease, --accent2 1.4s ease;
  color-scheme: dark;
}
/* Set colors instantly while the intro covers the page (animating them restyles everything). */
:root.no-theme-anim { transition: none; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Background layers ---------- */
#bg, #fx {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
#bg { z-index: 0; }
#fx { z-index: 1; pointer-events: none; }
.grain {
  position: fixed; inset: -50%;
  z-index: 2; pointer-events: none;
  opacity: .1;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); } 60% { transform: translate(-2%, -1%); }
  80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

/* ---------- Intro (night sky) ----------
   Only transform + opacity are animated so everything stays on the GPU. */
#intro {
  position: fixed; inset: 0;
  z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
  cursor: pointer;
  background:
    radial-gradient(ellipse 80% 60% at 50% 38%, #18203d 0%, #0c1022 45%, #05060d 100%);
  transition: opacity .8s ease;
}
#stars { position: absolute; inset: 0; width: 100%; height: 100%; }

.moon-wrap {
  position: relative; z-index: 2;
  width: clamp(48px, 6vw, 68px); aspect-ratio: 1;
  margin-bottom: clamp(26px, 4.5vh, 44px);
  opacity: 0;
  transform: translateY(46px);
}
.moon {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 38%, #fffdf6 0%, #f1ecdb 50%, #d4cdb6 100%);
  /* Cut a circle out of the disc to leave a crescent. */
  -webkit-mask: radial-gradient(circle at 76% 30%, transparent 44%, #000 45.5%);
          mask: radial-gradient(circle at 76% 30%, transparent 44%, #000 45.5%);
  transform: rotate(-12deg);
}
.moon-glow {
  position: absolute; left: 50%; top: 50%;
  width: 520%; aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 244, 214, .26) 0%, rgba(200, 210, 255, .09) 30%, transparent 62%);
  animation: glow-breathe 3.2s ease-in-out infinite alternate;
}
@keyframes glow-breathe { from { opacity: .75; } to { opacity: 1; } }

/* Moonlight that floods the screen on the way out, tinted to today's edit. */
.flood {
  position: absolute; left: 50%; top: 50%;
  width: 300%; aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle,
    color-mix(in srgb, var(--accent) 45%, #fff) 0%,
    color-mix(in srgb, var(--accent) 40%, transparent) 35%,
    transparent 70%);
  opacity: 0;
  transform: scale(.3);
  will-change: transform, opacity;
}

.intro-word {
  position: relative; z-index: 1;
  margin: 0; padding: 0 16px;
  font-size: clamp(2.1rem, 8.6vw, 7.5rem);
  font-weight: 850;
  letter-spacing: -.035em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  color: #f6f4ff;
  text-shadow: 0 0 40px rgba(170, 185, 255, .35);
}
.intro-word .ch { display: inline-block; opacity: 0; transform: translateY(.45em); }
.intro-word .sp { display: inline-block; width: .28em; }
.intro-tag {
  position: relative; z-index: 1;
  margin: clamp(16px, 2.4vh, 24px) 0 0;
  font-size: clamp(10px, 1vw, 12px);
  font-weight: 600;
  letter-spacing: .42em;
  text-transform: uppercase;
  color: rgba(214, 220, 255, .62);
  opacity: 0;
}

/* Enter (after the font has loaded, so nothing swaps mid-animation) */
#intro.is-ready .moon-wrap { animation: moon-rise 1.6s var(--ease-out) .05s forwards; }
#intro.is-ready .ch {
  animation: ch-in .9s var(--ease-out) forwards;
  animation-delay: calc(var(--i) * 40ms + 380ms);
}
#intro.is-ready .intro-tag { animation: fade-in 1s ease 1.15s forwards; }
@keyframes moon-rise { to { opacity: 1; transform: none; } }
@keyframes ch-in { to { opacity: 1; transform: none; } }
@keyframes fade-in { to { opacity: 1; } }

/* Exit: letters drift up, moonlight floods out, then the sky fades away */
#intro.is-out .ch {
  animation: ch-out .55s ease-in forwards;
  animation-delay: calc(var(--d) * 26ms);
}
#intro.is-out .intro-tag { animation: fade-out .4s ease forwards; }
#intro.is-out .moon,
#intro.is-out .moon-glow { animation: moon-out .9s var(--ease-io) forwards; }
#intro.is-out .flood { animation: flood 1.2s cubic-bezier(.45, 0, .2, 1) .15s forwards; }
@keyframes ch-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-.35em); } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes moon-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(1.6); } }
@keyframes flood {
  0%   { opacity: 0;   transform: scale(.3); }
  35%  { opacity: .95; }
  100% { opacity: .85; transform: scale(9); }
}
#intro.is-open { opacity: 0; pointer-events: none; }
#intro.is-done { display: none; }
body.is-intro .grain { animation: none; }

/* ---------- Site ---------- */
.site {
  position: relative; z-index: 3;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: max(20px, env(safe-area-inset-top)) clamp(16px, 3vw, 36px) max(16px, env(safe-area-inset-bottom));
  transition: opacity 1s ease, transform 1.4s var(--ease-out);
}
body.is-intro .site { opacity: 0; transform: scale(1.04); }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.wordmark { font-weight: 800; letter-spacing: .18em; }
.issue { opacity: .62; font-variant-numeric: tabular-nums; text-align: right; }
.topbar-right { display: flex; align-items: center; gap: clamp(14px, 2.4vw, 28px); }
.nav-link {
  color: var(--text); text-decoration: none;
  font-weight: 700;
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  transition: color .3s ease, border-color .3s ease;
}
.nav-link:hover { color: var(--accent); border-color: var(--accent); }
.wordmark { color: inherit; text-decoration: none; }

.stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(18px, 2.6vh, 28px);
  padding: clamp(24px, 4vh, 48px) 0;
}

.meta { text-align: center; max-width: 1000px; }
.creator {
  display: inline-flex; align-items: center; gap: 14px;
  color: var(--accent);
  text-decoration: none;
  font-size: clamp(11px, 1.1vw, 13px);
  font-weight: 650;
  letter-spacing: .26em;
  text-transform: uppercase;
}
.creator::before, .creator::after {
  content: ""; width: 28px; height: 1px;
  background: currentColor; opacity: .6;
}
a.creator[href]:hover { color: var(--accent2); }
.title {
  margin: .3em 0 0;
  font-size: clamp(2.1rem, 5.8vw, 4.9rem);
  font-weight: 850;
  font-variation-settings: "wdth" 112;
  line-height: .95;
  letter-spacing: -.035em;
  text-wrap: balance;
  background: linear-gradient(100deg, var(--text) 15%, var(--accent) 60%, var(--accent2) 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  padding-bottom: .06em;
}

.player {
  position: relative;
  width: clamp(min(100%, 300px), calc((100svh - 360px) * 1.7778), min(980px, 100%));
  aspect-ratio: 16 / 9;
  border-radius: clamp(12px, 1.6vw, 20px);
  overflow: hidden;
  background: #000;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--text) 12%, transparent),
    0 30px 80px -30px rgba(0, 0, 0, .8),
    0 0 120px -20px color-mix(in srgb, var(--accent) 45%, transparent);
}
.facade {
  all: unset;
  position: absolute; inset: 0;
  cursor: pointer;
  display: block;
}
.facade:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.facade img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transform: scale(1.02);
  transition: transform 1.2s var(--ease-out), filter .6s ease;
  filter: saturate(1.05);
}
.facade::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,.45));
  pointer-events: none;
}
.play {
  position: absolute; left: 50%; top: 50%; z-index: 1;
  width: clamp(60px, 7vw, 84px); aspect-ratio: 1;
  translate: -50% -50%;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff;
  background: color-mix(in srgb, var(--accent) 28%, rgba(255,255,255,.08));
  border: 1px solid rgba(255, 255, 255, .35);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  transition: transform .5s var(--ease-out), background .4s ease;
}
.play svg { margin-left: 3px; }
.play::before {
  content: ""; position: absolute; inset: -1px; border-radius: 50%;
  border: 1px solid var(--accent);
  animation: pulse 2.4s var(--ease-out) infinite;
}
@keyframes pulse { from { transform: scale(1); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }
.facade:hover img { transform: scale(1.06); }
.facade:hover .play { transform: scale(1.1); background: color-mix(in srgb, var(--accent) 55%, transparent); }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Project file + socials */
.extras {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 10px 14px;
  margin-top: -4px;
}
.pf-btn {
  display: inline-flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 18px;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px; font-weight: 650; letter-spacing: .03em;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background .35s ease, color .35s ease, transform .4s var(--ease-out), border-color .35s ease;
}
.pf-btn svg { color: var(--accent); transition: color .35s ease; }
.pf-btn:hover { background: var(--accent); color: var(--bg); transform: translateY(-2px); }
.pf-btn:hover svg { color: var(--bg); }
.socials { display: flex; gap: 8px; }
.social {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text);
  background: color-mix(in srgb, var(--text) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background .35s ease, color .35s ease, transform .4s var(--ease-out), border-color .35s ease;
}
.social:hover { background: var(--accent); color: var(--bg); border-color: var(--accent); transform: translateY(-2px); }
.pf-btn:focus-visible, .social:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.below { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.countdown { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.countdown-label {
  font-size: 10.5px; letter-spacing: .28em; text-transform: uppercase; opacity: .6;
}
.countdown-time {
  display: flex; align-items: flex-start;
  font-size: clamp(1.5rem, 2.8vw, 2.1rem);
  font-weight: 700;
  font-variation-settings: "wdth" 108;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  line-height: 1;
}
.unit { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 2.1ch; }
.unit i {
  font-style: normal; font-size: 9px; font-weight: 600;
  letter-spacing: .24em; text-transform: uppercase; opacity: .45;
}
.sep { opacity: .3; margin: 0 .22em; }
.yt-link {
  font-size: 12px; letter-spacing: .06em;
  color: var(--text); opacity: .5; text-decoration: none;
  transition: opacity .3s ease, color .3s ease;
}
.yt-link:hover { opacity: 1; color: var(--accent); }

.foot { display: flex; justify-content: center; padding-top: 8px; }
.support-link {
  all: unset;
  cursor: pointer;
  padding: 8px 12px;
  font-size: 10.5px;
  letter-spacing: .24em;
  text-transform: uppercase;
  opacity: .34;
  transition: opacity .3s ease, color .3s ease;
}
.support-link:hover, .support-link:focus-visible { opacity: .9; color: var(--accent); }
.support-link:focus-visible { outline: 1px solid var(--accent); border-radius: 6px; }

/* Day-change crossfade */
.stage > * { transition: opacity .7s ease, transform .9s var(--ease-out), filter .7s ease; }
.stage.is-swapping > * { opacity: 0; transform: translateY(12px); filter: blur(10px); }

/* ---------- Support modal ---------- */
.modal {
  border: 0; padding: 0; background: transparent; color: var(--text);
  width: min(440px, calc(100vw - 32px));
  max-width: none;
  overflow: visible;
}
.modal::backdrop {
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal[open] .modal-inner { animation: pop .5s var(--ease-out); }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.modal-inner {
  position: relative;
  padding: 34px 28px 28px;
  border-radius: 22px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  box-shadow: 0 40px 100px -30px rgba(0,0,0,.8), 0 0 80px -30px color-mix(in srgb, var(--accent) 50%, transparent);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
}
.modal-eyebrow {
  margin: 0 0 8px;
  font-size: 10.5px; letter-spacing: .26em; text-transform: uppercase;
  color: var(--accent);
}
.modal h3 {
  margin: 0 0 14px;
  font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em;
  font-variation-settings: "wdth" 110;
}
.modal p { margin: 0 0 12px; font-size: 15px; line-height: 1.6; opacity: .82; }
.modal strong { color: var(--accent); font-weight: 700; opacity: 1; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.btn {
  all: unset; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px; font-weight: 700; letter-spacing: .02em;
  transition: transform .3s var(--ease-out), background .3s ease, opacity .3s ease;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn--primary { background: var(--accent); color: var(--bg); }
.btn--primary:hover { transform: translateY(-2px); background: var(--accent2); }
.btn--ghost { border: 1px solid color-mix(in srgb, var(--text) 20%, transparent); opacity: .8; }
.btn--ghost:hover { opacity: 1; }
.modal-x {
  all: unset; cursor: pointer;
  position: absolute; top: 12px; right: 14px;
  width: 32px; height: 32px; display: grid; place-items: center;
  font-size: 22px; line-height: 1; opacity: .5; border-radius: 50%;
}
.modal-x:hover { opacity: 1; }
.modal-x:focus-visible { outline: 1px solid var(--accent); }

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  .topbar { font-size: 10px; letter-spacing: .16em; }
  .wordmark { letter-spacing: .14em; }
  .issue-date { display: none; }
  .creator::before, .creator::after { width: 16px; }
  .creator { gap: 10px; letter-spacing: .2em; }
  .title { font-variation-settings: "wdth" 104; }
  .player { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .play::before { animation: none; }
  .intro-word .ch { animation-duration: .4s; animation-delay: 0s; }
}

/* ---------- Share ---------- */
.below-links { display: flex; align-items: center; gap: 18px; }
.share-btn {
  all: unset; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px; font-weight: 650; letter-spacing: .06em;
  color: var(--text);
  background: color-mix(in srgb, var(--text) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
  transition: background .3s ease, color .3s ease, border-color .3s ease, transform .4s var(--ease-out);
}
.share-btn:hover { background: var(--accent); color: var(--bg); border-color: var(--accent); transform: translateY(-1px); }
.share-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.share-preview {
  white-space: pre-line;
  font-size: 13.5px !important;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  word-break: break-word;
}
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.share-item {
  all: unset; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 6px 12px;
  border-radius: 14px;
  color: var(--text);
  text-align: center;
  font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  transition: background .3s ease, border-color .3s ease, transform .35s var(--ease-out);
}
.share-item i {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  transition: background .3s ease, color .3s ease;
}
.share-item:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); transform: translateY(-2px); }
.share-item:hover i { background: var(--accent); color: var(--bg); }
.share-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal-fine { font-size: 13px !important; opacity: .62 !important; }

/* ---------- Footer row ---------- */
.foot { gap: 6px; flex-wrap: wrap; }
.foot .support-link + .support-link::before { content: "·"; margin-right: 12px; opacity: .6; }

/* ---------- Install / notification card ---------- */
.nudge {
  position: fixed; z-index: 40;
  left: 50%; bottom: max(16px, env(safe-area-inset-bottom));
  width: min(520px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 14px;
  padding: 14px 14px 14px 14px;
  border-radius: 20px;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 13%, transparent);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.7), 0 0 60px -25px color-mix(in srgb, var(--accent) 60%, transparent);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  opacity: 0;
  transform: translate(-50%, 24px);
  transition: opacity .45s ease, transform .6s var(--ease-out);
}
.nudge.is-in { opacity: 1; transform: translate(-50%, 0); }
.nudge-icon { width: 46px; height: 46px; border-radius: 12px; flex: none; }
.nudge-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; line-height: 1.45; }
.nudge-text strong { font-size: 14.5px; font-weight: 750; }
.nudge-text span { opacity: .75; }
.nudge-text b { color: var(--accent); font-weight: 700; }
.nudge-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.btn--sm { padding: 9px 16px; font-size: 13px; }
.nudge-x {
  all: unset; cursor: pointer;
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 50%; font-size: 20px; opacity: .55;
}
.nudge-x:hover { opacity: 1; }
.nudge-x:focus-visible { outline: 1px solid var(--accent); }

.toast {
  position: fixed; z-index: 60;
  left: 50%; top: max(16px, env(safe-area-inset-top));
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  box-shadow: 0 16px 40px -14px rgba(0,0,0,.6);
  opacity: 0; pointer-events: none;
  transform: translate(-50%, -12px);
  transition: opacity .35s ease, transform .5s var(--ease-out);
}
.toast.is-in { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 600px) {
  .nudge { flex-wrap: wrap; }
  .nudge-text { flex-basis: calc(100% - 60px); }
  .nudge-actions { margin-left: auto; }
}
@media (max-width: 600px) {
  .foot { flex-direction: column; align-items: center; gap: 0; }
  .foot .support-link + .support-link::before { content: none; }
}
