/* ========================================
   ANIMATION LAYER — Global Motion System
   ======================================== */

/* ----------------------------------------
   MOTION TOKENS
   ---------------------------------------- */
:root {
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 0.3s;
    --duration-normal: 0.5s;
    --duration-slow: 0.8s;
    --reveal-distance: 24px;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    .reveal { opacity: 1 !important; transform: none !important; }
}

/* ----------------------------------------
   SCROLL REVEAL BASE
   ---------------------------------------- */
.reveal {
    opacity: 0;
    transform: translateY(var(--reveal-distance));
    transition: opacity var(--duration-slow) var(--ease-out-expo),
                transform var(--duration-slow) var(--ease-out-expo);
}

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

/* Stagger delays for grouped items */
.reveal-stagger > .reveal:nth-child(1) { transition-delay: 0s; }
.reveal-stagger > .reveal:nth-child(2) { transition-delay: 0.08s; }
.reveal-stagger > .reveal:nth-child(3) { transition-delay: 0.16s; }
.reveal-stagger > .reveal:nth-child(4) { transition-delay: 0.24s; }
.reveal-stagger > .reveal:nth-child(5) { transition-delay: 0.32s; }
.reveal-stagger > .reveal:nth-child(6) { transition-delay: 0.40s; }
.reveal-stagger > .reveal:nth-child(7) { transition-delay: 0.48s; }

/* ----------------------------------------
   BUTTON INTERACTIONS
   ---------------------------------------- */

/* Solid / Filled buttons — cursor-origin ripple */
.btn-primary,
.btn-submit {
    position: relative;
    overflow: hidden;
    transition: filter var(--duration-fast) var(--ease-in-out);
}

.btn-primary::after,
.btn-submit::after {
    content: '';
    position: absolute;
    left: var(--ripple-x, 50%);
    top: var(--ripple-y, 50%);
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
}

.btn-primary.ripple-active::after,
.btn-submit.ripple-active::after {
    animation: ripple-expand 0.6s var(--ease-out-expo) forwards;
}

@keyframes ripple-expand {
    0% {
        width: 0;
        height: 0;
        opacity: 0.5;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

.btn-primary:hover,
.btn-submit:hover {
    filter: brightness(1.08);
}

/* Outline buttons — fill inward on hover */
.btn-outline-white,
.btn-outline-light,
.btn-secondary {
    position: relative;
    overflow: hidden;
    transition: color var(--duration-fast) var(--ease-in-out);
    z-index: 1;
}

.btn-outline-white::before,
.btn-outline-light::before,
.btn-secondary::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform var(--duration-normal) var(--ease-out-expo),
                opacity var(--duration-normal) var(--ease-out-expo);
    z-index: -1;
}

.btn-outline-white:hover::before,
.btn-outline-light:hover::before,
.btn-secondary:hover::before {
    transform: scaleX(1);
    opacity: 0.1;
}

/* ----------------------------------------
   SECTION LABEL — Dash + Typewriter
   ---------------------------------------- */
.section-label .section-label-dot,
.hero-subtitle-line {
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.4s var(--ease-out-expo);
}

.section-label.is-visible .section-label-dot,
.hero-subtitle-row.is-visible .hero-subtitle-line {
    transform: scaleX(1);
}

.section-label .section-label-text,
.hero-subtitle-row .hero-subtitle-text {
    opacity: 0;
    clip-path: inset(0 100% 0 0);
    transition: opacity 0.4s var(--ease-out-expo) 0.25s,
                clip-path 0.5s var(--ease-out-expo) 0.25s;
}

.section-label.is-visible .section-label-text,
.hero-subtitle-row.is-visible .hero-subtitle-text {
    opacity: 1;
    clip-path: inset(0 0% 0 0);
}

/* ----------------------------------------
   STAT COUNT-UP (handled by JS, these
   ensure the transition feels smooth)
   ---------------------------------------- */
.surface-stat-number,
.surface-stat-desc,
.surface-stat-label {
    transition: opacity var(--duration-normal) var(--ease-out-expo);
}

/* ----------------------------------------
   CARD HOVER MICRO-INTERACTIONS
   ---------------------------------------- */
.ai-card,
.surface-card,
.scenario-card,
.pipeline-step,
.why-pill,
.outcome-pill,
.pill-card,
.detection-card,
.team-card,
.logo-card {
    transition: border-color var(--duration-fast) var(--ease-in-out),
                box-shadow var(--duration-fast) var(--ease-in-out);
}

.ai-card:hover,
.surface-card:hover,
.scenario-card:hover,
.pipeline-step:hover,
.outcome-pill:hover,
.pill-card:hover,
.detection-card:hover,
.team-card:hover {
    box-shadow: 0 0 20px rgba(32, 102, 255, 0.08);
}

.why-pill:hover {
    border-color: rgba(32, 102, 255, 0.6);
}

/* ----------------------------------------
   NAVBAR ENTRANCE
   ---------------------------------------- */
.navbar {
    animation: navbar-slide-down 0.6s var(--ease-out-expo) both;
}

@keyframes navbar-slide-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ----------------------------------------
   HERO ENTRANCE (first section only)
   ---------------------------------------- */
.section-hero .hero-content {
    animation: hero-fade-up 0.9s var(--ease-out-expo) 0.3s both;
}

@keyframes hero-fade-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero illustration fade — preserves translateY(-50%) positioning */
.hero-illustration {
    animation: hero-illustration-in 1.2s var(--ease-out-expo) 0.5s both;
}

@keyframes hero-illustration-in {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}
