/* =========================================================
   NEXT Portal — Luxury logo splash → settle into header
   ========================================================= */

/* Lock scroll while splash is active */
html.portal-splash-active,
html.portal-splash-active body {
    overflow: hidden !important;
}

/* Hide page chrome until intro finishes */
.portal-landing-page.portal-splash-pending .portal-header,
.portal-landing-page.portal-splash-pending main,
.portal-landing-page.portal-splash-pending .portal-footer,
.portal-landing-page.portal-splash-pending footer,
.portal-landing-page.portal-splash-flying main,
.portal-landing-page.portal-splash-flying .portal-footer,
.portal-landing-page.portal-splash-flying footer {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* During fly: header layout is live (for FLIP target), but muted */
.portal-landing-page.portal-splash-flying .portal-header {
    opacity: 1;
    visibility: visible;
    pointer-events: none;
}

.portal-landing-page.portal-splash-flying .portal-nav-center,
.portal-landing-page.portal-splash-flying .portal-nav,
.portal-landing-page.portal-splash-flying .portal-nav-toggle {
    opacity: 0;
}

.portal-landing-page.portal-splash-done .portal-header,
.portal-landing-page.portal-splash-done main,
.portal-landing-page.portal-splash-done .portal-footer,
.portal-landing-page.portal-splash-done footer {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Header brand invisible until fly completes (clone is moving) */
.portal-landing-page.portal-splash-pending .portal-brand,
.portal-landing-page.portal-splash-flying .portal-brand {
    opacity: 0 !important;
}

.portal-landing-page.portal-splash-done .portal-brand {
    opacity: 1 !important;
    transition: opacity 0.2s ease;
}

/* Hero image invisible until fly completes */
.portal-landing-page.portal-splash-pending .portal-hero__visual,
.portal-landing-page.portal-splash-flying .portal-hero__visual {
    opacity: 0 !important;
    visibility: hidden !important;
}

.portal-landing-page.portal-splash-done .portal-hero__visual {
    opacity: 1 !important;
    visibility: visible !important;
}

/* During fly: hero section must layout for FLIP target */
.portal-landing-page.portal-splash-flying .portal-hero {
    opacity: 1 !important;
    visibility: visible !important;
}

.portal-landing-page.portal-splash-flying .portal-hero__content,
.portal-landing-page.portal-splash-flying .portal-hero__orb {
    opacity: 0 !important;
}

.portal-landing-page.portal-splash-flying main {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: none !important;
}

.portal-landing-page.portal-splash-flying main > *:not(.portal-hero) {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* ── Splash overlay ── */
.portal-splash {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary, #070A09);
    overflow: hidden;
}

.portal-splash::before {
    content: "";
    position: absolute;
    width: min(70vw, 640px);
    height: min(70vw, 640px);
    border-radius: 50%;
    background: radial-gradient(circle, var(--color-primary-glow, rgba(0, 255, 136, 0.35)) 0%, transparent 70%);
    opacity: 0;
    animation: portalSplashGlow 2s ease forwards;
    pointer-events: none;
}

.portal-splash::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 50% 40% at 50% 55%, rgba(212, 175, 55, 0.08), transparent 60%);
    opacity: 0;
    animation: portalSplashGlow 2.2s ease 0.15s forwards;
    pointer-events: none;
}

[data-theme="light"] .portal-splash {
    background: #F8F6F1;
}

.portal-splash__stage {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    width: min(92vw, 720px);
    padding: 1rem;
}

.portal-splash__logo-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.portal-splash__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid var(--color-primary, #00FF88);
    opacity: 0;
    transform: scale(0.7);
}

.portal-splash__ring--outer {
    inset: -18px;
    border-color: var(--luxury-gold, #D4AF37);
}

.portal-splash__logo {
    width: clamp(100px, 18vw, 160px);
    height: auto;
    display: block;
    opacity: 0;
    transform: scale(0.7);
    filter: blur(16px) brightness(1.6);
    will-change: transform, opacity, filter;
}

.portal-splash__tagline {
    display: none;
}

.portal-splash__copy {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
    min-height: 4.5rem;
    width: min(100%, 640px);
    text-align: center;
    padding: 0 0.75rem;
}

.portal-splash__vision {
    margin: 0;
    min-height: 1.55em;
    font-family: 'Cinzel', 'Times New Roman', Georgia, serif;
    font-size: clamp(1.15rem, 3.2vw, 1.85rem);
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    text-align: center;
    color: var(--text-primary, #F4F7F5);
    line-height: 1.45;
    opacity: 0;
}

.portal-splash__fullform {
    margin: 0;
    min-height: 1.4em;
    font-family: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
    font-size: clamp(1.05rem, 2.5vw, 1.5rem);
    font-weight: 600;
    font-style: italic;
    letter-spacing: 0.06em;
    text-transform: none;
    text-align: center;
    color: var(--text-muted, #7A8A82);
    line-height: 1.4;
    opacity: 0;
}

.portal-splash__vision.is-active,
.portal-splash__fullform.is-active {
    opacity: 1;
    transition: opacity 0.45s ease;
}

.portal-splash__vision.is-typing::after,
.portal-splash__fullform.is-typing::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 0.95em;
    margin-left: 4px;
    vertical-align: -0.08em;
    background: var(--color-primary, #00FF88);
    animation: portalSplashCaret 0.7s steps(1) infinite;
}

[data-theme="light"] .portal-splash__vision {
    color: #004E5C;
}

html:not([data-theme="light"]) .portal-splash__vision,
[data-theme="dark"] .portal-splash__vision {
    color: #F8FAFC;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.7),
        0 0 22px rgba(0, 255, 136, 0.2),
        0 0 1px rgba(255, 255, 255, 0.35);
}

[data-theme="light"] .portal-splash__fullform {
    color: #3D4A44;
}

html:not([data-theme="light"]) .portal-splash__fullform,
[data-theme="dark"] .portal-splash__fullform {
    color: #D4CBB8;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.portal-splash__hero-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 0.35rem;
}

.portal-splash__hero {
    width: min(72vw, 420px);
    max-height: min(42vh, 360px);
    height: auto;
    object-fit: contain;
    object-position: bottom center;
    display: block;
    opacity: 0;
    transform: translateY(40px) scale(0.92);
    filter: blur(12px) drop-shadow(0 20px 50px rgba(0, 0, 0, 0.45));
    will-change: transform, opacity, filter;
}

/* Phase: entrance */
.portal-splash.is-entering .portal-splash__logo {
    animation: portalSplashLogoIn 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.portal-splash.is-entering .portal-splash__ring {
    animation: portalSplashRingIn 1.4s cubic-bezier(0.22, 1, 0.36, 1) 0.25s forwards;
}

.portal-splash.is-entering .portal-splash__ring--outer {
    animation-delay: 0.4s;
}

.portal-splash.is-entering .portal-splash__hero {
    animation: portalSplashHeroIn 1.15s cubic-bezier(0.22, 1, 0.36, 1) 0.35s forwards;
}

/* Phase: hold */
.portal-splash.is-holding .portal-splash__logo {
    opacity: 1;
    transform: scale(1);
}

html:not([data-theme="light"]) .portal-splash.is-holding .portal-splash__logo,
[data-theme="dark"] .portal-splash.is-holding .portal-splash__logo {
    filter: blur(0)
            drop-shadow(0 2px 4px rgba(0, 0, 0, 0.65))
            drop-shadow(0 0 16px rgba(255, 255, 255, 0.24))
            drop-shadow(0 0 32px rgba(0, 255, 136, 0.35));
}

[data-theme="light"] .portal-splash.is-holding .portal-splash__logo {
    filter: blur(0) drop-shadow(0 4px 16px rgba(0, 99, 116, 0.18));
}

.portal-splash.is-holding .portal-splash__hero {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0) drop-shadow(0 24px 48px rgba(0, 0, 0, 0.4));
    animation: portalSplashHeroFloat 3s ease-in-out infinite;
}

.portal-splash.is-holding .portal-splash__ring {
    opacity: 0.35;
    transform: scale(1);
    animation: portalSplashRingPulse 2.4s ease-in-out infinite;
}

.portal-splash.is-holding .portal-splash__ring--outer {
    opacity: 0.2;
    animation: portalSplashRingPulse 2.8s ease-in-out 0.3s infinite;
}

/* Phase: flying */
.portal-splash.is-flying .portal-splash__vision,
.portal-splash.is-flying .portal-splash__fullform,
.portal-splash.is-flying .portal-splash__copy,
.portal-splash.is-flying .portal-splash__ring {
    opacity: 0 !important;
    transition: opacity 0.4s ease;
    animation: none;
}

.portal-splash.is-flying .portal-splash__logo,
.portal-splash.is-flying .portal-splash__hero {
    opacity: 0;
    visibility: hidden;
}

/* Flying clones */
.portal-splash-fly-logo,
.portal-splash-fly-hero {
    position: fixed;
    z-index: 100000;
    margin: 0;
    padding: 0;
    pointer-events: none;
    object-fit: contain;
    will-change: transform, width, height, top, left, filter;
    transition:
        top 1.15s cubic-bezier(0.65, 0, 0.35, 1),
        left 1.15s cubic-bezier(0.65, 0, 0.35, 1),
        width 1.15s cubic-bezier(0.65, 0, 0.35, 1),
        height 1.15s cubic-bezier(0.65, 0, 0.35, 1),
        filter 1.15s ease;
}

.portal-splash-fly-logo {
    filter: drop-shadow(0 0 24px var(--color-primary-glow, rgba(0, 255, 136, 0.35)));
}

html:not([data-theme="light"]) .portal-splash-fly-logo,
[data-theme="dark"] .portal-splash-fly-logo {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6))
            drop-shadow(0 0 14px rgba(255, 255, 255, 0.22))
            drop-shadow(0 0 24px rgba(0, 255, 136, 0.3));
}

.portal-splash-fly-logo.is-settling {
    filter: drop-shadow(0 0 6px var(--color-primary-glow, rgba(0, 255, 136, 0.2)));
}

html:not([data-theme="light"]) .portal-splash-fly-logo.is-settling,
[data-theme="dark"] .portal-splash-fly-logo.is-settling {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55))
            drop-shadow(0 0 10px rgba(255, 255, 255, 0.18));
}

.portal-splash-fly-hero {
    filter: drop-shadow(0 16px 40px rgba(0, 0, 0, 0.45));
    object-position: bottom right;
}

.portal-splash-fly-hero.is-settling {
    filter: drop-shadow(0 12px 36px rgba(0, 0, 0, 0.4));
}

/* Phase: exit overlay */
.portal-splash.is-exiting {
    opacity: 0;
    transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

.portal-splash.is-gone {
    display: none !important;
}

/* Mobile fly target: keep hero measurable even if layout would hide it */
.portal-landing-page.portal-splash-flying .portal-hero__visual--fly-target,
.portal-landing-page.portal-splash-flying .portal-hero__visual-img--fly-target {
    display: block !important;
    visibility: visible !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

@media (max-width: 767.98px) {
    .portal-splash__stage {
        gap: 0.85rem;
        width: min(94vw, 520px);
        padding: 0.5rem;
    }

    .portal-splash__logo {
        width: clamp(88px, 28vw, 132px);
    }

    .portal-splash__hero {
        width: min(78vw, 340px);
        max-height: min(36vh, 280px);
    }

    .portal-splash__copy {
        min-height: 3.75rem;
        gap: 0.45rem;
        padding: 0 0.35rem;
    }

    .portal-splash__vision {
        font-size: clamp(0.78rem, 3.6vw, 1.15rem);
        letter-spacing: 0.12em;
        line-height: 1.35;
    }

    .portal-splash__fullform {
        font-size: clamp(0.95rem, 4vw, 1.25rem);
    }
}

/* Site content entrance after splash */
.portal-landing-page.portal-splash-done .portal-header {
    animation: portalHeaderReveal 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.portal-landing-page.portal-splash-done .portal-nav-center a,
.portal-landing-page.portal-splash-done .portal-nav > .portal-theme-toggle,
.portal-landing-page.portal-splash-done .portal-nav > .portal-nav__link,
.portal-landing-page.portal-splash-done .portal-nav > .dropdown {
    opacity: 0;
    animation: portalHeaderItemIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.portal-landing-page.portal-splash-done .portal-nav-center a:nth-child(1) { animation-delay: 0.1s; }
.portal-landing-page.portal-splash-done .portal-nav-center a:nth-child(2) { animation-delay: 0.18s; }
.portal-landing-page.portal-splash-done .portal-nav-center a:nth-child(3) { animation-delay: 0.26s; }
.portal-landing-page.portal-splash-done .portal-nav > .portal-theme-toggle { animation-delay: 0.15s; }
.portal-landing-page.portal-splash-done .portal-nav > .portal-nav__link:nth-of-type(1) { animation-delay: 0.22s; }
.portal-landing-page.portal-splash-done .portal-nav > .portal-nav__link:nth-of-type(2) { animation-delay: 0.3s; }
.portal-landing-page.portal-splash-done .portal-nav > .dropdown { animation-delay: 0.26s; }

.portal-landing-page.portal-splash-done .portal-animate-in--1 { animation-delay: 0.25s; }
.portal-landing-page.portal-splash-done .portal-animate-in--2 { animation-delay: 0.4s; }
.portal-landing-page.portal-splash-done .portal-animate-in--3 { animation-delay: 0.55s; }
.portal-landing-page.portal-splash-done .portal-animate-in--4 { animation-delay: 0.7s; }

/* Hero already flew into place — no second entrance fade */
.portal-landing-page.portal-splash-done .portal-hero__visual.portal-animate-in {
    animation: none !important;
    opacity: 1 !important;
}

.portal-landing-page.portal-splash-done .portal-hero__orb {
    opacity: 0;
    animation: portalOrbFadeIn 1.2s ease 0.2s forwards;
}

/* Hero content stays hidden until splash done (avoid double anim) */
.portal-landing-page.portal-splash-pending .portal-animate-in {
    animation: none !important;
    opacity: 0 !important;
}

@keyframes portalSplashLogoIn {
    0% {
        opacity: 0;
        transform: scale(0.7);
        filter: blur(16px) brightness(1.8);
    }
    55% {
        opacity: 1;
        transform: scale(1.06);
        filter: blur(0) brightness(1.15) drop-shadow(0 0 40px var(--color-primary-glow, rgba(0, 255, 136, 0.45)));
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0) drop-shadow(0 0 28px var(--color-primary-glow, rgba(0, 255, 136, 0.4)));
    }
}

@keyframes portalSplashHeroIn {
    0% {
        opacity: 0;
        transform: translateY(48px) scale(0.9);
        filter: blur(14px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0) drop-shadow(0 24px 48px rgba(0, 0, 0, 0.4));
    }
}

@keyframes portalSplashHeroFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.01); }
}

@keyframes portalSplashRingIn {
    0% {
        opacity: 0;
        transform: scale(0.6);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.05);
    }
    100% {
        opacity: 0.35;
        transform: scale(1);
    }
}

@keyframes portalSplashRingPulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.08); opacity: 0.55; }
}

@keyframes portalSplashTagIn {
    from {
        opacity: 0;
        transform: translateY(12px);
        letter-spacing: 0.4em;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        letter-spacing: 0.28em;
    }
}

@keyframes portalSplashVisionIn {
    from {
        opacity: 0;
        transform: translateY(16px);
        letter-spacing: 0.32em;
        filter: blur(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        letter-spacing: 0.18em;
        filter: blur(0);
    }
}

@keyframes portalSplashCaret {
    0%, 45% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

@keyframes portalSplashGlow {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes portalHeaderReveal {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes portalHeaderItemIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes portalOrbFadeIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

/* ── Scroll reveal (unchanged API) ── */
[data-reveal] {
    opacity: 0;
    will-change: transform, opacity, filter;
    transition:
        opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.9s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.9s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--reveal-delay, 0ms);
}

[data-reveal].is-revealed {
    opacity: 1;
    transform: none;
    filter: none;
}

[data-reveal="fade-up"] { transform: translateY(48px); }
[data-reveal="fade-down"] { transform: translateY(-32px); }
[data-reveal="fade-left"] { transform: translateX(48px); }
[data-reveal="fade-right"] { transform: translateX(-48px); }
[data-reveal="scale-up"] { transform: scale(0.92) translateY(24px); }
[data-reveal="blur-up"] { transform: translateY(36px); filter: blur(10px); }
[data-reveal="zoom-in"] { transform: scale(0.88); }

[data-reveal-stagger] > [data-reveal-item] {
    opacity: 0;
    transform: translateY(36px);
    transition:
        opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}

[data-reveal-stagger].is-revealed > [data-reveal-item] {
    opacity: 1;
    transform: none;
}

[data-reveal-stagger].is-revealed > [data-reveal-item]:nth-child(1) { transition-delay: 0ms; }
[data-reveal-stagger].is-revealed > [data-reveal-item]:nth-child(2) { transition-delay: 80ms; }
[data-reveal-stagger].is-revealed > [data-reveal-item]:nth-child(3) { transition-delay: 160ms; }
[data-reveal-stagger].is-revealed > [data-reveal-item]:nth-child(4) { transition-delay: 240ms; }
[data-reveal-stagger].is-revealed > [data-reveal-item]:nth-child(5) { transition-delay: 320ms; }
[data-reveal-stagger].is-revealed > [data-reveal-item]:nth-child(6) { transition-delay: 400ms; }
[data-reveal-stagger].is-revealed > [data-reveal-item]:nth-child(7) { transition-delay: 480ms; }
[data-reveal-stagger].is-revealed > [data-reveal-item]:nth-child(8) { transition-delay: 560ms; }

.portal-section--animated.is-revealed::before,
[data-reveal].portal-section--animated.is-revealed::before {
    animation: portalLineDraw 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.portal-header {
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease;
}

.portal-header--scrolled {
    box-shadow: var(--shadow-md) !important;
}

.portal-header--hidden {
    transform: translateY(-110%);
}

@keyframes portalLineDraw {
    from { width: 0; opacity: 0; }
    to { width: min(120px, 20%); opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
    .portal-splash,
    .portal-splash-fly-logo,
    .portal-landing-page.portal-splash-pending .portal-header,
    .portal-landing-page.portal-splash-pending main,
    .portal-landing-page .portal-animate-in,
    [data-reveal],
    [data-reveal-stagger] > [data-reveal-item] {
        animation: none !important;
        transition: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        filter: none !important;
    }

    .portal-splash {
        display: none !important;
    }
}
