/* r33 owner: header-navigation. Sole active owner for the public header, desktop rail, project collection, compact menu, and header actions. */
/* Header shell
   ========================================================================== */

.site-header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 1000;
    height: var(--header-h);
    border-bottom: 1px solid var(--line);
    background: rgba(7, 7, 9, 0.84);
    backdrop-filter: blur(1.15rem) saturate(1.25);
    transition:
        background 0.3s ease,
        border-color 0.3s ease,
        transform 0.36s var(--ease);
}

html[data-theme="dawn"] .site-header,
html[data-theme="dawn"] .site-header.is-scrolled {
    background: rgba(236, 231, 221, 0.92);
}

.site-header.is-scrolled {
    background: rgba(7, 7, 9, 0.94);
}

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

.site-header:has(details[open]),
html.nav-open .site-header {
    transform: none;
}

.site-header__inner {
    display: flex;
    height: 100%;
    gap: clamp(0.7rem, 1.35vw, 1.4rem);
    align-items: center;
    justify-content: space-between;
}

/* Brand
   ========================================================================== */

.brand {
    display: inline-flex;
    min-width: 0;
    gap: 0.7rem;
    align-items: center;
    flex: 0 0 auto;
    color: var(--text);
    white-space: nowrap;
}

.brand__mark {
    display: grid;
    width: 1.9rem;
    height: 1.9rem;
    place-items: center;
    flex: 0 0 auto;
}

.brand__mark svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: var(--signal);
    stroke-linecap: round;
    stroke-width: 1.4;
    transition: transform 0.55s var(--ease);
}

.brand:hover .brand__mark svg {
    transform: rotate(90deg) scale(1.06);
}

.brand__word {
    display: flex;
    align-items: baseline;
    font-family: var(--font-display);
    letter-spacing: -0.03em;
    line-height: 1;
}

.brand__word strong {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: -0.045em;
}

.brand__word em {
    color: var(--signal);
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-style: normal;
    font-weight: 900;
    letter-spacing: 0.02em;
}

.brand__descriptor {
    display: block;
    max-width: 8rem;
    color: var(--faint);
    font-family: var(--font-mono);
    font-size: 0.49rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    line-height: 1.25;
    text-transform: uppercase;
    white-space: normal;
}

/* Desktop route rail
   ========================================================================== */

.desktop-nav {
    display: flex;
    min-width: 0;
    padding: 0.2rem;
    gap: 0.1rem;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    background: rgba(255, 255, 255, 0.015);
}

.desktop-nav__link {
    position: relative;
    display: inline-flex;
    min-width: 0;
    min-height: 2.75rem;
    padding: 0.68rem clamp(0.56rem, 0.82vw, 0.82rem);
    gap: 0.45rem;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.56rem;
    color: var(--muted);
    background: transparent;
    font-size: 0.66rem;
    font-weight: 850;
    letter-spacing: 0.075em;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
    transition:
        color 0.2s ease,
        background 0.2s ease;
}

.desktop-nav__link::after {
    position: absolute;
    right: 0.7rem;
    bottom: 0.22rem;
    left: 0.7rem;
    height: 0.12rem;
    content: "";
    background: var(--signal);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.28s var(--ease);
}

.desktop-nav__link:hover,
.desktop-nav__link[aria-current="page"],
.nav-collection.is-current > .nav-collection__summary,
.nav-collection[open] > .nav-collection__summary {
    color: var(--text);
    background: rgba(255, 255, 255, 0.035);
}

.desktop-nav__link:hover::after,
.desktop-nav__link[aria-current="page"]::after,
.nav-collection.is-current > .nav-collection__summary::after,
.nav-collection[open] > .nav-collection__summary::after {
    transform: scaleX(1);
    transform-origin: left;
}

.desktop-nav__label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
}

/* Desktop Project collection
   ========================================================================== */

.nav-collection {
    position: relative;
}

.nav-collection > summary,
.site-menu > summary,
.site-menu__group--project > summary {
    list-style: none;
    cursor: pointer;
}

.nav-collection > summary::-webkit-details-marker,
.site-menu > summary::-webkit-details-marker,
.site-menu__group--project > summary::-webkit-details-marker {
    display: none;
}

.nav-collection__summary svg {
    width: 0.62rem;
    height: 0.42rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    transition: transform 0.24s var(--ease);
}

.nav-collection[open] .nav-collection__summary svg {
    transform: rotate(180deg);
}

.nav-collection__panel {
    position: absolute;
    top: calc(100% + 0.72rem);
    right: 0;
    z-index: 1012;
    display: grid;
    width: min(25rem, calc(100vw - 2rem));
    padding: 0.6rem;
    gap: 0.3rem;
    border: 1px solid var(--line-strong);
    border-radius: 1rem;
    background: rgba(9, 9, 13, 0.98);
    box-shadow: var(--shadow);
}

html[data-theme="dawn"] .nav-collection__panel {
    background: rgba(246, 241, 232, 0.99);
}

.nav-collection__heading {
    display: grid;
    padding: 0.72rem 0.8rem 0.8rem;
    gap: 0.2rem;
    border-bottom: 1px solid var(--line);
}

.nav-collection__heading > span {
    color: var(--signal);
    font-family: var(--font-mono);
    font-size: 0.61rem;
    font-weight: 850;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.nav-collection__heading small,
.nav-collection__item small {
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.45;
}

.nav-collection__item {
    display: grid;
    min-height: 4.2rem;
    padding: 0.72rem 0.8rem;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
    border: 1px solid transparent;
    border-radius: 0.72rem;
    color: var(--text);
    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        transform 0.2s var(--ease);
}

.nav-collection__item:hover,
.nav-collection__item[aria-current="page"] {
    border-color: var(--line-strong);
    background: rgba(var(--signal-rgb), 0.065);
    transform: translateX(0.12rem);
}

.nav-collection__item > span:last-child {
    display: grid;
    min-width: 0;
    gap: 0.2rem;
}

.nav-collection__item strong {
    font-size: 0.8rem;
    line-height: 1.25;
}

.nav-collection__index,
.site-menu__index {
    color: var(--signal);
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    line-height: 1.5;
}

/* Header actions
   ========================================================================== */

.header-actions {
    display: flex;
    gap: 0.42rem;
    align-items: center;
    flex: 0 0 auto;
}

.icon-button,
.command-button,
.menu-button,
.site-menu__close {
    min-height: 2.75rem;
    border: 1px solid var(--line);
    border-radius: 0.72rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.018);
    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        transform 0.2s var(--ease);
}

.icon-button,
.site-menu__close {
    display: grid;
    width: 2.75rem;
    min-width: 2.75rem;
    padding: 0;
    place-items: center;
}

.command-button {
    display: flex;
    min-width: 7.1rem;
    padding: 0 0.75rem;
    gap: 0.48rem;
    align-items: center;
}

.icon-button:hover,
.command-button:hover,
.menu-button:hover,
.site-menu__close:hover {
    border-color: var(--signal);
    background: rgba(var(--signal-rgb), 0.09);
}

.icon-button:hover,
.site-menu__close:hover {
    transform: rotate(3deg);
}

.command-button__icon {
    color: var(--signal);
}

.command-button__label {
    font-size: 0.68rem;
    font-weight: 800;
}

.command-button__hint {
    margin-left: auto;
    padding-left: 0.45rem;
    border-left: 1px solid var(--line);
    color: var(--faint);
    font-family: var(--font-mono);
    font-size: 0.63rem;
}

.theme-icon--dawn {
    display: none;
}

html[data-theme="dawn"] .theme-icon--void {
    display: none;
}

html[data-theme="dawn"] .theme-icon--dawn {
    display: inline;
}

/* Compact menu — hidden above its declared breakpoint
   ========================================================================== */

.site-menu {
    display: none;
}

.menu-button {
    display: none;
    min-width: 4.65rem;
    padding: 0 0.72rem;
    gap: 0.55rem;
    align-items: center;
    justify-content: center;
}

.menu-button__glyph {
    display: grid;
    width: 1rem;
    gap: 0.2rem;
}

.menu-button__glyph i {
    display: block;
    width: 1rem;
    height: 0.1rem;
    background: currentColor;
    transition:
        transform 0.26s var(--ease),
        opacity 0.18s ease;
}

.menu-button__label {
    font-size: 0.66rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.site-menu[open] .menu-button__glyph i:first-child {
    transform: translateY(0.3rem) rotate(45deg);
}

.site-menu[open] .menu-button__glyph i:nth-child(2) {
    opacity: 0;
}

.site-menu[open] .menu-button__glyph i:last-child {
    transform: translateY(-0.3rem) rotate(-45deg);
}

.site-menu__scrim,
.site-menu__panel {
    display: none;
}

/* Intermediate width management
   ========================================================================== */

@media (max-width: 1420px) {
    .brand__descriptor {
        display: none;
    }
}

@media (max-width: 1320px) {
    .command-button__hint {
        display: none;
    }

    .command-button {
        min-width: 5.65rem;
    }
}

@media (max-width: 1240px) {
    .command-button {
        width: 2.75rem;
        min-width: 2.75rem;
        padding: 0;
        justify-content: center;
    }

    .command-button__label,
    .command-button__hint {
        display: none;
    }

    .desktop-nav__link {
        padding-inline: 0.56rem;
        font-size: 0.62rem;
    }
}

/* Compact drawer
   ========================================================================== */

@media (max-width: 1180px) {
    .site-header__inner {
        gap: 0.75rem;
    }

    .desktop-nav {
        display: none;
    }

    .site-menu {
        position: static;
        display: block;
    }

    .menu-button {
        display: flex;
    }

    .site-menu[open] .site-menu__scrim {
        position: fixed;
        inset: var(--header-h) 0 0;
        z-index: 1004;
        display: block;
        width: 100%;
        height: auto;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: rgba(0, 0, 0, 0.68);
        cursor: default;
    }

    .site-menu[open] .site-menu__panel {
        position: fixed;
        top: calc(var(--header-h) + 0.55rem);
        right: max(1rem, calc((100vw - var(--shell)) / 2));
        left: max(1rem, calc((100vw - var(--shell)) / 2));
        z-index: 1006;
        display: grid;
        max-height: calc(100svh - var(--header-h) - 1.1rem);
        padding: clamp(0.75rem, 2.2vw, 1.15rem);
        gap: 0.75rem;
        overflow-y: auto;
        overscroll-behavior: contain;
        border: 1px solid var(--line-strong);
        border-radius: 1rem;
        background: rgba(9, 9, 13, 0.985);
        box-shadow: var(--shadow);
    }

    html[data-theme="dawn"] .site-menu[open] .site-menu__panel {
        background: rgba(246, 241, 232, 0.992);
    }

    html.nav-open {
        overflow: hidden;
        scrollbar-gutter: stable;
    }

    .site-menu__top {
        display: flex;
        min-height: 3.2rem;
        padding: 0.1rem 0.1rem 0.75rem;
        gap: 1rem;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid var(--line);
    }

    .site-menu__top > div {
        display: grid;
        gap: 0.12rem;
    }

    .site-menu__eyebrow {
        color: var(--signal);
        font-family: var(--font-mono);
        font-size: 0.58rem;
        font-weight: 850;
        letter-spacing: 0.15em;
        text-transform: uppercase;
    }

    .site-menu__top strong {
        font-size: clamp(1rem, 2.4vw, 1.35rem);
        letter-spacing: -0.02em;
    }

    .site-menu__close {
        font-size: 1.45rem;
        line-height: 1;
    }

    .no-js .site-menu__close,
    .no-js .site-menu__utility {
        display: none;
    }

    .site-menu__home,
    .site-menu__link,
    .site-menu__search {
        display: grid;
        min-height: 3.75rem;
        padding: 0.68rem 0.78rem;
        grid-template-columns: auto minmax(0, 1fr);
        gap: 0.68rem;
        align-items: start;
        border: 1px solid var(--line);
        border-radius: 0.76rem;
        color: var(--text);
        background: rgba(255, 255, 255, 0.016);
        text-align: left;
        transition:
            border-color 0.2s ease,
            background 0.2s ease,
            transform 0.2s var(--ease);
    }

    .site-menu__home {
        grid-template-columns: auto minmax(0, 1fr);
        border-color: rgba(var(--signal-rgb), 0.3);
        background: rgba(var(--signal-rgb), 0.045);
    }

    .site-menu__home:hover,
    .site-menu__home[aria-current="page"],
    .site-menu__link:hover,
    .site-menu__link[aria-current="page"],
    .site-menu__search:hover {
        border-color: var(--signal);
        background: rgba(var(--signal-rgb), 0.075);
        transform: translateY(-0.08rem);
    }

    .site-menu__home > span:last-child,
    .site-menu__link > span:last-child,
    .site-menu__search > span:nth-child(2) {
        display: grid;
        min-width: 0;
        gap: 0.16rem;
    }

    .site-menu__home strong,
    .site-menu__link strong,
    .site-menu__search strong {
        font-size: 0.77rem;
        letter-spacing: 0.015em;
        line-height: 1.25;
    }

    .site-menu__home small,
    .site-menu__link small,
    .site-menu__search small {
        color: var(--muted);
        font-size: 0.67rem;
        line-height: 1.42;
    }

    .site-menu__groups {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(15rem, 1fr);
        gap: 0.75rem;
        align-items: start;
    }

    .site-menu__group {
        min-width: 0;
        padding: 0.65rem;
        border: 1px solid var(--line);
        border-radius: 0.85rem;
        background: rgba(255, 255, 255, 0.012);
    }

    .site-menu__group:first-child {
        grid-row: span 2;
    }

    .site-menu__group-heading {
        display: grid;
        min-height: 2.75rem;
        margin: 0;
        padding: 0.45rem 0.5rem 0.62rem;
        gap: 0.12rem;
        align-content: center;
        border: 0;
        color: var(--text);
        background: transparent;
        text-align: left;
    }

    .site-menu__group-heading > span {
        color: var(--signal);
        font-family: var(--font-mono);
        font-size: 0.59rem;
        font-weight: 850;
        letter-spacing: 0.14em;
        text-transform: uppercase;
    }

    .site-menu__group-heading small {
        color: var(--faint);
        font-size: 0.65rem;
        line-height: 1.35;
    }

    .site-menu__links {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.4rem;
    }

    .site-menu__group:nth-child(2) .site-menu__links,
    .site-menu__group--project .site-menu__links {
        grid-template-columns: minmax(0, 1fr);
    }

    .site-menu__group--project > .site-menu__group-heading {
        position: relative;
        min-height: 3.25rem;
        padding-right: 2.4rem;
        cursor: pointer;
    }

    .site-menu__group--project > .site-menu__group-heading svg {
        position: absolute;
        top: 50%;
        right: 0.7rem;
        width: 0.72rem;
        height: 0.48rem;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.5;
        transform: translateY(-50%);
        transition: transform 0.24s var(--ease);
    }

    .site-menu__group--project[open] > .site-menu__group-heading svg {
        transform: translateY(-50%) rotate(180deg);
    }

    .site-menu__group--project[open] > .site-menu__group-heading {
        margin-bottom: 0.35rem;
        border-bottom: 1px solid var(--line);
    }

    .site-menu__utility {
        padding-top: 0.1rem;
    }

    .site-menu__search {
        width: 100%;
        grid-template-columns: auto minmax(0, 1fr) auto;
        cursor: pointer;
    }

    .site-menu__search > span:first-child {
        color: var(--signal);
        font-size: 1rem;
    }

    .site-menu__search kbd {
        align-self: center;
        padding: 0.28rem 0.38rem;
        border: 1px solid var(--line);
        border-radius: 0.35rem;
        color: var(--faint);
        font-family: var(--font-mono);
        font-size: 0.58rem;
        background: rgba(255, 255, 255, 0.02);
    }
}

@media (max-width: 720px) {
    .site-header__inner {
        width: calc(100vw - 1.25rem);
    }

    .brand__mark {
        width: 1.7rem;
        height: 1.7rem;
    }

    .brand__word strong {
        font-size: 0.9rem;
    }

    .icon-button,
    .command-button,
    .menu-button {
        min-height: 2.75rem;
    }

    .site-menu[open] .site-menu__panel {
        top: calc(var(--header-h) + 0.35rem);
        right: 0.625rem;
        left: 0.625rem;
        max-height: calc(100svh - var(--header-h) - 0.7rem);
        padding: 0.68rem;
        border-radius: 0.85rem;
    }

    .site-menu__groups {
        grid-template-columns: minmax(0, 1fr);
    }

    .site-menu__group:first-child {
        grid-row: auto;
    }

    .site-menu__group:nth-child(2) .site-menu__links {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .site-menu__home small,
    .site-menu__link small,
    .site-menu__search small,
    .site-menu__group-heading small {
        display: none;
    }

    .site-menu__home,
    .site-menu__link {
        min-height: 3.35rem;
        align-items: center;
    }

    .site-menu__group-heading {
        min-height: 2.75rem;
        padding-block: 0.4rem;
    }
}

@media (max-width: 520px) {
    .brand__word em {
        font-size: 0.57rem;
    }

    .header-actions {
        gap: 0.3rem;
    }

    .menu-button {
        width: 2.75rem;
        min-width: 2.75rem;
        padding: 0;
    }

    .menu-button__label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .site-menu__top strong {
        font-size: 1rem;
    }
}

@media (max-width: 390px) {
    .site-header__inner {
        gap: 0.42rem;
    }

    .brand {
        gap: 0.48rem;
    }

    .brand__word strong {
        font-size: 0.82rem;
    }

    .brand__word em {
        display: none;
    }

    .site-menu__links,
    .site-menu__group:nth-child(2) .site-menu__links {
        grid-template-columns: minmax(0, 1fr);
    }

    .site-menu__top {
        min-height: 2.9rem;
    }
}

@media (max-width: 330px) {
    .brand__mark {
        width: 1.55rem;
        height: 1.55rem;
    }

    .brand__word strong {
        font-size: 0.76rem;
    }

    .icon-button,
    .command-button,
    .menu-button {
        width: 2.65rem;
        min-width: 2.65rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-header,
    .brand__mark svg,
    .desktop-nav__link,
    .desktop-nav__link::after,
    .nav-collection__summary svg,
    .nav-collection__item,
    .menu-button__glyph i,
    .site-menu__home,
    .site-menu__link,
    .site-menu__search,
    .site-menu__group--project > .site-menu__group-heading svg {
        transition-duration: 0.001ms;
    }
}

@media print {
    .site-header {
        display: none;
    }
}
