/**
 * Brahmanath Clinic - Cinematic Animation & Motion System
 * Upgraded with:
 * 1. Desktop Custom Cursor & Follower
 * 2. Seamless Page-to-Page Multipage Transitions
 * 3. Directional Image Masks & Wipes
 * 4. Staggered Mobile Menu Reveals
 * 5. Button Magnetic Shimmer & Elevation
 * 6. Full Reduced-Motion & Touch Overrides
 */

/* ==========================================================================
   1. Base Visibility & Progressive Enhancement Fallback
   ========================================================================== */
.reveal-init {
    opacity: 1;
    transform: none;
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

html:not(.no-js) .reveal-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    will-change: opacity, transform;
    transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1), transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html:not(.no-js) .reveal-left {
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1), transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}
html:not(.no-js) .reveal-left.is-revealed {
    opacity: 1;
    transform: translateX(0);
}

html:not(.no-js) .reveal-right {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1), transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}
html:not(.no-js) .reveal-right.is-revealed {
    opacity: 1;
    transform: translateX(0);
}

html:not(.no-js) .reveal-scale {
    opacity: 0;
    transform: scale(0.94);
    transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1), transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}
html:not(.no-js) .reveal-scale.is-revealed {
    opacity: 1;
    transform: scale(1);
}

/* Directional Image Mask Reveal */
html:not(.no-js) .reveal-mask {
    clip-path: inset(0 0 100% 0 round 16px);
    transition: clip-path 0.9s cubic-bezier(0.16, 1, 0.3, 1), transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}
html:not(.no-js) .reveal-mask.is-revealed {
    clip-path: inset(0 0 0% 0 round 16px);
}

/* When GSAP is active, disable CSS transitions on tweened properties to eliminate jitter & stutter */
html.gsap-active .reveal-on-scroll,
html.gsap-active .reveal-left,
html.gsap-active .reveal-right,
html.gsap-active .reveal-scale,
html.gsap-active .service-card,
html.gsap-active .doctor-card,
html.gsap-active .insight-card,
html.gsap-active .journey-step {
    transition: none !important;
}

/* ==========================================================================
   2. Desktop Custom Cursor (Fine Pointer Only)
   ========================================================================== */
.custom-cursor {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    .custom-cursor {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 999999;
        pointer-events: none;
        will-change: transform;
    }

    .cursor-dot {
        position: fixed;
        top: 0;
        left: 0;
        width: 8px;
        height: 8px;
        background-color: #2E7D32;
        border-radius: 50%;
        transform: translate(-50%, -50%);
        pointer-events: none;
        box-shadow: 0 0 10px rgba(46, 125, 50, 0.7);
        transition: opacity 0.2s ease, transform 0.15s ease-out;
    }

    .cursor-follower {
        position: fixed;
        top: 0;
        left: 0;
        width: 38px;
        height: 38px;
        border: 1.5px solid rgba(140, 83, 37, 0.45);
        background-color: rgba(140, 83, 37, 0.04);
        border-radius: 50%;
        transform: translate(-50%, -50%);
        pointer-events: none;
        display: flex;
        align-items: center;
        justify-content: center;
        backdrop-filter: blur(0.5px);
        -webkit-backdrop-filter: blur(0.5px);
        transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                    height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                    background-color 0.3s ease,
                    border-color 0.3s ease,
                    box-shadow 0.3s ease,
                    opacity 0.2s ease;
    }

    .cursor-label {
        opacity: 0;
        transform: scale(0.7);
        font-size: 0.65rem;
        font-weight: 700;
        color: #FFFFFF;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        pointer-events: none;
        transition: opacity 0.2s ease, transform 0.2s ease;
    }

    /* Hover States */
    .custom-cursor.cursor-hover .cursor-follower {
        width: 52px;
        height: 52px;
        background-color: rgba(140, 83, 37, 0.12);
        border-color: #8C5325;
    }
    .custom-cursor.cursor-hover .cursor-dot {
        transform: translate(-50%, -50%) scale(0.6);
        background-color: #2E7D32;
    }

    /* Hover CTA State */
    .custom-cursor.cursor-hover-cta .cursor-follower {
        width: 66px;
        height: 66px;
        background-color: rgba(140, 83, 37, 0.18);
        border-color: #8C5325;
        box-shadow: 0 0 24px rgba(140, 83, 37, 0.30);
    }
    .custom-cursor.cursor-hover-cta .cursor-dot {
        transform: translate(-50%, -50%) scale(0.4);
    }

    /* Hover View/Explore State on Visual Panels */
    .custom-cursor.cursor-view .cursor-follower {
        width: 76px;
        height: 76px;
        background-color: rgba(36, 22, 13, 0.94);
        border-color: rgba(140, 83, 37, 0.7);
        box-shadow: 0 8px 30px rgba(36, 22, 13, 0.35);
    }
    .custom-cursor.cursor-view .cursor-dot {
        opacity: 0;
    }
    .custom-cursor.cursor-view .cursor-label {
        opacity: 1;
        transform: scale(1);
    }

    /* Hidden State (When leaving window or hovering text inputs) */
    .custom-cursor.cursor-hidden {
        opacity: 0;
    }
}

/* ==========================================================================
   3. Multipage Coordinated Transition System
   ========================================================================== */
.page-transition {
    position: fixed;
    inset: 0;
    z-index: 99999;
    pointer-events: none;
    visibility: hidden;
    overflow: hidden;
}

.page-transition.is-active {
    visibility: visible;
    pointer-events: auto;
}

.page-transition__curtain {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: translateY(100%);
    will-change: transform;
}

.page-transition__curtain--primary {
    background-color: #24160D;
    z-index: 2;
    transition: transform 0.42s cubic-bezier(0.77, 0, 0.175, 1);
}

.page-transition__curtain--secondary {
    background-color: #2E7D32;
    z-index: 1;
    transition: transform 0.48s cubic-bezier(0.77, 0, 0.175, 1);
}

/* Exiting Current Page */
.page-transition.is-leaving .page-transition__curtain--secondary {
    transform: translateY(0%);
}
.page-transition.is-leaving .page-transition__curtain--primary {
    transform: translateY(0%);
    transition-delay: 0.05s;
}

/* Entering Destination Page */
.page-transition.is-entering .page-transition__curtain--primary {
    transform: translateY(-100%);
}
.page-transition.is-entering .page-transition__curtain--secondary {
    transform: translateY(-100%);
    transition-delay: 0.05s;
}

.page-transition__content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.page-transition.is-leaving .page-transition__content {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    transition-delay: 0.15s;
}

.page-transition.is-entering .page-transition__content {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.95);
}

.page-transition__text {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: #FFFFFF;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   4. Staggered Mobile Menu Reveal
   ========================================================================== */
.mobile-drawer__item {
    opacity: 0;
    transform: translateX(25px);
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-drawer.is-open .mobile-drawer__item:nth-child(1) { transition-delay: 0.08s; opacity: 1; transform: translateX(0); }
.mobile-drawer.is-open .mobile-drawer__item:nth-child(2) { transition-delay: 0.13s; opacity: 1; transform: translateX(0); }
.mobile-drawer.is-open .mobile-drawer__item:nth-child(3) { transition-delay: 0.18s; opacity: 1; transform: translateX(0); }
.mobile-drawer.is-open .mobile-drawer__item:nth-child(4) { transition-delay: 0.23s; opacity: 1; transform: translateX(0); }
.mobile-drawer.is-open .mobile-drawer__item:nth-child(5) { transition-delay: 0.28s; opacity: 1; transform: translateX(0); }
.mobile-drawer.is-open .mobile-drawer__item:nth-child(6) { transition-delay: 0.33s; opacity: 1; transform: translateX(0); }
.mobile-drawer.is-open .mobile-drawer__item:nth-child(7) { transition-delay: 0.38s; opacity: 1; transform: translateX(0); }

/* ==========================================================================
   5. Cinematic Hero Zoom & Micro Animations
   ========================================================================== */
@keyframes heroZoom {
    0% {
        transform: scale(1.0);
    }
    50% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1.0);
    }
}

.hero__image--animated {
    animation: heroZoom 28s ease-in-out infinite alternate;
}

.glass-sheen {
    position: relative;
    overflow: hidden;
}

.glass-sheen::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20%;
    height: 200%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.18) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(25deg);
    pointer-events: none;
    transition: all 0.85s ease;
    opacity: 0;
}

.glass-sheen:hover::after {
    left: 130%;
    opacity: 1;
}

@keyframes pulseDot {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(46, 125, 50, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(46, 125, 50, 0);
    }
}

.pulse-indicator {
    animation: pulseDot 2.2s infinite;
}

/* Scroll Progress Bar at the top */
.scroll-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(to right, #8C5325, #2E7D32);
    z-index: 1001;
    transition: width 0.1s linear;
}

/* ==========================================================================
   6. Reduced Motion Accessibility Overrides
   ========================================================================== */
@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;
    }

    .custom-cursor {
        display: none !important;
    }

    .page-transition {
        display: none !important;
    }

    .hero__image--animated {
        animation: none !important;
        transform: none !important;
    }

    html:not(.no-js) .reveal-on-scroll,
    html:not(.no-js) .reveal-left,
    html:not(.no-js) .reveal-right,
    html:not(.no-js) .reveal-scale,
    html:not(.no-js) .reveal-mask {
        opacity: 1 !important;
        transform: none !important;
        clip-path: none !important;
    }

    .mobile-drawer__item {
        opacity: 1 !important;
        transform: none !important;
    }
}
