/**
 * DR. MAHAR KASHIF RASHEED — CINEMATIC MOTION ENGINE STYLESHEET
 * Archetype: Premium Clinical / Botanical Luxury
 * Standard Easing: cubic-bezier(0.16, 1, 0.3, 1)
 * Motion Layers: Primary (Feedback), Secondary (Choreography), Ambient (Living System)
 * Zero Layout Thrashing — 100% GPU Accelerated (Transforms & Opacity Only)
 */

:root {
    /* ─── Premium Motion Design Tokens ─── */
    --motion-ease-premium: cubic-bezier(0.16, 1, 0.3, 1);
    --motion-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --motion-ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
    --motion-ease-inout: cubic-bezier(0.65, 0, 0.35, 1);

    --motion-dur-instant: 180ms;
    --motion-dur-fast: 320ms;
    --motion-dur-normal: 480ms;
    --motion-dur-slow: 700ms;
    --motion-dur-cinematic: 950ms;

    /* Lighting & Glare Tints */
    --motion-glare-emerald: radial-gradient(circle at var(--glare-x, 50%) var(--glare-y, 50%), rgba(52, 211, 153, 0.32) 0%, rgba(16, 185, 129, 0.12) 35%, transparent 70%);
    --motion-glare-white: radial-gradient(circle at var(--glare-x, 50%) var(--glare-y, 50%), rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.15) 30%, transparent 65%);
    --motion-glare-sapphire: radial-gradient(circle at var(--glare-x, 50%) var(--glare-y, 50%), rgba(56, 189, 248, 0.3) 0%, rgba(37, 99, 235, 0.1) 40%, transparent 70%);

    --motion-aura-emerald: 0 0 60px rgba(16, 185, 129, 0.22), 0 0 120px rgba(6, 78, 59, 0.14);
}

/* ─────────────────────────────────────────────────────────────
   LAYER 3: AMBIENT LIVING CANVAS (Cellular / Botanical Field)
   ───────────────────────────────────────────────────────────── */
#motion-canvas-ambient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    opacity: 0.88;
    transition: opacity 1.2s var(--motion-ease-premium);
}

body.canvas-loaded #motion-canvas-ambient {
    opacity: 1;
}

/* Ensure foreground sections stay cleanly above canvas */
.hero-section,
.quick-apk-strip,
.section-padding,
.site-footer {
    position: relative;
    z-index: 2;
}

.site-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
}

.modal-overlay {
    position: fixed !important;
    z-index: 9999 !important;
}

.toast-notify {
    position: fixed !important;
    z-index: 99999 !important;
}

/* Ambient glow mesh background */
.hero-section::before {
    content: '';
    position: absolute;
    top: -10%;
    right: 5%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, rgba(2, 132, 199, 0.04) 50%, transparent 70%);
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
    z-index: 0;
    animation: ambientAuraDrift 16s ease-in-out infinite alternate;
}

@keyframes ambientAuraDrift {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
    }
    50% {
        transform: translate3d(-30px, 40px, 0) scale(1.08);
    }
    100% {
        transform: translate3d(25px, -20px, 0) scale(0.96);
    }
}

/* ─────────────────────────────────────────────────────────────
   LAYER 1: 3D CARD TILT MICRO-INTERACTIONS & DYNAMIC GLARE
   ───────────────────────────────────────────────────────────── */
.motion-tilt-container {
    perspective: 1200px;
    transform-style: preserve-3d;
}

.motion-tilt-target {
    position: relative;
    transform-style: preserve-3d;
    transform: perspective(1200px) rotateX(0deg) rotateY(0deg) translate3d(0, 0, 0);
    transition: transform 0.5s var(--motion-ease-premium), box-shadow 0.5s var(--motion-ease-premium);
    backface-visibility: hidden;
}

/* Active tilt movement (JS updates transform directly, no CSS transition delay while tracking) */
.motion-tilt-target.motion-is-tilting {
    transition: none !important;
}

/* Dynamic Glare Overlay */
.motion-glare {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    background: var(--motion-glare-white);
    mix-blend-mode: overlay;
    transition: opacity 0.35s var(--motion-ease-premium);
    overflow: hidden;
}

.motion-glare.is-active {
    opacity: 1;
}

/* Tint variations for glare depending on card type */
.hero-visual-card .motion-glare {
    background: var(--motion-glare-emerald);
    mix-blend-mode: soft-light;
}

.clinic-card.highlight .motion-glare {
    background: var(--motion-glare-sapphire);
    mix-blend-mode: overlay;
}

/* Holographic 3D Lift for Nested Elements */
.motion-tilt-target .motion-3d-child {
    transform-style: preserve-3d;
    transform: translateZ(26px);
    transition: transform 0.4s var(--motion-ease-premium);
}

.motion-tilt-target .motion-3d-deep {
    transform-style: preserve-3d;
    transform: translateZ(42px);
    transition: transform 0.4s var(--motion-ease-premium);
}

/* Specific Card Tilt Enhancements */
.hero-visual-card {
    perspective: 1400px;
    transform-style: preserve-3d;
    transition: transform 0.6s var(--motion-ease-premium), box-shadow 0.6s var(--motion-ease-premium);
}

.hero-visual-card:hover {
    box-shadow: 0 35px 80px -20px rgba(6, 78, 59, 0.28), 0 12px 30px -8px rgba(15, 23, 42, 0.12);
}

.hero-portrait-img {
    transform-style: preserve-3d;
    transform: translateZ(28px);
    transition: transform 0.5s var(--motion-ease-premium), filter 0.5s var(--motion-ease-premium);
}

.hero-visual-card:hover .hero-portrait-img {
    filter: drop-shadow(0 20px 32px rgba(6, 78, 59, 0.24));
}

.clinic-card {
    perspective: 1000px;
    transform-style: preserve-3d;
    transition: transform 0.45s var(--motion-ease-premium), box-shadow 0.45s var(--motion-ease-premium), border-color 0.45s ease;
}

.clinic-card:hover {
    box-shadow: 0 24px 50px -12px rgba(6, 78, 59, 0.18), 0 8px 20px -4px rgba(15, 23, 42, 0.08);
    border-color: rgba(16, 185, 129, 0.45);
}

.bento-card {
    perspective: 1100px;
    transform-style: preserve-3d;
    transition: transform 0.45s var(--motion-ease-premium), box-shadow 0.45s var(--motion-ease-premium), border-color 0.45s ease;
}

.bento-card:hover {
    box-shadow: 0 24px 54px -14px rgba(6, 78, 59, 0.16), 0 6px 18px -4px rgba(15, 23, 42, 0.06);
    border-color: rgba(16, 185, 129, 0.4);
}

.pillar-card {
    perspective: 1000px;
    transform-style: preserve-3d;
    transition: transform 0.45s var(--motion-ease-premium), box-shadow 0.45s var(--motion-ease-premium), border-color 0.45s ease;
}

.pillar-card:hover {
    box-shadow: 0 20px 45px -10px rgba(6, 78, 59, 0.15);
    border-color: rgba(16, 185, 129, 0.35);
}

.testi-card {
    perspective: 1000px;
    transform-style: preserve-3d;
    transition: transform 0.45s var(--motion-ease-premium), box-shadow 0.45s var(--motion-ease-premium);
}

.testi-card:hover {
    box-shadow: 0 22px 48px -12px rgba(15, 23, 42, 0.12);
}

/* ─────────────────────────────────────────────────────────────
   LAYER 1: MAGNETIC CTA BUTTONS & TACTILE RESPONSIVENESS
   ───────────────────────────────────────────────────────────── */
.motion-magnetic-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transform: translate3d(0, 0, 0);
    transition: transform 0.45s var(--motion-ease-premium), box-shadow 0.45s var(--motion-ease-premium);
    will-change: transform;
    isolation: isolate;
}

/* Active magnetic lock (smooth cursor follow) */
.motion-magnetic-btn.motion-is-magnetized {
    transition: none !important;
}

/* Magnetic inner text and icon parallax layer */
.motion-magnetic-inner {
    display: inline-flex;
    align-items: center;
    gap: inherit;
    pointer-events: none;
    transform: translate3d(0, 0, 0);
    transition: transform 0.45s var(--motion-ease-premium);
    will-change: transform;
}

.motion-magnetic-btn.motion-is-magnetized .motion-magnetic-inner {
    transition: none !important;
}

/* Tactile Click Punch */
.motion-magnetic-btn:active {
    transform: scale3d(0.965, 0.965, 1) !important;
    transition: transform 0.12s ease-out !important;
}

/* Soft Spotlight Halo around Primary CTA */
.btn-hero-primary::after,
.btn-download-main::after,
.btn-strip-download::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.5), rgba(37, 99, 235, 0.3));
    z-index: -1;
    opacity: 0;
    filter: blur(8px);
    transition: opacity 0.4s var(--motion-ease-premium);
}

.btn-hero-primary:hover::after,
.btn-download-main:hover::after,
.btn-strip-download:hover::after {
    opacity: 0.9;
}

/* ─────────────────────────────────────────────────────────────
   LAYER 2: SCROLL-DRIVEN PARALLAX (Portrait, Badges & Backdrops)
   ───────────────────────────────────────────────────────────── */
.motion-parallax-portrait {
    will-change: transform;
    transform: translate3d(0, var(--parallax-y, 0px), 0);
    transition: transform 0.12s linear;
}

.floating-badge-top {
    will-change: transform;
    transform: translate3d(0, var(--parallax-badge-top, 0px), 0);
    animation: floatSlowOrbit 7s ease-in-out infinite !important;
}

.floating-badge-bottom {
    will-change: transform;
    transform: translate3d(0, var(--parallax-badge-bottom, 0px), 0);
    animation: floatSlowOrbitReverse 8.5s ease-in-out infinite 1.2s !important;
}

@keyframes floatSlowOrbit {
    0%, 100% {
        transform: translate3d(0, 0, 0) rotate(0deg);
    }
    33% {
        transform: translate3d(3px, -9px, 0) rotate(0.4deg);
    }
    66% {
        transform: translate3d(-2px, -5px, 0) rotate(-0.3deg);
    }
}

@keyframes floatSlowOrbitReverse {
    0%, 100% {
        transform: translate3d(0, 0, 0) rotate(0deg);
    }
    33% {
        transform: translate3d(-3px, -8px, 0) rotate(-0.4deg);
    }
    66% {
        transform: translate3d(2px, -4px, 0) rotate(0.3deg);
    }
}

/* Phone Mockup Smooth Parallax Rise */
.phone-mockup-wrap {
    will-change: transform;
    transform: translate3d(0, var(--parallax-mockup, 0px), 0);
    transition: transform 0.15s linear;
}

.phone-frame {
    transition: transform 0.5s var(--motion-ease-premium), box-shadow 0.5s var(--motion-ease-premium);
}

.phone-frame:hover {
    transform: translateY(-8px) scale(1.015);
    box-shadow: 0 32px 70px -15px rgba(6, 78, 59, 0.35);
}

/* ─────────────────────────────────────────────────────────────
   LAYER 2: TIMELINE CHOREOGRAPHY & STAGGERED ENTRANCES
   ───────────────────────────────────────────────────────────── */
/* Upgraded reveal system with cinematic focus blur and GPU acceleration */
.reveal,
.reveal-left,
.reveal-right,
.reveal-scale,
.motion-stagger-item {
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.reveal {
    opacity: 0;
    transform: translate3d(0, 36px, 0);
    filter: blur(4px);
    transition: opacity 0.75s var(--motion-ease-premium),
                transform 0.75s var(--motion-ease-premium),
                filter 0.75s var(--motion-ease-premium);
}

.reveal.active {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    filter: blur(0px);
}

/* Stagger Delay Matrix */
.motion-stagger-parent .motion-stagger-item,
.bento-grid > .bento-card,
.kitchen-pillars-grid > .pillar-card,
.locations-grid > .clinic-card,
.testimonials-grid > .testi-card,
.hero-stats-grid > .hero-stat-card {
    transition-delay: calc(var(--motion-stagger-index, 0) * 85ms);
}

/* Directional entrance variations */
.reveal-left {
    opacity: 0;
    transform: translate3d(-40px, 0, 0);
    filter: blur(4px);
    transition: opacity 0.8s var(--motion-ease-premium),
                transform 0.8s var(--motion-ease-premium),
                filter 0.8s var(--motion-ease-premium);
}

.reveal-left.active {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    filter: blur(0px);
}

.reveal-right {
    opacity: 0;
    transform: translate3d(40px, 0, 0);
    filter: blur(4px);
    transition: opacity 0.8s var(--motion-ease-premium),
                transform 0.8s var(--motion-ease-premium),
                filter 0.8s var(--motion-ease-premium);
}

.reveal-right.active {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    filter: blur(0px);
}

.reveal-scale {
    opacity: 0;
    transform: scale3d(0.92, 0.92, 1) translate3d(0, 20px, 0);
    filter: blur(4px);
    transition: opacity 0.85s var(--motion-ease-premium),
                transform 0.85s var(--motion-ease-premium),
                filter 0.85s var(--motion-ease-premium);
}

.reveal-scale.active {
    opacity: 1;
    transform: scale3d(1, 1, 1) translate3d(0, 0, 0);
    filter: blur(0px);
}

/* ─────────────────────────────────────────────────────────────
   LAYER 2: SMOOTH NUMBER STATS COUNTERS
   ───────────────────────────────────────────────────────────── */
.hero-stat-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.4s var(--motion-ease-premium), box-shadow 0.4s var(--motion-ease-premium), border-color 0.4s ease;
}

.hero-stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 12px 28px -6px rgba(6, 78, 59, 0.14);
}

.hero-stat-number {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    display: inline-block;
    transition: color 0.3s ease, transform 0.3s var(--motion-ease-spring);
}

.hero-stat-number.counting-active {
    color: var(--primary-600);
}

.hero-stat-number.counting-complete {
    animation: counterPunch 0.4s var(--motion-ease-spring);
}

@keyframes counterPunch {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* ─────────────────────────────────────────────────────────────
   CINEMATIC LIGHTING HIGHLIGHTS & AURA BORDERS
   ───────────────────────────────────────────────────────────── */
/* Pulsing emerald beacon dot in hero badge */
.pulse-dot {
    position: relative;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.8);
    animation: pulseRingGlow 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulseRingGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7), 0 0 10px rgba(16, 185, 129, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0), 0 0 16px rgba(16, 185, 129, 0.6);
    }
}

/* Shimmer highlight line across APK strip */
.quick-apk-strip {
    background-size: 200% 100%;
}

.quick-apk-strip::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(52, 211, 153, 0.12), transparent);
    transform: skewX(-25deg);
    animation: stripShimmerSweep 9s ease-in-out infinite;
    pointer-events: none;
}

@keyframes stripShimmerSweep {
    0% { left: -100%; }
    25% { left: 160%; }
    100% { left: 160%; }
}

/* ─────────────────────────────────────────────────────────────
   MOBILE & TOUCH OPTIMIZATIONS (60FPS LOCKED, ZERO LAYOUT SHIFT)
   ───────────────────────────────────────────────────────────── */

/* Touch Device Graceful Degradation for 3D Tilt & Magnetic Effects */
@media (hover: none), (pointer: coarse) {
    .motion-tilt-container {
        perspective: none !important;
    }

    .motion-tilt-target,
    .hero-visual-card,
    .clinic-card,
    .bento-card,
    .pillar-card,
    .testi-card {
        transform: none !important;
        perspective: none !important;
        transition: transform 0.22s var(--motion-ease-premium), box-shadow 0.22s var(--motion-ease-premium) !important;
    }

    /* Subtle smooth active press feedback on touch devices */
    .motion-tilt-target:active,
    .hero-visual-card:active,
    .clinic-card:active,
    .bento-card:active,
    .pillar-card:active,
    .testi-card:active,
    .motion-touch-active {
        transform: scale(0.985) !important;
    }

    /* Disable dynamic mouse glare on touch */
    .motion-glare {
        display: none !important;
    }

    /* Touch magnetic buttons graceful fallback */
    .motion-magnetic-btn {
        transform: none !important;
        transition: transform 0.2s var(--motion-ease-premium) !important;
    }

    .motion-magnetic-btn:active {
        transform: scale(0.975) !important;
    }

    .motion-magnetic-inner {
        transform: none !important;
    }
}

/* Mobile Screens (< 768px): Prevent Horizontal Overflow & Clamp Badge Shifts */
@media (max-width: 768px) {
    /* Safe directional reveals on mobile: vertical entry eliminates horizontal scrollbars */
    .reveal-left,
    .reveal-right {
        transform: translate3d(0, 24px, 0) !important;
    }

    .reveal-left.active,
    .reveal-right.active {
        transform: translate3d(0, 0, 0) !important;
    }

    /* Floating badges safety clamp on mobile */
    .floating-badge-top {
        left: 0 !important;
        top: 12px !important;
        max-width: calc(100% - 24px);
        transform: translate3d(0, var(--parallax-badge-top, 0px), 0);
    }

    .floating-badge-bottom {
        right: 0 !important;
        bottom: 12px !important;
        max-width: calc(100% - 24px);
        transform: translate3d(0, var(--parallax-badge-bottom, 0px), 0);
    }

    /* Hero portrait contained on mobile */
    .hero-portrait-img {
        max-height: 380px;
        transform: translate3d(0, var(--parallax-y, 0px), 0) !important;
    }
}

/* ─────────────────────────────────────────────────────────────
   ACCESSIBILITY: RESPECT PREFERS-REDUCED-MOTION
   ───────────────────────────────────────────────────────────── */
@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;
    }

    #motion-canvas-ambient {
        display: none !important;
    }

    .reveal,
    .reveal-left,
    .reveal-right,
    .reveal-scale {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
        transition: none !important;
    }

    .floating-badge-top,
    .floating-badge-bottom {
        animation: none !important;
        transform: none !important;
    }

    .motion-tilt-target,
    .hero-visual-card,
    .clinic-card,
    .bento-card,
    .pillar-card,
    .testi-card {
        transform: none !important;
        perspective: none !important;
    }

    .motion-magnetic-btn,
    .motion-magnetic-inner {
        transform: none !important;
    }

    .motion-glare {
        display: none !important;
    }

    .hero-stat-number.counting-complete {
        animation: none !important;
    }
}
