/* ─────────────────────────────────────────────
   Highlight Marker Text Reveal
   Professional · smooth · production-ready
   ───────────────────────────────────────────── */

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

:root {
  --font-display: "Syne", system-ui, sans-serif;
  --font-ui: "Inter", system-ui, sans-serif;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-smooth: cubic-bezier(0.65, 0, 0.35, 1);

  --bg-v1: #160816;
  --bg-v2: #0a0a0c;
  --bg-v3: #050f08;
  --bg-v4: #0b0b12;

  --text-v1: #f0e0f6;
  --text-v2: #f4f4f5;
  --text-v3: #e6ffe2;
  --text-v4: #ddd8f0;

  --nav-size: 2.5rem;
  --nav-gap: 0.35rem;
}

html {
  scroll-behavior: auto; /* Lenis owns scrolling */
}

html.lenis,
html.lenis body {
  height: auto;
}

body {
  font-family: var(--font-ui);
  color: #fff;
  background: #050505;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ── Film grain (subtle polish) ───────────── */

.grain {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px 180px;
}

/* ── Sections — exact full viewport ───────── */

.demo {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100svh;
  min-height: 100svh;
  max-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 clamp(1.25rem, 5vw, 4rem);
  text-align: center;
  overflow: hidden;
}

.demo--v1 {
  background: var(--bg-v1);
  color: var(--text-v1);
}

.demo--v2 {
  background: var(--bg-v2);
  color: var(--text-v2);
}

.demo--v3 {
  background: var(--bg-v3);
  color: var(--text-v3);
}

.demo--v4 {
  background: var(--bg-v4);
  color: var(--text-v4);
}

/* Soft ambient glow per version */
.demo__glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}

.demo--v1 .demo__glow {
  background:
    radial-gradient(
      ellipse 70% 55% at 50% 58%,
      rgba(180, 60, 200, 0.18) 0%,
      transparent 68%
    ),
    radial-gradient(
      ellipse 40% 30% at 80% 20%,
      rgba(120, 40, 140, 0.12) 0%,
      transparent 70%
    );
}

.demo--v2 .demo__glow {
  background:
    radial-gradient(
      ellipse 65% 50% at 50% 55%,
      rgba(199, 0, 239, 0.12) 0%,
      transparent 70%
    ),
    radial-gradient(
      ellipse 35% 28% at 20% 25%,
      rgba(255, 255, 255, 0.04) 0%,
      transparent 70%
    );
}

.demo--v3 .demo__glow {
  background:
    radial-gradient(
      ellipse 70% 55% at 50% 55%,
      rgba(124, 255, 107, 0.08) 0%,
      transparent 68%
    ),
    radial-gradient(
      ellipse 30% 25% at 75% 30%,
      rgba(80, 200, 100, 0.06) 0%,
      transparent 70%
    );
}

.demo--v4 .demo__glow {
  background:
    radial-gradient(
      ellipse 65% 50% at 50% 55%,
      rgba(184, 164, 255, 0.1) 0%,
      transparent 70%
    ),
    radial-gradient(
      ellipse 35% 28% at 25% 20%,
      rgba(140, 120, 220, 0.07) 0%,
      transparent 70%
    );
}

/* ── Meta header ──────────────────────────── */

.demo__meta {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1.5rem;
  padding: clamp(1.35rem, 3.5vw, 2.25rem) clamp(1.35rem, 4vw, 2.75rem);
  font-family: var(--font-ui);
  pointer-events: none;
}

.demo__meta-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.demo__index {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  opacity: 0.9;
}

.demo__divider {
  width: 1.25rem;
  height: 1px;
  background: currentColor;
  opacity: 0.28;
}

.demo__label {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.55;
}

.demo__attrs {
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  opacity: 0.35;
  font-variant-numeric: tabular-nums;
}

/* ── Stage — shared center axis for all text ─ */

.demo__stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: min(92vw, 1100px);
  margin: 0 auto;
  text-align: center;
}

.demo__stage--body {
  max-width: min(88vw, 920px);
}

/* ── Display titles — same size on every section ── */

.highlight-title,
.highlight-body {
  width: 100%;
  max-width: 16ch;
  margin: 0 auto;
  font-family: var(--font-display);
  /* Shared size — slightly smaller for clearer full-word reads */
  font-size: clamp(2.15rem, 6.2vw, 5.25rem);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  text-align: center;
  text-wrap: balance;
  opacity: 1;
}

/* ── Marker reveal core ───────────────────── */

[data-highlight-marker-reveal] {
  visibility: hidden;
  text-align: center;
}

/*
 * Each SplitText line is a centered row:
 * width: fit-content → bar only as wide as the words
 * margin auto → lines stack centered with each other
 */
[data-highlight-marker-reveal] .highlight-marker-line {
  display: block !important;
  width: fit-content !important;
  max-width: 100%;
  margin-left: auto !important;
  margin-right: auto !important;
  margin-top: -0.06em;
  margin-bottom: -0.06em;
  text-align: center;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.highlight-marker-bar {
  position: absolute;
  inset: -0.06em 0;
  z-index: 1;
  pointer-events: none;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.highlight-body .highlight-marker-line {
  margin-top: -0.04em;
  margin-bottom: -0.04em;
}

.highlight-body .highlight-marker-bar {
  inset: -0.04em 0;
}

/* ── Scroll hint (first section only) ─────── */

.demo__scroll-hint {
  position: absolute;
  bottom: clamp(1.5rem, 4vw, 2.5rem);
  left: 50%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  transform: translateX(-50%);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.4;
  pointer-events: none;
}

.demo__scroll-line {
  display: block;
  width: 1px;
  height: 2.25rem;
  background: linear-gradient(
    to bottom,
    currentColor 0%,
    transparent 100%
  );
  transform-origin: top center;
  animation: scrollPulse 2.4s var(--ease-in-out-smooth) infinite;
}

@keyframes scrollPulse {
  0%,
  100% {
    transform: scaleY(1);
    opacity: 0.55;
  }
  50% {
    transform: scaleY(0.45);
    opacity: 0.15;
  }
}

/* ── Version nav ──────────────────────────── */

.version-nav {
  position: fixed;
  right: clamp(0.85rem, 2.2vw, 1.4rem);
  top: 50%;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--nav-gap);
  transform: translateY(-50%);
}

.version-nav__track {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.version-nav__indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--nav-size);
  height: var(--nav-size);
  border-radius: 999px;
  background: #fff;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 8px 28px rgba(0, 0, 0, 0.35);
  will-change: transform;
  transition: none; /* GSAP drives motion */
}

.version-nav button {
  position: relative;
  z-index: 1;
  width: var(--nav-size);
  height: var(--nav-size);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(8, 8, 10, 0.42);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  color: rgba(255, 255, 255, 0.48);
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition:
    color 0.4s var(--ease-out-expo),
    border-color 0.4s var(--ease-out-expo),
    background 0.4s var(--ease-out-expo);
}

.version-nav button span {
  display: block;
  transition: transform 0.45s var(--ease-out-expo);
}

.version-nav button:hover {
  color: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(20, 20, 24, 0.55);
}

.version-nav button:hover span {
  transform: scale(1.06);
}

.version-nav button.is-active {
  color: #0a0a0a;
  border-color: transparent;
  background: transparent;
}

.version-nav button:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 3px;
}

/* ── Reduced motion ───────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .demo__scroll-line {
    animation: none;
  }

  [data-highlight-marker-reveal] {
    visibility: visible;
  }

  .highlight-marker-bar {
    display: none !important;
  }

  .grain {
    display: none;
  }
}

/* ── Small screens ────────────────────────── */

@media (max-width: 720px) {
  .demo__attrs {
    display: none;
  }

  .highlight-title,
  .highlight-body {
    max-width: 14ch;
    font-size: clamp(1.95rem, 8.5vw, 3.15rem);
  }

  .version-nav {
    right: 0.55rem;
  }

  :root {
    --nav-size: 2.2rem;
  }
}

@media (max-width: 480px) {
  .demo {
    padding-left: 1rem;
    padding-right: 3.1rem; /* room for nav */
  }
}
