@font-face {
    font-family: 'Newsreader';
    src: url('fonts/newsreader-latin.woff2') format('woff2');
    font-weight: 300 500;
    font-style: normal;
    font-display: swap;
}

/* ========================================
   CSS Variables
   ======================================== */
:root {
    --bg: #f7f6f3;
    --text: #2c2c2c;
    --text-muted: #666;
    --text-faint: #999;
    --accent: #1a1a1a;
    --border: #e0ddd8;
    --border-light: #eae7e2;
    --code-bg: #edeae5;
    --mark-bg: #fff3b0;
    --link: #2c2c2c;
    --link-hover: #000;
    --note-bg: #f0f7f4;
    --note-border: #b8d4c8;
    --warning-bg: #fef6e6;
    --warning-border: #e6c07b;
    --info-bg: #f0f4f8;
    --info-border: #a8c5da;
}

/* ========================================
   Reset & Base
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Newsreader', Georgia, serif;
    max-width: 600px;
    margin: 0 auto;
    padding: 24px 16px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    font-size: 1.05rem;
    -webkit-font-smoothing: antialiased;
}

/* ========================================
   Typography — Headings
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

h1 {
    font-size: 2rem;
    margin-bottom: 4px;
}

h2 {
    font-size: 1.5rem;
    margin-top: 48px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

h3 {
    font-size: 1.2rem;
    font-weight: 500;
    margin-top: 32px;
    margin-bottom: 8px;
}

h4 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-top: 24px;
    margin-bottom: 6px;
}

h5 {
    font-size: 1rem;
    font-weight: 500;
    margin-top: 20px;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}

h6 {
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 16px;
    margin-bottom: 4px;
    color: var(--text-muted);
}

/* ========================================
   Typography — Body Text
   ======================================== */
p {
    margin-bottom: 16px;
    font-weight: 300;
}

p.intro {
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 32px;
}

p.lead {
    font-size: 1.2rem;
    line-height: 1.5;
    color: var(--text);
    margin-bottom: 24px;
}

small {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ========================================
   Links
   ======================================== */
a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.15s ease;
}

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

/* ========================================
   Inline Elements
   ======================================== */
strong {
    font-weight: 500;
}

em {
    font-style: italic;
}

del {
    color: var(--text-muted);
    text-decoration: line-through;
}

mark {
    background: var(--mark-bg);
    padding: 1px 4px;
    border-radius: 2px;
}

abbr[title] {
    text-decoration: underline dotted;
    text-decoration-color: var(--text-faint);
    cursor: help;
}

/* ========================================
   Inline Code
   ======================================== */
code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 0.88em;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
}

/* ========================================
   Code Blocks
   ======================================== */
pre {
    background: var(--accent);
    color: #e8e6e3;
    padding: 16px 20px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 20px 0;
    line-height: 1.5;
}

pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
    color: inherit;
}

/* ========================================
   Keyboard
   ======================================== */
kbd {
    font-family: 'SF Mono', 'Monaco', monospace;
    font-size: 0.8em;
    background: var(--code-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 2px 6px;
    white-space: nowrap;
}

/* ========================================
   Blockquotes
   ======================================== */
blockquote {
    margin: 24px 0;
    padding: 0 0 0 20px;
    border-left: 2px solid var(--border);
}

blockquote p {
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 8px;
}

blockquote cite {
    font-size: 0.9rem;
    font-style: normal;
    color: var(--text-faint);
}

blockquote blockquote {
    margin: 12px 0;
}

/* ========================================
   Pull Quotes
   ======================================== */
.pull-quote {
    margin: 32px 0;
    padding: 0;
    border: none;
    text-align: center;
}

.pull-quote p {
    font-size: 1.4rem;
    font-style: italic;
    line-height: 1.4;
    color: var(--text);
    margin: 0;
}

/* ========================================
   Lists
   ======================================== */
ul, ol {
    margin: 16px 0;
    padding-left: 24px;
}

li {
    margin-bottom: 6px;
    font-weight: 300;
}

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

ul ul, ol ol, ul ol, ol ul {
    margin: 6px 0;
}

/* Definition Lists */
dl {
    margin: 16px 0;
}

dt {
    font-weight: 500;
    margin-top: 12px;
}

dt:first-child {
    margin-top: 0;
}

dd {
    margin-left: 0;
    padding-left: 16px;
    color: var(--text-muted);
    font-weight: 300;
    border-left: 2px solid var(--border-light);
}

/* Checklist */
.checklist {
    list-style: none;
    padding-left: 0;
}

.checklist li {
    position: relative;
    padding-left: 28px;
}

.checklist li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border);
    border-radius: 3px;
}

.checklist li.checked::before {
    background: var(--accent);
    border-color: var(--accent);
}

.checklist li.checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 8px;
    width: 10px;
    height: 5px;
    border: 2px solid #fff;
    border-top: none;
    border-right: none;
    transform: rotate(-45deg);
}

.checklist li.checked {
    color: var(--text-muted);
}

/* ========================================
   Images & Figures
   ======================================== */
img {
    width: 100%;
    height: auto;
    border-radius: 3px;
    margin: 20px 0;
}

figure {
    margin: 24px 0;
}

figure img {
    margin: 0 0 8px 0;
}

figcaption {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Gallery */
.gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 24px 0;
}

.gallery figure {
    margin: 0;
}

.gallery figcaption {
    font-size: 0.8rem;
}

/* ========================================
   Tables
   ======================================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 0.95rem;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
}

th {
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom-color: var(--border);
}

tr:last-child td {
    border-bottom: none;
}

/* ========================================
   Callouts
   ======================================== */
.callout {
    margin: 24px 0;
    padding: 16px 20px;
    border-radius: 4px;
    border-left: 3px solid;
}

.callout p {
    margin: 0;
    font-size: 0.95rem;
}

.callout.note {
    background: var(--note-bg);
    border-color: var(--note-border);
}

.callout.warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
}

.callout.info {
    background: var(--info-bg);
    border-color: var(--info-border);
}

/* ========================================
   Details / Collapsible
   ======================================== */
details {
    margin: 16px 0;
    border: 1px solid var(--border-light);
    border-radius: 4px;
}

summary {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 400;
    user-select: none;
    transition: background 0.15s ease;
}

summary:hover {
    background: rgba(0, 0, 0, 0.02);
}

details[open] summary {
    border-bottom: 1px solid var(--border-light);
}

details > *:not(summary) {
    padding: 0 16px;
}

details > p:first-of-type {
    margin-top: 16px;
}

details > *:last-child {
    margin-bottom: 16px;
}

/* ========================================
   Horizontal Rules
   ======================================== */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

hr.ornament {
    border: none;
    text-align: center;
    margin: 40px 0;
}

hr.ornament::before {
    content: '· · ·';
    color: var(--text-faint);
    letter-spacing: 0.5em;
}

/* ========================================
   Metadata
   ======================================== */
.meta {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.meta time {
    font-style: normal;
}

time {
    white-space: nowrap;
}

/* ========================================
   Article Footer
   ======================================== */
.article-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}

.article-footer p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ========================================
   Sections (for design page)
   ======================================== */
section {
    margin-bottom: 24px;
}

section:last-child {
    margin-bottom: 0;
}

/* ========================================
   Dark Mode (System Preference)
   ======================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a1a;
        --text: #e8e6e3;
        --text-muted: #a0a0a0;
        --text-faint: #707070;
        --accent: #f7f6f3;
        --border: #333;
        --border-light: #2a2a2a;
        --code-bg: #252525;
        --mark-bg: #4a4020;
        --link: #e8e6e3;
        --link-hover: #fff;
        --note-bg: #1a2a22;
        --note-border: #3a5a48;
        --warning-bg: #2a2418;
        --warning-border: #6a5030;
        --info-bg: #1a2230;
        --info-border: #3a506a;
    }

    pre {
        background: #0d0d0d;
    }

    kbd {
        background: var(--code-bg);
        border-color: #444;
    }

    summary:hover {
        background: rgba(255, 255, 255, 0.03);
    }

    .checklist li.checked::before {
        background: var(--text);
        border-color: var(--text);
    }

    .checklist li.checked::after {
        border-color: var(--bg);
    }
}
