/* ========== Scrolly – shared base styles ========== */

.scrolly[data-scrolly] {
  position: relative;

  /* Configurable via inline style or CSS overrides */
  --sticky-top: 0px;
  --down-vh: 40;
  --slot-start: 0.55;
  --slot-end: 0.75;
  --text-end: 0.55;
  --scroll-length-vh: 300;
  --after-guard-vh: 40;
  --extra-runway-px: 0;

  min-height: max(
    var(--scrolly-height, 0px),
    calc(var(--scroll-length-vh, 300) * 1vh)
  );
  scroll-margin-top: calc(var(--sticky-top, 0px) + env(safe-area-inset-top, 0px));
}

/* ── Sticky viewport ───────────────────────────────────── */
.scrolly [data-scrolly-sticky] {
  position: sticky;
  top: calc(var(--sticky-top, 0px) + env(safe-area-inset-top, 0px));
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  contain: layout paint style;
}

@supports not (height: 100dvh) {
  .scrolly [data-scrolly-sticky] {
    height: calc(100vh - var(--sticky-top, 0px));
  }
}

/* ── Copy (hero text) ──────────────────────────────────── */
.scrolly [data-scrolly-copy] {
  position: relative;
  pointer-events: none;
}

.scrolly .scrolly-title,
.scrolly .scrolly-subtitle,
.scrolly .scrolly-content {
  will-change: transform, opacity;
  backface-visibility: hidden;
}

/* ── Slot (scroll-in content) ──────────────────────────── */
.scrolly [data-scrolly-slot] {
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
  backface-visibility: hidden;
}

.scrolly [data-scrolly-slot].is-active {
  pointer-events: auto;
}

/* ── Reduced motion ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .scrolly .scrolly-title,
  .scrolly .scrolly-subtitle,
  .scrolly .scrolly-content,
  .scrolly [data-scrolly-slot],
  .scrolly [data-scrolly-copy] {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

/* ── Mobile touch devices ──────────────────────────────── */
@media (max-width: 768px) {
  .scrolly[data-scrolly] {
    --scroll-length-vh: 360;
    --slot-start: 0.45;
    --slot-end: 0.70;
    --text-end: 0.50;
    --down-vh: 22;
    --after-guard-vh: 56;
  }
}

@media (max-width: 360px) and (max-height: 640px) {
  .scrolly[data-scrolly] {
    --scroll-length-vh: 320;
    --down-vh: 18;
    --slot-start: 0.42;
    --slot-end: 0.66;
    --after-guard-vh: 48;
  }
}
