:root {
    --bg-light: #fafafa;
    --bg-dark: #0b0b0b;
    --transition: background 0.4s ease, color 0.3s ease;
}

html {
    height: 100%;
    background: var(--bg-light);
    color-scheme: light dark;
    transition: var(--transition);
    overflow-x: hidden;
}

html.dark {
    background: var(--bg-dark);
}

body {
    min-height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    background: transparent;
    transition: var(--transition);
    overflow-x: hidden;
}

html.no-scroll, body.no-scroll {
    overflow: hidden;
    height: 100%;
}

header {
    margin-top: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

html.dark header {
    border-color: rgba(255, 255, 255, 0.2);
}

nav, footer {
    font-family: var(--font-ui), sans-serif;
    font-size: 0.95rem;
}

nav a {
    margin-left: 1rem;
    text-decoration: none;
    color: inherit;
    font-weight: 500;
}

nav a:hover {
    color: var(--text-accent);
}

footer {
    margin-top: auto;
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.7;
    padding-bottom: 2rem;
}

button.theme-toggle {
    margin-left: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font-size: 1.2rem;
    transition: transform 0.2s ease;
}

button.theme-toggle:hover {
    transform: rotate(-10deg);
    color: var(--text-accent);
}

.site-logo { gap: 0.6rem; letter-spacing: -0.02em; }

html.dark .site-logo img { filter: invert(1); opacity: .9; }

@media print {
    html.dark .site-logo img { filter: none; }
}


/* === RESPONSIVE LAYOUT === */

html {
    font-size: clamp(14px, 1vw + 0.5rem, 18px);
}

/* 1. Mobile first adjustments */
#container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: column;
    justify-items: center;
    gap: .5rem;
}

nav {
    display: flex;
    flex-direction: row;
    justify-content: end;
    align-items: end;
    flex-wrap: nowrap;
    text-align: end;
    font-size: 0.95rem;
}

nav button.theme-toggle {
    order: initial;
}

/* Reduce outer spacing for small screens */
main, header, footer {
    padding: 0.75rem 1rem;
}

p.tagline {
    text-align: center;
}

div.sub-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-ui), sans-serif;
    font-size: 0.9rem;
    font-weight: 400;
    margin: 0 auto;
}

/* 2. Larger smart phones */
@media (min-width: 430px) {
    header {
        flex-direction: row;
    }

    nav {
        flex-direction: column;
    }

    nav button.theme-toggle {
        order: -1;
    }
}

/* 3. Medium screens (tablets / small laptops) */
@media (min-width: 648px) {
    :root {
        --measure: 80ch;     /* reading width for main content */
        --max-width: 1000px; /* header/footer container width */
    }

    main {
        width: min(var(--measure), calc(100vw - 4rem));
        margin: 2rem auto;
        padding: 0 2rem;
    }

    header, footer {
        width: min(var(--max-width), calc(100vw - 4rem));
        margin: 0 auto;
        padding: 1rem 2rem;
    }

    header {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    nav {
        flex-direction: row;
    }

    nav button.theme-toggle {
        order: initial;
    }

    div.sub-header {
        font-size: 0.95rem;
        width: min(var(--max-width), calc(100vw - 4rem));
    }

    p.tagline {
    }
}

/* 3. Large / high-res monitors */
@media (min-width: 1024px) {
    :root {
        --measure: 80ch;     /* reading width for main content */
        --max-width: 1200px; /* header/footer container width */
    }

    main {
        width: min(var(--measure), calc(90vw - 4rem));
        margin: 2rem auto;
        padding: 0 2rem;
    }

    header, footer {
        width: min(var(--max-width), calc(95vw - 4rem));
        margin: 0 auto;
        padding: 1rem 2rem;
    }

    header {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    nav {
        justify-content: end;
    }

    nav button.theme-toggle {
        order: initial;
    }

    div.sub-header {
        flex-direction: row;
        width: min(var(--max-width), calc(95vw - 4rem));
    }

    div.sub-header #search-wrapper {
        text-align: end;
    }
}

/* 4. Ultra-wide (>1440px) */
@media (min-width: 1440px) {
    :root {
        --measure: 88ch;
        --max-width: 1300px;
    }

    main {
        width: min(var(--measure), 88vw);
    }

    header, footer {
        width: min(var(--max-width), 92vw);
    }

    header {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    nav {
        justify-content: end;
    }

    nav button.theme-toggle {
        order: initial;
    }

    div.sub-header {
        width: min(var(--max-width), 92vw);
    }
}
