/**
 * Perfect Solution - Apple-Grade World-Class Motion Design System
 * Grounded in Emil Kowalski's Animation Philosophy & Apple Human Interface Guidelines
 * 
 * Rules:
 * 1. Hardware accelerated only (transform & opacity on compositor).
 * 2. Strictly no 'transition: all' - explicit property declaration.
 * 3. Never scale(0) - entrances start at scale(0.97) or translateY(8-14px).
 * 4. Never ease-in on UI - strictly strong ease-out / Apple spring curves.
 * 5. Respects prefers-reduced-motion & touch hover gating.
 */

:root {
    /* Emil Kowalski's Precision Animation Curves */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);        /* Snappy, responsive UI entrance */
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);    /* Symmetrical spatial movement */
    --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);     /* Apple iOS sheet/drawer curve */
    --spring-smooth: cubic-bezier(0.16, 1, 0.3, 1);   /* Critically damped spring simulation */

    /* Snappy Human-Perception Durations (strictly under 300ms for UI) */
    --dur-instant: 100ms;
    --dur-tactile: 140ms;
    --dur-ui: 220ms;
    --dur-reveal: 320ms;
    --dur-page: 180ms;
}

/* ==========================================================================
   1. NATIVE CROSS-DOCUMENT VIEW TRANSITIONS (Chrome, Edge, Safari 18+)
   ========================================================================== */
@view-transition {
    navigation: auto;
}

/* Persistent UI Chrome (Header & Bottom Dock remain rock-solid across page transitions) */
.glass-nav {
    view-transition-name: site-header;
}

.safe-bottom-dock {
    view-transition-name: site-mobile-dock;
}

::view-transition-old(root) {
    animation: 120ms var(--ease-out) both vt-fade-out;
}

::view-transition-new(root) {
    animation: 180ms var(--ease-out) both vt-fade-in;
}

@keyframes vt-fade-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-4px);
    }
}

@keyframes vt-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   2. PROGRESSIVE ENHANCEMENT PAGE TRANSITIONS (Universal Browser Support)
   ========================================================================== */
.page-wrap {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
    will-change: opacity, transform;
}

body.page-is-exiting .page-wrap {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 120ms var(--ease-out), transform 120ms var(--ease-out);
}

/* ==========================================================================
   3. TACTILE BUTTONS & INTERACTIVE FEEDBACK (Immediate Pointer-Down Response)
   ========================================================================== */
.btn-minimal,
button.btn-tactile,
a.btn-tactile {
    position: relative;
    transition: transform 120ms var(--ease-out), background-color 140ms ease, box-shadow 160ms ease, border-color 140ms ease;
    will-change: transform;
    user-select: none;
    -webkit-user-select: none;
}

/* Instantaneous physical depression on press */
.btn-minimal:active,
button.btn-tactile:active,
a.btn-tactile:active {
    transform: scale(0.97) !important;
}

/* Fine-pointer hover lift (Desktop only) */
@media (hover: hover) and (pointer: fine) {
    .btn-minimal:hover,
    button.btn-tactile:hover,
    a.btn-tactile:hover {
        transform: translateY(-1px);
    }
}

/* ==========================================================================
   4. APPLE FROSTED GLASS NAVIGATION & SCROLL DYNAMICS
   ========================================================================== */
.glass-nav {
    background: rgba(250, 247, 242, 0.88);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(35, 73, 157, 0.08);
    transition: background-color 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}

.glass-nav.is-scrolled {
    background: rgba(250, 247, 242, 0.96);
    box-shadow: 0 4px 24px -2px rgba(35, 73, 157, 0.07);
    border-bottom-color: rgba(35, 73, 157, 0.12);
}

/* Interactive Navigation Links with Smooth Indicator */
.nav-link {
    position: relative;
    transition: color 160ms ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: #23499D;
    border-radius: 9999px;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 200ms var(--ease-out);
    will-change: transform;
}

@media (hover: hover) and (pointer: fine) {
    .nav-link:hover::after {
        transform: scaleX(1);
    }
}

.nav-link.is-active::after {
    transform: scaleX(1);
}

/* ==========================================================================
   5. BENTO CARDS & TACTILE ELEVATION
   ========================================================================== */
.bento-card {
    background: #FFFFFF;
    border: 1px solid rgba(35, 73, 157, 0.08);
    border-radius: 28px;
    box-shadow: 0 4px 20px -2px rgba(35, 73, 157, 0.03);
    transition: transform 240ms var(--ease-out), box-shadow 240ms var(--ease-out), border-color 200ms ease;
    will-change: transform, box-shadow;
}

@media (hover: hover) and (pointer: fine) {
    .bento-card:hover {
        transform: translateY(-3px);
        border-color: rgba(35, 73, 157, 0.18);
        box-shadow: 0 16px 36px -4px rgba(35, 73, 157, 0.08);
    }
}

/* Image Subtle Zoom within Overflow Container */
.card-image-wrap {
    overflow: hidden;
    position: relative;
}

.card-image-wrap img {
    transition: transform 380ms var(--ease-out);
    will-change: transform;
}

@media (hover: hover) and (pointer: fine) {
    .bento-card:hover .card-image-wrap img,
    .card-image-wrap:hover img {
        transform: scale(1.028);
    }
}

/* ==========================================================================
   6. HARDWARE-ACCELERATED STAGGERED SCROLL REVEAL
   ========================================================================== */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 320ms var(--ease-out), transform 320ms var(--ease-out);
    will-change: opacity, transform;
}

.reveal-on-scroll.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Natural Stagger Cascades */
.stagger-1 { transition-delay: 35ms; }
.stagger-2 { transition-delay: 70ms; }
.stagger-3 { transition-delay: 105ms; }
.stagger-4 { transition-delay: 140ms; }
.stagger-5 { transition-delay: 175ms; }
.stagger-6 { transition-delay: 210ms; }

/* ==========================================================================
   7. FAQ ACCORDION TRANSITIONS
   ========================================================================== */
.faq-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 260ms var(--ease-out), opacity 200ms ease;
    will-change: max-height, opacity;
}

.faq-item.is-open .faq-body {
    opacity: 1;
}

.faq-icon {
    transition: transform 220ms var(--spring-smooth);
    will-change: transform;
}

/* ==========================================================================
   8. MOBILE DRAWER NAVIGATION (iOS Fluid Sheet Curve)
   ========================================================================== */
#mobile-nav-overlay {
    transition: opacity 200ms var(--ease-out), visibility 200ms;
}

#mobile-nav-overlay.is-open {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.mobile-nav-content {
    transform: translateY(14px) scale(0.98);
    transition: transform 240ms var(--ease-drawer), opacity 220ms var(--ease-out);
    will-change: transform, opacity;
}

#mobile-nav-overlay.is-open .mobile-nav-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* ==========================================================================
   9. STRICT ACCESSIBILITY (PREFERS-REDUCED-MOTION)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .reveal-on-scroll {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
    .page-wrap {
        transform: none !important;
        transition: opacity 80ms ease !important;
    }
    body.page-is-exiting .page-wrap {
        transform: none !important;
        opacity: 0.9 !important;
    }
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation: none !important;
    }
    .bento-card,
    .btn-minimal,
    .card-image-wrap img,
    .mobile-nav-content {
        transform: none !important;
        transition: none !important;
    }
}
