/* ============================================================
   Ruth's Pilates Studio — animations & motion
   All entrances are driven by [data-reveal] + IntersectionObserver
   (js/animations.js). Respects prefers-reduced-motion.
   ============================================================ */

/* ---------- Preloader ---------- */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bone);
  transition: clip-path 0.9s var(--ease-lux), visibility 0s linear 0.9s;
  clip-path: inset(0 0 0 0);
}

.preloader.is-done {
  clip-path: inset(0 0 100% 0);
  visibility: hidden;
}

.preloader-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.preloader-brand img {
  width: 4rem;
  animation: preloader-breathe 2.4s var(--ease-soft) infinite;
}

.preloader-brand .preloader-word {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  font-weight: 300;
  letter-spacing: 0.04em;
  overflow: hidden;
}

.preloader-word span {
  display: inline-block;
  animation: preloader-rise 1s var(--ease-lux) both;
}

.preloader-line {
  width: 6rem;
  height: 1px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}

.preloader-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--teal), var(--orange));
  transform-origin: left;
  animation: preloader-fill 1.6s var(--ease-lux) forwards;
}

@keyframes preloader-breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

@keyframes preloader-rise {
  from {
    transform: translateY(110%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes preloader-fill {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* ---------- Page veil (transition curtain) ---------- */
.page-veil {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: var(--ink);
  clip-path: inset(100% 0 0 0);
  pointer-events: none;
  transition: clip-path 0.7s var(--ease-lux);
}

.page-veil.is-covered {
  clip-path: inset(0 0 0 0);
}

.page-veil.is-out {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 0.85s var(--ease-lux) 0.1s;
}

.page-veil.is-instant {
  transition: none !important;
}

/* ---------- Scroll progress line ---------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: 2px;
  background: linear-gradient(90deg, var(--teal), var(--orange));
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0.75;
  pointer-events: none;
}

/* ---------- Scroll reveals ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(1.75rem);
  transition: opacity 1.15s var(--ease-lux), transform 1.3s var(--ease-lux);
  transition-delay: var(--reveal-delay, 0s);
  will-change: opacity, transform;
}

[data-reveal="left"] {
  transform: translateX(-2.5rem);
}

[data-reveal="right"] {
  transform: translateX(2.5rem);
}

[data-reveal="scale"] {
  transform: scale(0.95);
}

[data-reveal="fade"] {
  transform: none;
}

[data-reveal].is-inview {
  opacity: 1;
  transform: none;
}

/* Masked image reveal.
   Note: the clip lives on the inner img, not the observed element —
   Chrome's IntersectionObserver reports a zero intersection for elements
   whose own clip-path hides them, so clipping the frame would prevent
   the reveal from ever firing. */
[data-reveal="mask"] {
  transform: none;
  opacity: 1;
}

[data-reveal="mask"] img {
  clip-path: inset(100% 0 0 0);
  transform: scale(1.15);
  transition: clip-path 1.3s var(--ease-lux), transform 1.6s var(--ease-lux);
}

[data-reveal="mask"].is-inview img {
  clip-path: inset(0 0 0 0);
  transform: scale(1);
}

[data-reveal="mask"] .frame-caption {
  opacity: 0;
  transition: opacity 0.8s ease 0.9s;
}

[data-reveal="mask"].is-inview .frame-caption {
  opacity: 1;
}

/* keep frame hover zoom working after reveal */
[data-reveal="mask"].is-inview.frame:hover img {
  transform: scale(1.04);
}

/* Line-mask text reveal (hero + section titles) */
.reveal-lines .line {
  display: block;
  overflow: hidden;
}

.reveal-lines .line > span {
  display: inline-block;
  transform: translateY(115%);
  transition: transform 1.3s var(--ease-lux);
  transition-delay: calc(var(--line-index, 0) * 0.14s + var(--reveal-delay, 0s));
  will-change: transform;
}

.reveal-lines.is-inview .line > span {
  transform: translateY(0);
}

/* Stagger groups: children get sequential delays via JS */
[data-stagger] > * {
  opacity: 0;
  transform: translateY(1.5rem);
  transition: opacity 1.1s var(--ease-lux), transform 1.2s var(--ease-lux);
  transition-delay: var(--stagger-delay, 0s);
  will-change: opacity, transform;
}

[data-stagger].is-inview > * {
  opacity: 1;
  transform: none;
}

/* ---------- Parallax ---------- */
[data-parallax] {
  will-change: transform;
}

/* ---------- Hero entrance ---------- */
.hero-media img {
  transform: scale(1.12);
  transition: transform 2.4s var(--ease-lux);
}

.is-loaded .hero-media img {
  transform: scale(1);
}

/* ---------- Magnetic ---------- */
[data-magnetic] {
  transition: transform 0.4s var(--ease-soft);
}

/* ---------- Sticky storytelling ---------- */
/* The section is taller than the viewport; its inner pin holds the
   statement in place while the page glides past — a deliberate pause. */
.sticky-story {
  min-height: 165vh;
  padding-block: 0;
  overflow: visible;
}

.sticky-story .sticky-pin {
  position: sticky;
  top: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: clamp(4rem, 10vh, 8rem);
  overflow: hidden;
}

@media (max-width: 60rem) {
  .sticky-story {
    min-height: 0;
  }

  .sticky-story .sticky-pin {
    position: static;
    min-height: 0;
  }
}

/* ---------- Menu aside entrance ---------- */
.menu-aside > * {
  opacity: 0;
  transform: translateY(1rem);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.menu-open .menu-aside > * {
  opacity: 1;
  transform: none;
  transition: opacity 0.9s var(--ease-lux) 0.55s,
    transform 0.9s var(--ease-lux) 0.55s;
}

/* ---------- Floating ornament ---------- */
.float-slow {
  animation: float-slow 7s ease-in-out infinite;
}

@keyframes float-slow {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-0.875rem);
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  [data-reveal],
  [data-reveal="mask"] img,
  [data-stagger] > *,
  .menu-aside > *,
  .reveal-lines .line > span {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
  }

  .preloader,
  .page-veil,
  .scroll-progress {
    display: none;
  }

  .marquee-track {
    animation: none;
  }

  .sticky-story {
    min-height: 0;
  }

  .sticky-story .sticky-pin {
    position: static;
    min-height: 0;
  }
}
