html {
    padding-top: 110px;
    scroll-padding-top: 100px;
    scroll-behavior: smooth;
}

header#base-header {
    align-items: center;
    background: linear-gradient(110deg, var(--randopolis-ink), var(--randopolis-surface));
    border-bottom: 1px solid var(--randopolis-border, #514060);
    box-shadow: 0 8px 24px rgba(8, 7, 18, 0.28);
    box-sizing: border-box;
    color: var(--randopolis-text, #f3edf9);
    display: flex;
    flex-direction: row;
    height: 80px;
    justify-content: space-between;
    left: 0;
    line-height: 1.25;
    padding: 12px clamp(16px, 3vw, 36px);
    position: fixed;
    right: 0;
    top: 0;
    width: 100%;
    z-index: 9999;
}

#base-header #base-header-left {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
}

#base-header #site-title {
    align-items: center;
    color: var(--randopolis-gold, #f3d09a);
    display: inline-flex;
    gap: 12px;
    margin: 0;
    padding: 0;
    text-decoration: none;
}

#base-header #site-title img {
    display: block;
    height: 48px;
    margin: 0;
    object-fit: contain;
    width: 48px;
}

#base-header .site-wordmark {
    color: var(--randopolis-gold, #f3d09a);
    font-family: Cinzel, Georgia, serif;
    font-size: clamp(1rem, 1.7vw, 1.35rem);
    font-weight: 600;
    letter-spacing: 0.11em;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
}

#base-header-right {
    align-items: center;
    display: flex;
    flex: 0 1 auto;
    gap: clamp(4px, 0.75vw, 12px);
    justify-content: flex-end;
    margin: 0;
}

#base-header a,
#base-header-mobile-menu a,
#base-header-mobile-menu-button {
    border-radius: 999px;
    color: var(--randopolis-muted, #c3bad6);
    cursor: pointer;
    font-family: Lexend, LexendDeca-Regular, Arial, sans-serif;
    font-size: 0.87rem;
    font-weight: 500;
    letter-spacing: 0.015em;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 140ms ease, color 140ms ease;
}

#base-header-right a {
    padding: 0.6rem 0.72rem;
    white-space: nowrap;
}

#base-header a:hover,
#base-header-mobile-menu a:hover,
#base-header-mobile-menu-button:hover {
    background-color: rgba(243, 208, 154, 0.12);
    color: var(--randopolis-gold, #f3d09a);
}

#base-header a:focus-visible,
#base-header summary:focus-visible {
    outline: 2px solid var(--randopolis-gold, #f3d09a);
    outline-offset: 3px;
}

#base-header-right-mobile {
    display: none;
    position: relative;
}

#base-header-mobile-menu-button {
    align-items: center;
    border: 1px solid var(--randopolis-border, #514060);
    display: inline-flex;
    gap: 9px;
    list-style: none;
    padding: 0.6rem 0.9rem;
    user-select: none;
}

#base-header-mobile-menu-button::-webkit-details-marker {
    display: none;
}

#base-header-mobile-menu-button::marker {
    content: "";
}

#base-header .menu-icon {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    width: 15px;
}

#base-header .menu-icon span {
    background: currentColor;
    border-radius: 2px;
    display: block;
    height: 2px;
    width: 100%;
}

#base-header-mobile-menu {
    background: var(--randopolis-surface, #1a1730);
    border: 1px solid var(--randopolis-border, #514060);
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(8, 7, 18, 0.45);
    display: none;
    flex-direction: column;
    box-sizing: border-box;
    width: min(19rem, calc(100vw - 32px));
    max-height: calc(100dvh - 90px);
    overflow: auto;
    padding: 8px;
    position: absolute;
    right: 0;
    top: calc(100% + 12px);
    z-index: 10000;
}

#base-header-right-mobile[open] #base-header-mobile-menu {
    display: flex;
}

#base-header-mobile-menu a {
    border-radius: 8px;
    display: block;
    padding: 0.8rem 1rem;
}

@media all and (max-width: 960px), only screen and (max-device-width: 768px) {
    #base-header-right {
        display: none;
    }

    #base-header-right-mobile {
        display: block;
    }
}

/* Retain the tall header and matching document offset for legacy mobile pages
   that have no viewport meta tag and therefore use a desktop-width layout. */
@media only screen and (max-device-width: 768px) {
    html {
        padding-top: 260px;
        scroll-padding-top: 230px;
    }

    header#base-header {
        height: 200px;
        padding: 18px 20px;
    }

    #base-header #site-title img {
        height: 64px;
        width: 64px;
    }

    #base-header .site-wordmark {
        font-size: clamp(1.25rem, 4vw, 1.7rem);
    }
}

/* Viewport-aware mobile pages use the compact header and its normal scroll offset. */
@media only screen and (max-device-width: 768px) and (max-width: 960px) {
    html {
        padding-top: 110px;
        scroll-padding-top: 100px;
    }

    header#base-header {
        height: 80px;
        padding: 10px 16px;
    }

    #base-header #site-title img {
        height: 48px;
        width: 48px;
    }

    #base-header .site-wordmark {
        font-size: clamp(0.95rem, 4.5vw, 1.25rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    #base-header a,
    #base-header-mobile-menu-button {
        transition: none;
    }
}
