/* ---- Libertinus Serif (self-hosted) ----
   Open-source continuation of Linux Libertine, the font behind LaTeX's
   `libertine` package. Files from @fontsource/libertinus-serif 5.3.0. */
@font-face {
    font-family: 'Libertinus Serif';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/libertinus-serif-latin-400-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Libertinus Serif';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/libertinus-serif-latin-400-italic.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Libertinus Serif';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/libertinus-serif-latin-600-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Libertinus Serif';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/libertinus-serif-latin-700-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Libertinus Serif';
    font-style: italic;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/libertinus-serif-latin-700-italic.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Greek — so inline letters like σ, λ, Ω match the body text */
@font-face {
    font-family: 'Libertinus Serif';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/libertinus-serif-greek-400-normal.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
    font-family: 'Libertinus Serif';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/libertinus-serif-greek-400-italic.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
    font-family: 'Libertinus Serif';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/libertinus-serif-greek-700-normal.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

/* ---- Libertinus Sans (self-hosted) ----
   The Biolinum companion to the serif above. Ships 400/700 upright plus a
   400 italic; there is no bold italic or semibold face. */
@font-face {
    font-family: 'Libertinus Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/libertinus-sans-latin-400-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Libertinus Sans';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/libertinus-sans-latin-400-italic.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Libertinus Sans';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/libertinus-sans-latin-700-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Libertinus Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/libertinus-sans-greek-400-normal.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
    font-family: 'Libertinus Sans';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/libertinus-sans-greek-400-italic.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
    font-family: 'Libertinus Sans';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/libertinus-sans-greek-700-normal.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

/* ---- Josefin Sans (self-hosted) ----
   Display face for the nav and headings. Used uppercase at light weights,
   so only 300-500 are shipped. */
@font-face {
    font-family: 'Josefin Sans';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('fonts/josefin-sans-latin-300-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Josefin Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/josefin-sans-latin-400-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Josefin Sans';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('fonts/josefin-sans-latin-500-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Theme palettes ---- */
:root,
:root[data-theme="dark"] {
    --font-serif: 'Libertinus Serif', 'Linux Libertine O', 'Linux Libertine', 'Times New Roman', Times, serif;
    --font-sans: 'Libertinus Sans', 'Linux Biolinum O', 'Linux Biolinum', 'Segoe UI', sans-serif;
    --font-display: 'Josefin Sans', 'Century Gothic', 'Futura', sans-serif;

    /* Swap this between --font-sans and --font-serif to reskin every page. */
    --font-body: var(--font-sans);

    --bg: linear-gradient(135deg, #1a1a1a 0%, #0f0f0f 100%);
    --panel: rgba(23, 23, 23, 0.9);
    --card: linear-gradient(135deg, rgba(38, 38, 38, 0.8), rgba(26, 26, 26, 0.9));
    --card-hover: linear-gradient(135deg, rgba(56, 48, 40, 0.8), rgba(44, 38, 32, 0.9));
    --card-plain: rgba(255, 255, 255, 0.14);
    --badge: linear-gradient(135deg, #525252, #404040);
    --badge-text: #f4f4f5;
    --btn: linear-gradient(135deg, #404040, #2a2a2a, #1f1f1f);
    --btn-hover: linear-gradient(135deg, #8b7355, #a0845c, #b8956b);
    --btn-hover-text: #1a1a1a;
    --accent: #d4b896;
    --accent-hover: #a0845c;
    --accent-grad: linear-gradient(135deg, #d4b896, #c4a880, #b8956b);
    --text: #d4d4d8;
    --text-soft: #cbd5e1;
    --text-muted: #94a3b8;
    --border: rgba(64, 64, 64, 0.3);
    --border-strong: rgba(64, 64, 64, 0.6);
    --input-bg: rgba(31, 30, 27, 0.6);
    --shadow: rgba(0, 0, 0, 0.4);
    --ok-text: #4ade80;
    --warn-text: #fbbf24;
    --error-text: #fca5a5;
}

:root[data-theme="light"] {
    --bg: linear-gradient(135deg, #ffffff 0%, #eef5ea 100%);
    --panel: rgba(255, 255, 255, 0.92);
    --card: linear-gradient(135deg, rgba(244, 249, 241, 0.95), rgba(233, 243, 229, 0.95));
    --card-hover: linear-gradient(135deg, rgba(230, 243, 226, 0.95), rgba(214, 234, 209, 0.95));
    --card-plain: rgba(255, 255, 255, 0.95);
    --badge: linear-gradient(135deg, #6f9a6a, #4f8f52);
    --badge-text: #ffffff;
    --btn: linear-gradient(135deg, #e6f0e2, #d9e9d3, #cbe0c4);
    --btn-hover: linear-gradient(135deg, #4f8f52, #3f7d47, #35693c);
    --btn-hover-text: #ffffff;
    --accent: #3f7d47;
    --accent-hover: #2f6236;
    --accent-grad: linear-gradient(135deg, #3f7d47, #4f8f52, #6aa85a);
    --text: #1f2a22;
    --text-soft: #33443a;
    --text-muted: #5c6f60;
    --border: rgba(63, 125, 71, 0.22);
    --border-strong: rgba(63, 125, 71, 0.4);
    --input-bg: rgba(255, 255, 255, 0.85);
    --shadow: rgba(31, 61, 36, 0.15);
    --ok-text: #2f7d32;
    --warn-text: #9a6400;
    --error-text: #b91c1c;
}

/* Form controls do not inherit the page font by default */
button, input, select, textarea {
    font-family: inherit;
}

/* ---- Unified header and navigation ---- */
/* backdrop-filter makes every panel its own stacking context, so a later
   section would paint over the nav dropdown no matter how high the menu's
   own z-index was. Lift the whole header instead. */
.site-header {
    position: relative;
    z-index: 100;
}

.site-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-header h1 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0;
}

.site-header h1 a {
    color: inherit;
    -webkit-text-fill-color: inherit;
    text-decoration: none;
}

.site-nav ul {
    display: flex;
    list-style: none;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
}

.site-nav li {
    position: relative;
    display: block;
    margin: 0;
}

.site-nav a {
    display: inline-block;
    padding: 0.6rem 1.1rem;
    background: var(--btn);
    color: var(--text);
    text-decoration: none;
    border-radius: 0px;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow);
    border: 1px solid var(--border-strong);
}

.site-nav a:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px var(--shadow);
    background: var(--btn-hover);
    color: var(--btn-hover-text);
    text-decoration: none;
}

.site-nav .dropdown > a::after {
    content: ' \25BC';
    font-size: 0.7rem;
    margin-left: 0.3rem;
}

.site-nav .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--btn);
    border: 1px solid var(--border-strong);
    border-radius: 0px;
    box-shadow: 0 8px 16px var(--shadow);
    min-width: 180px;
    list-style: none;
    margin-top: 0;
    padding: 0.5rem 0;
    z-index: 1000;
}

.site-nav .dropdown:hover .dropdown-menu {
    display: block;
}

/* Touch devices have no hover; theme.js opens the menu with this class. */
.site-nav .dropdown.open > .dropdown-menu {
    display: block;
}

.site-nav .dropdown-menu a {
    display: block;
    padding: 0.6rem 1.2rem;
    margin: 0;
    box-shadow: none;
    border: none;
}

.site-nav .dropdown-menu a:hover {
    transform: none;
    box-shadow: none;
    padding-left: 1.5rem;
}

/* ---- Theme toggle ---- */
.theme-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    background: var(--btn);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 0px;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--shadow);
    transition: all 0.3s ease;
    margin: 0;
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.theme-toggle:hover {
    background: var(--btn-hover);
    color: var(--btn-hover-text);
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .site-header-inner {
        flex-direction: column;
        gap: 1rem;
    }

    .site-header h1 a {
        color: inherit;
        -webkit-text-fill-color: inherit;
        text-decoration: none;
    }

    .site-nav ul {
        justify-content: center;
    }

    /* Clear band at the top of the header so the centred title cannot run
       under the fixed toggle on narrow screens. */
    header.site-header {
        padding-top: 3.25rem;
    }

    .theme-toggle {
        top: 10px;
        left: 10px;
        width: 36px;
        height: 36px;
    }

    .theme-toggle svg {
        width: 18px;
        height: 18px;
    }
}