/* ═══════════════════════════════════════════════════════════
   MLC Site Navigation
   Hamburger + full-screen overlay. Two grouped columns sized off the
   viewport height so the menu fits a short laptop screen, a photo panel
   beside it on wide screens, a full-screen photo view on phones.
   Markup: inc/nav.php. Behavior: assets/js/nav.js.
   ═══════════════════════════════════════════════════════════ */

/* ─── HAMBURGER ──────────────────────────────────────────── */
.hamburger {
    position: fixed;
    top: 22px;
    right: 22px;
    z-index: 100 !important;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.hamburger__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.hamburger__line {
    display: block;
    width: 24px;
    height: 2px;
    border-radius: 2px;
    background: var(--dark);
    transition: transform 0.3s ease, opacity 0.3s ease, background 0.4s ease;
    transform-origin: center;
}

/* Light variant for dark backgrounds (toggled by global.js) */
.hamburger--light .hamburger__line {
    background: #fff;
}

.hamburger:hover .hamburger__line--1 { transform: translateY(8px) rotate(45deg); }
.hamburger:hover .hamburger__line--2 { opacity: 0; transform: scaleX(0); }
.hamburger:hover .hamburger__line--3 { transform: translateY(-8px) rotate(-45deg); }

.hamburger:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

/* ─── OVERLAY ────────────────────────────────────────────── */
/* Hidden with visibility, not display:none, so the photo panel's images can
   be fetched and decoded before the menu is ever opened. */
.nav-overlay {
    --nav-bg: #0e0e12;
    --nav-line: rgba(255, 255, 255, 0.08);
    --nav-muted: #6b6b78;
    --nav-pad-x: clamp(24px, 4.5vw, 72px);
    --nav-pad-y: clamp(18px, 4vh, 44px);

    position: fixed;
    inset: 0;
    z-index: 999999999 !important;
    display: flex;
    background: var(--nav-bg);
    color: #fff;
    font-family: var(--font-main);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

.nav-overlay.is-open {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.35s ease;
}

/* Faint brand glow behind the menu column */
.nav-overlay::before {
    content: '';
    position: absolute;
    inset: auto auto -30vh -20vw;
    width: 70vw;
    height: 70vh;
    background: radial-gradient(closest-side, rgba(124, 58, 237, 0.16), transparent);
    pointer-events: none;
}

html.nav-is-open,
html.nav-is-open body {
    overflow: hidden;
}

/* ─── MENU COLUMN ────────────────────────────────────────── */
.nav-menu {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: var(--nav-pad-y) var(--nav-pad-x);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.nav-menu__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    margin-bottom: clamp(16px, 5vh, 56px);
}

.nav-menu__brand {
    display: block;
    line-height: 0;
    border-radius: 6px;
}

.nav-menu__monogram {
    width: clamp(36px, 5vh, 48px);
    height: auto;
    display: block;
}

/* Close sits where the hamburger was, so open and close share one spot */
.nav-close {
    position: fixed;
    top: 22px;
    right: 22px;
    z-index: 5;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.3s ease;
}

.nav-close span {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: #fff;
}

.nav-close span:first-child { transform: translate(-50%, -50%) rotate(45deg); }
.nav-close span:last-child { transform: translate(-50%, -50%) rotate(-45deg); }

.nav-close:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: rotate(90deg);
}

/* On wide screens the close button floats over the photo, give it a backing */
.nav-overlay.has-photos .nav-close {
    background: rgba(14, 14, 18, 0.45);
}

.nav-overlay.has-photos .nav-close:hover {
    background: rgba(14, 14, 18, 0.75);
}

/* ─── GROUPS ─────────────────────────────────────────────── */
.nav-menu__groups {
    flex: 1 0 auto;
    display: grid;
    /* Columns size to their longest label and only wrap when they must */
    grid-template-columns: minmax(0, max-content) minmax(0, max-content);
    justify-content: start;
    column-gap: clamp(36px, 5vw, 96px);
    row-gap: clamp(20px, 4vh, 40px);
    align-content: center;
}

.nav-group__label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #8a8a98;
    padding-bottom: clamp(6px, 1.2vh, 12px);
    border-bottom: 1px solid var(--nav-line);
}

.nav-group__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link {
    border-bottom: 1px solid var(--nav-line);
}

.nav-link a {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: clamp(12px, 1.4vw, 20px);
    padding: clamp(7px, 1.45vh, 15px) 0;
    color: #fff;
    text-decoration: none;
    outline: none;
}

.nav-link__num {
    flex: 0 0 auto;
    min-width: 2ch;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #6b6b78;
    transition: color 0.3s ease;
}

.nav-link__label {
    font-size: clamp(19px, min(2.5vw, 4.4vh), 38px);
    font-weight: var(--weight-heading);
    letter-spacing: -0.02em;
    line-height: 1.12;
    transition: color 0.3s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Gradient rule that draws in under the hovered row */
.nav-link a::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-link a:hover .nav-link__label,
.nav-link a:focus-visible .nav-link__label {
    color: var(--accent);
    transform: translateX(6px);
}

.nav-link a:hover .nav-link__num,
.nav-link a:focus-visible .nav-link__num {
    color: var(--accent);
}

.nav-link a:hover::after,
.nav-link a:focus-visible::after {
    transform: scaleX(1);
}

/* The page you're on */
.nav-link.is-current .nav-link__num {
    color: var(--secondary);
}

.nav-link.is-current .nav-link__label {
    background: linear-gradient(90deg, #a78bfa, var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.nav-link.is-current a:hover .nav-link__label {
    -webkit-text-fill-color: var(--accent);
}

/* Rows rise in, one after another, each time the menu opens */
.nav-overlay.is-open .nav-link,
.nav-overlay.is-open .nav-group__label,
.nav-overlay.is-open .nav-menu__foot {
    animation: navRise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--i, 0) * 28ms + 60ms);
}

@keyframes navRise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

/* ─── MENU FOOT ──────────────────────────────────────────── */
.nav-menu__foot {
    --i: 14;
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 24px;
    margin-top: clamp(16px, 4vh, 44px);
    font-size: 13px;
    color: var(--nav-muted);
}

.nav-menu__photos {
    display: none;
    margin-left: auto;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
}

.nav-menu__photos:hover {
    color: var(--accent);
}

/* ─── PHOTO PANEL ────────────────────────────────────────── */
.nav-photos {
    position: relative;
    flex: 0 0 40%;
    overflow: hidden;
    background:
        radial-gradient(120% 80% at 70% 20%, rgba(6, 182, 212, 0.14), transparent 60%),
        radial-gradient(100% 70% at 20% 90%, rgba(124, 58, 237, 0.22), transparent 60%),
        #15151b;
}

.nav-photos__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 1.4s ease;
    backface-visibility: hidden;
}

.nav-photos__img.is-shown {
    opacity: 1;
}

.nav-photos__shade {
    position: absolute;
    inset: auto 0 0 0;
    height: 40%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
    pointer-events: none;
}

.nav-photos__caption {
    position: absolute;
    left: clamp(20px, 3vw, 40px);
    right: 140px;
    bottom: clamp(20px, 4vh, 40px);
    display: flex;
    flex-direction: column;
    gap: 3px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.nav-photos.has-caption .nav-photos__caption {
    opacity: 1;
}

.nav-photos__count {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.55);
}

.nav-photos__title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #fff;
}

.nav-photos__credit {
    font-size: 11px;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.6);
}

.nav-photos__controls {
    position: absolute;
    right: clamp(20px, 3vw, 40px);
    bottom: clamp(20px, 4vh, 40px);
    display: flex;
    gap: 10px;
}

.nav-photos__btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(14, 14, 18, 0.45);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.nav-photos__btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.nav-photos__btn:active {
    transform: scale(0.94);
}

.nav-photos__btn svg {
    width: 20px;
    height: 20px;
}

.nav-photos__back {
    display: none;
}

.nav-overlay button:focus-visible,
.nav-overlay a:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 3px;
}

.nav-link a:focus-visible {
    outline: none;
}

/* ─── MEDIUM WIDTHS: photo panel narrows, then drops away ─── */
@media (max-width: 1280px) {
    .nav-photos { flex-basis: 34%; }
}

@media (max-width: 1023px) {
    .nav-photos { display: none; }
    .nav-overlay.has-photos .nav-close { background: transparent; }
    .nav-menu__photos { display: inline-block; }
    .nav-link__label { font-size: clamp(19px, min(3.6vw, 4.4vh), 38px); }
}

/* ─── PHONES: one column ─────────────────────────────────── */
@media (max-width: 640px) {
    .nav-menu__groups {
        grid-template-columns: 1fr;
        align-content: start;
        row-gap: clamp(16px, 2.6vh, 28px);
    }

    .nav-link__label { font-size: clamp(20px, 6.2vw, 26px); }

    .nav-link a { padding: clamp(7px, 1.1vh, 11px) 0; }

    .nav-menu__top { margin-bottom: clamp(12px, 2.4vh, 28px); }

    .nav-menu__foot { margin-top: clamp(16px, 3vh, 28px); }

    .nav-menu__photos { margin-left: 0; flex-basis: 100%; margin-top: 6px; }

    .nav-photos__caption { right: 20px; bottom: 96px; }
    .nav-photos__controls { left: 20px; right: 20px; justify-content: space-between; }
}

/* Phone photo view: the panel takes over the screen */
.nav-overlay.is-viewing-photos .nav-menu {
    visibility: hidden;
}

.nav-overlay.is-viewing-photos .nav-photos {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 3;
}

.nav-overlay.is-viewing-photos .nav-photos__back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: absolute;
    top: 26px;
    left: 20px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    background: rgba(14, 14, 18, 0.5);
    color: #fff;
    font: 600 13px var(--font-main);
    cursor: pointer;
}

.nav-overlay.is-viewing-photos .nav-close {
    visibility: visible;
    background: rgba(14, 14, 18, 0.5);
}

/* ─── REDUCED MOTION ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .nav-overlay,
    .nav-overlay.is-open,
    .nav-photos__img {
        transition-duration: 0.01s;
    }

    .nav-overlay.is-open .nav-link,
    .nav-overlay.is-open .nav-group__label,
    .nav-overlay.is-open .nav-menu__foot {
        animation: none;
    }

    .nav-link__label,
    .nav-close {
        transition: color 0.2s ease;
    }
}
