/* ==========================================================================
   8billions.studio — design-5 "One in Eight Billion"
   ========================================================================== */

:root {
  --bg: #05050a;
  --ink: #f4f1ec;
  --ink-2: rgba(244, 241, 236, 0.66);
  --ink-3: rgba(244, 241, 236, 0.4);
  --line: rgba(244, 241, 236, 0.12);
  --ember: #ff5b2e;
  --ember-2: #ffb08a;
  --sans: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --pad: clamp(1.25rem, 4vw, 3.5rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { background: var(--bg); color: var(--ink); scroll-behavior: auto; -webkit-text-size-adjust: 100%; }
html.loading, html.loading body { overflow: hidden; }

body {
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(120vmax 80vmax at 70% 0%, #0d0b1f 0%, transparent 60%),
    radial-gradient(90vmax 70vmax at 0% 100%, #140a0a 0%, transparent 55%),
    var(--bg);
}

::selection { background: var(--ember); color: #0a0a0a; }

a { color: inherit; }
em { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
.mono { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }

:focus-visible { outline: 2px solid var(--ember); outline-offset: 4px; border-radius: 6px; }

.skip {
  position: fixed; top: 1rem; left: 1rem; z-index: 200;
  padding: 0.6rem 1rem; background: var(--ink); color: var(--bg);
  border-radius: 99px; transform: translateY(-200%); transition: transform 0.3s var(--ease);
}
.skip:focus { transform: none; }

/* ---------- WebGL + overlays ---------- */
#webgl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }

.grain {
  position: fixed; inset: -50%; z-index: 1; pointer-events: none; opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' 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); }
}

/* ---------- Loader ---------- */
.loader { display: none; }
html.js .loader {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(60vmax 60vmax at 50% 50%, rgba(20, 14, 30, 0.9), var(--bg) 70%);
  transition: opacity 1.2s var(--ease), visibility 1.2s;
}
.loader.out { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-inner { width: min(92vw, 900px); text-align: center; padding: var(--pad); }
.loader-kicker { color: var(--ember-2); }
.loader-quote {
  margin: 2rem 0 1.8rem; font-family: var(--serif); font-size: clamp(2.2rem, 6.4vw, 5.2rem);
  line-height: 1.05; letter-spacing: -0.02em; quotes: none;
}
.loader-quote em { color: var(--ember); }
.loader-note { color: var(--ink-2); font-size: clamp(0.95rem, 1.4vw, 1.1rem); max-width: 44ch; margin: 0 auto; }

/* lines fade up one after another */
.w-line { opacity: 0; transform: translateY(18px); filter: blur(6px); animation: wline 1.4s var(--ease) forwards; animation-delay: calc(0.25s + var(--d) * 0.45s); }
@keyframes wline { to { opacity: 1; transform: none; filter: none; } }

.loader-enter {
  margin-top: 2.6rem; display: inline-flex; flex-direction: column; align-items: center; gap: 0.7rem;
  background: none; border: 0; color: var(--ink); cursor: pointer;
  font: 500 0.72rem/1 var(--mono); letter-spacing: 0.2em; text-transform: uppercase; padding: 0.6rem 1rem;
}
.loader-enter:hover { color: var(--ember-2); }
/* progress line = time until auto-enter */
.loader-enter-bar { width: 120px; height: 1px; background: var(--line); overflow: hidden; }
.loader-enter-bar i { display: block; height: 100%; width: 100%; background: var(--ember); transform: scaleX(0); transform-origin: left; }
.loader.counting .loader-enter-bar i { transform: scaleX(1); transition: transform var(--auto, 6s) linear; }

/* ---------- Buttons ---------- */
.btn {
  --h: 3.1rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: var(--h); padding: 0 1.5rem; border-radius: 99px;
  font: 500 0.95rem/1 var(--sans); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background 0.4s var(--ease), color 0.4s var(--ease), border-color 0.4s;
  will-change: transform;
}
.btn-sm { --h: 2.5rem; padding: 0 1.1rem; font-size: 0.85rem; }
.btn-solid { background: var(--ink); color: #0a0a0f; }
.btn-solid:hover { background: var(--ember); color: #0a0a0f; }
.btn-ghost { background: rgba(255, 255, 255, 0.03); color: var(--ink); border-color: var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.btn-ghost:hover { border-color: var(--ink-2); }

/* ---------- Cursor ---------- */
.cursor { display: none; }
@media (hover: hover) and (pointer: fine) {
  html.js.cursor-on, html.js.cursor-on * { cursor: none !important; }
  html.js.cursor-on .cursor { display: block; }
}
.cursor-ring, .cursor-dot {
  position: fixed; top: 0; left: 0; z-index: 150; pointer-events: none; border-radius: 50%;
}
.cursor-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--ember); }
.cursor-ring {
  width: 40px; height: 40px; margin: -20px 0 0 -20px; border: 1px solid rgba(255, 255, 255, 0.5);
  display: grid; place-items: center; mix-blend-mode: difference;
  transition: width 0.45s var(--ease), height 0.45s var(--ease), margin 0.45s var(--ease), background 0.45s, border-color 0.45s;
}
.cursor-label { font: 500 0.62rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: #fff; opacity: 0; transition: opacity 0.3s; white-space: nowrap; }
.cursor.is-link .cursor-ring { width: 78px; height: 78px; margin: -39px 0 0 -39px; background: #fff; border-color: #fff; }
.cursor.is-link .cursor-label { opacity: 1; color: #000; }
.cursor.is-hold .cursor-ring { width: 120px; height: 120px; margin: -60px 0 0 -60px; border-color: var(--ember); border-style: dashed; animation: spin 6s linear infinite; }
.cursor.is-hold .cursor-label { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- "The one" label ---------- */
.the-one {
  position: fixed; top: 0; left: 0; z-index: 3; pointer-events: none;
  display: flex; align-items: center; gap: 0.5rem; opacity: 0; will-change: transform, opacity;
}
.the-one-line { width: 46px; height: 1px; background: linear-gradient(90deg, var(--ember), transparent); transform-origin: left; }
.the-one-text { color: var(--ember-2); background: rgba(5, 5, 10, 0.6); padding: 0.3rem 0.55rem; border: 1px solid rgba(255, 91, 46, 0.35); border-radius: 99px; font-size: 0.62rem; white-space: nowrap; }

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.25rem var(--pad);
}
.logo { display: inline-flex; align-items: baseline; text-decoration: none; font-weight: 600; letter-spacing: -0.02em; font-size: 1.05rem; }
.logo-8 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1.7rem; color: var(--ember); margin-right: 0.08em; line-height: 1; }
.logo .dot { color: var(--ember); }
.nav-links { display: flex; gap: 0.3rem; padding: 0.3rem; border: 1px solid var(--line); border-radius: 99px; background: rgba(5, 5, 10, 0.4); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.nav-links a { text-decoration: none; font-size: 0.85rem; padding: 0.45rem 0.95rem; border-radius: 99px; color: var(--ink-2); transition: color 0.3s, background 0.3s; }
.nav-links a:hover, .nav-links a.active { color: var(--ink); background: rgba(255, 255, 255, 0.07); }
.nav-right { display: flex; align-items: center; gap: 0.6rem; }

.sound {
  display: inline-flex; align-items: center; gap: 0.55rem; height: 2.5rem; padding: 0 0.9rem;
  background: transparent; color: var(--ink-2); border: 1px solid var(--line); border-radius: 99px; cursor: pointer;
}
.sound:hover { color: var(--ink); }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.bars i { width: 2px; height: 3px; background: currentColor; border-radius: 1px; transition: height 0.3s; }
.sound[aria-pressed="true"] { color: var(--ink); border-color: rgba(255, 91, 46, 0.5); }
.sound[aria-pressed="true"] .bars i { animation: eq 1s ease-in-out infinite; }
.sound[aria-pressed="true"] .bars i:nth-child(2) { animation-delay: -0.3s; }
.sound[aria-pressed="true"] .bars i:nth-child(3) { animation-delay: -0.6s; }
.sound[aria-pressed="true"] .bars i:nth-child(4) { animation-delay: -0.15s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }

/* ---------- HUD + rail ---------- */
.hud { position: fixed; inset: auto 0 0 0; z-index: 5; pointer-events: none; padding: 1.25rem var(--pad); display: flex; justify-content: space-between; align-items: flex-end; color: var(--ink-3); }
.hud-bl, .hud-br { display: flex; flex-direction: column; gap: 0.3rem; }
.hud-br { text-align: right; }
.hud-ch b { color: var(--ink); font-weight: 500; }
.hud-name { color: var(--ember-2); }

.rail { position: fixed; right: calc(var(--pad) * 0.5); top: 50%; transform: translateY(-50%); z-index: 6; display: flex; flex-direction: column; gap: 0.35rem; }
.rail a { display: grid; place-items: center; width: 24px; height: 24px; }
.rail span { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-3); transition: all 0.5s var(--ease); }
.rail a.active span { height: 22px; border-radius: 4px; background: var(--ember); }
.rail a:hover span { background: var(--ink); }

/* ---------- Layout / chapters ---------- */
main { position: relative; z-index: 2; }
.chapter { position: relative; min-height: 130vh; min-height: 130svh; display: flex; align-items: center; padding: 0 var(--pad); }

h1, h2 { font-weight: 500; letter-spacing: -0.045em; line-height: 0.95; }
h1 { font-size: clamp(3rem, 9vw, 8.8rem); }
h2 { font-size: clamp(2.6rem, 6.6vw, 6.2rem); }
h1 em, h2 em { font-size: 1.08em; letter-spacing: -0.02em; color: var(--ember-2); }
/* gradient lives on the innermost word spans so it survives the split/transform reveal */
h1 em .word > span, h2 em .word > span {
  background: linear-gradient(100deg, var(--ember-2), var(--ember) 70%);
  -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: 0.1em;
}

.hero { min-height: 100vh; min-height: 100svh; align-items: flex-end; padding-bottom: clamp(5rem, 14vh, 9rem); }
.hero-copy { max-width: min(880px, 70vw); }
.kicker { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--ink-2); margin-bottom: 1.6rem; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 0 0 rgba(255, 91, 46, 0.6); animation: pulse 2.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px rgba(255, 91, 46, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 91, 46, 0); } }
.lead { max-width: 46ch; margin-top: 1.8rem; font-size: clamp(1rem, 1.3vw, 1.2rem); color: var(--ink-2); }
.hero-cta { display: flex; gap: 0.7rem; margin-top: 2.2rem; flex-wrap: wrap; }
.hint { position: absolute; right: var(--pad); bottom: clamp(5rem, 14vh, 9rem); color: var(--ink-3); max-width: 22ch; text-align: right; line-height: 1.7; }
.hint-touch { display: none; }
@media (hover: none) { .hint-desktop { display: none; } .hint-touch { display: inline; } }
.scroll-cue { position: absolute; left: 50%; bottom: 1.6rem; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 0.6rem; color: var(--ink-3); }
.scroll-cue span { width: 1px; height: 44px; background: linear-gradient(var(--ink-3), transparent); overflow: hidden; position: relative; }
.scroll-cue span::after { content: ''; position: absolute; inset: 0; background: var(--ember); animation: drip 2s var(--ease) infinite; }
@keyframes drip { 0% { transform: translateY(-100%); } 100% { transform: translateY(100%); } }

.panel { position: relative; max-width: 540px; }
.panel::before {
  content: ''; position: absolute; inset: -18% -30% -18% -40%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(5, 5, 10, 0.72), transparent);
}
.ch-right { justify-content: flex-end; }
.ch-low { align-items: flex-end; padding-bottom: 22vh; }
.idx { color: var(--ember-2); margin-bottom: 1.4rem; }
.panel h2 + p, .contact-copy h2 + p { margin-top: 1.6rem; color: var(--ink-2); font-size: clamp(1rem, 1.2vw, 1.15rem); max-width: 44ch; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 1.8rem; }
.tags li { font-size: 0.8rem; padding: 0.4rem 0.8rem; border: 1px solid var(--line); border-radius: 99px; color: var(--ink-2); background: rgba(5, 5, 10, 0.35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

/* ---------- Stats ---------- */
.stats {
  position: relative; display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 0 var(--pad); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: rgba(5, 5, 10, 0.45); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.stat { padding: 2rem 1.6rem; display: flex; flex-direction: column; gap: 0.9rem; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-k { color: var(--ink-3); }
.stat-v { font-size: clamp(1.6rem, 3vw, 2.6rem); font-weight: 500; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-serif em { color: var(--ember-2); }

/* ---------- Marquee ---------- */
.marquee { position: relative; overflow: hidden; padding: 4rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(5, 5, 10, 0.5); }
.marquee-track { display: flex; width: max-content; animation: marquee 38s linear infinite; }
.marquee span { font-size: clamp(3rem, 8vw, 7rem); font-weight: 500; letter-spacing: -0.04em; white-space: nowrap; color: transparent; -webkit-text-stroke: 1px rgba(244, 241, 236, 0.35); }
.marquee i { font-style: normal; color: var(--ember); -webkit-text-stroke: 0; margin: 0 0.4em; font-size: 0.5em; vertical-align: middle; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Process ---------- */
.process { position: relative; padding: 18vh var(--pad); background: linear-gradient(transparent, rgba(5, 5, 10, 0.75) 20%, rgba(5, 5, 10, 0.75) 80%, transparent); }
.process h2 { max-width: 14ch; }
.steps { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-top: 5rem; border-top: 1px solid var(--line); }
.step { padding: 1.8rem 1.6rem 0 0; position: relative; }
.step::before { content: ''; position: absolute; top: -1px; left: 0; height: 1px; width: 0; background: var(--ember); transition: width 1.2s var(--ease) 0.2s; }
.step.in::before { width: 100%; }
.step .mono { color: var(--ember-2); }
.step h3 { font-size: 1.6rem; font-weight: 500; letter-spacing: -0.03em; margin: 1.2rem 0 0.6rem; }
.step p { color: var(--ink-2); font-size: 0.95rem; max-width: 26ch; }

/* ---------- Contact ---------- */
.contact { justify-content: center; text-align: center; min-height: 140vh; min-height: 140svh; }
.contact-copy { max-width: 1100px; display: flex; flex-direction: column; align-items: center; }
.contact h2 { font-size: clamp(2.8rem, 8vw, 7.6rem); }
.contact-copy h2 + p { margin-inline: auto; }
.mail {
  position: relative; display: inline-flex; align-items: center; gap: 0.3em; margin-top: 3rem;
  font-family: var(--serif); font-style: italic; font-size: clamp(1.8rem, 5vw, 4rem); text-decoration: none; letter-spacing: -0.02em;
}
.mail::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0.05em; height: 1px; background: var(--ember); transform: scaleX(0.25); transform-origin: left; transition: transform 0.8s var(--ease); }
.mail:hover::after, .mail:focus-visible::after { transform: scaleX(1); }
.mail span { font-family: var(--sans); font-style: normal; font-size: 0.6em; color: var(--ember); transition: transform 0.5s var(--ease); }
.mail:hover span { transform: translate(0.12em, -0.12em); }

.footer { position: relative; z-index: 2; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 2rem var(--pad) 5.5rem; color: var(--ink-3); border-top: 1px solid var(--line); }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--ink); }

/* ---------- Reveal animations (only when JS is running) ---------- */
html.js [data-reveal] { opacity: 0; transform: translateY(28px); transition: opacity 1.2s var(--ease), transform 1.2s var(--ease); }
html.js [data-reveal].in { opacity: 1; transform: none; }
.word { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.word > span { display: inline-block; }
html.js [data-split] .word > span { transform: translateY(110%) rotate(4deg); transition: transform 1.3s var(--ease); transition-delay: calc(var(--i) * 70ms); }
html.js [data-split].in .word > span { transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .nav-links { display: none; }
  .steps { grid-template-columns: repeat(2, 1fr); row-gap: 2.5rem; }
  .hud-br span:not(:first-child) { display: none; }
}
@media (max-width: 720px) {
  .sound-txt { display: none; }
  .hero-copy { max-width: 100%; }
  .hint { position: static; text-align: left; margin-top: 2rem; }
  .chapter, .ch-right, .ch-low { align-items: flex-end; justify-content: flex-start; padding-bottom: 14vh; }
  .chapter.hero { flex-direction: column; justify-content: flex-end; align-items: flex-start; padding-bottom: 11vh; }
  .hero h1 { font-size: clamp(2.6rem, 12vw, 3.6rem); }
  .hero .lead { margin-top: 1.2rem; }
  .hero .scroll-cue { display: none; }
  .panel { padding: 1.6rem; border: 1px solid var(--line); border-radius: 22px; background: rgba(5, 5, 10, 0.6); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  .panel::before { display: none; }
  .contact { align-items: center; justify-content: center; padding-bottom: 0; }
  .stats { grid-template-columns: 1fr; }
  .stat + .stat { border-left: 0; border-top: 1px solid var(--line); }
  .steps { grid-template-columns: 1fr; }
  .rail, .hud { display: none; }
  .the-one-line { width: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .marquee-track { animation: none; }
  .w-line { animation-delay: 0s !important; }
}
