/* =========================
   Color system
   ========================= */

:root {
    --bg-main: #f5f5f5;
    --bg-alt: #e6e6e6;
    --bg-header: #dcdcdc;
    --bg-footer: #dcdcdc;

    --fg-main: #1a1a1a;
    --fg-muted: #555;

    --link: #2a4f7a;
    --link-hover: #1d3a5c;
    --focus: #1d3a5c;

    --border: #bbb;

    --table-header: #d0d0d0;
    --table-row-odd: #ffffff;
    --table-row-even: #ededed;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-main: #1e1e1e;
        --bg-alt: DimGrey;
        --bg-header: #111;
        --bg-footer: #111;

        --fg-main: #e5e5e5;
        --fg-muted: #aaa;

        --link: #b3cdf0;
        --link-hover: #b3cdf0;
        --focus: #b3cdf0;

        --border: #444;

        --table-header: #333;
        --table-row-odd: #1f1f1f;
        --table-row-even: #2b2b2b;
    }
}

/* =========================
   Typography
   ========================= */

body {
    font-family: system-ui, sans-serif;
    line-height: 1.4;
    font-size: 1rem;
    margin: 0;
    color: var(--fg-main);
    background: var(--bg-main);
}

/* Skip-to-content link */
.skip-link {
    position: absolute;
    left: -999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: 100;
}

.skip-link:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    background: var(--bg-header);
    color: var(--fg-main);
    z-index: 1000;
}

/* Links */
a {
    color: var(--link);
    text-decoration: underline wavy;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    text-decoration: none;
}

/* =========================
   Container for main content
   ========================= */

.container {
    width: 100%;
    max-width: calc(65ch + 2rem); /* 65ch + left/right padding */
    padding: 0 0rem; /* equal left/right padding */
    margin-inline: auto;
    box-sizing: border-box;
}

/* =========================
   Header & Footer
   ========================= */

header, footer {
    padding: 0;
}

/* Header / footer content constrained to container width with background and centered */
.header-footer {
    background: var(--bg-header);
    color: var(--fg-main);
    padding: 1rem 1rem;
    box-sizing: border-box;
    /*max-width: calc(65ch + 5rem);*/
    margin-inline: auto;

    display: flex;
    justify-content: center;
    align-items: center;
}

footer .header-footer {
    background: var(--bg-footer);
    color: var(--fg-muted);
}

/* Header inner: logo + payoff side by side with 25px gap, centered as a group */
.header-inner {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 25px;
    justify-content: center;
    align-items: center;
}

/* =========================
   Table of contents
   ========================= */

.toc {
    padding: 0.5rem 1rem;
}

.toc details summary {
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    border: none;
    font-weight: bold;
}

.toc details summary:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.toc ul {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    counter-reset: toc-counter;
}

.toc ul li {
    counter-increment: toc-counter;
}

.toc ul li a::before {
    content: counter(toc-counter) ". ";
    display: inline-block;
    width: 2em;
}

.toc a {
    text-decoration: none;
}

.toc a:hover {
    text-decoration: underline;
}

/* =========================
   Details / summary triangle styling
   ========================= */

details summary::-webkit-details-marker {
    display: none;
}

details summary::marker {
    content: "";
}

details summary::before {
    content: "▶";
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s ease;
    font-size: 0.9rem;
    vertical-align: middle;
    color: var(--link);
}

details[open] summary::before {
    transform: rotate(90deg);
}

/* =========================
   Main content & Articles
   ========================= */

main {
    display: block;
    counter-reset: article-counter;
}

article {
    padding: 2rem 1rem;
    max-width: calc(65ch+2rem);
    margin-inline: auto;
    text-align: left;
    box-sizing: border-box;
}

article > * {
    max-width: 100%;
    scroll-margin-top: 1.5rem;
    margin-left: 0;
    margin-right: 0;
}

article > * + * {
    margin-top: 1.125rem;
}

article > :first-child {
    margin-top: 0;
}

article > :last-child {
    margin-bottom: 0;
}

article h1 {
    counter-increment: article-counter;
}

article h1::before {
    content: counter(article-counter) ". ";
    font-weight: bold;
}

article.even {
    background: var(--bg-main);
}

article.odd {
    background: var(--bg-alt);
}

/* =========================
   Tables
   ========================= */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    display: block;
    overflow-x: auto;
}

thead th {
    background: var(--table-header);
}

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

tbody tr:nth-child(odd) td {
    background: var(--table-row-odd);
}

tbody tr:nth-child(even) td {
    background: var(--table-row-even);
}

/* =========================
   Headings
   ========================= */

h1 { font-size: 1.55rem; line-height: 1.15; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.25rem; }
small { font-size: 0.8rem; }

html {
    scroll-behavior: smooth;
}

/* =========================
   Print stylesheet
   ========================= */

@media print {
    body {
        background: white;
        color: black;
    }

    header, footer, .toc {
        display: none;
    }

    article {
        padding: 1.5rem 0;
    }

    a {
        color: black;
        text-decoration: underline;
    }

    table {
        display: table;
        overflow-x: visible;
    }
}
