/* ============================================================
   Page transitions
   Single brand-colored curtain that reads as one box passing:
   - Exit: the curtain (with logo) rises from the bottom and covers
     the old page, then the browser navigates.
   - Entry: the new page first paints still covered by the same-colored
     preloader, which continues the motion by wiping off the top.
   Overrides the theme's dark #preloader in style.css.
   ============================================================ */

/* ---------- Entry: preloader as the departing curtain ---------- */

:root {
    --transition-bg: #473f30;
    --transition-logo-width: 148px;
}

#preloader {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-color: var(--transition-bg) !important;
    overflow: hidden;
}

/* Logo rides the curtain */
#preloader .preloader-logo {
    display: block;
    position: relative;
    width: var(--transition-logo-width);
    max-width: 70vw;
    height: auto;
    z-index: 2;
}

/* Spinner: sits below the logo, fades in only when loading takes a
   while so fast loads never flash it */
#preloader [data-loader="circle-side"] {
    z-index: 2;
    border: 2px solid rgba(255, 252, 245, 0.25);
    border-left-color: #fffcf5;
    margin-top: 40px;
    opacity: 0;
    animation: circle infinite 0.95s linear, spinnerIn 0.3s ease 0.6s forwards;
}

@keyframes spinnerIn {
    to {
        opacity: 1;
    }
}

/* Reveal: the whole curtain (logo included) slides off the top,
   replacing the theme's top:-100% animation */
#preloader.loaded {
    animation: none !important;
    transform: translate3d(0, -101%, 0);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.65s cubic-bezier(0.77, 0, 0.175, 1) 0.1s,
                visibility 0s linear 0.9s;
}

/* ---------- Exit: the same curtain rising from the bottom ---------- */

#page-curtain {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 99999999999;
    visibility: hidden;
    pointer-events: none;
}

#page-curtain .curtain-layer {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--transition-bg);
    transform: translate3d(0, 102%, 0);
}

#page-curtain .curtain-logo {
    display: block;
    position: relative;
    width: var(--transition-logo-width);
    max-width: 70vw;
    height: auto;
}

#page-curtain.active {
    visibility: visible;
    pointer-events: all;
}

#page-curtain.active .curtain-layer {
    transition: transform 0.5s cubic-bezier(0.77, 0, 0.175, 1);
    transform: translate3d(0, 0, 0);
}

/* ---------- Accessibility ---------- */

@media (prefers-reduced-motion: reduce) {
    #preloader.loaded {
        transition-duration: 0.01s;
        transition-delay: 0s;
    }

    #page-curtain.active .curtain-layer {
        transition-duration: 0.01s;
    }
}
