/* Shared look for the learning series (k8s, go, ...): the paper-on-sand reading style of
   c-string-pointers, with a dark reading mode. Pages add their own demo styles on top.
   Theme: <html data-theme="dark">, set before paint by the snippet in each page's <head>
   and toggled by shared/reading.js. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
    --bg-outer: #d4c5a9;
    --bg-page: #faf6ee;
    --bg-card: #fdfbf7;
    --bg-insight: #fdf8ee;
    --bg-code: #f3ece0;
    --text: #362b1f;
    --text-heading: #2c2416;
    --text-muted: #6b5b47;
    --border: #e0d5c4;
    --accent: #8b6f47;
    --accent-border: #c4a882;
    --page-border: #e8dfd0;
    --h-sub: #3d2e1c;
    --rule-strong: #5a4630;
    --code-comment: #8a7a62;
    --btn-text: #fff;
    --btn-hover: #6d5636;
    --ghost-hover: #f1e9da;
    --shadow-page: 0 1px 3px rgba(0, 0, 0, .08), 0 8px 24px rgba(0, 0, 0, .06);
    --grain: rgba(139, 115, 85, .08);

    /* demo colours */
    --blue: #2f6fb0;
    --blue-soft: #dbe8f6;
    --red: #b2452f;
    --red-soft: #f6e0d9;
    --green: #2e7d4f;
    --green-soft: #dcefe3;
    --slot: #fff;
    --slot-border: #cfc3ae;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg-outer: #161412;
    --bg-page: #22201d;
    --bg-card: #2a2724;
    --bg-insight: #2d2822;
    --bg-code: #2b2723;
    --text: #e0d5c4;
    --text-heading: #f0e8dc;
    --text-muted: #a89880;
    --border: #3d3631;
    --accent: #c4a882;
    --accent-border: #8b6f47;
    --page-border: #35302b;
    --h-sub: #e8dfd0;
    --rule-strong: #e0c9a6;
    --code-comment: #a8987f;
    --btn-text: #1a1612;
    --btn-hover: #d4b892;
    --ghost-hover: #332d26;
    --shadow-page: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .4);
    --grain: rgba(196, 168, 130, .04);

    --blue: #7fb2e5;
    --blue-soft: #1f3346;
    --red: #e8846c;
    --red-soft: #46261f;
    --green: #74c492;
    --green-soft: #1d3a29;
    --slot: #1d1b18;
    --slot-border: #4a423a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg-outer);
    background-image:
        radial-gradient(ellipse at 20% 50%, var(--grain) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 115, 85, .05) 0%, transparent 50%);
    padding: 2.5rem;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 820px;
    margin: 0 auto;
    background: var(--bg-page);
    padding: 2.5rem 3rem 3rem;
    border-radius: 3px;
    box-shadow: var(--shadow-page);
    border: 1px solid var(--page-border);
    position: relative;
}

.breadcrumb { font-size: .85rem; color: var(--text-muted); margin-bottom: 1rem; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---------- theme toggle ---------- */
.theme-toggle { position: absolute; top: 1.5rem; right: 1.5rem; display: flex; gap: .25rem; }
.theme-btn {
    font: .72rem 'JetBrains Mono', monospace;
    padding: .25rem .5rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.theme-btn:hover { color: var(--text); border-color: var(--accent); }
.theme-btn.active { background: var(--accent); color: var(--bg-page); border-color: var(--accent); }

/* ---------- headings ---------- */
.series-label {
    text-align: center;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: .4rem;
}
h1 {
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--text-heading);
    text-align: center;
    letter-spacing: -.5px;
    line-height: 1.25;
}
.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin: .5rem 0 2rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--accent-border);
}
h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 2.6rem 0 .8rem;
    color: var(--h-sub);
    letter-spacing: -.3px;
    scroll-margin-top: 1rem;
}
h2 .num { color: var(--accent); margin-right: .35rem; }
h3 { font-size: 1.08rem; font-weight: 600; margin: 1.6rem 0 .5rem; color: var(--h-sub); }

p, ul, ol, table { margin-bottom: .9rem; }
ul, ol { padding-left: 1.4rem; }
li { margin-bottom: .3rem; }
a { color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.4rem 0; }

code, .mono { font-family: 'JetBrains Mono', monospace; font-size: .88em; }
:not(pre) > code { background: var(--bg-code); padding: .05rem .3rem; border-radius: 3px; }
pre {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    line-height: 1.55;
}
pre code { font-size: .86rem; }
pre .c { color: var(--code-comment); }

/* the one-line takeaway at the end of a section */
.idea {
    padding: .7rem 1.1rem;
    background: var(--bg-insight);
    border-left: 3px solid var(--accent-border);
    margin: 1.1rem 0 1rem;
}
.idea strong { color: var(--rule-strong); }

.callout { font-weight: 600; color: var(--text-heading); }

/* ---------- table of contents ---------- */
.toc {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.3rem .6rem;
    margin-bottom: 1rem;
}
.toc h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.toc ol { margin: 0 0 .5rem; }

/* ---------- series home: list of parts ---------- */
.parts { list-style: none; padding: 0; counter-reset: part; }
.parts li {
    counter-increment: part;
    display: grid;
    grid-template-columns: 2.4rem 1fr;
    gap: .2rem .6rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    margin: 0;
}
.parts li::before {
    content: counter(part);
    grid-row: span 2;
    font: 600 1.3rem 'JetBrains Mono', monospace;
    color: var(--accent);
}
.parts .part-title { font-weight: 600; font-size: 1.08rem; color: var(--text-heading); text-decoration: none; }
a.part-title:hover { text-decoration: underline; }
.parts .part-desc { color: var(--text-muted); font-size: .93rem; }
.parts li.soon .part-title { color: var(--text-muted); }
.parts li.soon::before { color: var(--border); }
.soon-tag {
    font-size: .7rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
    color: var(--text-muted); border: 1px solid var(--border); border-radius: 3px;
    padding: 0 .35rem; margin-left: .4rem; vertical-align: 2px;
}

/* ---------- previous / next part ---------- */
.part-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border);
    font-size: .92rem;
}
.part-nav a { text-decoration: none; }
.part-nav a:hover { text-decoration: underline; }
.part-nav .label { display: block; font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.part-nav .next { text-align: right; margin-left: auto; }

/* ---------- step-through demos ---------- */
.stepper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.2rem 1.1rem;
    margin: 0 0 1.2rem;
}
.stepper-title { font-weight: 600; font-size: .92rem; margin-bottom: .6rem; }
.note { min-height: 3.2rem; margin: .5rem 0 .7rem; font-size: .93rem; }
.note code { background: var(--bg-code); padding: .05rem .3rem; border-radius: 3px; }
.controls { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.btn {
    font: 500 .85rem 'Inter', sans-serif;
    padding: .32rem .85rem;
    border-radius: 4px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--btn-text);
    cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--btn-hover); border-color: var(--btn-hover); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover:not(:disabled) { background: var(--ghost-hover); }
.count { font-size: .82rem; color: var(--text-muted); margin-left: auto; }

.footer {
    margin-top: 2.4rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: .88rem;
    color: var(--text-muted);
}
.footer h2 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
.footer h2:first-child { margin-top: 0; }

@media (max-width: 640px) {
    body { padding: .6rem; font-size: .97rem; }
    .container { padding: 1.4rem 1.1rem 2rem; }
    h1 { font-size: 1.6rem; margin-top: 1.2rem; }
    .theme-toggle { top: 1rem; right: 1rem; }
    .part-nav { flex-direction: column; }
    .part-nav .next { text-align: left; margin-left: 0; }
}
