#header {
    display: flex;
    position: fixed;
    top: 0;
    width: 100%;
    background-color: var(--background-color);
    opacity: 0.85;
    z-index: 9998;
    --sidebar-peek-width: calc(4vw * var(--scale));
    --sidebar-panel-width: min(320px, calc(27vw * var(--scale)));
    --content-left-offset: calc(max(72px, var(--sidebar-peek-width)) + calc(2.5vw * var(--scale)));
}

.navbar {
    width: 100%;
    background-color: var(--background-color);
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
    border-bottom: 1px solid var(--text-color-lower-opac);
    height: 55px;
    z-index: 1;
    position: relative;
}

.navbar-logo {
    margin-left: var(--content-left-offset);
    margin-right: auto;
    display: flex;
    align-items: center;
    color: var(--text-color);
    text-decoration: none;
}

.navbar-logo img {
    height: calc(22px * var(--logo-scale));
    width: auto;
}

.navbar-logo .logo-text {
    font-family: var(--edb);
    font-size: calc(36px * var(--scale));
    font-optical-sizing: auto;
    letter-spacing: -0.02em;
}

/* Glyph-based bottom border for navbar */
.navbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 18px;               /* required glyph size */
    pointer-events: none;
    background-repeat: repeat-x;
    background-position: left bottom;
    background-size: 18px 18px; /* one glyph cell */
    /* Repeating pattern using the custom font glyph U+E0D9 (&#57561;) */
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'><defs><style>@font-face{font-family:RosartOrnaments;src:url('/Users/peterkjackson/Systems-stuff-local/Projects/vlog/theme-development/pkj-zenith/assets/fonts/RosartOrnaments.otf') format('opentype');}</style><pattern id='p' patternUnits='userSpaceOnUse' width='18' height='18'><text x='9' y='14' text-anchor='middle' font-family='RosartOrnaments' font-size='18'>&#57561;</text></pattern></defs><rect width='100%' height='100%' fill='url(%23p)'/></svg>");
    border: none !important;
}

/* Rightmost cap glyph for navbar: U+E206 (&#57862;) */
.navbar::before {
    content: "\E206";  /* &#57862; */
    position: absolute;
    right: 0;
    bottom: 0;
    height: 18px;
    line-height: 18px;
    font-size: calc(18px * var(--scale));
    font-family: "RosartOrnaments";
    pointer-events: none;
    border: none !important;
}

.navbar-button {
    width: 11.2ch;
    min-width: 11.2ch;
    max-width: 11.2ch;
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 2.1ch;
    line-height: 1;
    align-self: stretch;
    box-sizing: border-box;
    overflow: hidden;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    vertical-align: middle;
}

.navbar .button {
    height: 100%;
    min-height: 100%;
    box-sizing: border-box;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    line-height: 1;
}

.navbar .button:hover,
.mobile-menu-cta .button:hover {
    background-color: var(--port);
    color: var(--background-color);
}

.signin-button {
    border: none;
    border-left: 1px solid var(--text-color);
}

.search-bar-wrapper {
    border-left: 1px solid var(--text-color);
    width: calc(28vw * var(--scale));
    display: flex;
    align-items: center;
}

.search-input {
    border: none;
    background-color: transparent;
}

.search-icon-wrapper {
    width: 29px;
    height: 29px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 20px;
}

.search-icon-open {
    position: relative;
    width: 100%;
    height: 100%;
}

.search-icon-close {
    position: relative;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.search-icon-close-line {
    height: 2px;
    width: 100%;
    background-color: var(--text-color);
    position: absolute;
    transform: rotateZ(45deg);
    pointer-events: none;
}

.search-icon-close-line-second {
    transform: rotateZ(-45deg);
}

.menu {
    position: fixed;
    z-index: 3;
    top: 0;
    width: var(--sidebar-panel-width);
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    transform: translateX(calc(-1 * (var(--sidebar-panel-width) - var(--sidebar-peek-width))));
    transition: transform var(--ease-transition);
    overflow: hidden;
    overscroll-behavior: contain;
}

.menu-top {
    height: 55px;
    min-height: 55px;
    border-bottom: 1px solid var(--text-color);
    display: flex;
    justify-content: flex-end;
    background-color: var(--background-color);
}

.menu-button {
    width: 60px;
    padding: 0;
    background-color: transparent;
    border: none !important;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.menu-glyph {
    font-family: 'RosartOrnaments', serif;
    font-size: calc(55px * var(--scale)); /* Match menu-top height of 55px */
    line-height: 1;
    color: var(--revolver);
    transition: all var(--ease-transition);
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none !important;
}

.menu-content {
    display: flex;
    opacity: 1;
    width: 100%;
    height: 100%;
    background-color: var(--background-color);
    height: calc(100vh - 55px);
    height: calc(100dvh - 55px);
    min-height: calc(100dvh - 55px);
    overflow: hidden;
    overscroll-behavior: contain;
}

/* Radial transparency effect for expanded sidebar */
.menu-content::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background-color);
    mask: radial-gradient(
        ellipse at center,
        rgba(0, 0, 0, 1) 0%,
        rgba(0, 0, 0, 0.99) 20%,
        rgba(0, 0, 0, 0.965) 40%,
        rgba(0, 0, 0, 0.925) 60%,
        rgba(0, 0, 0, 0.84) 80%,
        rgba(0, 0, 0, 0.75) 100%
    );
    -webkit-mask: radial-gradient(
        ellipse at center,
        rgba(0, 0, 0, 1) 0%,
        rgba(0, 0, 0, 0.99) 20%,
        rgba(0, 0, 0, 0.965) 40%,
        rgba(0, 0, 0, 0.925) 60%,
        rgba(0, 0, 0, 0.84) 80%,
        rgba(0, 0, 0, 0.75) 100%
    );
    pointer-events: none;
    z-index: -1;
}

/* Ensure menu content has relative positioning for the pseudo-element */
.menu-content {
    position: relative;
}

.menu-links {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    height: 100%;
    min-height: 100%;
    padding-right: 0;
}

.menu[isopen="true"] .sidebar {
    display: none;
}

.menu[isopen="true"] .menu-links {
    width: 100%;
}

.nav {
    display: flex;
    flex-direction: column;
    row-gap: calc(2.1vw * var(--scale));
    padding: calc(4.8vw * var(--scale)) calc(1.45vw * var(--scale));
    list-style: none;
    display: flex;
    justify-content: center;
    min-height: calc(100vh - 55px);
    min-height: calc(100dvh - 55px);
    width: 100%;
    overflow: hidden;
}

.secondary-links {
    display: grid;
    grid-template-columns: 1fr auto;
    list-style: none;
    gap: calc(1.7vw * var(--scale));
    padding-left: 0;
}

.secondary-links li a {
    font-size: calc(18px * var(--scale)) !important;
    font-family: var(--font3);
}

.secondary-links li a:hover {
    text-decoration: underline;
}

.nav-link:hover {
    text-decoration: underline;
    text-decoration-thickness: calc(3px * var(--scale));
    text-decoration-color: var(--swiss-coffee) !important;
}

.nav li a, .nav li .links-label {
    line-height: 110%;
    font-size: calc(42px * var(--scale));
    color: var(--text-color);
    text-decoration: none;
    word-break: normal;
    overflow-wrap: anywhere;
}

.nav li .links-label {
    border-bottom: 1px solid var(--text-color-lower-opac);
    padding-bottom: calc(0.7vw * var(--scale));
    margin-bottom: calc(1.25vw * var(--scale));
    margin-top: calc(2.8vw * var(--scale));
}

.sidebar {
    width: var(--sidebar-peek-width);
    min-width: var(--sidebar-peek-width);
    max-width: 56px;
    border-right: 1px solid var(--text-color-lower-opac);
    border-top: none;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    height: calc(100vh - 55px);
    height: calc(100dvh - 55px);
    min-height: calc(100dvh - 55px);
}

/* Glyph-based bottom border for sidebar: U+E20D (&#57869;) */
.sidebar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 18px;
    pointer-events: none;
    background-repeat: repeat-x;
    background-position: left bottom;
    background-size: 18px 18px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'><defs><style>@font-face{font-family:RosartOrnaments;src:url('/Users/peterkjackson/Systems-stuff-local/Projects/vlog/theme-development/pkj-zenith/assets/fonts/RosartOrnaments.otf') format('opentype');}</style><pattern id='p' patternUnits='userSpaceOnUse' width='18' height='18'><text x='9' y='14' text-anchor='middle' font-family='RosartOrnaments' font-size='18'>&#57869;</text></pattern></defs><rect width='100%' height='100%' fill='url(%23p)'/></svg>");
    border: none !important;
}

.logo {
    color: var(--text-color);
    text-decoration: none;
    transform: rotate(-90deg);
    white-space: nowrap;
}

.logo img{
    height: calc(22px * var(--logo-scale));
    width: auto; 
}

.logo-text {
    font-family: var(--edb); /* CommitMono for navbar title */
    font-size: calc(36px * var(--scale)); /* $text-xl equivalent */
    font-optical-sizing: auto;
    letter-spacing: -0.02em;
}



.blur {
    z-index: 2;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    background-color: color-mix(in srgb, var(--background-color) 14%, transparent);
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    display: none;
}

.blur-lower-index {
    z-index: 0;
}

.navbar-mobile, .search-icon-wrapper-mobile, .mobile-logo {
    display: none;
}

.mobile-menu-cta {
    display: none;
}

#header ul li {
    line-height: 130%;
    margin-bottom: 0;

}

.custom-search {
    position: absolute;
    bottom: 0px;
    right: 0;
    transform: translateY(100%);
    width: calc(100% - var(--sidebar-peek-width));
    background-color: var(--background-color);
}

.custom-search .section-header {
    border-top: none;
}

.custom-search .grid {
    display: none;
    padding-top: calc(2.5vw * var(--scale));
    padding-bottom: calc(2.5vw * var(--scale));
    max-height: 60vh;
    overflow-y: auto;
    border-bottom: 1px solid var(--text-color);
}

.custom-search {
    display: none;
}

.search-icon {
    position: absolute;
}

.site-content {
    padding-top: 55px;
}

body:has(#header .menu[isopen="true"]) {
    overflow: hidden;
}

body:has(#header .menu[isopen="true"]) .site-content,
body:has(#header .menu[isopen="true"]) main,
body:has(#header .menu[isopen="true"]) footer,
body:has(#header .menu[isopen="true"]) .site-footer,
body:has(#header .menu[isopen="true"]) #announcement-bar-root {
    filter: blur(5px);
    transition: filter var(--ease-transition);
}

body:has(#header .menu[isopen="true"]) #header .navbar,
body:has(#header .menu[isopen="true"]) #header .custom-search {
    filter: blur(5px);
    transition: filter var(--ease-transition);
}

#announcement-bar-root {
    transform: translateY(55px);
}

#announcement-bar-root .gh-announcement-bar {
    font-weight: 400;
    font-size: calc(16px * var(--scale));
    line-height: 150%;
    padding: 12px 6vw 12px calc(6vw + var(--sidebar-peek-width));
}

li ul li .nav-link {
    word-break: unset;
}

/* Styles for large desktop */
@media (min-width: 1439px) {
    #header {
        --sidebar-peek-width: calc(3.75vw * var(--scale));
        --sidebar-panel-width: min(320px, calc(25vw * var(--scale)));
    }

    .navbar {
        height: calc(3.8vw * var(--scale));
    }

    .nav {
        min-height: calc(100vh - (3.8vw * var(--scale)));
    }

    .menu-content {
        height: calc(100vh - (3.8vw * var(--scale)));
    }

    .navbar-button {
        width: 11.2ch;
        min-width: 11.2ch;
        max-width: 11.2ch;
        padding: 0 2.1ch;
    }

    .navbar-logo {
        margin-left: var(--content-left-offset);
    }

    .navbar-logo img {
        height: calc(1.5vw * var(--scale) * var(--logo-scale));
    }

    .navbar-logo .logo-text {
        font-size: calc(1.9vw * var(--scale));
    }

    .search-icon-wrapper {
        width: calc(2vw * var(--scale));
        height: calc(2vw * var(--scale));
        margin-right: calc(1.4vw * var(--scale));
    }

    .menu {
        transform: translateX(calc(-1 * (var(--sidebar-panel-width) - var(--sidebar-peek-width))));
        width: var(--sidebar-panel-width);
    }

    .menu-top {
        height: calc(3.8vw * var(--scale));
        min-height: calc(3.8vw * var(--scale));
    }

    .menu-button {
        width: calc(3.75vw * var(--scale)); /* Match sidebar width */
        row-gap: calc(0.5vw * var(--scale));
    }

    .menu-glyph {
        font-size: calc(3.8vw * var(--scale)); /* Match menu-top height for large desktop */
    }

    .sidebar {
        width: var(--sidebar-peek-width);
        min-width: var(--sidebar-peek-width);
        max-width: 56px;
    }
    
    .logo {
        transform: rotate(-90deg);
    }
    
    .logo img{
        height: calc(1.5vw * var(--scale) * var(--logo-scale));
    }
    
    .logo-text {
        font-size: calc(1.9vw * var(--scale));
    }



    .blur {
        -webkit-backdrop-filter: blur(0.35vw);
        backdrop-filter: blur(0.35vw);
    }

    .nav li a, .nav li .links-label {
        font-size: calc(2.9vw * var(--scale));
    }

    .secondary-links li a {
        font-size: calc(1.38vw * var(--scale)) !important;
    }

    .nav-link:hover {
        text-decoration-thickness: calc(0.14vw * var(--scale));
    }

    .custom-search {
        width: calc(100% - var(--sidebar-peek-width));
    }

    .site-content {
        padding-top: calc(3.8vw * var(--scale));
    }

    #announcement-bar-root {
        transform: translateY(calc(3.8vw * var(--scale)));
    }

    #announcement-bar-root .gh-announcement-bar {
        font-size: calc(1.11vw * var(--scale));
        padding: calc(0.8vw * var(--scale)) 6vw calc(0.8vw * var(--scale)) calc(6vw + var(--sidebar-peek-width));
        min-height: calc(3.3vw * var(--scale));
    }

    .gh-announcement-bar button {
        right: calc(0.55vw * var(--scale));
        margin-top: calc(-1.1vw * var(--scale));
        width: calc(2.2vw * var(--scale));
        height: calc(2.2vw * var(--scale));
    }

    .gh-announcement-bar button svg {
        width: calc(0.8vw * var(--scale));
        height: calc(0.8vw * var(--scale));
    }
}

/* Styles for tablet */
@media (max-width: 768px) {
    #header {
        position: fixed;
        top: 0;
        width: 100%;
        background-color: var(--background-color);
        opacity: 0.9;
        z-index: 9998;    }

    .navbar-button, .search-bar-wrapper, .navbar-logo {
        display: none;
    }

    .nav {
        align-items: flex-start;
        row-gap: 22px;
        padding: 72px 30px;
        min-height: calc(100dvh - 50px - 50px);
        text-align: left;
        justify-content: flex-start;
        height: calc(100dvh - 50px - 50px);
        overflow: hidden;
    }

    .menu-content {
        height: calc(100dvh - 50px);
        min-height: calc(100dvh - 50px);
        overflow: hidden;
    }

    .menu {
        top: 0;
        position: fixed;
        width: 100%;
        min-width: 100%;
        transform: translateX(0);
        width: 100%;
        height: 100dvh;
    }

    .navbar {
        height: 50px;
        border-bottom: none;
    }

    .menu-top {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        padding-left: 0;
        height: 50px;
        min-height: 50px;
    }

    .menu-button {
        border-right: none;
        border-left: none !important;
        border-right: 1px solid var(--text-color) !important;
        padding-left: 20px;
        padding-right: 20px;
        width: 68px;
        row-gap: 6px;
        order: -2;
    }

    .menu-glyph {
        font-size: calc(42px * var(--scale)); /* Keep icon optically centered in 50px bar */
    }

    .mobile-logo {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        flex: 1 1 auto;
        min-width: 0;
        padding-left: 20px;
        margin-top: auto;
        margin-bottom: auto;
        text-decoration: none;
        color: var(--text-color);
        min-height: 50px;
    }

    .mobile-logo img {
        object-fit: scale-down;
        width: auto;
        height: calc(21px * var(--logo-scale));
    }

    .menu-and-search-wrapper {
        display: flex;
        margin-left: 0;
        margin-right: auto;
    }

    .search-icon-wrapper-mobile {
        display: flex;
        justify-content: center;
        align-items: center;
        padding-left: 20px;
        padding-right: 20px;
        border: none;
        background-color: transparent;
        position: relative;
        min-width: 68px;
        border-right: 1px solid var(--text-color);
        order: -1;
    }

    .search-icon-wrapper-mobile svg{
        width: 24px;
        height: 24px;
    }

    .menu-content {
        display: none;
        flex-direction: column;
        opacity: 0;
        height: calc(100dvh - 50px);
        transition: opacity var(--ease-transition);
        overflow: hidden;
    }

    .menu-content::before {
        mask: none;
        -webkit-mask: none;
        opacity: 0.93;
    }

    .menu-links {
        width: 100%;
        padding: 0;
        height: calc(100dvh - 50px);
        min-height: calc(100dvh - 50px);
        overflow: hidden;
    }



    .nav li .links-label {
        padding-bottom: 15px;
        margin-bottom: 26px;
        margin-top: 0px;
        min-width: 0;
        display: flex;
        justify-content: flex-start;
        width: 100%;
    }

    .secondary-links {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .secondary-links li {
        display: flex;
        justify-content: flex-start;
    }

    .mobile-menu-cta {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
        width: 100%;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 50px;
    }

    .mobile-menu-cta button,  .mobile-menu-cta a{
        width: 100%;
        border: none;
        border-top: 1px solid var(--text-color);
        border-left: none;
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
        padding: 0 12px;
        text-align: center;
    }

    .nav-link:hover {
        text-decoration: none;
    }

    .custom-search {
        width: 100%;
    }

    .search-bar-wrapper {
        width: 100%;
        height: 50px;
        border-left: none;
        border-bottom: 1px solid var(--text-color);
    }

    .search-input {
        padding: 14px 30px;
    }

    .custom-search .grid {
        padding-top: 30px;
        padding-bottom: 30px;
        max-height: 70dvh;
    }

    #announcement-bar-root {
        transform: translateY(50px);
    }

    #announcement-bar-root .gh-announcement-bar {
        padding: 12px 30px;
    }

    #announcement-bar-root .gh-announcement-bar-content {
        padding: 0px 30px;
    }

    .site-content {
        padding-top: 50px;
    }

    .nav li a,
    .nav li .links-label {
        font-size: clamp(26px, calc(7.1vw * var(--scale)), 34px);
        line-height: 1.05;
        max-width: 100%;
    }
}

/* Styles for mobile */
@media (max-width: 479px) {
    .menu-top {
        padding-left: 0;
    }

    .menu-button {
        width: 58px;
        padding-left: 14px;
        padding-right: 14px;
    }

    .search-icon-wrapper-mobile {
        min-width: 58px;
        padding-left: 14px;
        padding-right: 14px;
    }

    .mobile-logo {
        padding-left: 14px;
    }

    .menu-glyph {
        font-size: calc(38px * var(--scale));
    }

    .nav {
        min-height: calc(100dvh - 50px - 46px);
        height: calc(100dvh - 50px - 46px);
    }

    .nav li a, .nav li .links-label {
        font-size: clamp(22px, calc(7.4vw * var(--scale)), 29px);
    }

    .nav li .links-label {
        min-width: 65vw;
    }

    .mobile-menu-cta button,
    .mobile-menu-cta a {
        min-height: 46px;
        font-size: calc(15px * var(--scale));
    }

    .search-input {
        padding: 14px 18px;
    }

    .custom-search .grid {
        padding-top: 18px;
        padding-bottom: 18px;
    }

    #announcement-bar-root .gh-announcement-bar {
        padding: 12px 18px;
    }

    #announcement-bar-root .gh-announcement-bar-content {
        padding: 0px 18px;
    }
}