/* ===========================================================================
   FERONEX SPICES THAILAND — MOTION LAYER
   ---------------------------------------------------------------------------
   Rules this file follows:
     - Animate only `transform` and `opacity` (GPU-friendly, 60fps).
     - Scroll reveals are driven by IntersectionObserver (see animations.js),
       which toggles `.is-revealed`. Without JS everything stays visible.
     - Continuous looping motion is switched off on small screens and for
       anyone with `prefers-reduced-motion`.
   ======================================================================== */

/* ---------------------------------------------------------------------------
   KEYFRAMES
------------------------------------------------------------------------- */
@keyframes fx-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-14px); }
}

@keyframes fx-float-soft {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

@keyframes fx-pulse-glow {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%      { opacity: 0.9;  transform: scale(1.06); }
}

@keyframes fx-line-flow {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes fx-spin-slow {
  to { transform: rotate(360deg); }
}

@keyframes fx-hero-slide {
  from { opacity: 0; transform: translate3d(-26px, 16px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes fx-reel-in {
  from { opacity: 0; transform: translate3d(34px, 0, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes fx-fade-up {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fx-scroll-hint {
  0%   { opacity: 0; transform: translateY(-6px); }
  40%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(10px); }
}

/* ---------------------------------------------------------------------------
   SCROLL REVEAL
   Markup: <div data-reveal> or <div data-reveal="left" data-reveal-delay="120">
------------------------------------------------------------------------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity 0.75s var(--ease-out),
    transform 0.75s var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: transform, opacity;
}

[data-reveal='left']  { transform: translateX(-30px); }
[data-reveal='right'] { transform: translateX(30px); }
[data-reveal='scale'] { transform: scale(0.94); }
[data-reveal='fade']  { transform: none; }

[data-reveal].is-revealed {
  opacity: 1;
  transform: none;
  will-change: auto;
}

/* Hero content animates in on load rather than on scroll. */
.hero [data-hero-in] {
  opacity: 0;
  animation: fx-fade-up 0.9s var(--ease-out) forwards;
  animation-delay: var(--hero-delay, 0ms);
}

/* Stagger steps for hero elements — used instead of inline delays. */
.delay-1 { --hero-delay: 80ms; }
.delay-2 { --hero-delay: 160ms; }
.delay-3 { --hero-delay: 260ms; }
.delay-4 { --hero-delay: 340ms; }
.delay-5 { --hero-delay: 420ms; }

/* Copy slides in from the left; the reel settles in from the right. */
.hero__copy [data-hero-in] {
  animation-name: fx-hero-slide;
  animation-duration: 1s;
}

.hero__visual[data-hero-in] {
  animation-name: fx-reel-in;
  animation-duration: 1.2s;
}

/* ---------------------------------------------------------------------------
   HERO 3D COMPOSITION
------------------------------------------------------------------------- */

/* The pack drifts gently; JS adds a mouse-driven tilt on top of this. */
.pack-stage {
  animation: fx-float 7s var(--ease-soft) infinite;
}

.hero__glow {
  animation: fx-pulse-glow 8s var(--ease-soft) infinite;
}

/* Brand statement seed glow. */
.statement__seed {
  animation: fx-pulse-glow 10s var(--ease-soft) infinite;
}

/* Scroll hint under the hero. */
.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  gap: 8px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted-dark);
  pointer-events: none;
}

.scroll-hint__track {
  position: relative;
  width: 22px;
  height: 36px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border-strong);
  overflow: hidden;
}

.scroll-hint__track::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 8px;
  width: 3px;
  height: 7px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--accent);
  animation: fx-scroll-hint 2.2s var(--ease-soft) infinite;
}

/* ---------------------------------------------------------------------------
   SUPPLY-CHAIN FLOW — travelling light along the rail
------------------------------------------------------------------------- */
.flow::after {
  content: '';
  grid-row: 2;
  grid-column: 1 / -1;
  align-self: center;
  height: 2px;
  margin-inline: 7%;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 34% 100%;
  background-repeat: no-repeat;
  animation: fx-line-flow 4.5s linear infinite;
}

/* The horizontal rail becomes a vertical one below 1024px. */
@media (max-width: 1024px) {
  .flow::after {
    display: none;
  }
}

/* The language pill still switches, but instantly, for reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .lang-lever__track::before {
    transition: none !important;
  }
}

/* ---------------------------------------------------------------------------
   MOUSE-FOLLOW AMBIENT GLOW
   A single fixed element whose position is set by animations.js.
------------------------------------------------------------------------- */
.cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  width: 520px;
  height: 520px;
  margin: -260px 0 0 -260px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, rgba(60, 143, 64, 0.11) 0%, transparent 62%);
  transition: opacity 0.6s var(--ease-soft);
  will-change: transform;
}

.cursor-glow.is-active {
  opacity: 1;
}

/* ---------------------------------------------------------------------------
   INTERACTION POLISH
------------------------------------------------------------------------- */

/* Card lift with a light sweep across the surface. */
.glass-card::after {
  pointer-events: none;
}

/* Nav CTA subtle shine on hover. */
.btn--primary {
  position: relative;
  overflow: hidden;
}

.btn--primary::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-120%);
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.4) 50%, transparent 70%);
  transition: transform 0.75s var(--ease-out);
}

.btn--primary:hover::after {
  transform: translateX(120%);
}

/* Header shrink is handled in style.css; this smooths the logo swap. */
.brand__logo,
.brand__logo--mobile {
  transition: height 0.4s var(--ease-out), opacity 0.3s var(--ease-soft);
}

/* ---------------------------------------------------------------------------
   MOBILE: drop continuous looping motion (battery + scroll smoothness)
------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .pack-stage,
  .hero__glow,
  .statement__seed {
    animation: none;
  }

  .cursor-glow {
    display: none;
  }

  [data-reveal] {
    transition-duration: 0.55s;
    transform: translateY(18px);
  }

  [data-reveal='left'],
  [data-reveal='right'] {
    transform: translateY(18px);
  }
}

/* ---------------------------------------------------------------------------
   REDUCED MOTION — honour the OS setting completely
------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  html {
    scroll-behavior: auto;
  }

  [data-reveal],
  .hero [data-hero-in] {
    opacity: 1 !important;
    transform: none !important;
  }

  .cursor-glow,
  .scroll-hint__track::after,
  .flow::after {
    display: none;
  }

  .glass-card:hover,
  .steps__item:hover,
  .flow__step:hover,
  .btn:hover {
    transform: none;
  }
}
