/**
 * DramaHub Cinematic Page Transitions v3.0
 * Ultra-smooth fade + slide transitions for fixed-navbar multi-page navigation.
 * Keeps the fixed navbar locked in place while content smoothly cross-fades.
 */

/* -------------------------------------------------------------------------
   1. View Transitions API (Hardware Accelerated — Modern Browsers)
   ------------------------------------------------------------------------- */
@view-transition {
    navigation: auto;
}

::view-transition-old(root) {
    animation: 160ms cubic-bezier(0.4, 0, 0.2, 1) both dh-vt-out;
}

::view-transition-new(root) {
    animation: 200ms cubic-bezier(0.4, 0, 0.2, 1) both dh-vt-in;
}

@keyframes dh-vt-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes dh-vt-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* -------------------------------------------------------------------------
   2. Smooth Scroll & Entrance Animations
   ------------------------------------------------------------------------- */
html {
    scroll-behavior: smooth;
}

/* Entering state for content (keeps navbar stationary) */
@keyframes dhContentEnter {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

body.dh-entering main,
body.dh-entering .hub-main-container,
body.dh-entering .pricing-section,
body.dh-entering .db-shell,
body.dh-entering #docs-app-root,
body.dh-entering .hub-footer,
body.dh-entering footer {
    animation: dhContentEnter 240ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Leaving state for content (navbar remains fixed and stable) */
body.dh-page-leaving main,
body.dh-page-leaving .hub-main-container,
body.dh-page-leaving .pricing-section,
body.dh-page-leaving .db-shell,
body.dh-page-leaving #docs-app-root,
body.dh-page-leaving .hub-footer,
body.dh-page-leaving footer {
    opacity: 0 !important;
    transform: translateY(-6px) !important;
    transition: opacity 120ms cubic-bezier(0.4, 0, 0.2, 1), transform 120ms cubic-bezier(0.4, 0, 0.2, 1) !important;
    pointer-events: none !important;
}

/* -------------------------------------------------------------------------
   3. Neon Gradient Progress Bar (Top Edge)
   ------------------------------------------------------------------------- */
#dh-top-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    z-index: 9999999;
    pointer-events: none;
    background: linear-gradient(90deg, #818cf8, #c084fc, #f472b6, #38bdf8);
    background-size: 200% 100%;
    animation: dh-progress-shimmer 2s linear infinite;
    box-shadow:
        0 0 16px rgba(129, 140, 248, 0.8),
        0 0 4px rgba(56, 189, 248, 0.6);
    transition: width 180ms cubic-bezier(0.16, 1, 0.3, 1), opacity 180ms ease;
    border-radius: 0 3px 3px 0;
    opacity: 0;
}

@keyframes dh-progress-shimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

#dh-top-progress.active {
    opacity: 1;
}

#dh-top-progress.completing {
    width: 100% !important;
    opacity: 0;
    transition: width 120ms ease-out, opacity 200ms ease-out 100ms;
}

/* Glowing head of progress bar */
#dh-top-progress::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -2px;
    width: 60px;
    height: 9px;
    background: radial-gradient(ellipse at right, rgba(255, 255, 255, 0.95) 0%, transparent 70%);
    filter: blur(1px);
    border-radius: 50%;
}

/* -------------------------------------------------------------------------
   4. Reduced Motion (Accessibility)
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    body.dh-entering *,
    body.dh-page-leaving * {
        animation: none !important;
        transition: opacity 60ms linear !important;
        transform: none !important;
    }
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation: none !important;
    }
    #dh-top-progress {
        transition: none !important;
    }
}
