/* ==========================================================
   GearShiftBD — Shared Premium Animation System
   Loaded after utilities.css.

   Principles:
   - GPU-only: animate transform + opacity, never layout props
   - No bounce, no spring — sharp decisive luxury motion
   - Duration: 80ms micro / 200ms standard / 400ms entrance
   - Always respect prefers-reduced-motion
   - Hover elevation via translateY, not scale
========================================================== */


/* ── 1. Keyframes ────────────────────────────────────────── */

/* Entrance — page sections, hero content */
@keyframes gs-enter {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* Entrance fast — dropdowns, tooltips, quick UI feedback */
@keyframes gs-enter-fast {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* Enter from left — mobile drawer, side panels */
@keyframes gs-enter-left {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0);     }
}

/* Enter from right — cart drawer */
@keyframes gs-enter-right {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0);    }
}

/* Exit — fade + sink */
@keyframes gs-exit {
  from { opacity: 1; transform: translateY(0);    }
  to   { opacity: 0; transform: translateY(8px);  }
}

/* Scale in — modals, overlays */
@keyframes gs-scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1);    }
}

/* Hero text — extra travel for cinematic entrance */
@keyframes gs-hero-enter {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* Scroll indicator bar */
@keyframes gs-scroll-bar {
  from { transform: translateY(-100%); }
  to   { transform: translateY(200%);  }
}

/* Horizontal marquee — brand strip */
@keyframes gs-marquee {
  from { transform: translateX(0);    }
  to   { transform: translateX(-50%); }
}

/* Shimmer — skeleton loading */
@keyframes gs-shimmer {
  from { background-position: -200% 0; }
  to   { background-position:  200% 0; }
}

/* Pulse dot — live availability indicators */
@keyframes gs-pulse-dot {
  0%, 100% { opacity: 1;   transform: scale(1);    }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

/* Counter — stat number entrance */
@keyframes gs-count-enter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* Accent line — left/bottom decorative reveal */
@keyframes gs-line-x {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@keyframes gs-line-y {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}


/* ── 2. Entrance Utility Classes ─────────────────────────── */
/*
   Usage: add .gs-reveal to any element. JS IntersectionObserver
   adds .is-visible when it enters the viewport.
   Without JS: elements are visible by default (no hidden state
   until JS initialises — graceful degradation).
*/

.gs-reveal {
  opacity: 1; /* Visible by default — JS overrides to 0 */
}

.js-ready .gs-reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s var(--ease-out-fast),
              transform 0.5s var(--ease-out-fast);
  will-change: opacity, transform;
}

.js-ready .gs-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delays — apply as modifier classes */
.js-ready .gs-reveal.delay-1 { transition-delay: 80ms; }
.js-ready .gs-reveal.delay-2 { transition-delay: 160ms; }
.js-ready .gs-reveal.delay-3 { transition-delay: 240ms; }
.js-ready .gs-reveal.delay-4 { transition-delay: 320ms; }
.js-ready .gs-reveal.delay-5 { transition-delay: 400ms; }
.js-ready .gs-reveal.delay-6 { transition-delay: 480ms; }

/* From-left variant */
.js-ready .gs-reveal-left {
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity 0.45s var(--ease-out-fast),
              transform 0.45s var(--ease-out-fast);
  will-change: opacity, transform;
}

.js-ready .gs-reveal-left.is-visible {
  opacity: 1;
  transform: translateX(0);
}

/* Static animation — no JS needed, fires once on load */
.animate-enter {
  animation: gs-enter 0.5s var(--ease-out-fast) both;
}

.animate-enter-fast {
  animation: gs-enter-fast 0.2s var(--ease-out-fast) both;
}

.animate-scale-in {
  animation: gs-scale-in 0.25s var(--ease-out-fast) both;
}

.animate-hero {
  animation: gs-hero-enter 0.75s var(--ease-out-fast) both;
}

/* Stagger delays for static animations */
.animate-delay-1 { animation-delay: 80ms; }
.animate-delay-2 { animation-delay: 160ms; }
.animate-delay-3 { animation-delay: 240ms; }
.animate-delay-4 { animation-delay: 320ms; }
.animate-delay-5 { animation-delay: 480ms; }
.animate-delay-6 { animation-delay: 640ms; }


/* ── 3. Hover Elevation System ───────────────────────────── */
/*
   Elevation is achieved via translateY + shadow — NOT scale.
   Scale distorts text and borders. translateY is clean.
*/

/* Primary lift — product cards, brand cards */
.hover-lift {
  transition: transform  200ms var(--ease-sharp),
              box-shadow 200ms var(--ease-sharp);
  will-change: transform;
}

.hover-lift:hover {
  transform:  translateY(-3px);
  box-shadow: 0 8px 32px rgba(204, 0, 0, 0.12);
}

/* Subtle lift — blog cards, info tiles */
.hover-lift-sm {
  transition: transform  200ms var(--ease-sharp),
              box-shadow 200ms var(--ease-sharp);
  will-change: transform;
}

.hover-lift-sm:hover {
  transform:  translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.40);
}

/* Strong lift — hero CTAs, featured cards */
.hover-lift-lg {
  transition: transform  200ms var(--ease-sharp),
              box-shadow 200ms var(--ease-sharp);
  will-change: transform;
}

.hover-lift-lg:hover {
  transform:  translateY(-5px);
  box-shadow: 0 12px 40px rgba(204, 0, 0, 0.20);
}

/* Reset lift on touch devices — avoid sticky hover states */
@media (hover: none) {
  .hover-lift:hover,
  .hover-lift-sm:hover,
  .hover-lift-lg:hover {
    transform:  translateY(0);
    box-shadow: none;
  }
}


/* ── 4. Brand Glow Hover ─────────────────────────────────── */

.hover-glow {
  transition: box-shadow 200ms var(--ease-sharp),
              border-color 200ms var(--ease-sharp);
}

.hover-glow:hover {
  box-shadow:   0 0 0 1px rgba(204, 0, 0, 0.3),
                0 8px 32px rgba(204, 0, 0, 0.15);
  border-color: var(--stroke-brand);
}


/* ── 5. Product Image Hover ──────────────────────────────── */
/*
   Wrap the <img> in a container with overflow:hidden.
   Apply .img-hover to the container, not the img.
*/

.img-hover {
  overflow: hidden;
}

.img-hover img {
  transition: transform 500ms var(--ease-sharp);
  will-change: transform;
}

.img-hover:hover img {
  transform: scale(1.05);
}

/* Subtle — for blog thumbnails */
.img-hover-sm img { transition: transform 500ms var(--ease-sharp); }
.img-hover-sm:hover img { transform: scale(1.04); }

/* Strong — for category hero cards */
.img-hover-lg img { transition: transform 600ms var(--ease-sharp); }
.img-hover-lg:hover img { transform: scale(1.08); }


/* ── 6. CTA Hover Interactions ───────────────────────────── */
/*
   Arrow icons inside CTAs should translate on parent hover.
   Apply .cta-arrow to the <svg> inside any link/button.
*/

.cta-arrow {
  transition: transform 150ms var(--ease-sharp);
  will-change: transform;
}

a:hover .cta-arrow,
button:hover .cta-arrow,
.group:hover .cta-arrow {
  transform: translateX(3px);
}

/* Diagonal arrow — for external links */
.cta-arrow-diag {
  transition: transform 150ms var(--ease-sharp);
}

a:hover .cta-arrow-diag,
.group:hover .cta-arrow-diag {
  transform: translate(2px, -2px);
}

/* Down arrow — for accordion/expand CTAs */
.cta-arrow-down {
  transition: transform 200ms var(--ease-sharp);
}

.is-open .cta-arrow-down,
[aria-expanded="true"] .cta-arrow-down {
  transform: rotate(180deg);
}


/* ── 7. Decorative Line Reveals ──────────────────────────── */
/*
   Accent lines on cards, category tiles, brand cards.
   Apply to the <div> element, set origin via modifier.
*/

/* Horizontal bottom line — scales in from left */
.line-reveal-x {
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 300ms var(--ease-sharp);
}

.group:hover .line-reveal-x,
.line-reveal-x.is-visible {
  transform: scaleX(1);
}

/* Horizontal — from center */
.line-reveal-x-center {
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 300ms var(--ease-sharp);
}

.group:hover .line-reveal-x-center { transform: scaleX(1); }

/* Vertical left line — scales in from bottom */
.line-reveal-y {
  transform: scaleY(0);
  transform-origin: bottom center;
  transition: transform 300ms var(--ease-sharp);
}

.group:hover .line-reveal-y,
.line-reveal-y.is-visible {
  transform: scaleY(1);
}

/* Top line — scales in from left */
.line-reveal-top {
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 300ms var(--ease-sharp);
}

.group:hover .line-reveal-top { transform: scaleX(1); }


/* ── 8. Overlay Fade ─────────────────────────────────────── */

/* Quick-view, Instagram hover overlays */
.overlay-fade {
  opacity: 0;
  transition: opacity 200ms var(--ease-sharp);
}

.group:hover .overlay-fade,
.overlay-fade.is-visible {
  opacity: 1;
}

/* Slower for hero/full-bleed backgrounds */
.overlay-fade-slow {
  opacity: 0;
  transition: opacity 400ms var(--ease-sharp);
}

.group:hover .overlay-fade-slow { opacity: 1; }


/* ── 9. Text Colour Transitions ──────────────────────────── */

/* Used on headings inside card groups */
.text-hover-brand {
  transition: color var(--transition-base);
}

.group:hover .text-hover-brand { color: var(--red-500); }

.text-hover-primary {
  transition: color var(--transition-base);
}

.group:hover .text-hover-primary { color: var(--ink-primary); }


/* ── 10. Skeleton Loading ────────────────────────────────── */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-1) 25%,
    var(--surface-2) 50%,
    var(--surface-1) 75%
  );
  background-size: 200% 100%;
  animation: gs-shimmer 1.6s linear infinite;
}

/* Rounded variant for avatar/icon placeholders */
.skeleton-circle {
  border-radius: 50%;
}

/* Text-width shimmer lines */
.skeleton-line {
  height: 0.875rem;
  border-radius: 2px;
  margin-bottom: 0.5rem;
}

.skeleton-line-sm  { width: 40%; }
.skeleton-line-md  { width: 65%; }
.skeleton-line-full { width: 100%; }


/* ── 11. Tab / Indicator Transitions ─────────────────────── */

/* Active tab underline — for product showcase tabs */
.tab-indicator {
  position: relative;
}

.tab-indicator::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0; right: 0;
  height: 2px;
  background: var(--red-600);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 150ms var(--ease-sharp);
}

.tab-indicator.is-active::after,
[aria-selected="true"].tab-indicator::after {
  transform: scaleX(1);
}


/* ── 12. Reduced Motion Overrides ────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  /* Disable all entrance animations */
  .gs-reveal,
  .gs-reveal-left,
  .animate-enter,
  .animate-enter-fast,
  .animate-scale-in,
  .animate-hero {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  /* Keep hover feedback, just instant */
  .hover-lift,
  .hover-lift-sm,
  .hover-lift-lg,
  .img-hover img,
  .img-hover-sm img,
  .img-hover-lg img,
  .cta-arrow,
  .line-reveal-x,
  .line-reveal-y,
  .overlay-fade {
    transition-duration: 0ms !important;
  }

  /* Disable looping animations */
  .skeleton,
  .animate-marquee,
  .animate-pulse-dot,
  .animate-scroll-bar {
    animation: none !important;
  }

  /* Header never hides */
  #site-header { transform: none !important; }

  /* Stagger + reveal: show immediately, no motion */
  .gs-stagger > *,
  .gs-reveal,
  .gs-reveal-left {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  /* Images visible without fade */
  .js-ready img[loading="lazy"] {
    opacity: 1 !important;
    transition: none !important;
  }
}


/* ── 13. Motion Duration Tokens ──────────────────────────── */
/*
   Single source of timing truth. Reference these vars instead
   of hardcoded ms values in component-level transitions.
*/
:root {
  --dur-instant:    80ms;   /* micro-feedback: active states, icon swaps */
  --dur-fast:      150ms;   /* button hover, badge swap */
  --dur-base:      220ms;   /* standard UI transitions */
  --dur-slow:      380ms;   /* card reveals, panel opens */
  --dur-enter:     500ms;   /* page section entrances */
  --dur-dramatic:  750ms;   /* hero elements, feature reveals */
  --dur-cinematic: 1100ms;  /* full-bleed image fades, brand moments */
}


/* ── 14. Header Motion ───────────────────────────────────── */
/*
   Three states managed by main.js:
   default             → transparent (Alpine handles bg logic)
   .header--scrolled   → glass/frosted bg (read by Alpine x-bind:class)
   .header--hidden     → translateY(-100%), re-enters on scroll-up
*/

#site-header {
  transition:
    transform        var(--dur-slow) var(--ease-snap),
    background-color var(--dur-base) var(--ease-sharp),
    box-shadow       var(--dur-base) var(--ease-sharp),
    backdrop-filter  var(--dur-base) var(--ease-sharp);
  will-change: transform;
}

#site-header.header--hidden {
  transform: translateY(-100%);
}

/* Mobile: keep header visible — pills nav must stay reachable */
@media (max-width: 1023px) {
  #site-header.header--hidden {
    transform: none;
  }
}

/* Scrolled: glass state (complements Alpine reactive classes) */
#site-header.header--scrolled {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04),
              0 4px 24px rgba(0, 0, 0, 0.45);
}


/* ── 15. Stagger Grid System ─────────────────────────────── */
/*
   .gs-stagger wraps any grid or flex container.
   JS assigns per-child transition-delay, then adds .is-visible.
   Transition fires on opacity + translateY simultaneously.

   Usage:
     <div class="gs-stagger grid grid-cols-4 gap-4">
       <?php while (...): ?>
         <?php get_template_part('template-parts/ui/product-card', ...); ?>
       <?php endwhile; ?>
     </div>
*/

/* Children start hidden (only when JS has loaded) */
.js-ready .gs-stagger > * {
  opacity:    0;
  transform:  translateY(18px);
  transition:
    opacity   var(--dur-slow) var(--ease-out-fast),
    transform var(--dur-slow) var(--ease-out-fast);
  will-change: opacity, transform;
}

/* JS adds .is-visible to parent → children animate in */
.js-ready .gs-stagger.is-visible > * {
  opacity:   1;
  transform: translateY(0);
}

/* Reduced motion: show immediately, no stagger */
@media (prefers-reduced-motion: reduce) {
  .js-ready .gs-stagger > * {
    opacity:   1 !important;
    transform: none !important;
    transition: none !important;
  }
}


/* ── 16. Lazy Image Fade-in ──────────────────────────────── */
/*
   .js-ready gates this — prevents invisible images when JS
   hasn't loaded yet (e.g. script blocked or slow network).
   JS adds .is-loaded synchronously for cached images.
*/

.js-ready img[loading="lazy"] {
  opacity:    0;
  transition: opacity var(--dur-slow) var(--ease-out-fast);
  will-change: opacity;
}

.js-ready img[loading="lazy"].is-loaded {
  opacity: 1;
}

/* Images inside skeleton/placeholder containers */
.img-error {
  position: relative;
}

.img-error::after {
  content:  '';
  position: absolute;
  inset:    0;
  background: var(--surface-2);
}


/* ── 17. Cart Pulse ──────────────────────────────────────── */
/*
   Brief bounce on the cart icon when item is added.
   Keyframe uses scale — only affects a small icon, not layout.
*/

@keyframes gs-cart-pulse {
  0%   { transform: scale(1);    }
  25%  { transform: scale(1.35); }
  55%  { transform: scale(0.92); }
  75%  { transform: scale(1.10); }
  100% { transform: scale(1);    }
}

.cart-pulse {
  animation: gs-cart-pulse 0.55s var(--ease-sharp) both;
}


/* ── 18. Search Bar Transition ───────────────────────────── */
/*
   #search-bar transitions between hidden (default) and .open.
   Uses visibility + opacity combo so it's keyboard-unreachable
   when closed but still accessible with screen readers via aria.
*/

#search-bar {
  opacity:         0;
  transform:       translateY(-8px);
  visibility:      hidden;
  pointer-events:  none;
  transition:
    opacity    var(--dur-base) var(--ease-sharp),
    transform  var(--dur-base) var(--ease-sharp),
    visibility 0ms            linear var(--dur-base);
}

#search-bar.open {
  opacity:        1;
  transform:      translateY(0);
  visibility:     visible;
  pointer-events: auto;
  transition:
    opacity   var(--dur-base) var(--ease-sharp),
    transform var(--dur-base) var(--ease-sharp),
    visibility 0ms linear;
}


/* ── 19. ATC (Add-to-Cart) Button States ─────────────────── */
/*
   WooCommerce adds .loading and .added classes to ATC buttons.
   These provide visual loading / success feedback.
*/

.add_to_cart_button.loading {
  opacity:        0.6;
  pointer-events: none;
  position:       relative;
  overflow:       hidden;
}

/* Shimmer loading stripe */
.add_to_cart_button.loading::after {
  content:    '';
  position:   absolute;
  inset:      0;
  background: linear-gradient(
    90deg,
    transparent        0%,
    rgba(255,255,255,0.15) 50%,
    transparent       100%
  );
  background-size: 200% 100%;
  animation: gs-shimmer 1s linear infinite;
}

.add_to_cart_button.added {
  background-color: var(--red-800) !important;
  transition: background-color var(--dur-fast) var(--ease-sharp);
}


/* ── 21. Focus-Visible Motion ────────────────────────────── */
/*
   Smooth focus ring appearance — subtle scale on the outline
   so keyboard focus feels intentional, not abrupt.
*/

:focus-visible {
  transition: outline-offset var(--dur-fast) var(--ease-out-fast);
}

:focus-visible:not(:focus-visible) {
  outline-offset: 0;
}
