/* ════════════════════════════════════════════════════════════════════
 * Naruto Monitor — landing page
 * Aesthetic: dark + neon (#a855f7 / #d946ef / #c084fc), glassmorphic
 * panels, premium scroll choreography.
 * ═══════════════════════════════════════════════════════════════════ */

/* ─── 1. DESIGN TOKENS ─────────────────────────────────────────────── */
:root {
  --bg-0:    #0a0114;
  --bg-1:    #14082a;
  --bg-deep: #050009;

  --neon-pp:   #a855f7;
  --neon-pk:   #d946ef;
  --neon-li:   #c084fc;
  --neon-soft: rgba(168, 85, 247, 0.35);
  --neon-edge: rgba(168, 85, 247, 0.18);

  --txt-0: #f5f5f5;
  --txt-1: #c4b5d4;
  --txt-2: #8b7ca0;

  --glass-bg:    rgba(15, 8, 30, 0.42);
  --glass-bg-hi: rgba(20, 10, 40, 0.55);
  --glass-blur:  blur(22px) saturate(140%);
  --glass-edge:  rgba(255, 255, 255, 0.06);

  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

/* ─── 2. RESET / BASE ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html       { scroll-behavior: auto; }
html, body { height: 100%; }
body {
  background: var(--bg-0);
  color: var(--txt-0);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a       { color: inherit; text-decoration: none; }
button  { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
img, canvas { display: block; max-width: 100%; }

/* ─── 3. HEADER ────────────────────────────────────────────────────── */
.lp-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px;
  background: linear-gradient(180deg, rgba(10,1,20,0.85), rgba(10,1,20,0));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.lp-logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: 0.02em; font-size: 15px;
}
.lp-logo__mark {
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--neon-pp), var(--neon-pk));
  color: #fff; font-size: 14px;
  box-shadow: 0 0 22px var(--neon-soft);
}
.lp-logo__text em { font-style: normal; color: var(--neon-li); }
.lp-nav { display: flex; gap: 22px; align-items: center; font-size: 13.5px; }
.lp-nav a { color: var(--txt-1); transition: color 180ms var(--ease-out); }
.lp-nav a:hover { color: var(--neon-li); }
.lp-nav__cta {
  padding: 8px 16px; border-radius: 999px;
  background: linear-gradient(135deg, var(--neon-pp), var(--neon-pk));
  color: #fff !important;
  box-shadow: 0 6px 22px var(--neon-soft);
  transition: transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
}
.lp-nav__cta:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(217,70,239,0.45); }

/* ─── 4. PRELOADER ─────────────────────────────────────────────────── */
.lp-preloader {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-content: center; gap: 14px;
  text-align: center;
  background: var(--bg-0);
  transition: opacity 600ms var(--ease-out), visibility 600ms;
}
.lp-preloader.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.lp-preloader__ring {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px solid rgba(168,85,247,0.18);
  border-top-color: var(--neon-pp);
  margin: 0 auto;
  animation: lpSpin 900ms linear infinite;
}
@keyframes lpSpin { to { transform: rotate(360deg); } }
.lp-preloader__label {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--txt-2);
}
.lp-preloader__bar {
  width: 220px; height: 2px; margin: 0 auto;
  background: rgba(168,85,247,0.15); border-radius: 2px; overflow: hidden;
}
.lp-preloader__bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--neon-pp), var(--neon-pk));
  transition: width 120ms linear;
}
.lp-preloader__pct {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px; color: var(--neon-li);
}

/* ─── 5. SCROLL STAGE ──────────────────────────────────────────────── */
.scroll-stage { position: relative; height: 600vh; }
.stage-pin {
  position: relative;
  width: 100%; height: 100vh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 60%, var(--bg-1) 0%, var(--bg-0) 70%);
  isolation: isolate;
}

/* The .stage-pin already has `overflow: hidden`, which is what makes
   the scale trick work: the canvas + hero-frame are scaled up slightly
   so any AI watermark in the bottom-right of the source frames spills
   past the pin's edges and gets clipped. transform-origin: 0 0 (top-
   left) means the EXTRA pixels grow toward the bottom-right, where
   the watermark lives — pushing it out of view in a single stroke,
   without overlays, masks, or extra DOM. */
.frame-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 1;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
  transform: scale(1.04);
  transform-origin: 0 0;
}

/* Hero-frame overlay — covers the canvas pixel-for-pixel when the user
   rests on a snap target. The high-res WebP has way more detail than
   the 1280px JPG sequence; this swap is what gives "4K crispness on
   pause" without blowing up the page weight (each WebP is ~250–360 KB).
   z-index matches the canvas so it stacks directly on top, and fades
   in/out via a single opacity transition for jank-free swaps.
   Same scale-trick as the canvas so the watermark is hidden during
   rest, not just during scrub. */
.hero-frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 380ms var(--ease-out);
  transform: scale(1.04);
  transform-origin: 0 0;
}
.hero-frame.is-visible { opacity: 1; }

.stage-vignette {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 30%, rgba(0,0,0,0.55) 100%),
    radial-gradient(ellipse at 18% 22%, rgba(168,85,247,0.16), transparent 55%),
    radial-gradient(ellipse at 82% 78%, rgba(217,70,239,0.12), transparent 55%);
}
.stage-grid {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0.16;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 36px 36px;
          mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
}

/* ─── 6. PANELS (glassmorphic side cards) ──────────────────────────── *
 * Vertical centering is GSAP-owned (yPercent: -50, set once at boot).
 * Horizontal anchoring is pure CSS (`right:` / `left:`) so panels
 * alternate sides without GSAP having to know about layout.
 * Do NOT add `transform: translate(...)` here — GSAP rewrites the
 * transform on every tween. */
.panel {
  position: absolute; z-index: 5;
  top: 50%;
  width: min(380px, 38vw);     /* compact side panel */
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
}
.panel.is-active            { pointer-events: auto; }
.panel--intro               { right: 5%; }
.panel--chain               { left:  5%; }
.panel--quota               { right: 5%; width: min(440px, 42vw); }

.panel__card {
  position: relative;
  padding: 24px 26px;
  border-radius: 20px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
          backdrop-filter: var(--glass-blur);
  border: 1px solid var(--neon-edge);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(168, 85, 247, 0.08),
    inset 0 1px 0 var(--glass-edge);
  text-align: left;             /* side panels read better left-aligned */
}
.panel--quota .panel__card,
.panel__card--wide { padding: 22px 26px 20px; text-align: center; }

.panel__card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, rgba(168,85,247,0.22), rgba(217,70,239,0.0) 60%);
  mix-blend-mode: overlay; opacity: 0.7;
}

.panel__tag {
  display: inline-block;
  padding: 4px 11px; margin-bottom: 14px;
  border: 1px solid rgba(168,85,247,0.4);
  border-radius: 999px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--neon-li);
  background: rgba(168,85,247,0.08);
}
.panel__heading {
  font-size: clamp(22px, 2.6vw, 34px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.022em;
  margin-bottom: 12px;
  overflow-wrap: break-word;   /* never let a long word spill the card on mobile */
}
.panel__heading .grad {
  background: linear-gradient(135deg, var(--neon-pp), var(--neon-pk) 60%, var(--neon-li));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(168, 85, 247, 0.3);
}
.panel__body {
  font-size: clamp(12.5px, 0.95vw, 14.5px);
  color: var(--txt-1);
  line-height: 1.6;
}
.panel__body strong { color: var(--neon-li); font-weight: 700; }

.panel__hint {
  margin-top: 22px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--txt-2);
  animation: lpBob 2.4s var(--ease-in-out) infinite;
}
@keyframes lpBob { 50% { transform: translateY(6px); } }

.panel__bullets {
  list-style: none;
  margin: 16px 0 0;
  display: flex; flex-direction: column; gap: 8px;
}
.panel__bullets li {
  display: flex; align-items: center; gap: 9px;
  font-size: 12px; color: var(--txt-1);
}
.panel__bullets .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--neon-pk);
  box-shadow: 0 0 8px var(--neon-pk);
  flex: 0 0 auto;
}

.panel__cta-row {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  margin-top: 6px;
}

/* ─── 7. CTA BUTTONS ───────────────────────────────────────────────── */
.cta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 22px;
  border-radius: 11px;
  font-size: 14px; font-weight: 700; letter-spacing: 0.01em;
  transition: transform 200ms var(--ease-out),
              box-shadow 200ms var(--ease-out),
              opacity 200ms;
  will-change: transform;
}
.cta:hover { transform: translateY(-1px); }
.cta--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--neon-pp), var(--neon-pk));
  box-shadow: 0 8px 28px var(--neon-soft), inset 0 1px 0 rgba(255,255,255,0.12);
}
.cta--primary:hover { box-shadow: 0 12px 36px rgba(217,70,239,0.5); }
.cta--ghost {
  color: var(--neon-li);
  background: rgba(168,85,247,0.06);
  border: 1px solid rgba(168,85,247,0.35);
}
.cta--ghost:hover { background: rgba(168,85,247,0.14); }

/* ─── 8. STAGE RAIL (snap indicator) ───────────────────────────────── */
.stage-rail {
  list-style: none;
  position: absolute; right: 30px; top: 50%; transform: translateY(-50%);
  z-index: 6;
  display: flex; flex-direction: column; gap: 28px;
  padding: 14px 8px;
  border-left: 1px solid var(--neon-edge);
}
.stage-rail__tick {
  width: 8px; height: 8px; margin-left: -12px;
  border-radius: 50%;
  background: rgba(168,85,247,0.30);
  border: 1px solid rgba(255,255,255,0.10);
  transition: transform 220ms var(--ease-out),
              background 220ms,
              box-shadow 220ms;
}
.stage-rail__tick.is-current {
  background: var(--neon-pk);
  transform: scale(1.55);
  box-shadow: 0 0 16px rgba(217,70,239,0.7);
}

/* ─── 9. GLOBE WRAP ───────────────────────────────────────────────── *
 * The quota panel uses the original size (~240px). The intro and chain
 * panels are narrower (380px) so they get a smaller in-line variant
 * (~190px) — same canvas, smaller frame, same neon drop-shadow.
 *
 * Mobile resilience:
 *  · `min-height` is a hard floor so even on browsers that mis-evaluate
 *    `aspect-ratio` (or where the parent collapses to 0×0 momentarily
 *    during scroll-trigger pin reflow on iOS Safari), the box still has
 *    a visible slot and the inner canvas is sized > 0 — which lets
 *    cobe's `if (width <= 0) return` guard see a positive width and
 *    actually run `createGlobe`.
 *  · `display: block` is reasserted on the canvas so the cobe-generated
 *    inline styles can't accidentally be overridden to inline-block by
 *    a more specific rule loaded later. */
.globe-wrap {
  position: relative;
  width: 100%;
  max-width: 312px;         /* +30% from 240px (quota card hero globe) */
  aspect-ratio: 1 / 1;
  min-height: 260px;        /* +30% from 200px — fallback floor for aspect-ratio failures */
  margin: 12px auto 14px;
  filter: drop-shadow(0 0 32px rgba(168, 85, 247, 0.35));
}
.globe-wrap canvas {
  width: 100%; height: 100%;
  display: block;
  cursor: grab; opacity: 0;
  transition: opacity 1.2s ease; touch-action: none;
}
/* Smaller variant for the side panels (intro + chain). */
.globe-wrap--inline {
  max-width: 190px;
  min-height: 160px;        /* match smaller frame */
  margin: 14px auto 10px;
  filter: drop-shadow(0 0 26px rgba(168, 85, 247, 0.32));
}

/* ─── 10. OUTRO ────────────────────────────────────────────────────── */
.outro {
  min-height: 60vh;
  display: grid; place-content: center; gap: 26px; padding: 80px 24px;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-0) 0%, var(--bg-deep) 100%);
}
.outro__kicker { color: var(--txt-1); font-size: 18px; max-width: 540px; margin: 0 auto; }
.outro__cta-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.outro__foot { color: var(--txt-2); font-size: 12px; }
.outro__foot a { color: var(--neon-li); }
.outro__foot a:hover { text-decoration: underline; }

/* ─── 11. RESPONSIVE ───────────────────────────────────────────────── */
/* On narrow viewports the alternating-side layout collapses — there's
   not enough horizontal real estate for a side card. Stack centered,
   one per snap point, edge-to-edge with a small gutter. */
@media (max-width: 768px) {
  .lp-header { padding: 12px 18px; }
  .lp-nav    { gap: 14px; font-size: 12.5px; }
  /* Previous mobile rule hid the first nav link (the Explorer link) to
     save horizontal space; that link has been removed entirely now,
     so no nth-of-type override is needed. */

  /* Override side anchors with symmetric inset so each panel spans the
     viewport width, then GSAP's yPercent: -50 still vertical-centers. */
  .panel,
  .panel--intro,
  .panel--chain,
  .panel--quota {
    left: 5%; right: 5%;
    width: auto;
  }
  .panel__card    { text-align: center; padding: 22px 20px; }
  .panel__bullets { align-items: center; }
  .panel__heading { font-size: clamp(22px, 6vw, 30px); }
  .panel__body    { font-size: 13.5px; }
  .stage-rail     { display: none; }

  /* Mobile globe strategy: keep ONE globe (in the quota panel where the
     "join the mesh" CTA lives) and drop the other two. Reasoning:
       · 3 simultaneous WebGL contexts is the per-page limit on iOS
         Safari (8) minus what the rest of the page uses, plus the
         frame-canvas. Low-end Android can be even tighter. The 2nd or
         3rd context creation silently failed on real devices.
       · Each cobe instance also runs its own RAF + GPU draw, which on
         a thermally throttled phone halves the frame-canvas scrub
         framerate.
     The intro/chain panels lose nothing visually critical — their job
     is the copy, not the globe. */
  .panel--intro .globe-wrap,
  .panel--chain .globe-wrap { display: none; }

  /* Quota's globe stays — sized so it sits comfortably above the CTAs.
     +30% from 220px / 200px to match the desktop globe-wrap bump. */
  .panel--quota .globe-wrap { max-width: 286px; min-height: 260px; }
}
@media (max-width: 380px) {
  .panel__card { padding: 18px 14px; }
  .cta         { padding: 10px 16px; font-size: 13px; }
}

/* ─── 12. ACCESSIBILITY · reduced-motion bypasses pin/scrub ────────── */
@media (prefers-reduced-motion: reduce) {
  .scroll-stage { height: auto; }
  .stage-pin    { height: auto; min-height: 100vh; }
  .panel {
    position: relative;
    top: auto; left: auto; transform: none;
    opacity: 1 !important;
    pointer-events: auto;
    margin: 80px auto;
  }
  .stage-rail { display: none; }
}

/* ─── 13. STATIC LANDING · mobile + reduced-motion native scroll ────── *
 * scroll-landing.js adds `.lp-static` to <html> on phones (≤768px) and
 * whenever reduced-motion is requested. In that mode the JS NEVER builds
 * the GSAP pin/scrub timeline and NEVER loads the 528-frame sequence, so
 * here we tear down everything that depended on the pin and re-flow the
 * page as ordinary stacked sections the browser scrolls natively.
 *
 * Selectors are `:root.lp-static …` (specificity 0,3,0) so they win over
 * both the base `.panel` rules and the animated `@media (max-width:768px)`
 * block above without needing !important on layout — opacity keeps it
 * because GSAP's inline `opacity:0` would otherwise hide the panels. */
:root.lp-static .scroll-stage {
  height: auto;
}
:root.lp-static .stage-pin {
  position: relative;
  height: auto;
  min-height: 0;
  overflow: visible;
  isolation: auto;
  padding-bottom: 32px;
  /* Cheap ambient backdrop in place of the live canvas: the same neon
     radial wash the desktop vignette provides, but as a static paint. */
  background:
    radial-gradient(ellipse at 18% 12%, rgba(168,85,247,0.16), transparent 55%),
    radial-gradient(ellipse at 88% 70%, rgba(217,70,239,0.12), transparent 55%),
    var(--bg-0);
}

/* Kill the pieces that only make sense for the pinned scrub experience. */
:root.lp-static .frame-canvas,
:root.lp-static .stage-grid,
:root.lp-static .stage-vignette,
:root.lp-static .stage-rail,
:root.lp-static .panel__hint {
  display: none;
}

/* The snap-overlay <img> becomes a real, in-flow hero banner at the top
   (it is the first child of .stage-pin in the DOM). Fades into the dark
   page background so the stacked cards sit cleanly beneath it. */
:root.lp-static .hero-frame {
  position: relative;
  inset: auto;
  opacity: 1;
  width: 100%;
  height: 56vw;
  max-height: 360px;
  transform: none;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, #000 58%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 58%, transparent 100%);
}

/* Stacked, centered, comfortably padded glass cards — one after another,
   in natural document order (intro → chain → quota → outro). */
:root.lp-static .panel,
:root.lp-static .panel--intro,
:root.lp-static .panel--chain,
:root.lp-static .panel--quota {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  width: auto;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 18px;
  opacity: 1;          /* override GSAP's inline opacity:0 on chain/quota */
  transform: none;
  pointer-events: auto;
  will-change: auto;
}
:root.lp-static .panel + .panel {
  margin-top: 28px;
}
/* Pull the first card up so it overlaps the fading hero for depth. */
:root.lp-static .panel--intro {
  margin-top: -56px;
  z-index: 5;
}
:root.lp-static .panel__card {
  text-align: center;
  padding: 24px 22px;
}
:root.lp-static .panel__bullets {
  align-items: center;
}
:root.lp-static .panel__cta-row {
  justify-content: center;
}
/* On mobile keep only the quota globe (matches the animated-layout rule);
   the intro/chain globes are decorative and cost a WebGL context each. */
:root.lp-static .panel--intro .globe-wrap,
:root.lp-static .panel--chain .globe-wrap {
  display: none;
}
:root.lp-static .panel--quota .globe-wrap {
  max-width: 260px;
  min-height: 240px;
}

/* Very small phones: tighten gutters and CTA sizing. */
@media (max-width: 380px) {
  :root.lp-static .panel { padding: 0 12px; }
  :root.lp-static .panel__card { padding: 20px 16px; }
}
