/* Fixed, full-viewport pattern background */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: var(--pattern-url);
    background-repeat: repeat;
    background-size: var(--pattern-size) var(--pattern-size);
    background-position: top left;
    opacity: var(--pattern-opacity);
}

/* Accent per theme */
.theme-base-08 {
    --accent: var(--theme-red);
}

.theme-base-09 {
    --accent: var(--theme-orange);
}

.theme-base-0a {
    --accent: var(--theme-yellow);
}

.theme-base-0b {
    --accent: var(--theme-green);
}

.theme-base-0c {
    --accent: var(--theme-cyan);
}

.theme-base-0d {
    --accent: var(--theme-blue);
}

.theme-base-0e {
    --accent: var(--theme-magenta);
}

.theme-base-0f {
    --accent: var(--theme-brown);
}

/* Sidebar */
.sidebar {
    text-align: center;
    padding: var(--space-2) var(--space-2);
    color: var(--sidebar-fg);
    background: var(--sidebar-bg);
}

.sidebar a {
    color: #fff;
}

.sidebar-about h1 {
    color: #fff;
    margin-top: 0;
    font-family: inherit;
    font-weight: 800;
    font-size: 3.25rem;
}

/* NAV WRAPPER */
.sidebar-nav-wrap {
    margin-top: var(--space-2);
}

/* NAV LIST */
.sidebar .sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--nav-gap);
}

.sidebar .sidebar-nav li {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar a.sidebar-nav-item,
.sidebar .sidebar-nav-item {
    font-size: var(--nav-fs);
    font-weight: var(--nav-weight);
    line-height: 1.35;
    padding: var(--nav-pad-y) 0;
}

a.sidebar-nav-item:hover,
a.sidebar-nav-item:focus {
    text-decoration: underline;
}

.sidebar-nav-item.active {
    font-weight: 700;
}

.sidebar h2,
.sidebar h3 {
    font-family: inherit;
    font-weight: 700;
}

/* HAMBURGER BUTTON (mobile-first) */
.nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: var(--space-1);
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(0, 0, 0, 0.18);
    cursor: pointer;
    font-size: 0.8rem;
    color: #fff;
}

.nav-toggle-bar {
    display: block;
    width: 14px;
    height: 2px;
    border-radius: 999px;
    background: #fff;
}

.nav-toggle-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

/* CONTENT AREA (main pane) */
.content {
    padding-top: var(--space-5);
    padding-bottom: var(--player-h);
    text-underline-offset: var(--underline-offset);
    text-decoration-thickness: var(--underline-thickness);
    scrollbar-color: var(--accent) transparent;
    background: transparent;
    /* show the global pattern */
}

@supports (scrollbar-width:auto) {
    .content {
        scrollbar-width: auto;
    }
}

.content::-webkit-scrollbar {
    width: var(--scrollbar-w);
}

.content::-webkit-scrollbar-track {
    background: transparent;
    margin-block: var(--scrollbar-gap);
}

.content::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: var(--scrollbar-radius);
    border: calc((var(--scrollbar-w)-8px)/2) solid transparent;
    background-clip: content-box;
}

.content::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Theme colours applied to sidebar + links */
.theme-base-08 .sidebar {
    background: var(--theme-red);
}

.theme-base-08 .content a,
.theme-base-08 .related-posts li a:hover {
    color: var(--theme-red);
}

.theme-base-09 .sidebar {
    background: var(--theme-orange);
}

.theme-base-09 .content a,
.theme-base-09 .related-posts li a:hover {
    color: var(--theme-orange);
}

.theme-base-0a .sidebar {
    background: var(--theme-yellow);
}

.theme-base-0a .content a,
.theme-base-0a .related-posts li a:hover {
    color: var(--theme-yellow);
}

.theme-base-0b .sidebar {
    background: var(--theme-green);
}

.theme-base-0b .content a,
.theme-base-0b .related-posts li a:hover {
    color: var(--theme-green);
}

.theme-base-0c .sidebar {
    background: var(--theme-cyan);
}

.theme-base-0c .content a,
.theme-base-0c .related-posts li a:hover {
    color: var(--theme-cyan);
}

.theme-base-0d .sidebar {
    background: var(--theme-blue);
}

.theme-base-0d .content a,
.theme-base-0d .related-posts li a:hover {
    color: var(--theme-blue);
}

.theme-base-0e .sidebar {
    background: var(--theme-magenta);
}

.theme-base-0e .content a,
.theme-base-0e .related-posts li a:hover {
    color: var(--theme-magenta);
}

.theme-base-0f .sidebar {
    background: var(--theme-brown);
}

.theme-base-0f .content a,
.theme-base-0f .related-posts li a:hover {
    color: var(--theme-brown);
}

/* MOBILE BEHAVIOUR: collapse menu behind hamburger */
@media (max-width: 47.99em) {

    /* default: menu closed */
    .sidebar .sidebar-nav {
        display: none;
    }

    /* when body has .nav-open, show menu */
    body.nav-open .sidebar .sidebar-nav {
        display: grid;
        margin-top: var(--space-1);
    }

    .sidebar-nav-wrap {
        margin-top: var(--space-1);
    }
}

/* DESKTOP LAYOUT: fixed sidebar + scrollable content */
@media (min-width:48em) {

    .nav-toggle {
        display: none;
    }

    .sidebar a.sidebar-nav-item,
    .sidebar .sidebar-nav-item {
        font-size: var(--nav-fs-lg);
    }

    .sidebar {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        bottom: 0;
        width: var(--sidebar-width);
        z-index: 3;
    }

    .layout-reverse .sidebar {
        right: 0;
        left: auto;
    }

    body:not(.layout-reverse) .sidebar {
        left: 0;
        right: auto;
    }

    .sidebar .container {
        max-width: unset;
        height: 100%;
        margin: 0;
        display: flex;
        flex-direction: column;
        padding: var(--space-2) var(--space-2);
    }

    .sidebar-about {
        margin-bottom: var(--space-3);
    }

    .sidebar-nav-wrap {
        margin: var(--space-2) 0;
    }

    .sidebar-footer {
        margin-top: auto;
        padding-top: var(--space-3);
    }
}

@media (min-width:48em) {
    body {
        overflow: hidden;
    }

    .layout-reverse .content {
        margin-left: var(--space-2);
        margin-right: calc(var(--sidebar-width) + var(--content-gutter));
    }

    body:not(.layout-reverse) .content {
        margin-left: calc(var(--sidebar-width) + var(--content-gutter));
        margin-right: var(--space-2);
    }

    .content {
        max-width: none;
        height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-gutter: stable both-edges;
        padding-right: var(--space-2);
    }

    .content .container {
        max-width: var(--container-max);
        margin: 0 auto;
        padding: 0 var(--space-2);
    }
}

/* Language switcher */
.language-switcher {
    background: var(--lang-bg);
    color: var(--lang-fg);
    padding: var(--lang-pad-y) var(--lang-pad-x);
    border-radius: var(--lang-radius);
    font-size: var(--lang-fs);
    display: inline-block;
}

.sidebar .language-switcher {
    display: block;
    width: max-content;
    margin: var(--space-1) auto 0;
}

.language-switcher p {
    font-size: var(--lang-btn-fs);
    margin: 0;
    font-weight: 700;
}

.language-switcher a {
    display: inline-block;
    margin: 2px;
    padding: 2px 6px;
    background: var(--lang-btn-bg);
    font-size: var(--lang-btn-fs);
    color: #fff;
    text-decoration: none;
    border-radius: var(--lang-radius);
    transition: background .2s linear;
}

.language-switcher a:hover {
    background: var(--lang-btn-hover);
}

/* Sidebar footer text */
.sidebar-rights {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 0.25rem;
    letter-spacing: 0.02em;
}

.sidebar-rights strong {
    color: #fff;
    font-weight: 600;
}

@media (min-width: 48em) {
    .sidebar {
        --space-2: 0.75rem;
        --space-3: 1rem;
        --nav-gap: .15rem;
        --nav-pad-y: .2rem;
        --nav-fs: clamp(1rem, 0.35svh + 0.90rem, 1.25rem);
        --nav-fs-lg: clamp(1.05rem, 0.40svh + 0.95rem, 1.35rem);
    }

    .sidebar-about h1 {
        font-size: clamp(2rem, 1.6svh + 1.2rem, 3.25rem);
    }

    .language-switcher {
        font-size: clamp(10px, 0.22svh + 8px, 12px);
    }

    .language-switcher p {
        font-size: clamp(9px, 0.20svh + 7px, 10px);
    }
}

@media (min-width: 48em) {
    .sidebar-logo {
        display: block;
        margin: 0 auto var(--space-2);
        max-width: 80%;
        max-height: 320px;
        height: auto;
    }

    .sidebar-about {
        margin-bottom: var(--space-2);
    }
}