/* ==========================================================================
   Vofan — Ghost theme stylesheet
   Warm editorial design · light + dark themes · justified prose
   ========================================================================== */

:root {
    --ink: #14181d;
    --ink-soft: #4a5261;
    --paper: #fbfaf7;
    --paper-alt: #f3f1eb;
    --card: #ffffff;
    --line: #e3ded2;
    --line-strong: #c9c2b2;
    --muted: #8b8578;
    --accent: #9a2617;
    --accent-hover: #7d1f13;
    --gold: #f0c96a;
    --topbar-bg: #14181d;
    --topbar-text: #d8dbe0;
    --serif: Georgia, "Times New Roman", serif;
    --sans: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
}

:root.dark {
    --ink: #ece6da;
    --ink-soft: #b3ab9a;
    --paper: #16130e;
    --paper-alt: #201c14;
    --card: #241f16;
    --line: #3a3427;
    --line-strong: #4a4231;
    --muted: #948b78;
    --accent: #cd4532;
    --accent-hover: #e5604a;
}

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

body {
    font-family: var(--sans);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.6;
    transition: background 0.25s ease, color 0.25s ease;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

a { color: inherit; }

/* ---------- Reading progress ---------- */

.progress {
    position: fixed; top: 0; left: 0; height: 3px;
    background: var(--accent); width: 0%; z-index: 10;
}

/* ---------- Top bar ---------- */

.topbar {
    background: var(--topbar-bg);
    color: var(--topbar-text);
    font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
}
.topbar-wrap {
    display: flex; justify-content: space-between; align-items: center;
    height: 36px; gap: 12px;
}
.topbar .independent { color: var(--gold); }
.topbar .right { display: flex; align-items: center; gap: 16px; }
.topbar a { color: var(--topbar-text); text-decoration: none; }
.topbar a:hover { color: #fff; }

.theme-toggle {
    font: inherit; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
    background: none; color: var(--topbar-text);
    border: 1px solid #3a4048; border-radius: 999px; padding: 3px 12px; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- Masthead ---------- */

header.masthead { padding: 36px 0 18px; text-align: center; border-bottom: 3px double var(--ink); }
.masthead h1 { font-family: var(--serif); font-size: 56px; font-weight: 700; letter-spacing: 0.01em; }
.masthead h1 a { text-decoration: none; }
.masthead .tagline {
    margin-top: 6px; color: var(--ink-soft);
    font-size: 14px; letter-spacing: 0.14em; text-transform: uppercase;
}

nav.sections {
    display: flex; justify-content: center; gap: 28px; padding: 14px 0;
    font-size: 14px; letter-spacing: 0.04em; flex-wrap: wrap;
}
nav.sections a { color: var(--ink); text-decoration: none; text-transform: uppercase; }
nav.sections a:hover { color: var(--accent); }

/* ---------- Homepage hero ---------- */

.hero {
    display: grid; grid-template-columns: 1.2fr 1fr; gap: 36px; align-items: center;
    padding: 34px 0; border-bottom: 1px solid var(--line);
}
@media (max-width: 800px) { .hero { grid-template-columns: 1fr; } }

.hero-left .kicker {
    color: var(--accent); font-size: 12px; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase;
}
.hero figure.img { width: fit-content; margin: 0 auto; }
.hero figure.img img { height: auto; width: auto; max-width: 100%; max-height: 320px; }
.hero-left h2 { font-family: var(--serif); font-size: 34px; line-height: 1.18; margin: 10px 0 12px; }
.hero-left h2 a { text-decoration: none; }
.hero-left h2 a:hover { color: var(--accent); }
.hero-left p { color: var(--ink-soft); font-size: 16px; }

.meta { margin-top: 14px; font-size: 13px; color: var(--ink-soft); }
.meta .by { color: var(--ink); font-weight: 600; }

/* ---------- Article cards ---------- */

.section-title { display: flex; align-items: center; gap: 14px; margin: 30px 0 20px; }
.section-title h2 { font-family: var(--serif); font-size: 24px; white-space: nowrap; }
.section-title .rule { flex: 1; height: 1px; background: var(--line); }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; }
.related .grid { grid-template-columns: 1fr 1fr; }
@media (max-width: 800px) { .grid { grid-template-columns: 1fr; } }

.card {
    background: var(--card); border: 1px solid var(--line);
    padding: 16px; display: flex; flex-direction: column;
}
.card figure.img { aspect-ratio: 16 / 9; margin-bottom: 14px; background: var(--card); }
.card figure.img img { object-fit: contain; }
.card .tag {
    font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--accent); margin-bottom: 6px;
}
.card h3 { font-family: var(--serif); font-size: 20px; line-height: 1.25; font-weight: 400; }
.card h3 a { text-decoration: none; }
.card h3 a:hover { color: var(--accent); }
.card p { font-size: 14px; color: var(--ink-soft); flex: 1; margin-top: 8px; }
.card .meta { margin-top: 12px; font-size: 12px; color: var(--muted); }

figure.img { overflow: hidden; background: var(--paper-alt); }
figure.img img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ---------- Pagination ---------- */

nav.pagination { display: flex; justify-content: center; gap: 14px; margin: 40px 0; }
nav.pagination a {
    font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none;
    color: var(--ink-soft); border: 1px solid var(--line-strong);
    border-radius: 999px; padding: 8px 20px;
}
nav.pagination a:hover { border-color: var(--accent); color: var(--accent); }
nav.pagination .page-number {
    align-self: center; font-size: 13px; color: var(--muted);
    letter-spacing: 0.06em; text-transform: uppercase;
}

/* ---------- Newsletter ---------- */

.newsletter {
    text-align: center; margin: 50px 0 0;
    padding: 40px 24px;
    border-top: 3px double var(--ink);
}
.newsletter h2 { font-family: var(--serif); font-size: 20px; margin-bottom: 8px; }
.newsletter p { color: var(--ink-soft); font-size: 13px; max-width: 68ch; margin: 0 auto 20px; }
.newsletter .row { display: flex; justify-content: center; }
.newsletter form {
    display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}
.newsletter input[type="email"] {
    font: inherit; padding: 11px 14px; width: 300px; max-width: 90%;
    border: 1px solid var(--ink); background: var(--card); color: var(--ink);
}
.newsletter button {
    font: inherit; padding: 11px 22px; background: var(--accent);
    border: 1px solid var(--accent); color: #fff; letter-spacing: 0.04em; cursor: pointer;
}
.newsletter button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.newsletter .small { margin-top: 12px; font-size: 12px; color: var(--muted); }

/* ---------- Article page ---------- */

.crumbs {
    font-size: 12px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase;
    padding: 12px 0;
}
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 8px; color: var(--muted); }

.article-head { max-width: 680px; margin: 0 auto; padding: 44px 24px 0; text-align: left; }
.article-head .kicker {
    color: var(--accent); font-size: 12px; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase;
}
.article-head .headline {
    font-family: var(--serif); font-size: 44px; line-height: 1.12; margin: 14px 0 18px;
}
.standfirst {
    font-family: var(--serif); font-size: 20px; line-height: 1.5; color: var(--ink-soft);
}
.byline-row {
    display: flex; align-items: center; justify-content: flex-start; gap: 18px;
    margin: 28px 0 0; flex-wrap: wrap;
}
.avatar {
    width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
    background: var(--accent); color: #fff; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--serif); font-size: 22px; font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 56px; height: 56px; font-size: 27px; }
.byline-text { text-align: left; font-size: 14px; color: var(--ink-soft); line-height: 1.45; }
.byline-text .by { color: var(--ink); font-weight: 700; }

.hero-figure { max-width: 860px; margin: 32px auto 0; padding: 0 24px; }
.hero-figure figure.img { width: fit-content; margin: 0 auto; }
.hero-figure figure.img img { height: auto; width: auto; max-width: 100%; max-height: 440px; }

/* ---------- Prose ---------- */

.prose { max-width: 680px; margin: 0 auto; padding: 44px 24px 10px; }
.prose p {
    font-family: var(--serif); font-size: 18px; line-height: 1.75; margin-bottom: 1.2em;
    text-align: justify; hyphens: auto; -webkit-hyphens: auto;
}
.prose > p:first-of-type::first-letter {
    font-family: var(--serif); font-size: 3.4em; float: left; line-height: 0.82;
    padding: 4px 12px 0 0; color: var(--accent); font-weight: 700;
}
.prose h2, .prose h3, .prose h4 {
    font-family: var(--serif); font-size: 26px; margin: 38px 0 14px; line-height: 1.25;
}
.prose h3 { font-size: 23px; }
.prose h4 { font-size: 20px; }
.prose blockquote {
    border-left: 4px solid var(--accent); padding: 8px 0 8px 24px;
    font-family: var(--serif); font-size: 24px; line-height: 1.4; margin: 34px 0;
}
.prose a { color: var(--accent); }
.prose a:hover { color: var(--accent-hover); }
.prose figure { margin: 34px 0; }
.prose figcaption {
    font-size: 12.5px; color: var(--muted); margin-top: 10px;
    padding-bottom: 8px; text-align: left;
}
.prose ol, .prose ul {
    font-family: var(--serif); font-size: 18px; line-height: 1.75;
    padding-left: 24px; margin-bottom: 1.2em;
    text-align: justify; hyphens: auto; -webkit-hyphens: auto;
}
.prose li { margin-bottom: 0.5em; }
.prose img { max-width: 100%; height: auto; }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 2.5em 0; }

/* Koenig editor image widths */
.kg-width-wide { width: 85vw; max-width: 960px; margin-left: 50%; transform: translateX(-50%); }
.kg-width-full { width: 100vw; margin-left: 50%; transform: translateX(-50%); }

/* ---------- Tags & author box ---------- */

.tags { display: flex; gap: 10px; flex-wrap: wrap; padding: 20px 24px 0; max-width: 680px; margin: 0 auto; }
.tags a {
    font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none;
    color: var(--ink-soft); border: 1px solid var(--line);
    padding: 6px 14px; border-radius: 999px; background: var(--card);
}
.tags a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Related ---------- */

.related { max-width: 860px; margin: 0 auto; padding: 56px 24px 10px; }

/* ---------- Footer ---------- */

footer.site {
    background: var(--paper-alt); border-top: 1px solid var(--line);
    padding: 24px 0 26px; font-size: 13px; color: var(--ink-soft);
}
footer.site .cols { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
footer.site a { color: var(--ink-soft); text-decoration: none; display: block; padding: 3px 0; }
footer.site a:hover { color: var(--accent); }
footer.site .legal {
    margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 12px;
}
.badge {
    display: inline-block; border: 1px solid var(--line-strong); border-radius: 999px;
    padding: 3px 10px; margin-right: 6px; font-size: 11px; color: var(--muted);
}

/* ---------- Dark mode editor embeds (tweets, embeds) ---------- */

:root.dark .kg-embed-card iframe,
:root.dark .kg-bookmark-card { color-scheme: dark; }

/* ---------- Social & newsletter icons ---------- */
footer.site .social { display: flex; gap: 16px; justify-content: flex-end; }
footer.site .social a { display: block; padding: 2px 0; color: var(--ink-soft); }
footer.site .social a:hover { color: var(--accent); }
footer.site .social svg { height: 20px; width: auto; display: block; }
footer.site .social .eye { fill: var(--paper); }
.newsletter .newsletter-icon { display: inline-block; margin-bottom: 12px; }
.newsletter .newsletter-icon svg { display: block; margin: 0 auto; }
footer.site .links { display: flex; gap: 28px; }

/* ---------- Support link (top bar) ---------- */
.topbar .support { display: inline-flex; align-items: center; gap: 7px; }
.topbar .support svg { width: 15px; height: 15px; display: block; }
.topbar .support .steam { transition: stroke 0.15s; }
.topbar .support:hover .steam { stroke: var(--gold); }

/* ---------- Ko-fi support modal ---------- */
.kofi-modal { position: fixed; inset: 0; z-index: 999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.kofi-modal[hidden] { display: none; }
.kofi-backdrop { position: absolute; inset: 0; background: rgba(10, 10, 12, 0.6); }
.kofi-dialog {
    position: relative; background: var(--paper); border: 3px double var(--ink);
    padding: 12px; width: 100%; max-width: 440px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.kofi-dialog iframe { display: block; width: 100%; height: 60vh; max-height: 540px; border: 0; background: var(--card); }
.kofi-close {
    position: absolute; top: -14px; right: -14px; width: 30px; height: 30px;
    border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card);
    color: var(--ink); font-size: 15px; line-height: 1; cursor: pointer;
}
.kofi-close:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
