/* Cinematic Slide 2 → 3 */

@font-face {
  font-family: "Aphrodite Slim Pro";
  src: url("../fonts/APHRODITESLIMPRO.OTF") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Agatho";
  src: url("../fonts/AGATHO_REGULAR.OTF") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Agatho";
  src: url("../fonts/AGATHO_ LIGHT.OTF") format("opentype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

.cinematic-portal {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
}

.cinematic-portal.is-active {
  visibility: visible;
}

.glitch-stage {
  position: absolute;
  inset: 0;
}

.glitch-ticket-host {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.glitch-ticket-clone {
  position: absolute;
  width: 500px;
  height: 760px;
  transform-origin: 50% 50%;
  will-change: transform, opacity, filter;
  pointer-events: none;
  overflow: hidden;
  border-radius: 8px;
  filter: drop-shadow(0 12px 40px rgba(0, 0, 0, 0.35));
}

.glitch-ticket-clone .scratch-ticket-scaler,
.glitch-ticket-clone .scratch-ticket-stack {
  width: 100%;
  height: 100%;
}

/* Digital glitch FX */
.glitch-fx {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
}

.glitch-fx.is-on {
  opacity: 1;
  animation: glitchBurst 0.65s steps(1) forwards;
}

@keyframes glitchBurst {
  0% {
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.glitch-rgb {
  position: absolute;
  inset: -4%;
  background: center / cover no-repeat;
  opacity: 0;
  mix-blend-mode: screen;
}

.cinematic-portal.is-glitching .glitch-r {
  background: rgba(255, 40, 60, 0.12);
  opacity: 0.85;
  transform: translate(-6px, 2px);
  animation: glitchR 0.55s steps(2) infinite;
}

.cinematic-portal.is-glitching .glitch-g {
  background: rgba(40, 255, 120, 0.08);
  opacity: 0.7;
  transform: translate(4px, -3px);
  animation: glitchG 0.45s steps(2) infinite reverse;
}

.cinematic-portal.is-glitching .glitch-b {
  background: rgba(40, 80, 255, 0.12);
  opacity: 0.85;
  transform: translate(7px, 1px);
  animation: glitchB 0.5s steps(3) infinite;
}

@keyframes glitchR {
  0% {
    clip-path: inset(0 0 88% 0);
    transform: translate(-8px, 0);
  }
  50% {
    clip-path: inset(35% 0 40% 0);
    transform: translate(10px, 4px);
  }
  100% {
    clip-path: inset(70% 0 5% 0);
    transform: translate(-5px, -2px);
  }
}

@keyframes glitchG {
  0% {
    clip-path: inset(15% 0 70% 0);
  }
  100% {
    clip-path: inset(55% 0 20% 0);
    transform: translate(-12px, 6px);
  }
}

@keyframes glitchB {
  0% {
    clip-path: inset(60% 0 0 0);
  }
  100% {
    clip-path: inset(0 0 50% 0);
    transform: translate(14px, -4px);
  }
}

.glitch-scanlines {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.14) 2px,
    rgba(0, 0, 0, 0.14) 4px
  );
  mix-blend-mode: multiply;
}

.cinematic-portal.is-glitching .glitch-scanlines {
  opacity: 0.55;
  animation: scanSweep 0.6s linear infinite;
}

@keyframes scanSweep {
  0% {
    transform: translateY(-8%);
  }
  100% {
    transform: translateY(8%);
  }
}

.glitch-displace {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 48px,
    rgba(255, 255, 255, 0.04) 48px,
    rgba(255, 255, 255, 0.04) 52px
  );
  filter: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.02' numOctaves='3'/%3E%3C/filter%3E%3C/svg%3E");
}

.cinematic-portal.is-glitching .glitch-displace {
  opacity: 0.35;
  animation: displaceJitter 0.12s steps(3) infinite;
}

@keyframes displaceJitter {
  0% {
    transform: translateX(0) skewX(0deg);
  }
  33% {
    transform: translateX(-12px) skewX(2deg);
  }
  66% {
    transform: translateX(14px) skewX(-3deg);
  }
  100% {
    transform: translateX(-6px) skewX(1deg);
  }
}

.glitch-tears {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.cinematic-portal.is-glitching .glitch-tears {
  opacity: 1;
  background: linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.15) 48%,
      transparent 52%
    ),
    linear-gradient(
      180deg,
      transparent 20%,
      rgba(0, 0, 0, 0.25) 20.5%,
      transparent 21%
    ),
    linear-gradient(
      180deg,
      transparent 55%,
      rgba(255, 255, 255, 0.2) 55.4%,
      transparent 56%
    ),
    linear-gradient(
      180deg,
      transparent 78%,
      rgba(0, 0, 0, 0.3) 78.3%,
      transparent 79%
    );
  animation: tearShift 0.5s steps(4) forwards;
}

@keyframes tearShift {
  0% {
    transform: translate(0, 0);
    clip-path: inset(0 0 0 0);
  }
  25% {
    transform: translate(-18px, 6px);
    clip-path: inset(8% 0 72% 0);
  }
  50% {
    transform: translate(22px, -8px);
    clip-path: inset(40% 0 35% 0);
  }
  75% {
    transform: translate(-10px, 12px);
    clip-path: inset(65% 0 10% 0);
  }
  100% {
    transform: translate(0, 0);
    clip-path: inset(0 0 0 0);
    opacity: 0;
  }
}

/* Slide 2 — three-layer scratch ticket */
.slide[data-slide="1"]:not(.s1-scratch-active) .s1-s2-scratch-stage .scratch-card-premium,
.slide[data-slide="1"]:not(.s1-scratch-active) .s1-s2-scratch-stage .scratch-ticket-stack,
.slide[data-slide="1"]:not(.s1-scratch-active) .s1-s2-scratch-stage .scratch-layer-canvas {
  pointer-events: none !important;
}

.scratch-card-premium {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  pointer-events: auto;
}

.scratch-ticket-stack {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  overflow: hidden;
  pointer-events: auto;
  cursor: crosshair;
  touch-action: none;
  background: transparent;
}

/* Layer 1 — hidden reveal */
.scratch-layer-reveal,
.scratch-card-premium .scratch-reveal {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 1;
  object-fit: cover;
  object-position: center;
  -webkit-user-drag: none;
}

/* Layer 2 — opaque gradient painted on canvas bitmap only (no CSS bg) */
.scratch-layer-canvas,
.scratch-card-premium .scratch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  z-index: 2;
  opacity: 1;
  animation: none !important;
  transform: none !important;
}

/* Ticket edge chrome (frame art is composited onto canvas, not a blocking overlay) */
.scratch-ticket-stack::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.12),
    inset 0 0 24px rgba(0, 0, 0, 0.08);
}

.scratch-particles-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

.scratch-glow-ring {
  position: absolute;
  inset: -14px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  box-shadow:
    0 0 45px rgba(255, 210, 130, 0.55),
    0 0 90px rgba(255, 180, 80, 0.3),
    inset 0 0 36px rgba(255, 235, 200, 0.2);
  z-index: 0;
}

.scratch-card.is-golden-reveal .scratch-glow-ring,
.scratch-card-premium.is-golden-reveal .scratch-glow-ring,
.scratch-card.is-revealing .scratch-glow-ring,
.scratch-card-premium.is-revealing .scratch-glow-ring {
  opacity: 1;
  animation: s2GlowRingPulse 2.2s ease-in-out forwards;
}

@keyframes s2GlowRingPulse {
  0% {
    opacity: 0;
    transform: scale(0.96);
  }
  20% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0.85;
    transform: scale(1.02);
  }
}

.scratch-card-premium.is-complete .scratch-layer-canvas,
.scratch-card-premium.is-revealing .scratch-layer-canvas {
  pointer-events: none;
}

.scratch-card-premium.is-revealing {
  z-index: 120;
}

.scratch-card-premium.is-revealing .scratch-ticket-stack {
  overflow: visible;
}

/* Golden sparkle trace around revealed ticket */
.s2-golden-reveal-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
}

.s2-golden-reveal-fx.is-active {
  opacity: 1;
}

.s2-golden-trace-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.s2-golden-trace-lit {
  opacity: 0.95;
}

.s2-golden-trace-bg {
  opacity: 0.35;
}

.s2-golden-runner {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  opacity: 0;
  background: radial-gradient(
    circle,
    rgba(255, 252, 235, 1) 0%,
    rgba(255, 220, 130, 0.95) 35%,
    rgba(255, 180, 60, 0.4) 62%,
    transparent 72%
  );
  box-shadow:
    0 0 16px rgba(255, 220, 140, 0.95),
    0 0 36px rgba(255, 190, 80, 0.65),
    0 0 64px rgba(255, 160, 40, 0.35);
  filter: blur(0.3px);
}

.s2-golden-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.s2-golden-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  opacity: 0;
  background: radial-gradient(circle, #fffef5 0%, #ffd878 55%, transparent 100%);
  box-shadow: 0 0 8px rgba(255, 220, 140, 0.9);
}

.slide[data-slide="1"] .s1-s2-scratch-stage {
  transform-origin: 50% 50%;
}

/* Slide 3 — Rishikesh scene (CSS reveal sequence) */
.slide[data-slide="3"].slide-cinematic {
  overflow: hidden;
}

.slide[data-slide="3"] .s3-bg {
  z-index: 0;
  transform-origin: 50% 50%;
  transform: scale(2);
  will-change: transform;
}

.slide[data-slide="3"] .s3-rishikesh-wrap,
.slide[data-slide="3"] .s3-boat-wrap {
  position: absolute;
  overflow: hidden;
}

.slide[data-slide="3"] .s3-rishikesh-wrap {
  left: 0;
  bottom: 0;
  z-index: 2;
}

.slide[data-slide="3"] .s3-boat-wrap {
  z-index: 5;
  transform-origin: 50% 80%;
  opacity: 0;
  transform: translateX(40px) scale(0.94);
}

.slide[data-slide="3"] .s3-logo-reveal,
.slide[data-slide="3"] .s3-couple-reveal,
.slide[data-slide="3"] .s3-hashtag-reveal {
  width: 100%;
  height: 100%;
  overflow: hidden;
  will-change: clip-path;
}

.slide[data-slide="3"] .s3-rishikesh-reveal {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.slide[data-slide="3"] .s3-logo-reveal,
.slide[data-slide="3"] .s3-couple-reveal,
.slide[data-slide="3"] .s3-hashtag-reveal {
  clip-path: inset(100% 0 0 0);
  -webkit-clip-path: inset(100% 0 0 0);
}

.slide[data-slide="3"] .s3-rishikesh,
.slide[data-slide="3"] .s3-boat,
.slide[data-slide="3"] .s3-logo,
.slide[data-slide="3"] .s3-couple-name,
.slide[data-slide="3"] .s3-hashtag {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.slide[data-slide="3"] .s3-header {
  --s3-logo-width: 360px;
  --s3-gap-logo-name: 40px;
  --s3-gap-name-hash: 12px;

  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
}

.slide[data-slide="3"] .s3-logo-reveal {
  width: var(--s3-logo-width);
  line-height: 0;
}

.slide[data-slide="3"] .s3-couple-reveal {
  width: 512px;
  max-width: 92%;
  margin-top: var(--s3-gap-logo-name);
}

.slide[data-slide="3"] .s3-hashtag-reveal {
  width: 512px;
  max-width: 92%;
  margin-top: var(--s3-gap-name-hash);
}

@keyframes s3BgZoomOut {
  from {
    transform: scale(2);
  }

  to {
    transform: scale(1);
  }
}

@keyframes s3SketchRevealDown {
  to {
    clip-path: inset(0 0 0 0);
    -webkit-clip-path: inset(0 0 0 0);
  }
}

@keyframes s3RevealDown {
  to {
    clip-path: inset(0 0 0 0);
    -webkit-clip-path: inset(0 0 0 0);
  }
}

@keyframes s3BoatIn {
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes s3BoatFloat {
  0%,
  100% {
    transform: translate3d(0, -8px, 0) rotate(-2deg);
  }

  50% {
    transform: translate3d(0, 8px, 0) rotate(2deg);
  }
}

.slide[data-slide="3"].s3-play .s3-bg {
  animation: s3BgZoomOut 2.8s ease-out 0.45s forwards;
}

.slide[data-slide="3"].s3-play .s3-logo-reveal,
.slide[data-slide="3"].s3-play .s3-couple-reveal,
.slide[data-slide="3"].s3-play .s3-hashtag-reveal {
  animation: s3RevealDown 1.55s cubic-bezier(0.33, 1, 0.42, 1) forwards;
  animation-delay: 0.45s;
}

.slide[data-slide="3"].s3-play .s3-boat-wrap {
  animation:
    s3BoatIn 1.2s cubic-bezier(0.22, 0, 0.22, 1) forwards,
    s3BoatFloat 2.8s ease-in-out infinite;
  animation-delay: 2s, 3.2s;
}

/* ── Slide 2 golden reveal (CSS) ── */
.scratch-card.is-golden-reveal .s2-golden-reveal-fx {
  opacity: 1;
}

.scratch-card.is-golden-reveal .s2-golden-trace-lit {
  animation: s2GoldenTrace 2.4s linear forwards;
}

@keyframes s2GoldenTrace {
  to {
    stroke-dashoffset: calc(var(--s2-trace-len, 2200px) * -2);
  }
}

.scratch-card.is-golden-reveal .s2-golden-spark {
  animation: s2SparkTwinkle 0.55s ease forwards;
  animation-delay: calc(0.35s + var(--i, 0) * 0.14s);
}

@keyframes s2SparkTwinkle {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.2);
  }
}

#slides-container.s2-s3-handoff .s1-s2-scratch-stage {
  animation: s2HandoffOut 2.2s ease-in-out forwards;
}

#slides-container.s2-s3-handoff .s1-s2-scratch-stage .anim-scratch-hint,
#slides-container.s2-s3-handoff .s1-s2-scratch-stage .anim-names {
  animation: none !important;
  opacity: 0;
  transition: opacity 1.4s ease;
}

#slides-container.s2-s3-handoff .slide[data-slide="3"] {
  opacity: 1 !important;
  z-index: 25 !important;
  visibility: visible !important;
}

@keyframes s2HandoffOut {
  to {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scratch-card.is-golden-reveal .s2-golden-trace-lit,
  .slide[data-slide="3"] .s3-logo-reveal,
  .slide[data-slide="3"] .s3-couple-reveal,
  .slide[data-slide="3"] .s3-hashtag-reveal {
    clip-path: none !important;
    -webkit-clip-path: none !important;
  }

  .slide[data-slide="3"].s3-play .s3-bg,
  .slide[data-slide="3"].s3-play .s3-logo-reveal,
  .slide[data-slide="3"].s3-play .s3-couple-reveal,
  .slide[data-slide="3"].s3-play .s3-hashtag-reveal,
  .slide[data-slide="3"].s3-play .s3-boat-wrap {
    animation: none !important;
    opacity: 1;
    transform: none;
  }

  .slide[data-slide="3"].s3-play .s3-boat-wrap {
    opacity: 1;
  }
}

@media (hover: none) and (pointer: coarse) {
  .scratch-card.is-golden-reveal .s2-golden-trace-lit {
    animation-duration: 1.4s;
  }

  .scratch-card,
  .scratch-ticket-stack,
  .glitch-ticket-clone {
    will-change: auto;
  }

  /* After entrance settles — mobile canvas visibility (entrance uses animate-in keyframes) */
  .s1-s2-scratch-stage.s2-settled .layer,
  .s1-s2-scratch-stage.s2-settled .s2-scratch-block,
  .s1-s2-scratch-stage.s2-settled .scratch-layer-canvas {
    opacity: 1 !important;
    visibility: visible;
  }

  .s1-s2-scratch-stage.s2-settled .scratch-card {
    pointer-events: auto;
  }
}
