/* ─── reset & base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
    /* Warm paper palette — cream, ink, terracotta, deep plum */
    --bg: #f7f3e9;
    --bg-alt: #efe8d3;
    --bg-code: #2a1f3d;
    --bg-code-inline: #ede3c9;
    --border: #e0d4b5;
    --border-soft: #ebe1c6;
    --text: #1a1a2e;
    --text-muted: #7a7392;
    --text-soft: #3d3d52;
    --accent: #c75b39;
    --accent-hover: #9a4527;
    --accent-soft: #e8b6a0;
    --link-underline: #e8c4b3;
    --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
    --serif: "Iowan Old Style", "Georgia", "Times New Roman", serif;
}

html {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 80% 0%, rgba(199, 91, 57, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 10% 100%, rgba(42, 31, 61, 0.04) 0%, transparent 45%);
    background-attachment: fixed;
}

/* ─── top bar ──────────────────────────────────────── */
.topbar {
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(247, 243, 233, 0.88);
}

.topbar-inner {
    max-width: 780px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.logo::before {
    content: "{ ";
    color: var(--accent);
    font-weight: 400;
}

.logo::after {
    content: " }";
    color: var(--accent);
    font-weight: 400;
}

.lang-switch {
    margin-left: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--mono);
    font-size: 12px;
    padding: 3px 10px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.lang-switch a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
    font-weight: 500;
}

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

.lang-switch a.lang-active {
    color: var(--accent);
    font-weight: 700;
}

.lang-switch .lang-sep {
    color: var(--border);
}

.topbar-links {
    margin-left: auto;
    display: flex;
    gap: 20px;
}

.topbar-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.15s;
}

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

/* ─── article container ───────────────────────────── */
article {
    max-width: 720px;
    margin: 0 auto;
    padding: 64px 24px 120px;
}

/* ─── header ───────────────────────────────────────── */
.article-header {
    margin-bottom: 56px;
}

.article-kicker {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 14px;
}

h1.article-title {
    font-size: 42px;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin: 0 0 18px;
    color: var(--text);
}

.article-subtitle {
    font-size: 19px;
    color: var(--text-soft);
    line-height: 1.5;
    margin: 0 0 28px;
    font-style: italic;
    font-family: var(--serif);
}

.article-meta {
    font-size: 13px;
    color: var(--text-muted);
    font-family: var(--mono);
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.article-meta strong {
    color: var(--text-soft);
    font-weight: 600;
}

/* ─── body text ────────────────────────────────────── */
article p {
    margin: 0 0 22px;
    color: var(--text);
}

article h2 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.2;
    margin: 64px 0 18px;
    color: var(--text);
    scroll-margin-top: 80px;
}

article h2::before {
    content: "§ ";
    color: var(--accent);
    font-weight: 400;
    opacity: 0.65;
}

article h3 {
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 40px 0 14px;
    color: var(--text);
}

article a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--link-underline);
    transition: border-color 0.15s, color 0.15s;
}

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

article strong {
    font-weight: 600;
    color: var(--text);
}

article em {
    font-style: italic;
    color: var(--text-soft);
}

article ul, article ol {
    margin: 0 0 22px;
    padding-left: 24px;
}

article li {
    margin-bottom: 8px;
}

article li::marker {
    color: var(--accent);
}

article blockquote {
    margin: 22px 0;
    padding: 2px 0 2px 20px;
    border-left: 3px solid var(--accent);
    color: var(--text-soft);
    font-style: italic;
    font-family: var(--serif);
    font-size: 18px;
}

article hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 48px 0;
}

/* ─── inline code ──────────────────────────────────── */
article code {
    font-family: var(--mono);
    font-size: 0.88em;
    background: var(--bg-code-inline);
    padding: 2px 6px;
    border-radius: 4px;
    color: #9a4527;
    border: 1px solid var(--border-soft);
}

/* ─── code blocks ──────────────────────────────────── */
article pre {
    background: var(--bg-code);
    border-radius: 8px;
    padding: 20px 24px;
    margin: 24px 0 28px;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid #3d2e52;
    box-shadow: 0 2px 8px rgba(42, 31, 61, 0.12);
}

article pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: #e9dcd0;
    font-size: 14px;
    font-family: var(--mono);
}

/* Rose Pine-inspired syntax highlighting on deep plum */
article pre code .keyword { color: #c4a7e7; }  /* iris/lavender */
article pre code .type    { color: #9ccfd8; }  /* foam/cyan */
article pre code .string  { color: #f6c177; }  /* gold */
article pre code .comment { color: #8b7d96; font-style: italic; } /* muted lavender */
article pre code .number  { color: #eb6f92; }  /* love/pink */
article pre code .attr    { color: #ebbcba; }  /* rose */
article pre code .json-key { color: #9ccfd8; }
article pre code .json-str { color: #f6c177; }

/* ─── callout / note box ──────────────────────────── */
.callout {
    background: #f4ebd6;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    padding: 16px 20px;
    border-radius: 6px;
    margin: 24px 0;
    font-size: 15px;
    color: var(--text-soft);
}

.callout strong {
    color: var(--accent-hover);
}

.callout.aside {
    border-left-color: #7a5195;
    background: #efe4f0;
}

.callout.aside strong {
    color: #5a2b6b;
}

/* ─── ToC ──────────────────────────────────────────── */
.toc {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 24px;
    margin: 36px 0 40px;
}

.toc-title {
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 10px;
}

.toc ol {
    margin: 0;
    padding-left: 20px;
    font-size: 15px;
}

.toc ol li {
    margin-bottom: 4px;
}

.toc ol li::marker {
    color: var(--text-muted);
}

.toc a {
    border-bottom: none;
    color: var(--text-soft);
}

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

/* ─── footer ───────────────────────────────────────── */
.footer {
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 24px 60px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    font-family: var(--mono);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.footer a {
    color: var(--text-soft);
    text-decoration: none;
    border-bottom: 1px dotted var(--border);
}

.footer a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.footer-sep {
    color: var(--border);
}

/* ─── responsive ───────────────────────────────────── */
@media (max-width: 720px) {
    html { font-size: 16px; }
    article { padding: 40px 20px 80px; }
    h1.article-title { font-size: 32px; }
    article h2 { font-size: 22px; margin-top: 48px; }
    article pre { padding: 16px; font-size: 13px; }
    .topbar-inner { padding: 12px 20px; }
}

/* ─── selection ────────────────────────────────────── */
::selection {
    background: var(--accent-soft);
    color: var(--text);
}
