/* ==========================================================================
   nav.css — the site menu. Single source of truth.

   Previously the menu was duplicated across six stylesheets and seven
   scripts, and the submenus were shown by toggling `display` from JS. That
   wrote an inline style which outranks any CSS :hover rule, so after one
   click anywhere on the page the hover stopped working. Here the submenus
   are shown with opacity/visibility only — nothing writes inline styles, so
   hover and tap can never fight each other.
   ========================================================================== */

:root {
    --nav-h: 76px;
    --nav-accent: #f28d1f;
    --nav-text: rgba(255, 255, 255, 0.82);
    --nav-text-strong: #ffffff;
    --nav-bg: rgba(18, 18, 18, 0.72);
    --nav-bg-solid: rgba(15, 15, 15, 0.97);
    --nav-panel: #1e1e1e;
    --nav-hairline: rgba(255, 255, 255, 0.09);
    --nav-hover: rgba(255, 255, 255, 0.07);
}

/* The bar is fixed, so pages have to start below it. Pages whose hero is
   meant to run behind the bar opt out with `.nav-overlay` on <body>. */
body {
    padding-top: var(--nav-h);
}

body.nav-overlay {
    padding-top: 0;
}

/* Jumping to #section should not land under the bar either. */
html {
    scroll-padding-top: calc(var(--nav-h) + 12px);
}

.site-nav {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    height: var(--nav-h);
    padding: 0 clamp(1rem, 3vw, 2.5rem);
    border-bottom: 1px solid transparent;
    font-family: 'Poppins', sans-serif;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* The blurred bar is painted by a pseudo-element rather than by .site-nav
   itself. A backdrop-filter on an element makes it the containing block for
   its position:fixed descendants, which collapsed the slide-in menu panel to
   the height of the bar. Keeping the filter off .site-nav lets the panel
   size against the viewport as intended. */
.site-nav::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--nav-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: background 0.3s ease;
}

.site-nav.is-scrolled::before {
    background: var(--nav-bg-solid);
}

.site-nav.is-scrolled {
    border-bottom-color: var(--nav-hairline);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

/* ===== Brand ============================================================ */
.site-nav__brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    line-height: 0;
}

.site-nav__brand img {
    height: 40px;
    width: auto;
    transition: opacity 0.2s ease;
}

.site-nav__brand:hover img {
    opacity: 0.85;
}

/* ===== Menu ============================================================= */
.site-nav__menu {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav__menu>li {
    position: relative;
}

.site-nav__link {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    color: var(--nav-text);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.2s ease, background 0.2s ease;
}

.site-nav__link:hover,
.site-nav__link:focus-visible {
    color: var(--nav-text-strong);
    background: var(--nav-hover);
    outline: none;
}

.site-nav__link:focus-visible {
    box-shadow: 0 0 0 2px var(--nav-accent);
}

/* Current page */
.site-nav__link[aria-current="page"] {
    color: var(--nav-accent);
}

/* Chevron — decorative only; it is part of the link, never a separate
   hit target, which is what used to make the submenus feel unreliable. */
.site-nav__chev {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
    opacity: 0.55;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.site-nav__menu>li:hover>.site-nav__link .site-nav__chev,
.site-nav__menu>li.is-open>.site-nav__link .site-nav__chev {
    transform: rotate(180deg);
    opacity: 1;
}

/* ===== Submenu ========================================================== */
.site-nav__sub {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 230px;
    margin: 0;
    /* The 8px of padding is also the bridge between the link and the panel,
       so the pointer never crosses a gap that would drop the hover. */
    padding: 8px;
    list-style: none;
    background: var(--nav-panel);
    border: 1px solid var(--nav-hairline);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.site-nav__menu>li:hover>.site-nav__sub,
.site-nav__menu>li:focus-within>.site-nav__sub,
.site-nav__menu>li.is-open>.site-nav__sub {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.site-nav__sub a {
    display: block;
    padding: 0.65rem 0.8rem;
    border-radius: 8px;
    color: var(--nav-text);
    font-size: 0.85rem;
    font-weight: 400;
    text-decoration: none;
    transition: color 0.18s ease, background 0.18s ease;
}

.site-nav__sub a:hover,
.site-nav__sub a:focus-visible {
    color: var(--nav-accent);
    background: rgba(242, 141, 31, 0.12);
    outline: none;
}

/* Keep the last tab's panel inside the viewport */
.site-nav__menu>li:last-child .site-nav__sub,
.site-nav__sub--end {
    left: auto;
    right: 0;
}

/* ===== Burger =========================================================== */
.site-nav__burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.site-nav__burger:hover {
    background: var(--nav-hover);
}

.site-nav__burger span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--nav-accent);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.site-nav__burger[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.site-nav__burger[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.site-nav__burger[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ===== Collapsed menu =================================================== */
@media (max-width: 1100px) {
    .site-nav__burger {
        display: flex;
    }

    .site-nav__menu {
        position: fixed;
        top: var(--nav-h);
        right: 0;
        bottom: 0;
        width: min(330px, 86vw);
        flex-direction: column;
        align-items: stretch;
        gap: 0.1rem;
        padding: 1rem;
        overflow-y: auto;
        overscroll-behavior: contain;
        background: #141414;
        border-left: 1px solid var(--nav-hairline);
        box-shadow: -16px 0 40px rgba(0, 0, 0, 0.45);
        transform: translateX(100%);
        visibility: hidden;
        transition: transform 0.28s ease, visibility 0.28s;
    }

    .site-nav__menu.is-open {
        transform: translateX(0);
        visibility: visible;
    }

    .site-nav__link {
        width: 100%;
        justify-content: space-between;
        padding: 0.85rem 0.9rem;
        font-size: 0.95rem;
    }

    /* Submenus expand in place instead of floating over the page. */
    .site-nav__sub {
        position: static;
        min-width: 0;
        max-height: 0;
        padding: 0 0 0 0.9rem;
        background: none;
        border: 0;
        border-left: 2px solid rgba(242, 141, 31, 0.35);
        border-radius: 0;
        box-shadow: none;
        margin: 0 0 0 0.9rem;
        opacity: 1;
        visibility: visible;
        transform: none;
        overflow: hidden;
        transition: max-height 0.28s ease, padding 0.28s ease;
    }

    .site-nav__menu>li:hover>.site-nav__sub,
    .site-nav__menu>li:focus-within>.site-nav__sub {
        max-height: 0;
    }

    .site-nav__menu>li.is-open>.site-nav__sub {
        max-height: 320px;
        padding: 0.25rem 0 0.5rem;
    }

    .site-nav__sub a {
        padding: 0.65rem 0.75rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    :root {
        --nav-h: 66px;
    }

    .site-nav__brand img {
        height: 32px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .site-nav,
    .site-nav__link,
    .site-nav__sub,
    .site-nav__chev,
    .site-nav__menu,
    .site-nav__burger span {
        transition: none;
    }
}
