/**
 * Scroll-Reactive Perspective Tunnel
 * Dependency-free and fully scoped to .spt-tunnel.
 */

.spt-tunnel {
  --spt-background: #3046df;
  --spt-foreground: #f3efe5;
  --spt-accent: #d9ff57;
  --spt-accent-glow: rgba(217, 255, 87, 0.16);
  --spt-muted: rgba(243, 239, 229, 0.76);
  --spt-ring: #f3efe5;
  --spt-ring-accent: #d9ff57;
  --spt-ring-secondary: var(--spt-ring-accent);
  --spt-frame: rgba(243, 239, 229, 0.17);
  --spt-progress: 0;
  --spt-pointer-x: 0px;
  --spt-pointer-y: 0px;
  --spt-scroll-length: 210svh;
  position: relative;
  isolation: isolate;
  block-size: auto;
  min-block-size: 1080px;
  background: var(--spt-background);
  color: var(--spt-foreground);
}

.spt-tunnel__sticky {
  position: relative;
  display: grid;
  place-items: center;
  block-size: auto;
  min-block-size: 620px;
  overflow: hidden;
}

.spt-tunnel[data-spt-mounted="true"] {
  block-size: var(--spt-scroll-length);
}

.spt-tunnel[data-spt-mounted="true"] .spt-tunnel__sticky {
  position: sticky;
  top: 0;
  block-size: 100svh;
}

.spt-tunnel__sticky::after {
  content: "";
  position: absolute;
  z-index: 4;
  inset: clamp(12px, 1.75vw, 28px);
  border: 1px solid var(--spt-frame);
  pointer-events: none;
}

.spt-tunnel__rings {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  perspective: 1100px;
  pointer-events: none;
}

.spt-tunnel__ring {
  --spt-i: 0;
  --spt-scale: calc(0.07 + (var(--spt-i) * 0.052) + (var(--spt-progress) * (1.06 + var(--spt-i) * 0.077)));
  position: absolute;
  top: calc(50% + var(--spt-pointer-y));
  left: calc(50% + var(--spt-pointer-x));
  width: min(68vw, 920px);
  aspect-ratio: 1;
  border: clamp(18px, 3vw, 44px) solid var(--spt-ring);
  border-radius: calc(42% + var(--spt-i) * 1%);
  opacity: calc(0.09 + var(--spt-i) * 0.05);
  transform: translate(-50%, -50%) scale(var(--spt-scale)) rotate(calc(var(--spt-i) * 8deg + var(--spt-progress) * 32deg));
  transform-origin: center;
  will-change: transform;
}

.spt-tunnel__ring:nth-child(3n) { border-color: var(--spt-ring-accent); }
.spt-tunnel__ring:nth-child(5n) { border-color: var(--spt-ring-secondary); }
.spt-tunnel__ring:nth-child(2n) { border-radius: 50% 38% 46% 42%; }
.spt-tunnel__ring:nth-child(4n) { border-radius: 38% 51% 44% 49%; }

.spt-tunnel__content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92vw, 1100px);
  text-align: center;
}

.spt-tunnel__eyebrow {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.spt-tunnel__eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--spt-accent);
  box-shadow: 0 0 0 5px var(--spt-accent-glow);
}

.spt-tunnel__title {
  margin: 1.5rem 0 0;
  color: var(--spt-foreground);
  font: 400 max(16px, clamp(4rem, 11vw, 10rem)) / 0.72 Georgia, serif;
  letter-spacing: -0.06em;
}

.spt-tunnel__title span,
.spt-tunnel__title em { display: block; }
.spt-tunnel__title em { color: var(--spt-accent); font-size: max(16px, 0.48em); font-weight: 400; line-height: 0.85; }

.spt-tunnel__note {
  max-width: 380px;
  margin: 2rem 0 0;
  color: var(--spt-muted);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0.035em;
}

/* Optional multi-step credibility/story sequence. It stays readable without JS. */
.spt-tunnel__steps {
  display: grid;
  gap: 2rem;
  width: min(92vw, 980px);
}

.spt-tunnel__step {
  text-align: center;
}

.spt-tunnel__step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 42px;
  margin: 0 0 1.1rem;
  border: 1px solid var(--spt-frame);
  border-radius: 50%;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.spt-tunnel__step h2,
.spt-tunnel__step h3 {
  max-width: 17ch;
  margin: 0 auto;
  color: var(--spt-foreground);
  font: 400 max(16px, clamp(2.7rem, 6.5vw, 6.4rem)) / 0.9 Georgia, serif;
  letter-spacing: -0.045em;
}

.spt-tunnel__step p:not(.spt-tunnel__step-index) {
  max-width: 670px;
  margin: 1.35rem auto 0;
  color: var(--spt-muted);
  font-size: max(16px, clamp(0.82rem, 1.1vw, 1rem));
  line-height: 1.7;
}

.spt-tunnel[data-spt-mounted="true"] .spt-tunnel__steps {
  display: grid;
  place-items: center;
  min-height: min(58vh, 560px);
}

.spt-tunnel[data-spt-mounted="true"] .spt-tunnel__step {
  grid-area: 1 / 1;
  width: 100%;
  opacity: 0;
  transform: translateY(28px);
  pointer-events: none;
  transition: opacity 480ms ease, transform 650ms cubic-bezier(.22, 1, .36, 1);
}

.spt-tunnel[data-spt-mounted="true"] .spt-tunnel__step[data-spt-state="active"] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.spt-tunnel[data-spt-mounted="true"] .spt-tunnel__step[data-spt-state="previous"] { transform: translateY(-28px); }

.spt-tunnel__meta {
  position: absolute;
  z-index: 3;
  bottom: clamp(2rem, 4vw, 3.5rem);
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.68;
}

.spt-tunnel__meta--left { left: clamp(2rem, 4vw, 4rem); }
.spt-tunnel__meta--right { right: clamp(2rem, 4vw, 4rem); writing-mode: vertical-rl; }

@media (max-width: 760px) {
  .spt-tunnel { --spt-scroll-length: 185svh; }
  .spt-tunnel__ring { width: 96vw; border-width: clamp(14px, 6vw, 30px); }
  .spt-tunnel__title { font-size: max(16px, clamp(3.8rem, 20vw, 7rem)); }
  .spt-tunnel__note { max-width: min(78vw, 360px); }
  .spt-tunnel__meta--right { right: 1.6rem; }
  .spt-tunnel__meta--left { left: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .spt-tunnel[data-spt-mounted="true"] {
    --spt-progress: 0.34 !important;
    block-size: auto;
    min-block-size: max(680px, 100svh);
  }
  .spt-tunnel[data-spt-mounted="true"] .spt-tunnel__sticky {
    position: relative;
    block-size: auto;
    min-block-size: max(680px, 100svh);
  }
  .spt-tunnel__ring { will-change: auto; }
  .spt-tunnel[data-spt-mounted="true"] .spt-tunnel__steps {
    display: grid;
    gap: 3.5rem;
    min-height: 0;
    padding-block: 5rem;
  }
  .spt-tunnel[data-spt-mounted="true"] .spt-tunnel__step {
    grid-area: auto;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    transition: none;
  }
}

@media print {
  .spt-tunnel[data-spt-mounted="true"] {
    --spt-progress: 0.32 !important;
    block-size: 720px;
    min-block-size: 720px;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .spt-tunnel[data-spt-mounted="true"] .spt-tunnel__sticky { position: relative; block-size: 720px; }
}
