/* ================================================
   SAMOYA V11 — PREMIUM MOTION SYSTEM
   Creative Developer Build
   Inspired by: Locomotive, Active Theory, Aristide Benoist
   ================================================ */

/* ---- LENIS SMOOTH SCROLL ---- */
html.lenis, html.lenis body {
  height: auto;
}
.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}
.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

/* ---- PRELOADER ---- */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: #F8F9F5;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.preloader.is-done {
  opacity: 0;
  pointer-events: none;
}
.preloader__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.preloader__logo {
  width: 40px;
  height: 40px;
  opacity: 0.6;
  animation: preloaderPulse 1.5s ease-in-out infinite;
}
@keyframes preloaderPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.05); }
}
.preloader__counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(29, 43, 30, 0.35);
}

/* ---- PAGE TRANSITIONS ---- */
.page-transition {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #1D2B1E;
  transform: scaleY(0);
  transform-origin: bottom;
  pointer-events: none;
  will-change: transform;
}

/* ---- FILM GRAIN OVERLAY ---- */
.grain-overlay {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  animation: grainShift 0.5s steps(4) infinite;
}
@keyframes grainShift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-2%, -3%); }
  50%  { transform: translate(1%, 2%); }
  75%  { transform: translate(-1%, 1%); }
  100% { transform: translate(2%, -2%); }
}

/* ---- SCROLL PROGRESS BAR ---- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, rgba(29, 43, 30, 0.08), rgba(29, 43, 30, 0.25));
  transform-origin: left;
  transform: scaleX(0);
  z-index: 10000;
  pointer-events: none;
  will-change: transform;
}

/* ---- CUSTOM CURSOR ---- */
.custom-cursor {
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(29, 43, 30, 0.25);
  border-radius: 50%;
  position: fixed;
  pointer-events: none;
  z-index: 99998;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              height 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.3s ease,
              background 0.3s ease,
              opacity 0.3s ease;
  transform: translate(-50%, -50%);
  will-change: transform;
  mix-blend-mode: difference;
  opacity: 0;
}
.custom-cursor.is-visible {
  opacity: 1;
}
.custom-cursor.is-hovering {
  width: 56px;
  height: 56px;
  border-color: rgba(29, 43, 30, 0.5);
  background: rgba(29, 43, 30, 0.04);
}
/* Cursor label */
.custom-cursor__label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 7px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(29, 43, 30, 0.7);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.custom-cursor.is-hovering .custom-cursor__label {
  opacity: 1;
}
@media (pointer: coarse) {
  .custom-cursor { display: none; }
}

/* ---- KEN BURNS + PARALLAX IMAGE BREAKS ---- */
.img-break {
  overflow: hidden;
  position: relative;
}
.img-break img {
  will-change: transform;
  transform: scale(1.15);
  transition: none;
}
.img-break .img-break__overlay {
  background: linear-gradient(
    to bottom,
    rgba(29, 43, 30, 0.15) 0%,
    rgba(29, 43, 30, 0.55) 50%,
    rgba(29, 43, 30, 0.15) 100%
  );
  mix-blend-mode: multiply;
}
.img-break__text {
  opacity: 0;
  transform: translateY(40px);
}
.img-break__text.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1),
              transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.img-break--clip {
  clip-path: inset(8% 0);
  transition: clip-path 1s cubic-bezier(0.16, 1, 0.3, 1);
}
.img-break--clip.is-revealed {
  clip-path: inset(0% 0);
}

/* ---- SPLIT TEXT ANIMATION ---- */
.split-word {
  display: inline-block;
  overflow: hidden;
}
.split-word span {
  display: inline-block;
  transform: translateY(110%);
  will-change: transform;
}

/* ---- REVEAL SYSTEM ---- */
.reveal-up {
  opacity: 0;
  transform: translateY(24px);
  will-change: transform, opacity;
}
.reveal-up.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Stagger delays for children */
.stagger-children > * { transition-delay: 0s; }
.stagger-children.is-visible > *:nth-child(1) { transition-delay: 0s; }
.stagger-children.is-visible > *:nth-child(2) { transition-delay: 0.08s; }
.stagger-children.is-visible > *:nth-child(3) { transition-delay: 0.16s; }
.stagger-children.is-visible > *:nth-child(4) { transition-delay: 0.24s; }
.stagger-children.is-visible > *:nth-child(5) { transition-delay: 0.32s; }
.stagger-children.is-visible > *:nth-child(6) { transition-delay: 0.40s; }

/* ---- NUMBER COUNTER ---- */
.counter-value {
  font-variant-numeric: tabular-nums;
}

/* ---- MAGNETIC BUTTONS ---- */
.mag-btn {
  position: relative;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- HORIZONTAL SCROLL SECTION ---- */
.h-scroll-container {
  overflow: hidden;
  position: relative;
}
.h-scroll-track {
  display: flex;
  flex-wrap: nowrap;
  gap: 2rem;
  will-change: transform;
  padding: 0 2rem;
}
.h-scroll-track > * {
  flex-shrink: 0;
  width: 340px;
}
@media (max-width: 768px) {
  .h-scroll-track > * {
    width: 85vw;
  }
}

/* ---- DOT GRID BREATHING ---- */
@keyframes breathe {
  0%, 100% { opacity: 0.06; }
  50% { opacity: 0.14; }
}
.dot-breathe {
  animation: breathe 8s ease-in-out infinite;
}

/* ---- TEXT SCRAMBLE ---- */
.text-scramble {
  font-variant-numeric: tabular-nums;
}
.text-scramble .char {
  display: inline-block;
  will-change: opacity, transform;
}

/* ---- SECTION TRANSITION BLEND ---- */
section {
  position: relative;
  z-index: 1;
}

/* ---- HERO GRADIENT NOISE CANVAS ---- */
.hero-shader-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.12;
  mix-blend-mode: overlay;
}

/* ---- LIQUID DISTORTION CANVAS ---- */
.liquid-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.img-break:hover .liquid-canvas,
div[class*="h-["]:hover .liquid-canvas {
  opacity: 1;
}
@media (pointer: coarse) {
  .liquid-canvas { display: none !important; }
  .hero-shader-canvas { display: none !important; }
}

/* ---- PINNED SECTION HELPERS ---- */
.pin-spacer {
  /* GSAP adds this automatically, but we need overflow visible */
  overflow: visible !important;
}

/* ---- VARIABLE FONT WEIGHT ANIMATION ---- */
.vf-weight {
  font-variation-settings: 'wght' 300;
  transition: font-variation-settings 0.1s ease-out;
}
.vf-weight.is-focused {
  font-variation-settings: 'wght' 500;
}

/* ---- MOBILE SCROLL FIX ---- */
/* Ensure native touch scrolling is never hijacked on mobile */
@media (pointer: coarse) {
  html, body {
    overflow-x: hidden;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: auto;
  }

  /* Kill GSAP pin spacers on mobile — they can trap scroll */
  .pin-spacer {
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Disable film grain on mobile (GPU overhead causes jank) */
  .grain-overlay {
    display: none !important;
  }

  /* Ensure sections are visible even if ScrollTrigger hasn't fired */
  section {
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
  }

  /* Prevent scroll-smooth from conflicting with touch */
  html.scroll-smooth {
    scroll-behavior: auto !important;
  }

  /* Simplify image break transitions on mobile */
  .img-break img {
    transform: none !important;
    will-change: auto;
  }
}
