/**
 * Mikal Stats Premium — Interactive Statistics Section
 * Distinctive aesthetic: deep emerald depth + floating glow orbs
 */

/* ─── Section Wrapper ─── */
.mikal-stats-premium {
    position: relative;
    overflow: hidden;
    padding: 100px 24px 80px;
    background: #070f0a;
    isolation: isolate;
}

@media (min-width: 768px) {
    .mikal-stats-premium {
        padding: 120px 64px 96px;
    }
}

/* ─── Background Layers ─── */
.stats-bg-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.stats-bg-gradient {
    background:
        radial-gradient(ellipse 80% 60% at 20% 30%, rgba(26, 107, 42, 0.25) 0%, transparent 70%),
        radial-gradient(ellipse 60% 50% at 85% 70%, rgba(232, 168, 23, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse 100% 100% at 50% 100%, rgba(10, 60, 20, 0.4) 0%, transparent 50%);
}

.stats-bg-pattern {
    opacity: 0.035;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255,255,255,0.5) 1px, transparent 0);
    background-size: 40px 40px;
}

.stats-bg-glow {
    animation: statsGlowDrift 12s ease-in-out infinite alternate;
    background:
        radial-gradient(circle 300px at 30% 50%, rgba(136, 217, 130, 0.08) 0%, transparent 70%);
}

@keyframes statsGlowDrift {
    0%   { transform: translate(0, 0) scale(1); opacity: 0.6; }
    100% { transform: translate(40px, -20px) scale(1.15); opacity: 1; }
}

/* ─── Container ─── */
.stats-container {
    position: relative;
    z-index: 2;
    max-width: 1280px;
    margin: 0 auto;
}

/* ─── Header ─── */
.stats-header {
    text-align: center;
    margin-bottom: 64px;
}

.stats-eyebrow {
    display: inline-block;
    font-family: 'Cairo', 'Noto Sans Arabic', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(136, 217, 130, 0.7);
    margin-bottom: 16px;
    position: relative;
    padding: 0 24px;
}

.stats-eyebrow::before,
.stats-eyebrow::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 32px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(136, 217, 130, 0.4));
}
.stats-eyebrow::before { right: 100%; }
.stats-eyebrow::after  { left: 100%; transform: scaleX(-1); }

.stats-heading {
    font-family: 'Cairo', 'Noto Sans Arabic', sans-serif;
    font-size: clamp(28px, 5vw, 44px);
    font-weight: 800;
    color: #f0f5ec;
    line-height: 1.3;
    margin: 0 0 20px;
}

.stats-divider {
    width: 64px;
    height: 3px;
    margin: 0 auto;
    background: linear-gradient(90deg, #e8a817, #88d982);
    border-radius: 3px;
    transform-origin: center;
    transform: scaleX(0);
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible .stats-divider,
.reveal.is-visible .stats-divider,
.stats-divider.revealed {
    transform: scaleX(1);
}

/* ─── Stats Grid ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 32px;
    }
}

/* ─── Stat Card ─── */
.stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 16px 32px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                background 0.4s ease,
                border-color 0.4s ease,
                box-shadow 0.5s ease;
    opacity: 0;
    transform: translateY(32px);
    animation: statCardReveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) var(--delay, 0ms) forwards;
}

.stat-card:hover {
    transform: translateY(-6px) scale(1.02);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(136, 217, 130, 0.2);
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.3),
        0 0 80px rgba(136, 217, 130, 0.06);
}

@keyframes statCardReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Ring SVG ─── */
.stat-ring {
    position: absolute;
    top: 12px;
    right: 50%;
    transform: translateX(50%);
    width: 100px;
    height: 100px;
    opacity: 0.12;
    transition: opacity 0.4s ease;
}

.stat-card:hover .stat-ring {
    opacity: 0.22;
}

.stat-ring-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.stat-ring-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 2;
}

.stat-ring-progress {
    fill: none;
    stroke: url(#stat-ring-gradient);
    stroke: #88d982;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-dasharray: 339.29;
    stroke-dashoffset: 339.29;
    animation: ringDraw 1.8s cubic-bezier(0.16, 1, 0.3, 1) var(--progress-delay, 0.5s) forwards;
}

@keyframes ringDraw {
    to {
        stroke-dashoffset: 85;
    }
}

/* ─── Icon ─── */
.stat-icon-wrap {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    z-index: 2;
}

.stat-icon {
    font-size: 32px;
    color: #88d982;
    font-variation-settings: 'FILL' 0, 'wght' 400;
    transition: font-variation-settings 0.3s ease, color 0.3s ease;
    position: relative;
    z-index: 2;
}

.stat-card:hover .stat-icon {
    font-variation-settings: 'FILL' 1, 'wght' 500;
    color: #a3f69c;
}

/* Pulse rings */
.stat-icon-pulse {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 1px solid rgba(136, 217, 130, 0.25);
    animation: iconPulse 3s ease-in-out infinite;
}

.stat-icon-pulse--delayed {
    animation-delay: 1.5s;
    inset: -16px;
    border-color: rgba(136, 217, 130, 0.1);
}

@keyframes iconPulse {
    0%, 100% { transform: scale(0.85); opacity: 0; }
    50%      { transform: scale(1.1);  opacity: 1; }
}

/* ─── Counter Number ─── */
.stat-value-wrap {
    margin-bottom: 8px;
    position: relative;
    z-index: 2;
}

.stat-number {
    font-family: 'Cairo', 'Noto Sans Arabic', sans-serif;
    font-size: clamp(36px, 6vw, 52px);
    font-weight: 900;
    color: #ffffff;
    line-height: 1;
    letter-spacing: -0.02em;
    text-shadow: 0 0 40px rgba(136, 217, 130, 0.2);
    transition: text-shadow 0.4s ease;
    /* Prevent FOUC — show 0 until JS takes over */
    min-width: 2.5ch;
    text-align: center;
}

/* Before animation triggers */
.stat-number.counter-pending {
    visibility: hidden;
}

/* During count-up */
.stat-number.counter-animating {
    visibility: visible;
    animation: counterPulse 0.1s ease-in-out infinite alternate;
}

/* After count completes */
.stat-number.counter-done {
    visibility: visible;
    animation: none;
}

@keyframes counterPulse {
    from { transform: scale(1); }
    to   { transform: scale(1.02); }
}

.stat-card:hover .stat-number {
    text-shadow: 0 0 60px rgba(136, 217, 130, 0.35);
}

/* ─── Label ─── */
.stat-label {
    font-family: 'Cairo', 'Noto Sans Arabic', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: rgba(240, 245, 236, 0.85);
    margin-bottom: 4px;
    position: relative;
    z-index: 2;
}

.stat-desc {
    font-family: 'Noto Sans Arabic', sans-serif;
    font-size: 13px;
    font-weight: 400;
    color: rgba(136, 217, 130, 0.5);
    position: relative;
    z-index: 2;
}

/* ─── Trust Strip ─── */
.stats-trust {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-top: 64px;
    padding-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

@media (min-width: 768px) {
    .stats-trust {
        flex-direction: row;
        justify-content: center;
        gap: 0;
    }
}

.stats-trust-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Cairo', 'Noto Sans Arabic', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: rgba(240, 245, 236, 0.6);
    transition: color 0.3s ease;
}

.stats-trust-item:hover {
    color: rgba(240, 245, 236, 0.9);
}

.stats-trust-item .material-symbols-outlined {
    font-size: 20px;
    color: #e8a817;
}

.stats-trust-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    display: none;
}

@media (min-width: 768px) {
    .stats-trust-divider {
        display: block;
        width: 1px;
        height: 24px;
        margin: 0 32px;
    }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
    .stat-card,
    .stats-divider,
    .stat-ring-progress,
    .stat-icon-pulse,
    .stats-bg-glow,
    .stat-number.counter-animating {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .stat-card {
        opacity: 1;
        transform: none;
    }

    .stat-number.counter-pending,
    .stat-number.counter-done {
        visibility: visible;
    }
}
