/* Page Transitions - Overlay Blur Effect */

/* Transition Overlay - below navbar with glassy look */
.page-transition-overlay {
    position: fixed;
    top: 60px; /* Below navbar */
    left: 0;
    width: 100%;
    height: calc(100% - 60px);
    /* Glassy transparent effect */
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.4) 0%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(240, 253, 250, 0.3) 100%
    );
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    z-index: 900; /* Below navbar z-index 1000 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), 
                visibility 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.page-transition-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Loading spinner inside overlay - glassy card */
.page-transition-spinner {
    width: 80px;
    height: 80px;
    position: relative;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1),
                inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-transition-spinner::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 3px solid rgba(15, 125, 116, 0.15);
    border-top-color: #0F7D74;
    border-radius: 50%;
    animation: spinnerRotate 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes spinnerRotate {
    to { transform: rotate(360deg); }
}

/* Logo animation in spinner */
.page-transition-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 2px;
    align-items: flex-end;
}

.page-transition-logo .candle {
    width: 4px;
    border-radius: 1px;
    animation: candlePulse 0.6s ease-in-out infinite alternate;
}

.page-transition-logo .candle:nth-child(1) {
    height: 12px;
    background: #22c55e;
    animation-delay: 0s;
}

.page-transition-logo .candle:nth-child(2) {
    height: 8px;
    background: #ef4444;
    animation-delay: 0.15s;
}

.page-transition-logo .candle:nth-child(3) {
    height: 16px;
    background: #22c55e;
    animation-delay: 0.3s;
}

@keyframes candlePulse {
    from { transform: scaleY(0.7); opacity: 0.7; }
    to { transform: scaleY(1); opacity: 1; }
}

/* Progress bar at top */
.page-transition-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #0F7D74, #14b8a6, #22c55e);
    z-index: 100000;
    width: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(15, 125, 116, 0.6);
}

.page-transition-progress.loading {
    animation: progressLoad 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-transition-progress.complete {
    width: 100%;
    opacity: 0;
    transition: width 0.2s ease, opacity 0.3s ease 0.1s;
}

@keyframes progressLoad {
    0% { width: 0; }
    30% { width: 40%; }
    60% { width: 70%; }
    80% { width: 85%; }
    100% { width: 95%; }
}

/* Page content wrapper */
body {
    opacity: 1;
    transition: none;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Navbar - prevent flicker with stable styles */
.navbar,
nav.navbar {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Nav links - smooth hover without flicker */
.nav-links a {
    transition: color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: color, background-color;
}

/* Active state - no flicker */
.nav-links a.active {
    transition: none !important;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .page-transition-overlay,
    .page-transition-spinner,
    .page-transition-progress {
        transition: none !important;
        animation: none !important;
    }
    
    .page-transition-overlay.active {
        opacity: 1;
    }
}

/* Mobile adjustments for overlay position */
@media (max-width: 768px) {
    .page-transition-overlay {
        top: 42px; /* Mobile navbar height */
        height: calc(100% - 42px);
    }
}

@media (max-width: 480px) {
    .page-transition-overlay {
        top: 38px; /* Small mobile navbar height */
        height: calc(100% - 38px);
    }
    
    .page-transition-spinner {
        width: 70px;
        height: 70px;
        border-radius: 14px;
    }
}
