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

/* ---- Theme colors ---- */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #fff;
    --bg-secondary: #f4f4f5;
    --text: #18181b;
    --text-light: #71717a;
    --border: #e4e4e7;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --code-bg: #f4f4f5;
    --code-text: #c026d3;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #18181b;
    --bg-secondary: #27272a;
    --text: #e4e4e7;
    --text-light: #a1a1aa;
    --border: #3f3f46;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --code-bg: #27272a;
    --code-text: #e879f9;
}

/* ---- Base ---- */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
}

/* ---- Single container ---- */
/* Every horizontal section uses this exact same width and padding.
   This is the ONE rule that guarantees alignment. */
.container {
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

/* ---- Typography ---- */
h1, h2, h3, h4 {
    line-height: 1.2;
    letter-spacing: -0.025em;
}

h1 { font-size: 2.5rem; margin-bottom: 0.25rem; }
h2 { font-size: 1.8rem; margin-bottom: 0.25rem; }
h3 { font-size: 1.4rem; margin-bottom: 0.25rem; }

p { margin-bottom: 1rem; }

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.15s;
}

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

ul, ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

li { margin-bottom: 0.25rem; }

blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

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

img { max-width: 100%; height: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

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

th { background-color: var(--bg-secondary); }

/* ---- Code ---- */
code {
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;
    font-size: 0.9em;
    color: var(--code-text);
    background-color: var(--code-bg);
    padding: 0.15em 0.35em;
    border-radius: 4px;
}

pre {
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-x: auto;
}

pre code {
    padding: 0;
    background: none;
    color: inherit;
}

.highlight {
    border-radius: 8px;
    margin-bottom: 1rem;
}

.highlight pre {
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

/* ---- Header ---- */
header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

header nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

header nav a {
    text-decoration: none;
}

header nav a:first-child {
    margin-right: auto;
    font-weight: 600;
    font-size: 1.1rem;
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
    letter-spacing: -0.02em;
    color: var(--text);
    padding: 0.4rem 0;
}

header nav a:not(:first-child) {
    color: var(--text-light);
    padding: 0.4rem 0.9rem;
    font-size: 0.95rem;
    border-radius: 999px;
    transition: color 0.15s, background-color 0.15s;
}

header nav a:not(:first-child):hover {
    color: var(--text);
    background-color: var(--bg-secondary);
}

header nav a[aria-current="page"] {
    color: var(--text);
    background-color: var(--bg-secondary);
    font-weight: 600;
}

/* ---- Nav icons (feed, etc.) ---- */
.nav-icon {
    color: var(--text-light);
    padding: 0.4rem;
    line-height: 1;
    display: flex;
    align-items: center;
    border-radius: 999px;
    transition: color 0.15s, background-color 0.15s;
}

.nav-icon:hover {
    color: var(--text);
    background-color: var(--bg-secondary);
}

/* ---- Theme toggle ---- */
#theme-toggle {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.4rem;
    line-height: 1;
    transition: color 0.15s, background-color 0.15s;
    display: flex;
    align-items: center;
    border-radius: 999px;
}

#theme-toggle:hover {
    color: var(--text);
    background-color: var(--bg-secondary);
}

#theme-toggle svg {
    width: 18px;
    height: 18px;
}

[data-theme="light"] #theme-toggle .icon-sun { display: none; }
[data-theme="light"] #theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] #theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

/* ---- Main ---- */
main {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
}

/* ---- Post entries on index ---- */
.post-entry {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.post-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.post-entry h1 a {
    text-decoration: none;
    color: var(--text);
    transition: color 0.15s;
}

.post-entry h1 a:hover {
    color: var(--accent);
}

/* ---- Date ---- */
.post-date {
    color: var(--text-light);
    font-size: 0.9rem;
}
