/* ── Tokens ── */
:root {
    --bg: #FFFCF0;
    --text: #100F0F;
    --muted: #6F6E69;
    --accent: #AF3029;
}

[data-theme="dark"] {
    --bg: #100F0F;
    --text: #CECDC3;
    --muted: #575653;
    --accent: #D14D41;
}

/* ── Root scale ── */
html {
    font-size: 18px;
}

/* ── Reset ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Base ── */
body {
    background: var(--bg);
    color: var(--text);
    font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    font-size: 1.15rem;
    line-height: 1.85;
    letter-spacing: 0.015em;
    max-width: 680px;
    margin: 0 auto;
    padding: 3.5rem 2rem;
    transition: background 0.3s, color 0.3s;
}

/* ── Selection ── */
::selection {
    background: var(--accent);
    color: #fff;
}

/* ── Mobile ── */
@media (max-width: 640px) {
    html {
        font-size: 16px;
    }

    body {
        padding: 2rem 1.25rem;
    }

    article h1 {
        font-size: 1.8rem;
    }
}

/* ── Nav ── */
header {
    margin-bottom: 4rem;
}

nav {
    display: flex;
    align-items: center;
    gap: 2rem;
}

nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.72rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 600;
}

nav a:hover {
    text-decoration: underline;
}

nav a[aria-current="page"] {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ── Theme toggle (sliding pill) ── */
.theme-toggle {
    margin-left: auto;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.theme-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    display: inline-flex;
    align-items: center;
    width: 36px;
    height: 20px;
    border-radius: 20px;
    background: var(--muted);
    position: relative;
    transition: background 0.25s;
}

.theme-toggle input:checked+.toggle-track {
    background: var(--accent);
}

.toggle-thumb {
    position: absolute;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg);
    transition: transform 0.25s, background 0.25s;
}

.theme-toggle input:checked+.toggle-track .toggle-thumb {
    transform: translateX(16px);
}

/* ── Typography ── */
h1 {
    font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

p {
    margin-bottom: 1.4rem;
}

a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--muted);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

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

hr {
    border: none;
    border-top: 1px solid var(--muted);
    margin: 2.5rem 0;
    opacity: 0.25;
}

/* ── Post list ── */
.post-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.post-list li {
    display: flex;
    align-items: baseline;
    gap: 1.2rem;
    font-size: 1.02rem;
    padding: 0.3rem 0;
}

.post-list .post-date {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.88rem;
    color: var(--muted);
    flex-shrink: 0;
    min-width: 7.5ch;
    letter-spacing: 0.02em;
}

.post-list a {
    text-decoration: none;
    color: var(--text);
}

.post-list a:hover {
    text-decoration: underline;
    text-decoration-color: var(--muted);
    text-underline-offset: 3px;
}

/* ── Post page ── */
article h1 {
    font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    margin-bottom: 0.8rem;
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.025em;
}

.post-date {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--muted);
    font-size: 0.72rem;
    margin-bottom: 3rem;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.read-time {
    font-weight: 400;
    letter-spacing: 0.04em;
}

article p,
article li {
    font-size: 1.15rem;
    line-height: 1.9;
    letter-spacing: 0.015em;
}

article .post-date+p::first-letter {
    font-size: 4.5em;
    font-weight: 700;
    float: left;
    line-height: 0.75;
    margin: 0.08em 0.08em 0 0;
    color: var(--accent);
}

/* ── Tags ── */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 3rem;
}

.tag {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    border: 1px solid var(--muted);
    border-radius: 2px;
    padding: 0.15rem 0.5rem;
    text-decoration: none;
}

.tag:hover {
    color: var(--accent);
    border-color: var(--accent);
    text-decoration: none;
}

/* ── Lists ── */
ul,
ol {
    margin-left: 1.5rem;
    margin-bottom: 1.4rem;
}

li {
    margin-bottom: 0.6rem;
}

/* ── Blockquote ── */
blockquote {
    border-left: 3px solid var(--muted);
    padding-left: 1.2rem;
    margin-left: 0;
    margin-bottom: 1.4rem;
    font-style: italic;
    color: var(--muted);
}

/* ── Code ── */
code {
    background: color-mix(in srgb, var(--muted) 18%, var(--bg));
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: "SF Mono", Monaco, "Inconsolata", monospace;
    font-size: 0.9em;
}

pre {
    background: color-mix(in srgb, var(--muted) 10%, var(--bg));
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 1.4rem;
}

pre code {
    background: none;
    opacity: 1;
    padding: 0;
}