/* ═══════════════════════ 10,000 DAYS ═══════════════════════ */
:root {
  --ink: #0B0D17;
  --ink-2: #141826;
  --paper: #e8e4da;
  --lilac: #B8A9E8;
  --gold: #EEA954;
  --mono: 'IBM Plex Mono', monospace;
  --grot: 'Space Grotesk', sans-serif;
  --serif: 'Cormorant Garamond', serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--grot);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* film grain over everything — oil-paint tooth */
body::after {
  content: '';
  position: fixed; inset: -50%;
  pointer-events: none; z-index: 90;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.05;
  animation: grain 1.2s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0,0); } 25% { transform: translate(-2%,1%); }
  50% { transform: translate(1%,-2%); } 75% { transform: translate(-1%,2%); } 100% { transform: translate(0,0); }
}

/* ══════════ HUD ══════════ */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 80;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px;
  mix-blend-mode: screen;
  pointer-events: none;
}
.hud-left { font-family: var(--mono); font-size: 13px; letter-spacing: 0.18em; color: #9a97a8; }
.hud-label { opacity: 0.6; margin-right: 8px; }
#day-counter { color: var(--paper); font-size: 15px; }
.hud-total { opacity: 0.45; }
.hud-right { width: min(30vw, 260px); }
#spectrum-progress {
  height: 3px; background: rgba(255,255,255,0.12); border-radius: 2px; overflow: hidden;
}
#spectrum-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg,#7B5EA7,#1B2A5E,#2451C4,#3B2F8F,#B8A9E8,#C23BA8,#E35D8F,#F2756B,#C22F4E,#F08A3C,#F5A83D,#F2C14E,#F7C9A0,#2FA37C);
}

/* ══════════ fixed fx layers ══════════ */
#lightning-layer {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 70;
}
#wireframe-drifters { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.drifter {
  position: absolute; bottom: -15vh;
  animation: drift linear infinite;
  opacity: 0;
}
.drifter svg { display: block; filter: drop-shadow(0 0 6px currentColor); }
@keyframes drift {
  0%   { transform: translateY(0) rotate(0deg); opacity: 0; }
  8%   { opacity: var(--o, 0.35); }
  92%  { opacity: var(--o, 0.35); }
  100% { transform: translateY(-130vh) rotate(340deg); opacity: 0; }
}

/* ══════════ panels ══════════ */
.panel { position: relative; min-height: 100vh; display: flex; align-items: center; overflow: hidden; }
.panel.tall { min-height: 160vh; }
.panel-inner {
  position: relative; z-index: 5;
  width: min(1100px, 92vw);
  margin: 0 auto;
  padding: 14vh 0;
}
.overlay-top { align-self: flex-start; padding-top: 12vh; }

.kicker {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.32em;
  text-transform: uppercase; color: var(--lilac); margin-bottom: 22px;
}
h1, h2 { font-family: var(--serif); font-weight: 500; line-height: 1.04; }
h2 { font-size: clamp(34px, 5.2vw, 64px); margin-bottom: 26px; }
.prose {
  max-width: 560px; font-weight: 300; font-size: clamp(15px, 1.4vw, 18px);
  line-height: 1.75; color: #b9b6c4;
}
.prose.small { font-size: 14px; max-width: 720px; }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(34px); transition: opacity 1.1s ease, transform 1.1s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }

/* ══════════ I · hero ══════════ */
.hero { justify-content: center; text-align: center; }
#stars-canvas, #valley-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-copy { position: relative; z-index: 5; padding-bottom: 12vh; }
.hero .title {
  font-size: clamp(64px, 13vw, 190px);
  letter-spacing: 0.02em; color: #d7d4de;
  text-shadow: 0 0 80px rgba(184,169,232,0.25);
}
.hero .title span { font-style: italic; font-weight: 400; color: #8f8c9c; }
.hero .subtitle { font-family: var(--serif); font-style: italic; font-size: clamp(18px, 2.4vw, 30px); color: #8f8c9c; margin-top: 8px; }
.scroll-hint { margin: 60px auto 0; width: 1px; height: 72px; background: rgba(255,255,255,0.15); position: relative; overflow: hidden; }
.scroll-hint span { position: absolute; left: 0; top: -30%; width: 100%; height: 30%; background: var(--lilac); animation: hint 2.2s ease-in-out infinite; }
@keyframes hint { to { top: 110%; } }

/* ══════════ II · aurora ══════════ */
#aurora { background: radial-gradient(120% 90% at 50% 0%, #14162a 0%, var(--ink) 70%); }
#aurora-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#aurora .panel-inner { margin-top: 22vh; }
#aurora-sequence { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 44px; max-width: 760px; }
.seq-chip {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 8px 14px 8px 10px; border: 1px solid rgba(255,255,255,0.14); border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px; color: #cfccd8;
  opacity: 0; transform: translateY(12px) scale(0.92);
  transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1);
  background: rgba(11,13,23,0.55); backdrop-filter: blur(4px);
}
.seq-chip.on { opacity: 1; transform: none; }
.seq-chip i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }

/* ══════════ III · rgb ══════════ */
#rgb { background: linear-gradient(180deg, var(--ink) 0%, #101223 100%); }
.rgb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 28px; margin-top: 54px; }
.rgb-card {
  border: 1px solid rgba(255,255,255,0.1); border-radius: 18px;
  padding: 30px; background: rgba(20,24,38,0.5);
}
.rgb-card h3, .palette-block h3 {
  font-family: var(--grot); font-weight: 500; font-size: 14px;
  letter-spacing: 0.22em; text-transform: uppercase; color: #9a97a8; margin-bottom: 24px;
}
.composer-body { display: flex; gap: 24px; align-items: stretch; }
#mix-swatch {
  width: 110px; border-radius: 14px; background: var(--lilac);
  box-shadow: 0 0 40px rgba(184,169,232,0.35);
  transition: background 0.15s linear, box-shadow 0.3s;
}
.sliders { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.slider-row { display: grid; grid-template-columns: 18px 1fr 36px; align-items: center; gap: 12px; font-family: var(--mono); font-size: 13px; }
.slider-row.r label { color: #ff5d5d; } .slider-row.g label { color: #51e08a; } .slider-row.b label { color: #5d8bff; }
.slider-row span { text-align: right; color: #cfccd8; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.14); outline: none; }
.slider-row.r input { background: linear-gradient(90deg,#3a0d0d,#ff5d5d); }
.slider-row.g input { background: linear-gradient(90deg,#0d3a1e,#51e08a); }
.slider-row.b input { background: linear-gradient(90deg,#0d1c3a,#5d8bff); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--ink); cursor: pointer;
  box-shadow: 0 0 10px rgba(255,255,255,0.4);
}
.mix-readout { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 13px; color: #cfccd8; margin: 22px 0 14px; }
.channel-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.channel-bars.tall { margin-top: 20px; }
.cbar { position: relative; height: 10px; background: rgba(255,255,255,0.08); border-radius: 5px; overflow: visible; }
.channel-bars.tall .cbar { height: 14px; }
.cbar i { position: absolute; inset: 0 auto 0 0; width: 50%; border-radius: 5px; transition: width .5s cubic-bezier(.2,.7,.2,1); }
.cbar i.r { background: #ff5d5d; box-shadow: 0 0 12px rgba(255,93,93,.5); }
.cbar i.g { background: #51e08a; box-shadow: 0 0 12px rgba(81,224,138,.5); }
.cbar i.b { background: #5d8bff; box-shadow: 0 0 12px rgba(93,139,255,.5); }
.cbar em { position: absolute; right: 0; top: 18px; font-style: normal; font-family: var(--mono); font-size: 11px; color: #9a97a8; }

#decomp-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.dchip {
  width: 30px; height: 30px; border-radius: 9px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.16); background: var(--c);
  transition: transform .25s, box-shadow .25s;
}
.dchip:hover { transform: translateY(-3px); }
.dchip.sel { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--c), 0 0 18px var(--c); }
.decomp-readout { display: flex; align-items: center; gap: 18px; }
#decomp-swatch { width: 58px; height: 58px; border-radius: 14px; background: var(--lilac); transition: background .3s; box-shadow: 0 0 24px rgba(184,169,232,.3); }
#decomp-name { font-family: var(--serif); font-style: italic; font-size: 24px; text-transform: capitalize; }
.mono { font-family: var(--mono); font-size: 12px; color: #9a97a8; letter-spacing: 0.08em; }

.palette-block { margin-top: 70px; }
#palette-strip { display: grid; grid-template-columns: repeat(32, 1fr); height: 74px; border-radius: 12px; overflow: hidden; margin: 26px 0 14px; border: 1px solid rgba(255,255,255,0.1); }
#palette-strip div { cursor: pointer; transition: transform .2s; }
#palette-strip div:hover { transform: scaleY(1.18); }
#palette-readout { min-height: 18px; }

/* ══════════ IV · rain ══════════ */
#rain { background: #0d0f1a; }
#rain-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ══════════ V · tree ══════════ */
#tree {
  flex-direction: column; justify-content: flex-start;
  background: radial-gradient(90% 70% at 50% 100%, #1a1426 0%, var(--ink) 75%);
}
.tree-stage { position: relative; z-index: 4; width: min(640px, 88vw); margin: -4vh auto 0; }
#tree-svg { width: 100%; height: auto; display: block; overflow: visible; }
.blossom { transform-box: fill-box; transform-origin: center; transform: scale(0); transition: transform 1.4s cubic-bezier(.34,1.56,.64,1); }
.blossom.open { transform: scale(1); }
.petal-fall { animation: petalfall linear forwards; }
@keyframes petalfall {
  0%   { transform: translate(0,0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(300deg); opacity: 0; }
}

/* ══════════ VI · river ══════════ */
#river { background: #0a0c16; }
#river-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ══════════ VII · remedy ══════════ */
#remedy { background: linear-gradient(180deg, var(--ink) 0%, #131126 100%); }
#remedy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-top: 50px; }
.remedy-card {
  border: 1px solid rgba(255,255,255,0.09); border-radius: 14px; overflow: hidden;
  background: rgba(20,24,38,0.45);
}
.remedy-visual { height: 74px; position: relative; }
.remedy-visual::after {
  content: '→'; position: absolute; inset: 0; display: grid; place-items: center;
  color: rgba(255,255,255,0.85); font-size: 18px; text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}
.remedy-label { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: #b9b6c4; text-transform: uppercase; }
.remedy-label span, .remedy-label b { min-width: 0; }
.remedy-label b { text-align: right; }
.remedy-label b { font-weight: 400; color: var(--paper); }

/* ══════════ VIII · finale ══════════ */
.finale { text-align: center; }
.finale .prose { margin: 0 auto; }
#final-spectrum {
  height: 86px; border-radius: 14px; margin: 60px auto 30px; max-width: 860px;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 0 60px rgba(184,169,232,0.18);
}
.coda { font-family: var(--mono); font-size: 12px; letter-spacing: 0.24em; text-transform: uppercase; color: #6f6c7e; padding-bottom: 6vh; }

@media (max-width: 720px) {
  .hud-right { display: none; }
  .composer-body { flex-direction: column; }
  #mix-swatch { width: 100%; height: 74px; }
  #palette-strip { grid-template-columns: repeat(16, 1fr); height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .drifter, body::after, .scroll-hint span { animation: none !important; }
}
