/* =================================================================
   MAMERI EXPORT — Home Premium Animations
   Vanilla adaptation of:
     • ScrollExpandMedia  → hero scroll-to-fullscreen (vídeo principal)
     • ContainerScroll    → 3D card flatten on the secondary video
   + scroll-reveal stagger, parallax, count-up, scroll progress bar.
   Loaded ONLY on the homepage. Desktop-driven; mobile = graceful static.
   ================================================================= */

/* ── Top scroll-progress bar (gold) ──────────────────────────── */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px; width: 0;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
  box-shadow: 0 0 12px rgba(196, 160, 90, 0.55);
  z-index: 9999;
  pointer-events: none;
  will-change: width;
}

/* ═══════════════════════════════════════════════════════════════
   HERO — scroll-expand (ScrollExpandMedia adaptation)
   The video starts framed (letterboxed, rounded) and expands to
   full-bleed as you scroll; the headline drifts up & fades, handing
   off to the page. JS drives clip-path / scale / opacity.
   ═══════════════════════════════════════════════════════════════ */
.hero-stage { position: relative; }

.hero-media {
  position: absolute; inset: 0; z-index: 0;
  overflow: hidden;
}

@media (min-width: 769px) {
  /* Give the sticky hero room to "play" while scrolling */
  .hero-stage      { height: 200vh; background: #0c0a06; }
  .hero-stage .hero {
    position: sticky; top: 0;
    height: 100svh; min-height: 640px;
    background: #0c0a06;
  }
  .hero-media     { will-change: clip-path; clip-path: inset(6.2vw round 28px); }
  .hero-media .hero-vid { transform: scale(1.12); will-change: transform; }
  .hero-content   { will-change: transform, opacity; }
  .hero-scroll-hint { will-change: opacity; }
}

/* ═══════════════════════════════════════════════════════════════
   3D CONTAINER SCROLL (ContainerScroll adaptation)
   The secondary video card rotates from tilted to flat + scales up
   as it scrolls into view. JS sets transform via [data-scroll-tilt].
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  .video-section-inner { perspective: 1600px; }
  .tilt-card {
    transform-style: preserve-3d;
    will-change: transform, opacity;
    transform: perspective(1600px) rotateX(22deg) scale(0.9) translateY(40px);
    opacity: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
   STAGGERED CARD REVEALS (collections + projects)
   Container keeps its .reveal trigger but no longer moves itself;
   children fade/rise in sequence once the container is .visible.
   ═══════════════════════════════════════════════════════════════ */
.cat-cards.reveal,
.proj-preview-grid.reveal { opacity: 1 !important; transform: none !important; }

.cat-cards .cat-card,
.proj-preview-grid .proj-preview-item {
  opacity: 0;
  transform: translateY(38px);
  transition: opacity 0.85s var(--ease), transform 0.85s var(--ease);
}
.cat-cards.visible .cat-card,
.proj-preview-grid.visible .proj-preview-item { opacity: 1; transform: none; }

.cat-cards.visible .cat-card:nth-child(1) { transition-delay: 0.06s; }
.cat-cards.visible .cat-card:nth-child(2) { transition-delay: 0.16s; }
.cat-cards.visible .cat-card:nth-child(3) { transition-delay: 0.26s; }
.cat-cards.visible .cat-card:nth-child(4) { transition-delay: 0.36s; }

.proj-preview-grid.visible .proj-preview-item:nth-child(1) { transition-delay: 0.05s; }
.proj-preview-grid.visible .proj-preview-item:nth-child(2) { transition-delay: 0.13s; }
.proj-preview-grid.visible .proj-preview-item:nth-child(3) { transition-delay: 0.21s; }
.proj-preview-grid.visible .proj-preview-item:nth-child(4) { transition-delay: 0.29s; }
.proj-preview-grid.visible .proj-preview-item:nth-child(5) { transition-delay: 0.37s; }
.proj-preview-grid.visible .proj-preview-item:nth-child(6) { transition-delay: 0.45s; }

/* ═══════════════════════════════════════════════════════════════
   PARALLAX (about image)
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  .about-visual { overflow: hidden; border-radius: 2px; }
  .about-visual .about-img { transform: scale(1.14); will-change: transform; }
}

/* ═══════════════════════════════════════════════════════════════
   COUNT-UP — subtle gold pulse when a stat finishes counting
   ═══════════════════════════════════════════════════════════════ */
.stat-number.counted { animation: statPop 0.5s var(--ease); }
@keyframes statPop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.08); color: var(--gold-light); }
  100% { transform: scale(1); }
}

/* ═══════════════════════════════════════════════════════════════
   RICHER BASELINE REVEAL (gentle blur-in upgrade)
   ═══════════════════════════════════════════════════════════════ */
.reveal           { filter: blur(6px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease), filter 0.9s var(--ease); }
.reveal.visible   { filter: blur(0); }

/* ═══════════════════════════════════════════════════════════════
   SCROLL-VELOCITY MARQUEE (ScrollVelocity adaptation)
   Replaces the static "obras realizadas" grid with two infinite
   horizontal image strips whose speed reacts to scroll velocity.
   ═══════════════════════════════════════════════════════════════ */
.sv-section {
  background: var(--midnight);
  padding-top: var(--section-py);
  padding-bottom: var(--section-py);
  overflow: hidden;
}
.sv-section .eyebrow    { color: rgba(255,255,255,0.38); }
.sv-section .section-title { color: var(--cream); margin-bottom: 0; }

.sv-stage {
  margin-top: clamp(40px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.sv-row {
  overflow: hidden;
  width: 100%;
}

.sv-track {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  will-change: transform;
  /* GPU-accelerate the strip */
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* CSS-driven infinite loop — no JS required to show images */
@keyframes sv-scroll-left {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
@keyframes sv-scroll-right {
  0%   { transform: translateX(-50%); }
  100% { transform: translateX(0); }
}

.sv-left  { animation: sv-scroll-left  42s linear infinite; }
.sv-right { animation: sv-scroll-right 42s linear infinite; }

.sv-item {
  flex-shrink: 0;
  width: clamp(200px, 22vw, 380px);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  position: relative;
  border-radius: 3px;
}

.sv-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  transition: transform 0.55s var(--ease), filter 0.55s ease;
  filter: brightness(0.88) saturate(0.9);
}
.sv-item:hover img {
  transform: scale(1.06);
  filter: brightness(1.05) saturate(1.1);
}

/* ═══════════════════════════════════════════════════════════════
   REDUCED MOTION — disable everything cinematic
   ═══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .hero-stage              { height: auto !important; }
  .hero-stage .hero        { position: relative !important; }
  .hero-media              { clip-path: none !important; }
  .hero-media .hero-vid    { transform: none !important; }
  .hero-content,
  .hero-scroll-hint        { transform: none !important; opacity: 1 !important; }
  .tilt-card               { transform: none !important; opacity: 1 !important; }
  .cat-cards .cat-card,
  .proj-preview-grid .proj-preview-item { opacity: 1; transform: none; transition: none; }
  .about-visual .about-img { transform: none !important; }
  .reveal                  { filter: none; }
  .scroll-progress         { display: none; }
  /* Marquee: pause on reduced-motion */
  .sv-left, .sv-right { animation-play-state: paused !important; }
}
