/* ==========================================================================
   Global Header & Ecosystem (Decoupled Layout)
   ========================================================================== */

#ecosystem-container {
    display: none;
    /* Removed from new layout */
}

#navbar-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 2.5rem 3rem;
    pointer-events: none;
    transition: padding 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Sticky glass lives on ::after — never on the parent.
   Parent backdrop-filter blocks child elements from sampling the page directly.
   Pseudo-element keeps backdrop-filter always pre-rendered, opacity-transitions it. */
#navbar-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 26, 0.80);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

#navbar-container.scrolled {
    padding: 1rem 3rem;
    pointer-events: auto;
}

#navbar-container.scrolled::after {
    opacity: 1;
}

.global-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    pointer-events: auto;
    transition: align-items 0s; /* no visual transition needed */
}

/* In sticky mode, perfectly center logo + nav on the same axis */
#navbar-container.scrolled .global-header {
    align-items: center;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transform: translateX(0);
    transition: transform 0.55s 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Slide brand to the left after morph completes — desktop only */
#navbar-container.scrolled .header-left {
    transform: translateX(-1.25rem);
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    font-family: 'NeoGeo', 'Inter', sans-serif;
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--fg-color);
    letter-spacing: -0.02em;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
    transition: font-size 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

#navbar-container.scrolled .brand-logo {
    font-size: 3rem; /* Desktop sticky — punchy but not tiny */
}

.logo-prefix {
    display: inline-flex;
    overflow: hidden;
    /* max-width collapses layout; clip-path smooths the visual edge */
    max-width: 400px;
    clip-path: inset(0 0% 0 0);
    transform: translateX(0);
    transition:
        max-width  0.85s cubic-bezier(0.77, 0, 0.175, 1),
        clip-path  0.85s cubic-bezier(0.77, 0, 0.175, 1),
        transform  0.85s cubic-bezier(0.77, 0, 0.175, 1);
}

#navbar-container.scrolled .logo-prefix {
    max-width: 0;
    clip-path: inset(0 100% 0 0);
    transform: translateX(-5px);
    /* Animation B: la Scala starts expanding at 0.15s, finishes at 0.95s — L' is already gone at 0.3s */
    transition:
        max-width  0.8s 0.15s cubic-bezier(0.16, 1, 0.3, 1),
        clip-path  0.8s 0.15s cubic-bezier(0.16, 1, 0.3, 1),
        transform  0.8s 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.logo-l-apo {
    display: inline-flex;
    overflow: hidden;
    max-width: 0;
    clip-path: inset(0 100% 0 0);
    transform: translateX(5px);
    /* Animation A: starts 0.3s after la Scala begins, finishes at 0.75s (before 0.85s) */
    transition:
        max-width  0.45s 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        clip-path  0.45s 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        transform  0.45s 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--accent-color);
}

#navbar-container.scrolled .logo-l-apo {
    max-width: 50px;
    clip-path: inset(0 0% 0 0);
    transform: translateX(0);
    /* Return: L' exits immediately, fast, so la Scala can then appear */
    transition:
        max-width  0.3s 0s cubic-bezier(0.77, 0, 0.175, 1),
        clip-path  0.3s 0s cubic-bezier(0.77, 0, 0.175, 1),
        transform  0.3s 0s cubic-bezier(0.77, 0, 0.175, 1);
}

.brand-logo .logo-esar {
    color: var(--accent-color);
    transition: color 0.6s ease;
}

#navbar-container.scrolled .brand-logo .logo-esar,
#navbar-container.scrolled .logo-l-apo {
    color: #ffffff !important;
}

/* Light mode overrides for the logo text shadow */
:root[data-theme="light"] .brand-logo {
    text-shadow: 0 4px 20px rgba(255, 255, 255, 0.8);
}

.ecosystem-inline {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-left: 0.25rem;
}

.eco-inline-link {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.6);
    position: relative;
    transition: color var(--trans-fast), transform var(--trans-fast);
    padding: 0.25rem 0;
}

:root[data-theme="light"] .eco-inline-link {
    color: rgba(0, 0, 0, 0.6);
}

.eco-inline-link:hover {
    color: var(--fg-color);
    transform: translateY(-2px);
}

:root[data-theme="light"] .eco-inline-link:hover {
    color: var(--fg-color);
}

.eco-inline-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0%;
    height: 1px;
    background-color: var(--accent-color);
    transition: width var(--trans-fast);
}

.eco-inline-link:hover::after {
    width: 100%;
}

.eco-separator {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.6rem;
}

:root[data-theme="light"] .eco-separator {
    color: rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Main Site Navigation (Right Side)
   ========================================================================== */

.header-right {
    display: flex;
    justify-content: flex-end;
}

.site-nav {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
}

/* Pill glass effect lives on ::before — always stays in the paint tree.
   This guarantees backdrop-filter is pre-computed and renders instantly.
   We opacity-transition it instead of toggling backdrop-filter directly. */
.site-nav::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 40px;
    background: rgba(26, 26, 26, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: -1;
    opacity: 1;
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* In sticky mode: fade the pill out, shrink slightly — subtle pill→sticky transition */
#navbar-container.scrolled .site-nav {
    padding: 0;
}

#navbar-container.scrolled .site-nav::before {
    opacity: 0;
    transform: scale(0.96);
}

:root[data-theme="light"] .site-nav::before {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: opacity 0.4s ease;
}

.nav-item {
    position: relative;
    font-size: 0.95rem; /* Increased size as requested */
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
    transition: color var(--trans-fast);
}

/* Constant non-sticky and sticky base color */
#navbar-container.scrolled .nav-item {
    color: rgba(255, 255, 255, 0.75);
}

/* Hover fixes for specificity */
.nav-item:hover,
.nav-item.active,
#navbar-container.scrolled .nav-item:hover,
#navbar-container.scrolled .nav-item.active {
    color: var(--fg-color);
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background-color: var(--accent-color);
    transition: width var(--trans-fast);
}

.nav-item.active::after {
    width: 100%;
}

/* Call to Actions */
.nav-cta {
    background: var(--fg-color);
    color: var(--bg-color) !important;
    padding: 0.5rem 1.25rem;
    border-radius: 18px;
    transition: all var(--trans-fast);
}

.nav-cta::after {
    display: none;
}

.nav-cta:hover,
.nav-cta.active {
    background: var(--accent-color);
    color: #fff !important;
    transform: translateY(-2px);
}

/* Classy elegant JPO highlight with subtle beacon */
@keyframes beaconPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(var(--beacon-rgb), 0.8); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(var(--beacon-rgb), 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(var(--beacon-rgb), 0); }
}

.nav-jpo {
    --beacon-rgb: 212, 175, 55;
    border: 1px solid rgba(212, 175, 55, 0.4);
    padding: 0.4rem 1.25rem;
    border-radius: 18px;
    background: rgba(212, 175, 55, 0.05); /* Very subtle gold */
    color: var(--accent-color) !important;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    /* overflow: hidden; removed so pulse glow isn't cropped */
}

.nav-jpo::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgb(var(--beacon-rgb));
    animation: beaconPulse 2s infinite ease-in-out;
    flex-shrink: 0;
    transition: background 0.3s;
}

:root[data-theme="light"] .nav-jpo {
    border-color: rgba(0, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.05);
}

.nav-jpo::after {
    display: none;
}

.nav-jpo:hover,
#navbar-container.scrolled .nav-jpo:hover {
    --beacon-rgb: 6, 8, 16; /* Black/Dark color for inverted hover */
    border-color: var(--accent-color) !important;
    background: var(--accent-color) !important;
    color: #060810 !important; 
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.3) !important;
}