/* Reading themes for the primer.
   Component colors stay on the existing variables; this file only
   resets those tokens and the type/spacing rhythm. */

html[data-reading="paper"] {
    --bg: #f3eadb;
    --paper: #fbf6ec;
    --side: #efe4d0;
    --ink: #2a241c;
    --muted: #5a4e40;
    --accent: #1a5560;
    --soft: #f6ecdc;
    --line: #e0d0b8;
    --gold: #7a4e12;
    --code: #f4ead8;
    --shadow: 0 14px 40px rgba(62, 42, 18, 0.12);
    color-scheme: light;
}

html[data-reading="sepia"] {
    --bg: #efe2cf;
    --paper: #fbf4e6;
    --side: #ead9c0;
    --ink: #3b2f23;
    --muted: #5c4a38;
    --accent: #6b4630;
    --soft: #f6ead8;
    --line: #e0cdb4;
    --gold: #7a4e12;
    --code: #f3e6d0;
    --shadow: 0 14px 40px rgba(72, 48, 24, 0.14);
    color-scheme: light;
}

html[data-reading="light"] {
    --bg: #f4f6f8;
    --paper: #ffffff;
    --side: #f1f5f9;
    --ink: #0f172a;
    --muted: #3f4c5c;
    --accent: #0f5f58;
    --soft: #f0fdfa;
    --line: #e2e8f0;
    --gold: #7a4e12;
    --code: #f1f5f9;
    --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
    color-scheme: light;
}

html[data-reading="dark"] body,
body.dark {
    --bg: #141210;
    --paper: #1e1b17;
    --side: #181512;
    --ink: #f3ece3;
    --muted: #cbbba8;
    --accent: #e7c48a;
    --soft: #2a241e;
    --line: #3c342c;
    --gold: #f0d7a4;
    --code: #2a241c;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
}

html[data-reading="paper"] body,
html[data-reading="sepia"] body {
    background-color: var(--bg);
    background-image: repeating-linear-gradient(
        0deg,
        transparent 0,
        transparent 13px,
        rgba(90, 60, 30, 0.028) 14px
    );
    background-attachment: fixed;
}

html[data-reading="light"] body,
html[data-reading="dark"] body {
    background-image: none;
    background-color: var(--bg);
}

body {
    font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    font-size: 1.125rem;
    line-height: 1.78;
    letter-spacing: 0.011em;
}

::selection {
    background: color-mix(in srgb, var(--gold) 35%, var(--paper));
    color: var(--ink);
}

.sidebar {
    width: 280px;
    font-size: 0.92rem;
    line-height: 1.5;
}

.workspace {
    margin-left: 280px;
}

.sidebar nav a {
    padding: 0.48rem 0.7rem;
}

.toolbar {
    min-height: 64px;
    height: auto;
}

.reading-layout {
    grid-template-columns: minmax(0, 42rem) 13.5rem;
    gap: 3rem;
    padding: 2.75rem 2.25rem 4.5rem;
}

main {
    max-width: 42rem;
}

h1 {
    font-size: clamp(2rem, 4vw, 2.65rem);
    line-height: 1.18;
    letter-spacing: -0.02em;
    margin: 0.25em 0 0.55em;
}

h2 {
    font-size: 1.55rem;
    line-height: 1.28;
    margin: 2.05em 0 0.75em;
    padding-top: 1.15em;
}

h3 {
    font-size: 1.22rem;
    margin: 1.45em 0 0.5em;
}

p {
    margin: 0.8em 0 1.05em;
}

main > p,
.intro {
    font-size: 1.2rem;
    line-height: 1.75;
}

main ul,
main ol {
    margin: 0.3em 0 1.25em;
    padding-left: 1.35em;
}

main li {
    margin: 0.42em 0;
    line-height: 1.7;
}

.callout {
    padding: 1.25rem 1.4rem;
    margin: 1.6rem 0;
}

.callout p,
.exercise details p,
details.proof {
    font-size: 1.02rem;
    line-height: 1.7;
}

pre {
    font-size: 0.92rem;
    line-height: 1.65;
    padding: 1.05rem 1.15rem;
    margin: 0.4em 0 1.35em;
}

code {
    font-size: 0.88em;
}

table {
    font-size: 0.92rem;
    line-height: 1.55;
}

th,
td {
    padding: 0.55rem 0.7rem;
}

.exercise {
    padding: 1.35rem 0;
}

.on-page {
    font-size: 0.82rem;
    line-height: 1.55;
}

.reading-theme {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.reading-theme select {
    font-size: 13px;
    font-weight: 650;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    min-height: 34px;
    padding: 0.2rem 0.7rem;
}

.reading-theme select:hover {
    border-color: var(--accent);
    background: var(--soft);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 3px;
}

@media (max-width: 1200px) {
    .on-page {
        display: none;
    }

    .reading-layout {
        grid-template-columns: minmax(0, 42rem);
        padding: 2rem 1.5rem 3.5rem;
    }
}

@media (max-width: 850px) {
    .workspace {
        margin-left: 0;
    }

    .reading-layout {
        padding: 1.35rem 1rem 3rem;
    }

    .book-home h1 {
        font-size: 2.35rem;
    }

    h1 {
        font-size: 2rem;
    }
}

@media (max-width: 700px) {
    .toolbar {
        padding: 8px 12px;
        row-gap: 6px;
    }

    .reading-theme span {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

@media print {
    html[data-reading] body {
        background: #fff;
        color: #111;
    }
}
