/* ---- Global navbar ------------------------------------------------ */
/* Single source of truth for _includes/nav.html styling.
   Linked by every layout after the base sheet, so var(--…) resolves
   against whichever :root defines it (wos.css or plrn.css). Do not
   duplicate these rules in wos.css / plrn.css. */

.site-nav {
    width: 100vw;
    position: relative;
    z-index: 50;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: clamp(1.75rem, 4vh, 3rem);
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    /* Pin the nav's own type base so it stops inheriting the page body's
       font-size (18px on wos, 20px on plrn — that drift was the bug).
       18px matches the wos desktop base; em-sized children scale off it. */
    font-size: 18px;
}
.site-nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.7rem clamp(1.25rem, 3.5vw, 3rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.site-nav .brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: var(--ink);
    font-family: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
    font-weight: 700;
    font-size: 0.9em;
    letter-spacing: -0.01em;
}
.site-nav .brand svg { width: 24px; height: 24px; flex-shrink: 0; }
.nav-links {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-family: var(--font-mono);
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}
.nav-sep {
    color: var(--rule);
    font-size: 0.85em;
    user-select: none;
    line-height: 1;
}
.nav-links a {
    color: var(--dim);
    text-decoration: none;
    padding-bottom: 3px;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.14s, border-color 0.14s;
}
.nav-links a:hover { color: var(--dim); }
.nav-links a.active { color: var(--ink); border-bottom-color: var(--ink); }
.ade-nav {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.12rem;
}
.ade-nav-toggle {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--dim);
    cursor: pointer;
    font: inherit;
    line-height: 1;
    padding: 0 0.12rem 0.2rem;
}
.ade-nav-toggle span {
    display: block;
    transition: transform 0.14s;
}
.ade-nav-menu {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    z-index: 60;
    min-width: 14rem;
    max-width: calc(100vw - 2.5rem);
    padding: 0.35rem;
    background: var(--bg);
    border: 1px solid var(--rule);
    box-shadow: 0 0.65rem 1.5rem rgba(5, 5, 5, 0.1);
    font-family: var(--font-label);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-transform: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-0.25rem);
    transition: opacity 0.14s, visibility 0.14s, transform 0.14s;
}
.ade-nav-menu::before {
    content: "";
    position: absolute;
    top: -0.5rem;
    right: 0;
    left: 0;
    height: 0.5rem;
}
.ade-nav-menu a {
    display: block;
    padding: 0.55rem 0.65rem;
    border: 0;
    color: var(--dim);
}
.ade-nav-menu a:hover,
.ade-nav-menu a:focus,
.ade-nav-menu a.active {
    color: var(--ink);
    background: rgba(5, 5, 5, 0.045);
}
.ade-nav:hover .ade-nav-menu,
.ade-nav[data-open="true"] .ade-nav-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
}
.ade-nav:hover .ade-nav-toggle span,
.ade-nav[data-open="true"] .ade-nav-toggle span {
    transform: rotate(180deg);
}

/* Hamburger button — hidden on desktop, shown at the mobile breakpoint. */
.nav-menu-toggle {
    display: none;
    appearance: none;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0.35rem 0.1rem;
    margin: -0.35rem -0.1rem 0 0;
    color: var(--ink);
    font: inherit;
    line-height: 1;
    align-self: center;
}
/* Home link lives in the mobile panel only (the brand is the home link on
   desktop, and the brand is hidden when the panel is open). */
.nav-home { display: none; }
.nav-menu-toggle .bars {
    display: block;
    position: relative;
    width: 1.4rem;
    height: 1.4rem;
}
.nav-menu-toggle .bars span {
    display: block;
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--ink);
    transition: transform 0.18s, opacity 0.14s;
}
.nav-menu-toggle .bars span:nth-child(1) { top: 4px; }
.nav-menu-toggle .bars span:nth-child(2) { top: 50%; transform: translateY(-50%); }
.nav-menu-toggle .bars span:nth-child(3) { bottom: 4px; }
.nav-menu-toggle[aria-expanded="true"] .bars span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav-menu-toggle[aria-expanded="true"] .bars span:nth-child(2) { opacity: 0; }
.nav-menu-toggle[aria-expanded="true"] .bars span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}
.nav-menu-toggle .toggle-label {
    display: none; /* label is conveyed by aria-label; keep the icon clean */
}

/* On wos-layout pages the nav tucks up under the hero / publication plate.
   PLRN pages (blog, notes, posts) have no plate, so the default top margin
   is 0. The wos layout sets class="layout-wos" on <body>. */
.layout-wos .site-nav { margin-top: calc(-1 * clamp(3rem, 6vh, 6rem)); }

/* ---- Mobile (≤640px): hamburger → slide-down panel ---------------- */
@media (max-width: 640px) {
    .site-nav { font-size: 17px; }
    /* "· Pentad Labs" crowds the hamburger row; the wordmark alone is enough. */
    .brand-suffix { display: none; }
    /* Home link lives in the mobile panel only (brand is the home link on
       desktop, and the brand is hidden when the panel is open). */
    .nav-home { display: block; }
    .site-nav-inner {
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
    }
    .nav-menu-toggle { display: inline-flex; }

    /* When the panel is open, drop the brand/mark from the top row so the
       whole bar is given over to the menu: close button on the right,
       links below. The wordmark returns when the panel closes. */
    .site-nav[data-menu-open="true"] .site-nav-inner {
        justify-content: flex-end;
    }
    .site-nav[data-menu-open="true"] .brand { display: none; }

    /* Collapse the inline link row into a full-width panel that slides
       down under the nav bar. width:100% + flex-wrap on the inner row
       wraps it onto its own line; order:1 keeps the toggle on the top
       row with the brand (line 1 = brand + toggle, line 2 = links).
       Hidden by height + overflow until open. */
    .nav-links {
        order: 1;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        flex-wrap: nowrap;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        margin-top: 0;
        border-top: 1px solid transparent;
        transition: max-height 0.22s ease, border-color 0.14s, padding 0.14s;
        font-size: 0.78em;
    }
    .site-nav[data-menu-open="true"] .nav-links {
        max-height: 70vh;
        overflow-y: auto;
        border-top-color: var(--rule);
        padding-top: 0.2rem;
    }

    /* Separators become row dividers; the · glyph itself is hidden. */
    .nav-sep {
        display: block;
        height: 1px;
        font-size: 0;
        background: var(--rule);
        margin: 0;
    }

    .nav-links a {
        display: block;
        width: 100%;
        padding: 0.7rem 0.1rem;
        border-bottom: 0;
        white-space: normal;
    }
    .nav-links a.active { border-bottom: 0; }
    .nav-links a:hover { color: var(--ink); }

    /* ADE group: render as a labelled sub-section, not a hover flyout.
       The toggle arrow still works but the sub-links are stacked inline. */
    .ade-nav {
        display: block;
        width: 100%;
    }
    .ade-nav > a { /* the "Agentic Data Enclave" parent link */
        display: block;
        width: 100%;
        padding: 0.7rem 0.1rem;
    }
    .ade-nav-toggle {
        position: absolute;
        top: 0;
        right: 0;
        padding: 0.7rem 0.1rem;
    }
    .ade-nav-menu {
        position: static;
        max-width: none;
        min-width: 0;
        width: 100%;
        box-shadow: none;
        border: 0;
        padding: 0 0 0.2rem 0;
        background: transparent;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
        transition: none;
    }
    .ade-nav-menu::before { display: none; }
    .ade-nav-menu a {
        padding: 0.55rem 0.1rem 0.55rem 0.9rem;
        border-bottom: 1px solid var(--rule);
    }
    .ade-nav-menu a:last-child { border-bottom: 0; }
    .ade-nav-menu a:hover,
    .ade-nav-menu a:focus,
    .ade-nav-menu a.active { background: transparent; }
}