/* Scroll-driven sticky scale grid (cloned from Kope "Sticky Images" IX2 action a-58).
   Scroll progress through 300svh wrapper drives each cell from 100vw/100vh down to 32.7vw/33.33vh,
   revealing a 3x3 grid. */

.scale-grid-section {
  background-color: var(--base-ananya, #fbfbfb);
}

.scale-grid-section .sticky-wrapper {
  width: 100%;
  height: 300svh;
  position: relative;
  overflow: clip;
}

.scale-grid-section .sticky-images {
  width: 100%;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-flow: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.scale-grid-section .scale-grid {
  width: 100%;
  height: 100%;
  display: flex;
  flex-flow: row;
  justify-content: center;
  align-items: center;
  align-self: center;
  position: relative;
  gap: 1rem;
}

.scale-grid-section .scale-grid-images {
  flex: none;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

.scale-grid-section .scale-grid-images > img,
.scale-grid-section .scale-grid-images > video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scale-grid-section .scale-grid-feature-video {
  isolation: isolate;
}

.scale-grid-section .scale-grid-feature-video > video {
  position: relative;
  z-index: 0;
}

.ananya-video-control {
  position: absolute;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  color: #fff;
  background: rgba(27, 25, 23, 0.2);
  box-shadow: 0 12px 36px rgba(20, 18, 16, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
  cursor: pointer;
  transition: opacity 220ms ease, transform 220ms ease, background-color 220ms ease;
}

.ananya-video-control:hover {
  background: rgba(27, 25, 23, 0.34);
}

.ananya-video-control:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.ananya-video-play {
  top: 50%;
  left: 50%;
  width: 92px;
  height: 92px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.ananya-video-play:hover {
  transform: translate(-50%, -50%) scale(1.04);
}

.ananya-video-play svg {
  width: 30px;
  height: 30px;
  margin-left: 4px;
}

.scale-grid-feature-video.is-playing .ananya-video-play {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.94);
}

.ananya-video-volume {
  left: 22px;
  bottom: 22px;
  width: 52px;
  height: 52px;
  border-radius: 999px;
}

.ananya-video-volume svg {
  width: 21px;
  height: 21px;
}

.ananya-video-volume .ananya-volume-on,
.ananya-video-volume .ananya-volume-off {
  display: none;
}

.ananya-video-volume.is-muted .ananya-volume-off,
.ananya-video-volume:not(.is-muted) .ananya-volume-on {
  display: block;
}

/* Desktop finale: three images on either side of one full-height portrait film.
   The two hidden centre images keep the original 3x3 scale animation geometry,
   while the feature video spans all three rows. */
@media (min-width: 768px) {
  .scale-grid-section .scale-grid-feature-video::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: #d9d1c5 url("/ananya/hero/ananya-feature-poster-4k.webp") center center / cover no-repeat;
    pointer-events: none;
    opacity: 1;
    visibility: visible;
    transition: opacity 240ms ease, visibility 0s linear 0s;
  }

  .scale-grid-section .scale-grid-feature-video.has-started::before {
    opacity: 0;
    visibility: hidden;
    transition: opacity 240ms ease, visibility 0s linear 240ms;
  }

  .scale-grid-section .sticky-images {
    display: grid;
    grid-template-columns: repeat(3, auto);
    grid-template-rows: repeat(3, auto);
    place-content: center;
  }

  .scale-grid-section .scale-grid {
    display: contents;
  }

  .scale-grid-section .scale-grid:nth-child(1) > .scale-grid-images:nth-child(1) { grid-area: 1 / 1; }
  .scale-grid-section .scale-grid:nth-child(1) > .scale-grid-images:nth-child(2) { grid-area: 1 / 2; }
  .scale-grid-section .scale-grid:nth-child(1) > .scale-grid-images:nth-child(3) { grid-area: 1 / 3; }
  .scale-grid-section .scale-grid:nth-child(2) > .scale-grid-images:nth-child(1) { grid-area: 2 / 1; }
  .scale-grid-section .scale-grid:nth-child(2) > .scale-grid-images:nth-child(3) { grid-area: 2 / 3; }
  .scale-grid-section .scale-grid:nth-child(3) > .scale-grid-images:nth-child(1) { grid-area: 3 / 1; }
  .scale-grid-section .scale-grid:nth-child(3) > .scale-grid-images:nth-child(2) { grid-area: 3 / 2; }
  .scale-grid-section .scale-grid:nth-child(3) > .scale-grid-images:nth-child(3) { grid-area: 3 / 3; }

  .scale-grid-section .scale-grid:nth-child(1) > .scale-grid-images:nth-child(2),
  .scale-grid-section .scale-grid:nth-child(3) > .scale-grid-images:nth-child(2) {
    visibility: hidden;
    pointer-events: none;
  }

  .scale-grid-section .scale-grid-feature-video {
    grid-area: 1 / 2 / 4 / 3;
    align-self: center;
    height: 100vh !important;
    z-index: 2;
  }
}

/* On phones the portrait film becomes a clean, edge-to-edge full-screen beat.
   The desktop collage remains untouched above this breakpoint. */
@media (max-width: 767px) {
  .scale-grid-section .sticky-wrapper {
    height: 100svh;
  }

  .scale-grid-section .sticky-images {
    display: block;
    height: 100svh;
  }

  .scale-grid-section .scale-grid {
    display: none;
  }

  .scale-grid-section .scale-grid:nth-child(2) {
    display: block;
    width: 100%;
    height: 100%;
  }

  .scale-grid-section .scale-grid:nth-child(2) > .scale-grid-images:not(.scale-grid-feature-video) {
    display: none;
  }

  .scale-grid-section .scale-grid-feature-video {
    width: 100vw !important;
    height: 100svh !important;
  }

  .ananya-video-play {
    width: 76px;
    height: 76px;
  }

  .ananya-video-volume {
    left: max(16px, env(safe-area-inset-left));
    bottom: max(16px, env(safe-area-inset-bottom));
    width: 48px;
    height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ananya-video-control {
    transition: none;
  }
}
