/**
 * ============================================================================
 * MOBILESKINS ANIMATION & INTERACTION SYSTEM (MASTER SPECIFICATION)
 * public/assets/css/animations.css
 *
 * Modern, High-Performance, Silky Smooth Motion Engine
 * - Hardware-accelerated (transform & opacity only)
 * - CSS Scroll-Driven Animations (@supports animation-timeline: view())
 * - High-precision IntersectionObserver fallback
 * - Cubic-bezier luxury easing (Apple & Stripe inspired)
 * - Zero Layout Shift (CLS = 0)
 * - Full prefers-reduced-motion: reduce accessibility
 * ============================================================================
 */

:root {
  /* Motion Timing Curves */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out-smooth: cubic-bezier(0.65, 0, 0.35, 1);

  /* Duration Standards */
  --dur-instant: 120ms;
  --dur-fast: 220ms;
  --dur-normal: 400ms;
  --dur-enter: 650ms;
  --dur-deliberate: 900ms;

  /* Stagger Step Standard */
  --stagger-step: 75ms;
}

/* ============================================================================
   1. GLOBAL SCROLL READING PROGRESS INDICATOR
   ============================================================================ */
.scroll-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #bf2f2f 0%, #ea580c 35%, #f59e0b 70%, #06b6d4 100%);
  transform-origin: 0% 50%;
  transform: scaleX(0);
  z-index: 100000;
  pointer-events: none;
  transition: transform 0.08s linear;
  will-change: transform;
}

/* ============================================================================
   2. PAGE LOAD ENTRANCE SEQUENCE
   ============================================================================ */
@keyframes pageFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

body.page-loaded {
  animation: pageFadeIn 0.4s var(--ease-smooth) both;
}

/* Staggered Hero Sequence */
@keyframes heroEntranceFadeUp {
  0% {
    opacity: 0;
    transform: translateY(24px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes heroVisualScale {
  0% {
    opacity: 0;
    transform: scale(0.96) translateY(16px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.hero-enter-badge {
  animation: heroEntranceFadeUp var(--dur-enter) var(--ease-out-expo) 0.05s both;
}
.hero-enter-heading {
  animation: heroEntranceFadeUp var(--dur-enter) var(--ease-out-expo) 0.15s both;
}
.hero-enter-sub {
  animation: heroEntranceFadeUp var(--dur-enter) var(--ease-out-expo) 0.28s both;
}
.hero-enter-cta {
  animation: heroEntranceFadeUp var(--dur-enter) var(--ease-out-expo) 0.38s both;
}
.hero-enter-visual {
  animation: heroVisualScale var(--dur-deliberate) var(--ease-out-expo) 0.2s both;
}

/* ============================================================================
   3. UNIVERSAL SCROLL-TRIGGERED UTILITY CLASSES
   ============================================================================ */

/* Initial hidden states (GPU-composited properties only) */
.animate-fade-up,
.reveal,
.reveal-up,
.reveal-section,
[data-animate="fade-up"],
[data-reveal="up"] {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity var(--dur-enter) var(--ease-out-expo),
              transform var(--dur-enter) var(--ease-out-expo);
  will-change: opacity, transform;
}

.animate-fade-down,
[data-animate="fade-down"] {
  opacity: 0;
  transform: translateY(-26px);
  transition: opacity var(--dur-enter) var(--ease-out-expo),
              transform var(--dur-enter) var(--ease-out-expo);
  will-change: opacity, transform;
}

.animate-fade-left,
.reveal-left,
[data-animate="fade-left"],
[data-reveal="left"] {
  opacity: 0;
  transform: translateX(-36px);
  transition: opacity var(--dur-enter) var(--ease-out-expo),
              transform var(--dur-enter) var(--ease-out-expo);
  will-change: opacity, transform;
}

.animate-fade-right,
.reveal-right,
[data-animate="fade-right"],
[data-reveal="right"] {
  opacity: 0;
  transform: translateX(36px);
  transition: opacity var(--dur-enter) var(--ease-out-expo),
              transform var(--dur-enter) var(--ease-out-expo);
  will-change: opacity, transform;
}

.animate-scale,
.reveal-zoom,
.reveal-scale,
[data-animate="scale"],
[data-reveal="zoom"],
[data-reveal="scale"] {
  opacity: 0;
  transform: scale(0.93) translateY(18px);
  transition: opacity var(--dur-enter) var(--ease-out-expo),
              transform var(--dur-enter) var(--ease-out-expo);
  will-change: opacity, transform;
}

.animate-pop,
.reveal-pop,
[data-animate="pop"],
[data-reveal="pop"] {
  opacity: 0;
  transform: scale(0.86);
  transition: opacity var(--dur-normal) var(--ease-out-back),
              transform var(--dur-normal) var(--ease-out-back);
  will-change: opacity, transform;
}

/* Text Mask Reveal */
.animate-reveal,
.text-reveal,
[data-animate="reveal"] {
  opacity: 0;
  clip-path: inset(0 0 100% 0);
  transform: translateY(16px);
  transition: opacity var(--dur-enter) var(--ease-out-expo),
              clip-path var(--dur-enter) var(--ease-out-expo),
              transform var(--dur-enter) var(--ease-out-expo);
  will-change: opacity, clip-path, transform;
}

/* Image Reveal (Soft Zoom Transition) */
.img-reveal-wrap {
  overflow: hidden;
  position: relative;
}
.img-reveal-wrap img,
.img-reveal {
  opacity: 0;
  transform: scale(1.06);
  transition: opacity 0.8s var(--ease-smooth),
              transform 0.9s var(--ease-out-expo);
  will-change: opacity, transform;
}

/* Visible Trigger State (Set by Observer) */
.is-visible,
.is-revealed {
  opacity: 1 !important;
  transform: translate(0, 0) scale(1) !important;
}

.animate-reveal.is-visible,
.text-reveal.is-visible {
  clip-path: inset(0 0 0% 0) !important;
}

.img-reveal-wrap.is-visible img,
.img-reveal.is-visible {
  opacity: 1 !important;
  transform: scale(1) !important;
}

/* ============================================================================
   4. CSS SCROLL-DRIVEN ANIMATIONS (PROGRESSIVE ENHANCEMENT)
   Where supported, uses zero-overhead hardware view-timelines.
   ============================================================================ */
@supports ((animation-timeline: view()) and (animation-range: entry)) {
  @keyframes cssViewFadeUp {
    0% {
      opacity: 0;
      transform: translateY(28px);
    }
    100% {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes cssViewScale {
    0% {
      opacity: 0;
      transform: scale(0.94) translateY(16px);
    }
    100% {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  .scroll-driven-view-up {
    animation: cssViewFadeUp linear both;
    animation-timeline: view();
    animation-range: entry 10% cover 30%;
  }

  .scroll-driven-view-scale {
    animation: cssViewScale linear both;
    animation-timeline: view();
    animation-range: entry 10% cover 32%;
  }
}

/* ============================================================================
   5. STAGGER CASCADE DELAYS
   ============================================================================ */
.delay-1,  .stagger-1  { transition-delay: 0.06s !important; }
.delay-2,  .stagger-2  { transition-delay: 0.12s !important; }
.delay-3,  .stagger-3  { transition-delay: 0.18s !important; }
.delay-4,  .stagger-4  { transition-delay: 0.24s !important; }
.delay-5,  .stagger-5  { transition-delay: 0.30s !important; }
.delay-6,  .stagger-6  { transition-delay: 0.36s !important; }
.delay-7,  .stagger-7  { transition-delay: 0.42s !important; }
.delay-8,  .stagger-8  { transition-delay: 0.48s !important; }
.delay-9,  .stagger-9  { transition-delay: 0.54s !important; }
.delay-10, .stagger-10 { transition-delay: 0.60s !important; }
.delay-11, .stagger-11 { transition-delay: 0.66s !important; }
.delay-12, .stagger-12 { transition-delay: 0.72s !important; }

/* Dynamic Nth-Child Staggering inside Staggered Containers */
.animate-stagger > *:nth-child(1)  { transition-delay: 0.05s; }
.animate-stagger > *:nth-child(2)  { transition-delay: 0.11s; }
.animate-stagger > *:nth-child(3)  { transition-delay: 0.17s; }
.animate-stagger > *:nth-child(4)  { transition-delay: 0.23s; }
.animate-stagger > *:nth-child(5)  { transition-delay: 0.29s; }
.animate-stagger > *:nth-child(6)  { transition-delay: 0.35s; }
.animate-stagger > *:nth-child(7)  { transition-delay: 0.41s; }
.animate-stagger > *:nth-child(8)  { transition-delay: 0.47s; }
.animate-stagger > *:nth-child(9)  { transition-delay: 0.53s; }
.animate-stagger > *:nth-child(10) { transition-delay: 0.59s; }
.animate-stagger > *:nth-child(11) { transition-delay: 0.65s; }
.animate-stagger > *:nth-child(12) { transition-delay: 0.71s; }

/* ============================================================================
   6. STICKY HEADER SCROLL TRANSITION
   ============================================================================ */
.app-header {
  transition: background var(--dur-fast) var(--ease-smooth),
              box-shadow var(--dur-fast) var(--ease-smooth),
              padding var(--dur-fast) var(--ease-smooth),
              backdrop-filter var(--dur-fast) var(--ease-smooth);
}

.app-header.header-compact,
.app-header.scrolled {
  padding-top: 10px !important;
  padding-bottom: 10px !important;
  background: rgba(255, 255, 255, 0.94) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.08) !important;
  border-bottom-color: rgba(226, 232, 240, 0.8) !important;
}

/* Nav Link Subtle Animated Indicator */
.header-nav-desktop a {
  position: relative;
  transition: color var(--dur-fast) var(--ease-smooth);
}
.header-nav-desktop a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--brand-primary, #bf2f2f);
  border-radius: 999px;
  transition: width var(--dur-fast) var(--ease-out-expo),
              left var(--dur-fast) var(--ease-out-expo);
  pointer-events: none;
}
.header-nav-desktop a:hover::after,
.header-nav-desktop a.active::after {
  width: 70%;
  left: 15%;
}

/* ============================================================================
   7. CARD & IMAGE HOVER MICRO-INTERACTIONS
   ============================================================================ */
.product-card,
.catalog-card,
.white-card,
.capes-category-card,
.capes-device-box,
.capes-bento-card,
.bento-card,
.feature-card,
.review-card,
.step-card,
.material-card,
.faq-item,
.legal-card,
.blog-card {
  transition: transform var(--dur-fast) var(--ease-out-expo),
              box-shadow var(--dur-fast) var(--ease-out-expo),
              border-color var(--dur-fast) var(--ease-smooth);
  will-change: transform, box-shadow;
}

.product-card:hover,
.catalog-card:hover,
.capes-bento-card:hover,
.bento-card:hover,
.material-card:hover,
.review-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 36px -6px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(191, 47, 47, 0.12);
}

/* Interactive Card Image Subtle Zoom */
.product-card .card-thumb-wrap img,
.product-card .product-thumb,
.catalog-card img,
.capes-bento-img,
.capes-journey-photo img {
  transition: transform 0.45s var(--ease-out-expo);
}
.product-card:hover .card-thumb-wrap img,
.product-card:hover .product-thumb,
.catalog-card:hover img,
.capes-bento-card:hover .capes-bento-img,
.capes-journey-photo:hover img {
  transform: scale(1.045);
}

/* ============================================================================
   8. BUTTON & CTA MICRO-INTERACTIONS
   ============================================================================ */
.btn-capes-primary,
.btn-capes-outline,
.btn-neon-primary,
.btn-primary,
.btn-capes-hero-cta,
.btn-capes-hero-secondary,
.btn-detect-jump {
  transition: transform var(--dur-fast) var(--ease-out-expo),
              box-shadow var(--dur-fast) var(--ease-out-expo),
              background var(--dur-fast) var(--ease-smooth),
              border-color var(--dur-fast) var(--ease-smooth);
}

.btn-capes-primary:hover,
.btn-neon-primary:hover,
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -3px rgba(191, 47, 47, 0.38);
}

.btn-capes-primary:active,
.btn-capes-outline:active,
.btn-neon-primary:active,
.btn-primary:active,
.btn-capes-hero-cta:active,
.btn-capes-hero-secondary:active,
.icon-btn:active {
  transform: scale(0.96) !important;
}

/* Button Arrow Interactive Shift */
.btn-arrow svg,
.btn-arrow .cta-arrow,
.btn-capes-primary .cta-arrow,
.btn-capes-hero-cta .cta-arrow {
  display: inline-block;
  transition: transform var(--dur-fast) var(--ease-out-expo);
}
.btn-arrow:hover svg,
.btn-arrow:hover .cta-arrow,
.btn-capes-primary:hover .cta-arrow,
.btn-capes-hero-cta:hover .cta-arrow {
  transform: translateX(4px);
}

/* ============================================================================
   9. FAQ ACCORDION SMOOTH HEIGHT EXPANSION
   Grid-based zero-CLS smooth expansion with rotating icon (+ to ×)
   ============================================================================ */
.faq-accordion-item,
.faq-item,
.home-faq-item {
  transition: border-color var(--dur-fast) var(--ease-smooth),
              box-shadow var(--dur-fast) var(--ease-smooth);
}

.faq-accordion-item.active,
.faq-item.active,
.home-faq-item.active {
  border-color: rgba(191, 47, 47, 0.35) !important;
  box-shadow: 0 6px 18px -4px rgba(15, 23, 42, 0.06);
}

/* Accordion Rotating Icon (+ to ×) */
.faq-icon,
.home-faq-item .faq-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  transition: transform 0.28s var(--ease-out-expo), color 0.2s ease;
  transform-origin: center center;
}

.faq-item.active .faq-icon,
.home-faq-item.active .faq-icon,
.faq-accordion-item.active .faq-icon {
  transform: rotate(45deg);
  color: var(--brand-primary, #bf2f2f);
}

/* CSS Grid Smooth Height Wrapper */
.faq-answer-collapse {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s var(--ease-out-expo),
              opacity 0.25s var(--ease-smooth);
  opacity: 0;
}
.faq-answer-collapse.open,
.faq-item.active .faq-answer-collapse,
.home-faq-item.active .faq-answer-collapse {
  grid-template-rows: 1fr;
  opacity: 1;
}
.faq-answer-collapse > .faq-answer-content {
  overflow: hidden;
  min-height: 0;
}

/* ============================================================================
   10. FORM INPUT MICRO-INTERACTIONS
   ============================================================================ */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  transition: border-color var(--dur-fast) var(--ease-smooth),
              box-shadow var(--dur-fast) var(--ease-smooth),
              background var(--dur-fast) var(--ease-smooth);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-primary, #bf2f2f) !important;
  box-shadow: 0 0 0 3px rgba(191, 47, 47, 0.14) !important;
}

/* Form Submit Loading Pulse */
.btn-is-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
}
.btn-is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: btnSpinner 0.6s linear infinite;
}
@keyframes btnSpinner {
  to { transform: rotate(360deg); }
}

/* ============================================================================
   11. MOBILE DRAWER NAVIGATION STAGGER
   ============================================================================ */
.mobile-app-drawer.active .mobile-drawer-nav a {
  animation: drawerItemEnter 0.35s var(--ease-out-expo) both;
}
.mobile-app-drawer.active .mobile-drawer-nav a:nth-child(1) { animation-delay: 0.05s; }
.mobile-app-drawer.active .mobile-drawer-nav a:nth-child(2) { animation-delay: 0.09s; }
.mobile-app-drawer.active .mobile-drawer-nav a:nth-child(3) { animation-delay: 0.13s; }
.mobile-app-drawer.active .mobile-drawer-nav a:nth-child(4) { animation-delay: 0.17s; }
.mobile-app-drawer.active .mobile-drawer-nav a:nth-child(5) { animation-delay: 0.21s; }
.mobile-app-drawer.active .mobile-drawer-nav a:nth-child(6) { animation-delay: 0.25s; }

@keyframes drawerItemEnter {
  0% {
    opacity: 0;
    transform: translateX(18px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Animated Hamburger Morph */
.mobile-menu-toggle-btn svg line {
  transition: transform 0.25s var(--ease-out-expo), opacity 0.2s ease;
  transform-origin: center;
}
.mobile-menu-toggle-btn.is-active svg line:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.mobile-menu-toggle-btn.is-active svg line:nth-child(2) {
  opacity: 0;
}
.mobile-menu-toggle-btn.is-active svg line:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ============================================================================
   12. AMBIENT BACKGROUND GLOW PULSE
   ============================================================================ */
@keyframes ambientGlowPulse {
  0%, 100% {
    opacity: 0.35;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(1.08);
  }
}

.ambient-glow-pulse {
  animation: ambientGlowPulse 8s ease-in-out infinite;
  will-change: transform, opacity;
}

/* ============================================================================
   13. MOBILE RESPONSIVE TUNING (ZERO HORIZONTAL OVERFLOW, REDUCED MOTION DISTANCE)
   ============================================================================ */
@media (max-width: 768px) {
  /* Prevent horizontal scrollbars caused by translates */
  body, html {
    overflow-x: clip;
  }

  /* Reduce animation travel distance on mobile for snappy performance */
  .animate-fade-up,
  .reveal,
  .reveal-up,
  .reveal-section,
  [data-animate="fade-up"],
  [data-reveal="up"] {
    transform: translateY(16px);
  }

  .animate-fade-left,
  .reveal-left,
  [data-animate="fade-left"] {
    transform: translateX(-16px);
  }

  .animate-fade-right,
  .reveal-right,
  [data-animate="fade-right"] {
    transform: translateX(16px);
  }

  /* Disable mouse-tracking parallax on mobile */
  [data-parallax] {
    transform: none !important;
  }

  /* Tone down card hover elevates on touch screens */
  .product-card:hover,
  .catalog-card:hover,
  .material-card:hover,
  .review-card:hover {
    transform: none;
  }
}

/* ============================================================================
   14. STRICT ACCESSIBILITY: PREFERS-REDUCED-MOTION: REDUCE
   Completely complies with user OS motion preferences.
   Instant visibility, zero disorientation, zero layout shifts.
   ============================================================================ */
@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;
  }

  .animate-fade-up,
  .animate-fade-down,
  .animate-fade-left,
  .animate-fade-right,
  .animate-scale,
  .animate-pop,
  .animate-reveal,
  .text-reveal,
  .img-reveal,
  .reveal,
  .reveal-up,
  .reveal-left,
  .reveal-right,
  .reveal-zoom,
  .reveal-scale,
  .reveal-pop,
  [data-animate],
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    transition: none !important;
    animation: none !important;
  }

  .scroll-progress-bar {
    display: none !important;
  }

  [data-parallax] {
    transform: none !important;
  }

  .topbar-ticker-track {
    animation: none !important;
  }
}
