/* ═══════════════════════════════════════════════════════════════════
   style.css — Scroll Sequence Animation
   Minimal, premium design. All layout is driven by JS canvas logic.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --clr-bg        : #000;
  --clr-surface   : rgba(255,255,255,0.06);
  --clr-border    : rgba(255,255,255,0.10);
  --clr-text      : #f0f0f0;
  --clr-muted     : rgba(240,240,240,0.50);
  --clr-accent    : #4a9eff;
  --clr-accent-2  : #a78bfa;

  --font-sans     : 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --ease-out-expo : cubic-bezier(0.19, 1, 0.22, 1);
  --ease-in-out   : cubic-bezier(0.76, 0, 0.24, 1);

  --caption-pad   : clamp(2rem, 6vw, 5rem);
  --progress-h    : 2px;
}

html {
  scroll-snap-type: y mandatory;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Generated by JS in _setupScrollRoot() — one per waypoint */
.snap-section {
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* Premium Frame Counter top right */
.frame-counter {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--clr-text);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.frame-counter__label {
  color: var(--clr-muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  margin-right: 0.4rem;
}

body {
  background: var(--clr-bg);
  color: var(--clr-text);
  font-family: var(--font-sans);
  overflow-x: hidden;
}

/* ─── Loader ────────────────────────────────────────────────────── */
.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--clr-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s var(--ease-out-expo),
              visibility 0.6s var(--ease-out-expo);
}

.loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* SVG spinner */
.loader__ring {
  width: 56px;
  height: 56px;
  transform: rotate(-90deg);
  overflow: visible;
}

.loader__track {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 2.5;
}

.loader__fill {
  fill: none;
  stroke: var(--clr-accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 144.51; /* 2π × r=23 */
  stroke-dashoffset: 144.51;
  transition: stroke-dashoffset 0.3s ease;
}

.loader__text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.loader__label {
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--clr-muted);
}

.loader__pct {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--clr-text);
  font-variant-numeric: tabular-nums;
}

/* ─── Canvas ────────────────────────────────────────────────────── */
#seq-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* z-index 0 — sits behind captions, above body bg */
  z-index: 0;
  display: block;
}

/* ─── Scroll Root ───────────────────────────────────────────────── */
#scroll-root {
  position: relative;
  z-index: 1;
  /* height is set by JS via #scroll-spacer */
}

#scroll-spacer {
  /* JS will write: height = scrollVH * 100vh */
}

/* ─── Progress Bar ──────────────────────────────────────────────── */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--progress-h);
  z-index: 100;
  background: rgba(255,255,255,0.07);
}

.progress-bar__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--clr-accent), var(--clr-accent-2));
  transform-origin: left;
  transition: width 0.05s linear;
  /* subtle glow */
  box-shadow: 0 0 8px 1px var(--clr-accent);
}

/* ─── Scroll Hint ───────────────────────────────────────────────── */
.scroll-hint {
  position: fixed;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.scroll-hint.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.scroll-hint__label {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--clr-muted);
}

.scroll-hint__arrow {
  width: 20px;
  height: 20px;
  color: var(--clr-muted);
  animation: bounce 1.6s ease-in-out infinite;
}

.scroll-hint__arrow svg {
  width: 100%;
  height: 100%;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0);    }
  50%       { transform: translateY(6px); }
}

/* ─── Captions ──────────────────────────────────────────────────── */
/*
  Captions are fixed-position overlays that fade in/out based on
  the current scroll progress. JS handles opacity via inline style.
  They are positioned inside #scroll-root but use fixed positioning
  so they stay on screen while the user scrolls.
*/
.caption {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  padding: var(--caption-pad);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.05s linear; /* JS overrides this per-frame */
}

/* Horizontal alignment variants */
.caption--start { justify-content: flex-start; }
.caption--mid   { justify-content: flex-end;   }
.caption--end   { justify-content: flex-start; align-items: flex-end; padding-bottom: calc(var(--caption-pad) * 1.5); }

.caption__inner {
  max-width: min(540px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.caption__eyebrow {
  font-size: clamp(0.65rem, 1.2vw, 0.75rem);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--clr-accent);
}

.caption__headline {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: #ffffff;
  /* Subtle text shadow so it's readable on any frame */
  text-shadow: 0 2px 40px rgba(0,0,0,0.6);
}

.caption__body {
  font-size: clamp(0.9rem, 1.5vw, 1.05rem);
  font-weight: 300;
  line-height: 1.6;
  color: var(--clr-muted);
}



/* ─── Responsive tweaks ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .caption {
    padding: 2.2rem;
  }
  
  /* Initial Section Title: sits in the top reflective margin */
  .caption--start {
    align-items: flex-start;
    justify-content: flex-start;
    padding-top: 4.5rem;
  }

  /* Middle & End Sections: sit in the bottom reflective margin */
  .caption--mid {
    align-items: flex-end;
    justify-content: flex-start;
    padding-bottom: 4.5rem;
  }

  .caption--end {
    align-items: flex-end;
    justify-content: flex-start;
    padding-bottom: 4.5rem;
  }

  .caption__inner {
    max-width: 100%;
  }

  .caption__headline {
    /* Slightly smaller text for compact layout on mobile screens */
    font-size: clamp(1.8rem, 7vw, 2.5rem);
  }
}
