/*
 * L8 to Kube theme tuning on top of the Nikola base theme.
 * System font stacks only - no webfonts, no external requests.
 * Light/dark via CSS variables (see bottom), toggle in BODY_END.
 */

/* ---- Fonts ---- */
:root {
    --font-body: "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, "Liberation Serif", serif;
    --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---- Palette ---- */
:root {
    color-scheme: light;
    --bg: #f6f2e8;
    --fg: #2e2a24;
    --muted: #6e6759;
    --border: #dcd5c4;
    --accent: #3e5a76;
    --accent-hover: #2c4258;
    --code-bg: #ece7d9;
    --rule: #e6e0d1;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #141310;
    --fg: #dcd6c6;
    --muted: #948c7b;
    --border: #302e27;
    --accent: #e0aa5e;
    --accent-hover: #f0c185;
    --code-bg: #1c1b16;
    --rule: #211f1a;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #141310;
        --fg: #dcd6c6;
        --muted: #948c7b;
        --border: #302e27;
        --accent: #e0aa5e;
        --accent-hover: #f0c185;
        --code-bg: #1c1b16;
        --rule: #211f1a;
    }
}

/* ---- Page scaffold ---- */
body {
    background-color: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    font-size: 1.15rem;
    line-height: 1.65;
    padding: 1.25em;
}

#container {
    max-width: 46rem;
}

/* Header, nav, footer and other chrome read better in the sans face. */
#header, #menu, #footer, .metadata, .postpromonav, .pager,
#theme-toggle, .searchform, .comment-form {
    font-family: var(--font-ui);
}

#header h1, #header h2 {
    font-family: var(--font-ui);
    font-size: 1.45rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

#header h1 a, #header h2 a {
    color: var(--fg);
}

#header .metadata {
    color: var(--muted);
    font-size: 0.9rem;
}

.readingtime {
    font-family: var(--font-ui);
    color: var(--muted);
}

#menu {
    margin: 1.1rem 0 0;
    font-size: 0.92rem;
}

#menu a {
    color: var(--muted);
    text-decoration: none;
}

#menu a:hover, #menu a:focus {
    color: var(--accent);
}

#footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
    color: var(--muted);
    font-size: 0.88rem;
}

#footer a {
    color: var(--muted);
}

#footer a:hover, #footer a:focus {
    color: var(--accent);
}

/* ---- Prose ---- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 650;
    line-height: 1.25;
}

h1 {
    font-size: 1.6rem;
}

h1.entry-title {
    margin-bottom: 0.4rem;
}

/* Clear chapter breaks: every h2 opens with a rule. */
h2 {
    margin-top: 2.4rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--rule);
    font-size: 1.3rem;
}

h3 {
    margin-top: 1.8rem;
    font-size: 1.12rem;
}

p {
    margin-bottom: 1.15em;
}

/* Book-style justified prose. Hyphenation keeps the word spacing honest
   (html lang="en" makes it work); drop this block for ragged-right. */
.e-content p, .entry-content p,
.e-content li, .entry-content li {
    text-align: justify;
    -webkit-hyphens: auto;
    hyphens: auto;
}

li {
    margin-bottom: 0.35em;
}

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

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

/* Links inside prose get underlined for scanability. */
.e-content a, .entry-content a {
    text-decoration: underline;
    text-underline-offset: 0.18em;
    text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.e-content a:hover, .entry-content a:hover {
    text-decoration-color: var(--accent);
}

hr {
    border: 0;
    border-top: 1px solid var(--rule);
    margin: 2.2rem 0;
}

blockquote {
    margin: 1.4rem 0;
    padding: 0.1rem 0 0.1rem 1.1rem;
    border-left: 3px solid var(--border);
    color: var(--muted);
}

blockquote p {
    margin-bottom: 0.6rem;
}

table {
    border-collapse: collapse;
    font-size: 0.95em;
}

th, td {
    border: 1px solid var(--border);
    padding: 0.4rem 0.7rem;
    text-align: left;
}

/* ---- Code ---- */
code, pre, kbd, samp {
    font-family: var(--font-mono);
}

code {
    font-size: 0.82em;
    background-color: var(--code-bg);
    padding: 0.15em 0.35em;
    border-radius: 3px;
}

pre {
    border: 1px solid var(--border);
    border-radius: 4px;
    background-color: var(--code-bg);
    padding: 0.8rem 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow-x: auto;
}

pre code {
    background-color: transparent;
    padding: 0;
    font-size: inherit;
}

.form-control {
    font-family: var(--font-ui);
    background-color: var(--code-bg);
    color: var(--fg);
    border: 1px solid var(--border);
}

/* ---- Mermaid diagrams ---- */
.mermaid {
    margin: 1.5rem 0;
    text-align: center;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
}

/* ---- Nostalgia audio figure ---- */
figure.nostalgia {
    margin: 1.6rem 0;
    text-align: center;
}

figure.nostalgia .lead-in {
    margin-bottom: 0.6rem;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-style: italic;
    color: var(--muted);
}

figure.nostalgia audio {
    width: 100%;
    max-width: 26rem;
}

figure.nostalgia figcaption {
    margin-top: 0.4rem;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--muted);
}

/* ---- Chapter index on the front page ---- */
.post-list {
    padding-left: 0;
    list-style: none;
}

.post-list li {
    margin-bottom: 0.45rem;
}

.postlist-date {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--muted);
}

/* ---- Theme toggle button ---- */
#theme-toggle {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1050;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    color: var(--fg);
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: 2rem;
    cursor: pointer;
    opacity: 0.75;
}

#theme-toggle:hover {
    opacity: 1;
}
