:root {

    color-scheme: light dark;

    --background: #fafafa;
    --surface: #ffffff;

    --text: #202124;
    --muted: #666666;

    --border: #dddddd;

    --accent: #0066cc;
    --accent-hover: #004d99;

    --shadow: rgba(0,0,0,0.08);

    --max-width: 900px;

    --th-bg: #e9ecef;
    --pre-bg: #e9ecef;
    --th-text: #212529;
    --pre-text: #212529;
}

[data-theme="dark"] {

    --background: #161616;
    --surface: #222222;

    --text: #eeeeee;
    --muted: #aaaaaa;

    --border: #444444;

    --accent: #6ab7ff;
    --accent-hover: #90cbff;

    --shadow: rgba(0,0,0,0.35);

    --th-bg: #2d333b;
    --pre-bg: #2d333b;
    --th-text: #f0f6fc;
    --pre-text: #f0f6fc;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;

    background: var(--background);
    color: var(--text);

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    line-height: 1.7;

    transition:
        background-color 0.25s,
        color 0.25s;
}

/* ----------------------- */
/* Header */
/* ----------------------- */

header {
    position: sticky;
    top: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 10px var(--shadow);
    z-index: 1000;
}

.header-content {
    max-width: var(--max-width);
    margin: auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-title {
    font-weight: 700;
    text-decoration: none;
    color: var(--text);
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 1.25rem;
    flex: 1;
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
}

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

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text);
}

.theme-toggle:hover {
    background: var(--border);
}

/* ----------------------- */
/* Main */
/* ----------------------- */

.content {
    max-width: var(--max-width);
    margin: 3rem auto;
    padding: 0 1rem;
}

.content-wide {
    width: 100%;
    margin: 3rem 0;
    padding: 0 1rem;
}

article {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 8px var(--shadow);
}

h1,
h2,
h3 {
    line-height: 1.2;
    margin-top: 1.6em;
}

h1:first-child {
    margin-top: 0;
}

p {
    margin: 1rem 0;
}

a {
    color: var(--accent);
}

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

/* ----------------------- */
/* Lists */
/* ----------------------- */

ul,
ol {
    padding-left: 1.5rem;
}
/*
li {
    margin: 0.5rem 0;
}
*/

/* ----------------------- */
/* Code */
/* ----------------------- */

code {
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
}

pre {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);

    position: relative;
    margin: 1rem 0;
    padding: 2rem 0.5rem 0.5rem; /* extra top padding so button doesn't cover text */
    overflow: auto;
    vertical-align: top;
    border-radius: 0.5em;
}

.copy-btn {
    font-size: 0.875rem;
    line-height: 1;
    padding: 0.35rem 0.55rem;
    border: 1px solid #999;
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
}

.copy-btn-pre {
    position: absolute;
    top: 0rem;
    right: 0rem;
    z-index: 2;
}

.copy-btn-inline {
    margin-left: 0.4rem;
    vertical-align: baseline;
}

/* ----------------------- */
/* Tables */
/* ----------------------- */

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
}

th {
    background: var(--surface);
}

/* ----------------------- */
/* Footer */
/* ----------------------- */

footer {
    position: sticky;
    bottom: 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
    z-index: 1000;
}

footer p {
    max-width: var(--max-width);
    margin: auto;
    padding: 1.2rem 1rem;
    color: var(--muted);
    text-align: center;
}

/* ----------------------- */
/* Mobile */
/* ----------------------- */

@media (max-width: 700px) {
    main,
    .content {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 1em;
    }

    article {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 1em;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    article table {
        width: 100%;
        margin: 0;
        padding: 1em;
    }

    .topbar-content {
        flex-wrap: wrap;
    }

    .nav-links {
        order: 3;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
}

th {
    background-color: var(--th-bg);
    color: var(--th-text);
    font-weight: 600;
}

.faded {
    color: #757575; /* equal contrast against white and black backgrounds */
}

pre, code {
    background-color: var(--pre-bg);
    color: var(--pre-text);
}
