/**
 * MAHI Motors - Master Scroll Entrance & Dynamic Counter Animations
 * Tailored for Commercial Vehicle Dealership UI/UX
 */

/* ==========================================================================
   1. TOP SCROLL READING PROGRESS INDICATOR
   ========================================================================== */
#mahi-scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3.5px;
    background: linear-gradient(90deg, #0F3460 0%, #0F3460 50%, #0F3460 100%);
    box-shadow: 0 0 10px #1e3a8a, 0 0 4px #1e3a8a;
    z-index: 999999;
    pointer-events: none;
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
}

/* ==========================================================================
   2. SCROLL REVEAL ENTRANCE ANIMATIONS
   ========================================================================== */
[data-reveal] {
  opacity: 0;
  will-change: transform, opacity;
  transition-property: opacity, transform;
  transition-duration: 0.75s;
  transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Fade Up (Default) */
[data-reveal="fade-up"],
[data-reveal=""] {
  transform: translateY(32px);
}

/* Fade In */
[data-reveal="fade-in"] {
  transform: translateY(0);
}

/* Slide From Left */
[data-reveal="slide-left"] {
  transform: translateX(-40px);
}

/* Slide From Right */
[data-reveal="slide-right"] {
  transform: translateX(40px);
}

/* Zoom In / Pop */
[data-reveal="zoom-in"] {
  transform: scale(0.92) translateY(20px);
}

/* State when Scrolled into View */
[data-reveal].is-revealed {
  opacity: 1 !important;
  transform: translate(0, 0) scale(1) !important;
}

/* Stagger Delays */
[data-delay="50"] { transition-delay: 0.05s; }
[data-delay="100"] { transition-delay: 0.1s; }
[data-delay="150"] { transition-delay: 0.15s; }
[data-delay="200"] { transition-delay: 0.2s; }
[data-delay="250"] { transition-delay: 0.25s; }
[data-delay="300"] { transition-delay: 0.3s; }
[data-delay="350"] { transition-delay: 0.35s; }
[data-delay="400"] { transition-delay: 0.4s; }
[data-delay="500"] { transition-delay: 0.5s; }

/* Stagger Children Container */
[data-reveal-stagger] > * {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1), transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

[data-reveal-stagger].is-revealed > * {
  opacity: 1;
  transform: translateY(0);
}

[data-reveal-stagger].is-revealed > *:nth-child(1) { transition-delay: 0.05s; }
[data-reveal-stagger].is-revealed > *:nth-child(2) { transition-delay: 0.12s; }
[data-reveal-stagger].is-revealed > *:nth-child(3) { transition-delay: 0.19s; }
[data-reveal-stagger].is-revealed > *:nth-child(4) { transition-delay: 0.26s; }
[data-reveal-stagger].is-revealed > *:nth-child(5) { transition-delay: 0.33s; }
[data-reveal-stagger].is-revealed > *:nth-child(6) { transition-delay: 0.40s; }
[data-reveal-stagger].is-revealed > *:nth-child(7) { transition-delay: 0.47s; }
[data-reveal-stagger].is-revealed > *:nth-child(8) { transition-delay: 0.54s; }

/* ==========================================================================
   3. AUTOMATIC SCROLL COUNTER SYSTEM (UNIQUE DEALERSHIP STYLING)
   ========================================================================== */

/* Counter Numbers with Fixed Monospace Width / Tabular Nums */
.cargo-stat-num,
.cargo-stat-num-about,
.mahi-counter-val {
  font-variant-numeric: tabular-nums !important;
  font-feature-settings: "tnum" 1 !important;
  display: inline-block;
  position: relative;
  letter-spacing: -0.5px;
}

/* Glowing Aura on Counting */
.mahi-counting {
  text-shadow: 0 0 12px rgba(233, 69, 96, 0.25);
}

/* Counter Completion Micro-Flash */
@keyframes mahiCounterFlash {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.06); filter: brightness(1.25); }
  100% { transform: scale(1); filter: brightness(1); }
}

.mahi-counter-done {
  animation: mahiCounterFlash 0.45s ease-out;
}

/* Animated Progress Micro-Track under Counter Cards */
.mahi-counter-track {
  width: 100%;
  height: 3px;
  background: rgba(15, 52, 96, 0.08);
  border-radius: 99px;
  margin-top: 10px;
  overflow: hidden;
  position: relative;
}

.mahi-counter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0F3460, #E94560);
  border-radius: 99px;
  transition: width 1.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.mahi-counter-fill.active {
  width: 100% !important;
}

/* Global Counter Bar Section Styling */
.mahi-counter-bar {
  background: #F1F5F9;
  border-top: 1px solid #E2E8F0;
  border-bottom: 1px solid #E2E8F0;
  padding: 45px 24px;
  position: relative;
  overflow: hidden;
}

.mahi-counter-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #E94560, transparent);
  opacity: 0.6;
}

.mahi-counter-grid {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.mahi-counter-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 15px rgba(15, 52, 96, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.mahi-counter-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 3.5px;
  background: linear-gradient(90deg, #0F3460, #E94560);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mahi-counter-card:hover {
  transform: translateY(-4px);
  border-color: #0F3460;
  box-shadow: 0 12px 28px rgba(15, 52, 96, 0.1);
}

.mahi-counter-card:hover::after {
  opacity: 1;
}

.mahi-counter-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(233, 69, 96, 0.08);
  border: 1px solid rgba(233, 69, 96, 0.2);
  color: #E94560;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 12px;
  transition: transform 0.3s ease, background 0.3s ease;
}

.mahi-counter-card:hover .mahi-counter-icon {
  transform: scale(1.1);
  background: #E94560;
  color: #FFFFFF;
}

.mahi-counter-val {
  font-size: 2.2rem;
  font-weight: 900;
  color: #0F3460;
  line-height: 1.1;
  margin-bottom: 6px;
  font-family: 'Outfit', sans-serif;
}

.mahi-counter-lbl {
  font-size: 0.82rem;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.mahi-counter-sub {
  font-size: 0.72rem;
  color: #94A3B8;
  font-weight: 600;
}

/* ==========================================================================
   4. PAGE LOAD ENTRANCE FOR HERO ELEMENTS
   ========================================================================== */
.hero-entrance-stagger {
  animation: mahiHeroFadeUp 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes mahiHeroFadeUp {
  0% {
    opacity: 0;
    transform: translateY(28px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   5. RESPONSIVENESS & ACCESSIBILITY
   ========================================================================== */
@media (max-width: 992px) {
  .mahi-counter-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
  }
  .mahi-counter-bar {
    padding: 35px 20px;
  }
  .mahi-counter-val {
    font-size: 1.9rem;
  }
}

@media (max-width: 600px) {
  .mahi-counter-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .mahi-counter-card {
    padding: 18px 12px;
    border-radius: 12px;
  }
  .mahi-counter-val {
    font-size: 1.55rem;
  }
  .mahi-counter-lbl {
    font-size: 0.72rem;
  }
  .mahi-counter-icon {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
    margin-bottom: 8px;
  }
}

@media (max-width: 420px) {
  .mahi-counter-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* Accessibility: Respect Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
  [data-reveal],
  [data-reveal-stagger] > * {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  #mahi-scroll-progress {
    display: none !important;
  }
  .mahi-counter-fill {
    transition: none !important;
    width: 100% !important;
  }
}
