/* ============================================================
   ERASE LASER LABS — immersive scroll experience
   ============================================================ */

/* ---------- Fonts ---------- */
@font-face {
  font-family: 'Sora';
  src: url('../assets/fonts/sora-var.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../assets/fonts/inter-var.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('../assets/fonts/plexmono-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('../assets/fonts/plexmono-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #07090c;
  --bg-2: #0c1116;
  --ink: #e9eef2;
  --muted: #93a3ae;
  --pearl: #e6dcd0;
  --teal: #38a9c2;
  --teal-bright: #4fd6ff;
  --teal-deep: #006b9d;
  --emerald: #2e7d5f;
  --gold: #c9a44a;
  --line: rgba(79, 214, 255, 0.28);
  --glass: rgba(10, 16, 20, 0.55);
  --glass-border: rgba(79, 214, 255, 0.16);
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: auto; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; height: 100vh; }

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--font-mono); font-weight: 400; letter-spacing: 0.14em; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

::selection { background: var(--teal-deep); color: #fff; }

/* Film grain over everything */
body::after {
  content: '';
  position: fixed; inset: -50%;
  pointer-events: none;
  z-index: 200;
  opacity: 0.05;
  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)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 3%); }
  50% { transform: translate(3%, -2%); }
  75% { transform: translate(-3%, -3%); }
  100% { transform: translate(2%, 2%); }
}

/* ============================================================
   PRELOADER
   ============================================================ */
#preloader {
  position: fixed; inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.9s ease, visibility 0.9s;
}
#preloader.done { opacity: 0; visibility: hidden; }
#preloader-fx { position: absolute; inset: 0; width: 100%; height: 100%; }
.pre-meta {
  position: absolute;
  left: 50%; bottom: 12vh;
  transform: translateX(-50%);
  width: min(420px, 78vw);
}
.pre-status {
  display: flex; justify-content: space-between;
  font-size: 0.7rem; color: var(--muted);
  margin-bottom: 10px;
}
#pre-pct { color: var(--teal-bright); }
.pre-bar {
  height: 1px; background: rgba(255,255,255,0.12);
  position: relative; overflow: visible;
}
#pre-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--teal-deep), var(--teal-bright));
  box-shadow: 0 0 12px var(--teal-bright), 0 0 32px rgba(79,214,255,0.5);
}

/* ============================================================
   NAV / HUD / PROGRESS
   ============================================================ */
#nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 150;
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px clamp(20px, 4vw, 48px);
  opacity: 0;
  transition: opacity 1s ease 0.2s;
  pointer-events: none;
}
body.ready #nav { opacity: 1; pointer-events: auto; }
.nav-brand { display: flex; align-items: baseline; gap: 10px; }
.brand-erase {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  background: linear-gradient(100deg, var(--teal-bright), var(--teal) 45%, var(--pearl));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-labs { font-size: 0.6rem; color: var(--muted); letter-spacing: 0.34em; }
.nav-cta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 12px 22px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.3s, box-shadow 0.3s, color 0.3s;
}
.nav-cta:hover {
  border-color: var(--teal-bright);
  color: var(--teal-bright);
  box-shadow: 0 0 24px rgba(79,214,255,0.25);
}

#page-laser {
  position: fixed; top: 0; left: 0;
  height: 2px; width: 100%;
  transform-origin: 0 0;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--teal-deep), var(--teal-bright));
  box-shadow: 0 0 10px var(--teal-bright);
  z-index: 160;
}

#hud {
  position: fixed;
  left: clamp(20px, 4vw, 48px); bottom: 22px;
  z-index: 150;
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.62rem;
  color: rgba(147, 163, 174, 0.85);
  opacity: 0;
  transition: opacity 1s ease 0.4s;
}
body.ready #hud { opacity: 1; }
#hud-chapter { color: var(--teal-bright); }

#dust {
  position: fixed; inset: 0;
  z-index: 90;
  pointer-events: none;
  width: 100%; height: 100%;
}

/* ============================================================
   CHAPTERS (shared)
   ============================================================ */
.chapter { position: relative; }
.pin {
  position: relative;
  height: 100vh; height: 100svh;
  overflow: hidden;
}
.seq-canvas, .fx-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
.fx-canvas { z-index: 3; }

.veil {
  position: absolute; inset: 0;
  background: var(--bg);
  z-index: 4;
  pointer-events: none;
}

.scrim { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.scrim-hero {
  background:
    radial-gradient(ellipse 90% 70% at 50% 105%, rgba(7,9,12,0.82), transparent 60%),
    linear-gradient(180deg, rgba(7,9,12,0.55), transparent 30%, transparent 62%, rgba(7,9,12,0.88));
}
.scrim-soft {
  background: linear-gradient(180deg, rgba(7,9,12,0.42), transparent 32%, transparent 68%, rgba(7,9,12,0.62));
}

.overlay {
  position: absolute; inset: 0;
  z-index: 5;
  pointer-events: none;
  perspective: 900px;
}
.overlay > * { pointer-events: auto; }

/* Section titles */
.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.2rem, 5.4vw, 4.6rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
}
.kicker { font-size: 0.68rem; color: var(--teal-bright); }
.wp-tag { font-size: 0.62rem; color: var(--teal-bright); display: inline-block; margin-bottom: 14px; }
.wp-tag.gold { color: var(--gold); }

/* ============================================================
   CH 1 · HERO
   ============================================================ */
.overlay-hero {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  gap: 26px;
}
#hero-logo {
  width: min(62vw, 660px);
  height: auto;
  will-change: transform, opacity;
  filter: drop-shadow(0 22px 44px rgba(0, 0, 0, 0.3));
}
/* soft light-bloom behind the mark so its charcoal glyphs read over footage */
.overlay-hero { --bloom: 1; }
.overlay-hero::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -54%);
  width: min(78vw, 860px);
  aspect-ratio: 1.35;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(247, 243, 235, 0.5), rgba(247, 243, 235, 0.22) 42%, transparent 68%);
  opacity: var(--bloom);
  pointer-events: none;
}
.hero-sub {
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  color: rgba(233, 238, 242, 0.92);
  text-shadow: 0 1px 12px rgba(7, 9, 12, 0.6);
  text-wrap: balance;
}
.scroll-cue {
  position: absolute; bottom: 5vh; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-size: 0.6rem; color: var(--muted);
}
.cue-line {
  width: 1px; height: 54px;
  background: linear-gradient(180deg, transparent, var(--teal-bright));
  animation: cue 2s ease-in-out infinite;
}
@keyframes cue {
  0%, 100% { transform: scaleY(0.4); transform-origin: top; opacity: 0.4; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* ============================================================
   CH 2 · SCIENCE
   ============================================================ */
.chapter-dark .pin { background: radial-gradient(ellipse 120% 90% at 50% 40%, var(--bg-2), var(--bg)); }
.overlay-science { display: block; }
#science-title {
  position: absolute;
  top: 9vh; left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: 100%;
}
.sci-step {
  position: absolute;
  max-width: 300px;
  opacity: 0;
}
.sci-step p { color: var(--muted); font-size: 0.95rem; margin-top: 8px; }
.step-no { color: var(--teal-bright); font-size: 0.66rem; }
#sci-step-1 { left: clamp(24px, 9vw, 14vw); top: 34vh; }
#sci-step-2 { right: clamp(24px, 9vw, 14vw); top: 46vh; text-align: right; }
#sci-step-3 { left: clamp(24px, 9vw, 14vw); top: 64vh; }
.sci-footnote {
  position: absolute; bottom: 7vh; left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem; color: var(--muted);
  white-space: nowrap;
  opacity: 0;
}
@media (max-width: 480px) {
  .sci-footnote { white-space: normal; text-align: center; width: 88vw; }
}

/* ============================================================
   CH 3 · TOUR waypoints
   ============================================================ */
.waypoint {
  position: absolute;
  max-width: 360px;
  padding: 26px 28px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  will-change: transform, opacity;
}
.waypoint h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.waypoint p { color: rgba(233,238,242,0.78); font-size: 0.92rem; }
.wp-1 { left: clamp(20px, 6vw, 8vw); top: 20vh; }
.wp-2 { right: clamp(20px, 6vw, 8vw); top: 24vh; }
.wp-3 { left: clamp(20px, 6vw, 8vw); bottom: 18vh; }

/* ============================================================
   CH 3 · TREATMENTS cards
   ============================================================ */
.overlay-treatments {
  display: flex; align-items: center; justify-content: center;
}
.treat-kicker {
  position: absolute; top: 10vh; left: 50%;
  transform: translateX(-50%);
}
.tcard {
  position: absolute;
  width: min(440px, 86vw);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  overflow: hidden;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  transform-style: preserve-3d;
  will-change: transform, opacity;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
}
#tcard-1 { left: 8vw; top: 22vh; }
#tcard-2 { right: 9vw; top: 18vh; }
#tcard-2 img { object-position: 78% center; }
#tcard-3 { left: 12vw; bottom: 13vh; }
.tcard-img { height: 200px; overflow: hidden; }
.tcard-img img { width: 100%; height: 100%; object-fit: cover; }
.tcard-body { padding: 24px 26px 28px; }
.tcard-tag { font-size: 0.6rem; color: var(--teal-bright); }
.tcard h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  margin: 8px 0 8px;
}
.tcard p { color: rgba(233,238,242,0.78); font-size: 0.93rem; }

/* ============================================================
   CH 4 · THE FADE
   ============================================================ */
.overlay-fade { display: block; }
.fade-head {
  position: absolute; top: 9vh; left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: 100%;
}
.fade-counter { margin-top: 14px; font-size: 0.68rem; color: var(--muted); }
#ink-pct { color: var(--teal-bright); }
.fade-track {
  position: absolute;
  bottom: 10vh; left: 0;
  display: flex; gap: 24px;
  padding: 0 8vw;
  will-change: transform;
}
.scard {
  flex: 0 0 min(360px, 78vw);
  padding: 26px 28px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.scard .mono { font-size: 0.6rem; color: var(--teal-bright); }
.scard h4 {
  font-family: var(--font-display);
  font-weight: 600; font-size: 1.25rem;
  margin: 10px 0 6px;
}
.scard p { color: var(--muted); font-size: 0.9rem; }
.scard-final { border-color: rgba(79,214,255,0.45); box-shadow: 0 0 40px rgba(79,214,255,0.12); }

/* ============================================================
   CH 9 · BOOK / FOOTER
   ============================================================ */
#ch-book {
  position: relative;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse 90% 70% at 50% 30%, #0d1319, var(--bg));
}
.book-inner {
  text-align: center;
  padding: 16vh 24px 0;
  display: flex; flex-direction: column; align-items: center;
  width: 100%;
}
.book-logo-wrap {
  background: linear-gradient(165deg, #f6f1e8, var(--pearl));
  border-radius: 28px;
  padding: clamp(26px, 4vw, 44px) clamp(34px, 5vw, 60px);
  margin-bottom: 6vh;
  box-shadow:
    0 0 60px rgba(79, 214, 255, 0.14),
    0 30px 80px rgba(0, 0, 0, 0.5);
}
.book-logo { width: min(56vw, 440px); height: auto; display: block; }
.book-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.9rem, 3.6vw, 3rem);
  letter-spacing: -0.02em;
}
.book-sub { color: var(--muted); margin: 14px 0 5vh; max-width: 520px; }
.btn-primary {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 20px 44px;
  border-radius: 999px;
  color: #04121a;
  background: linear-gradient(100deg, var(--teal-bright), var(--teal));
  box-shadow: 0 0 34px rgba(79,214,255,0.35), 0 14px 40px rgba(0,0,0,0.5);
  transition: box-shadow 0.3s, transform 0.3s;
  will-change: transform;
}
.btn-primary:hover { box-shadow: 0 0 60px rgba(79,214,255,0.55), 0 18px 50px rgba(0,0,0,0.5); }
#ch-book footer { margin-top: 12vh; padding: 40px 24px 34px; width: 100%; }
.foot-row {
  display: flex; justify-content: center; gap: clamp(16px, 4vw, 54px);
  flex-wrap: wrap;
  font-size: 0.62rem; color: var(--muted);
}
.foot-fine { font-size: 0.78rem; color: rgba(163, 178, 189, 0.85); margin-top: 18px; }

.noscript-note {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--bg); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; }
  .cue-line { animation: none; }
}

/* The .reduced class is applied by JS for prefers-reduced-motion AND as the
   emergency fallback when boot fails — so these rules must live outside the
   media query. */
html.reduced .pin { height: auto; min-height: 60vh; }
html.reduced .overlay { position: relative; padding: 10vh 8vw; perspective: none; }
html.reduced .waypoint, html.reduced .sci-step,
html.reduced .tcard, html.reduced .sci-footnote,
html.reduced #science-title, html.reduced .fade-head,
html.reduced .treat-kicker { opacity: 1; position: relative; inset: auto; transform: none; margin: 20px 0; }
html.reduced .veil { display: none; }
html.reduced .fade-track { position: relative; flex-wrap: wrap; }
html.reduced #nav { opacity: 1; pointer-events: auto; }
html.reduced .book-inner > * { opacity: 1; }

/* Glass fallback when backdrop-filter is unsupported */
@supports not (backdrop-filter: blur(1px)) {
  .waypoint, .tcard, .scard, .nav-cta {
    background: rgba(10, 16, 20, 0.9);
  }
}

/* Short viewports (landscape phones, small laptops) */
@media (max-height: 520px) {
  #hero-logo { width: min(44vw, 400px); }
  .overlay-hero { gap: 12px; }
  .scroll-cue { display: none; }
  .sci-step { max-width: 220px; }
  .sci-step p { font-size: 0.8rem; }
  #sci-step-1 { top: 26vh; }
  #sci-step-2 { top: 40vh; }
  #sci-step-3 { top: 58vh; }
  #science-title { top: 5vh; }
  .waypoint { max-width: 280px; padding: 16px 18px; }
  .tcard { width: min(340px, 80vw); }
  .tcard-img { height: 100px; }
  .fade-head { top: 4vh; }
  .fade-track { bottom: 5vh; }
  .scard { padding: 16px 18px; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 760px) {
  #hud { display: none; }
  .sci-step { max-width: 240px; }
  #sci-step-1 { top: 30vh; }
  #sci-step-2 { top: 48vh; }
  #sci-step-3 { top: 66vh; }
  .waypoint { max-width: 300px; padding: 20px 22px; }
  .wp-1, .wp-3 { left: 16px; }
  .wp-2, .wp-4 { right: 16px; }
  .tcard-img { height: 150px; }
  #tcard-1, #tcard-3 { left: 7vw; }
  #tcard-2 { right: 7vw; }
  #tcard-3 { bottom: 10vh; }
  #hero-logo { width: min(84vw, 660px); }
}
