/* =========================================================
   DESIGN TOKENS
========================================================= */

:root {
    --color-bg: #1e1e1e;
    --color-surface: #1b1b1b;
    --color-surface-raised: #212121;
    --color-surface-hover: #292929;
    --color-border: #2e2e2e;
    --color-border-strong: #171717;
    --color-text: #eeeeee;
    --color-text-hover: #ffffff;
    --color-text-muted: #aaaaaa;
    --color-accent: #3898d4;

    --nav-height: 60px;
    --content-width: 100%;

    --duration-fast: 140ms;
    --duration-medium: 220ms;
}

/* =========================================================
   RESET / BASE
========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

html {
    background: var(--color-bg);
}

body {
    display: flex;
    flex-direction: column;
    font-family: "Montserrat", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    font-synthesis: none;
}

button,
a {
    font: inherit;
}

button {
    color: inherit;
}

ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

a {
    color: inherit;
}

[hidden] {
    display: none !important;
}

/* =========================================================
   PAGE
========================================================= */

main {
    display: grid;
    flex: 1 1 auto;
    min-height: 0;
    place-items: center;
    padding: 24px;
    overflow: auto;
}

/* =========================================================
   NAVIGATION
========================================================= */

nav {
    flex: 0 0 var(--nav-height);
    position: relative;
    z-index: 100;
    height: var(--nav-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border-strong);
}

.mobile-nav {
    display: none;
}

/* =========================================================
   DESKTOP NAVIGATION
========================================================= */

.desktop-nav {
    width: min(100%, var(--content-width));
    height: 100%;
    margin: 0 auto;
}

.desktop-nav-list {
    display: flex;
    height: 100%;
    margin: 0;
    padding: 0 30px;
    list-style: none;
}

.desktop-nav-item {
    flex: 0 0 auto;
}

.desktop-nav-trigger {
    height: 100%;
    padding: 0 18px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: #d8d8d8;
    font-size: 1em;
    cursor: pointer;
    white-space: nowrap;
    transition:
        color var(--duration-fast) ease,
        border-color var(--duration-fast) ease;
}

.desktop-nav-trigger:hover,
.desktop-nav-trigger:focus-visible,
.desktop-nav-item.is-open > .desktop-nav-trigger {
    color: var(--color-accent);
}

.desktop-nav-item.is-open > .desktop-nav-trigger {
    border-bottom-color: var(--color-accent);
}

.desktop-submenu {
    position: fixed;
    top: var(--nav-height);
    left: 50%;
    transform: translateX(-50%);
    z-index: 120;
    width: 100vw;
    max-height: calc(100dvh - var(--nav-height) - 30px);
    overflow: auto;
    padding: 30px 40px;
    border: 1px solid var(--color-border);
    background: var(--color-surface-raised);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity var(--duration-medium) ease,
        visibility 0s linear var(--duration-medium);
}

.desktop-nav-item.is-open > .desktop-submenu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
    transition:
        opacity var(--duration-medium) ease,
        transform var(--duration-medium) ease,
        visibility 0s linear 0s;
}

/* =========================================================
   SHARED LINK CONTENT
========================================================= */

.submenu-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 28px 0;
}

.submenu-section {
    flex: 0 0 auto;
    width: max-content;
    max-width: 100%;
    min-width: 0;
    padding: 0 80px 0 20px;
    border-left: 1px solid var(--color-border);
}

.submenu-section:first-child {
    padding-left: 8px;
    border-left: 0;
}

.submenu-section:last-child {
    padding-right: 8px;
}

.submenu-heading {
    margin: 0 0 24px;
    color: var(--color-accent);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.submenu-links {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.submenu-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 7px 0;
    overflow: hidden;
    text-decoration: none;
    color: var(--color-text);
    transition: color var(--duration-fast) ease;
}

.submenu-links a:hover,
.submenu-links a:focus-visible {
    color: var(--color-text-hover);
    font-weight: bold;
}

.submenu-links a span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.submenu-links > .submenu-separator {
    height: 0;
    margin: 12px 0;
    padding: 0;
    border: 0;
    border-top: 1px solid var(--color-border);
    list-style: none;
}

.link-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 2px;
    object-fit: contain;
}

.desktop-submenu,
.mobile-nav-panel {
    scrollbar-width: none;
}

.desktop-submenu::-webkit-scrollbar,
.mobile-nav-panel::-webkit-scrollbar {
    display: none;
}

/* =========================================================
   MOBILE / TABLET
========================================================= */

@media (max-width: 960px) {
    :root {
        --nav-height: 50px;
    }

    .desktop-nav {
        display: none;
    }

    .mobile-nav {
        display: block;
        width: 100%;
        height: 100%;
    }

    .mobile-nav-header {
        display: grid;
        grid-template-columns: 50px 1fr 50px;
        align-items: center;
        height: var(--nav-height);
        background: var(--color-surface);
    }

    .mobile-nav-title {
        text-align: center;
        font-weight: 500;
    }

    .mobile-nav-toggle {
        position: relative;
        display: grid;
        width: 50px;
        height: 50px;
        place-items: center;
        padding: 0;
        border: 0;
        background: transparent;
        cursor: pointer;
    }

    .mobile-nav-toggle span,
    .mobile-nav-toggle::before,
    .mobile-nav-toggle::after {
        position: absolute;
        width: 18px;
        height: 1px;
        background: currentColor;
        content: "";
        transition:
            transform var(--duration-fast) ease,
            opacity var(--duration-fast) ease;
    }

    .mobile-nav-toggle::before {
        transform: translateY(-6px);
    }

    .mobile-nav-toggle::after {
        transform: translateY(6px);
    }

    .mobile-nav.is-open .mobile-nav-toggle span {
        opacity: 0;
    }

    .mobile-nav.is-open .mobile-nav-toggle::before {
        transform: rotate(45deg);
    }

    .mobile-nav.is-open .mobile-nav-toggle::after {
        transform: rotate(-45deg);
    }

    .mobile-nav-panel {
        position: fixed;
        inset: var(--nav-height) 0 0;
        z-index: 180;
        width: 100%;
        height: calc(100dvh - var(--nav-height));
        overflow: auto;
        background: var(--color-surface);

        opacity: 0;
        visibility: hidden;
        pointer-events: none;

        transition:
            opacity var(--duration-medium) ease,
            visibility 0s linear var(--duration-medium);
    }

    .mobile-nav.is-open .mobile-nav-panel {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transition:
            opacity var(--duration-medium) ease,
            visibility 0s linear 0s;
    }

    .mobile-category-list {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .mobile-category-trigger {
        position: relative;
        width: 100%;
        min-height: 58px;
        padding: 0 48px 0 20px;
        border: 0;
        border-bottom: 1px solid var(--color-border);
        background: transparent;
        color: var(--color-text);
        text-align: left;
        cursor: pointer;
    }

    .mobile-category-trigger::after {
        content: "›";
        position: absolute;
        right: 20px;
        top: 50%;
        color: var(--color-text-muted);
        font-size: 1.35rem;
        line-height: 1;
        transform: translateY(-50%);
    }

    .mobile-category-trigger:hover,
    .mobile-category-trigger:focus-visible {
        background: var(--color-surface-hover);
    }

    .mobile-group {
        min-height: 100%;
        background: var(--color-bg);
    }

    .mobile-group-header {
        position: sticky;
        top: 0;
        z-index: 2;
        display: grid;
        grid-template-columns: 52px 1fr 52px;
        align-items: center;
        height: 54px;
        background: var(--color-surface);
        border-bottom: 1px solid var(--color-border);
    }

    .mobile-group-back {
        display: grid;
        width: 52px;
        height: 54px;
        place-items: center;
        padding: 0;
        border: 0;
        background: transparent;
        color: var(--color-text);
        cursor: pointer;
        font-size: 1.35rem;
    }

    .mobile-group-title {
        text-align: center;
        font-weight: 500;
    }

    .mobile-group .submenu-grid {
        padding: 8px 0 24px;
        gap: 0;
    }

    .mobile-group .submenu-section {
        padding: 16px 20px 10px;
        border: 0;
        border-top: 1px solid var(--color-border);
    }

    .mobile-group .submenu-section:first-child {
        border-top: 0;
    }

    .mobile-group .submenu-links a {
        min-height: 46px;
        padding: 9px 4px;
    }

    .mobile-group .link-icon {
        width: 20px;
        height: 20px;
        flex-basis: 20px;
    }

    main {
        padding: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Landing branding and footer, adapted to the existing dark theme. */
:root {
    --brand-color: #aaaaaa;
    --footer-color: #74777d;
    --page-inline-padding: clamp(1.25rem, 5vw, 4rem);
    --page-block-padding: clamp(1rem, 3.5vh, 2.5rem);
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.75rem, 2.3vh, 1.5rem);
    width: min(100%, 44rem);
    padding-block: clamp(1rem, 4vh, 3rem);
    text-align: center;
}

.brand__logo {
    display: block;
    width: clamp(8.5rem, 24vmin, 15rem);
    height: auto;
}

.brand__name {
    margin: 0;
    color: var(--brand-color);
    font-size: clamp(1.65rem, 6vw, 4rem);
    font-weight: 300;
    letter-spacing: clamp(0.12em, 1.2vw, 0.28em);
    line-height: 1;
    white-space: nowrap;
}

.brand__domain {
    font-size: 0.52em;
    font-weight: 400;
    letter-spacing: 0.08em;
}

.site-footer {
    flex: 0 0 auto;
    width: 100%;
    padding-top: clamp(0.75rem, 2vh, 1.25rem);
    color: var(--footer-color);
    font-size: clamp(0.62rem, 1.5vw, 0.75rem);
    font-weight: 400;
    line-height: 1.6;
    text-align: center;
}

.site-footer p {
    margin: 0;
}

@media (max-height: 34rem) {
    :root {
        --page-block-padding: 0.75rem;
    }

    .brand {
        gap: 0.5rem;
        padding-block: 0.5rem;
    }

    .brand__logo {
        width: clamp(6rem, 23vmin, 9rem);
    }

    .site-footer {
        padding-top: 0.5rem;
        line-height: 1.4;
    }
}

@media (max-width: 22rem) {
    .brand__name {
        letter-spacing: 0.08em;
    }
}

.site-footer {
    padding:
        clamp(0.75rem, 2vh, 1.25rem)
        max(var(--page-inline-padding), env(safe-area-inset-right))
        max(var(--page-block-padding), env(safe-area-inset-bottom))
        max(var(--page-inline-padding), env(safe-area-inset-left));
}

/* Let long labels wrap only when a whole section cannot fit. */
.submenu-links a span {
    white-space: normal;
    overflow-wrap: anywhere;
}
