/* Walnut for Ghost. Near-black with a brown cast, one copper accent.
   Rules: one accent, lines over fills, flat, quiet edges, two typefaces. */

@font-face {
    font-family: "Inter Variable";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
}
@font-face {
    font-family: "JetBrains Mono Variable";
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url("../fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2-variations");
}

:root {
    --bg: #12100e;
    --surface: #1b1815;
    --border: #2a2520;
    --text: #d6ccbf;
    --muted: #85786a;
    --copper: #b3703f;
    --copper-bright: #d08a55;
    --copper-deep: #7f4d2a;
    --red: #b5564a;
    --green: #7d8c5a;
    --yellow: #c9a05a;
    --blue: #5f7f93;
    --magenta: #96697f;
    --cyan: #5f8f86;

    --font-sans: var(--gh-font-body, "Inter Variable", Inter, system-ui, sans-serif);
    --font-head: var(--gh-font-heading, "Inter Variable", Inter, system-ui, sans-serif);
    --font-mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, monospace;

    --measure: 700px;
    --page: 1040px;
    --gutter: 20px;
    --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); color-scheme: dark; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    /* Koenig cards and Portal read this; keep them copper whatever the site setting says. */
    --ghost-accent-color: var(--copper);
}

::selection { background: var(--copper); color: var(--bg); }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; letter-spacing: -0.015em; margin: 0; text-wrap: balance; }
p { margin: 0; }

:focus-visible { outline: 2px solid var(--copper); outline-offset: 3px; border-radius: 2px; }

.wrap { width: 100%; max-width: calc(var(--page) + var(--gutter) * 2); margin: 0 auto; padding: 0 var(--gutter); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: 12px; z-index: 10; background: var(--surface); padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); }

.eyebrow {
    font-family: var(--font-mono);
    font-size: 12.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--copper);
}

/* Header */

.site-head { border-bottom: 1px solid var(--border); }
.head-inner { display: flex; align-items: center; gap: 20px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1 1 0; min-width: 0; }
.brand-mark { flex: none; }
.brand-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-nav .nav, .foot-nav .nav { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0; padding: 0; }
.site-nav a { font-size: 15px; color: var(--muted); padding: 6px 0; border-bottom: 1px solid transparent; }
.site-nav a:hover { color: var(--text); }
.site-nav .nav-current a { color: var(--text); border-bottom-color: var(--copper); }
.icon-btn { flex: none; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; background: none; border: 1px solid transparent; border-radius: var(--radius); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--border); }

/* Home hero */

.hero { position: relative; border-bottom: 1px solid var(--border); overflow: hidden; }
.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url("../images/contours.jpg") center / cover no-repeat;
    opacity: 0.85;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 55%);
    mask-image: linear-gradient(to right, transparent 0%, #000 55%);
}
.hero-inner { position: relative; padding-top: 72px; padding-bottom: 72px; }
.hero-title { font-size: clamp(30px, 5vw, 46px); max-width: 16ch; }
.hero-text { margin-top: 14px; color: var(--muted); font-size: 18px; max-width: 44ch; }

/* Post list */

.post-list { padding-top: 12px; padding-bottom: 12px; }
.card { border-bottom: 1px solid var(--border); }
.card:last-child { border-bottom: 0; }
.card-link { display: flex; align-items: center; gap: 32px; padding: 30px 0; }
.card-text { flex: 1; min-width: 0; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.card-tag { color: var(--copper); }
.card-title { margin-top: 10px; font-size: clamp(21px, 2.6vw, 26px); transition: color 0.12s; }
.card-link:hover .card-title { color: var(--copper-bright); }
.card-excerpt { margin-top: 10px; color: var(--muted); font-size: 16px; line-height: 1.55; max-width: 62ch; }
.card-image { flex: none; width: 240px; aspect-ratio: 40 / 21; object-fit: cover; border: 1px solid var(--border); border-radius: var(--radius); }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 0 56px; border-top: 1px solid var(--border); font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.pagination a { color: var(--text); padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.pagination a:hover { border-color: var(--copper); color: var(--copper-bright); }
.pagination .page-number { margin: 0 auto; }

/* Tag and author pages */

.archive-head { padding-top: 56px; padding-bottom: 28px; border-bottom: 1px solid var(--border); }
.archive-title { margin-top: 8px; font-size: clamp(30px, 5vw, 42px); }
.archive-text { margin-top: 12px; color: var(--muted); max-width: 60ch; }
.archive-text a, .error-page a { color: var(--copper-bright); text-decoration: underline; text-underline-offset: 3px; }
.error-page { border-bottom: 0; padding-bottom: 96px; }

/* Article */

.article { padding-bottom: 24px; }
.article-head { width: 100%; max-width: calc(var(--measure) + var(--gutter) * 2); margin: 0 auto; padding: 60px var(--gutter) 0; }
.article-title { margin-top: 12px; font-size: clamp(32px, 5.4vw, 48px); letter-spacing: -0.022em; }
.article-excerpt { margin-top: 16px; font-size: 20px; line-height: 1.5; color: var(--muted); }
.article-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.article-image { max-width: calc(var(--page) + var(--gutter) * 2); margin: 40px auto 0; padding: 0 var(--gutter); }
.article-image img { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); }

figcaption { margin-top: 10px; font-size: 14px; line-height: 1.45; color: var(--muted); text-align: center; }
figcaption a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* Article body. Named grid lines give Ghost's wide and full-width cards their columns. */

.gh-content {
    display: grid;
    grid-template-columns:
        [full-start] minmax(var(--gutter), 1fr)
        [wide-start] minmax(0, 170px)
        [main-start] min(var(--measure), 100% - var(--gutter) * 2) [main-end]
        minmax(0, 170px) [wide-end]
        minmax(var(--gutter), 1fr) [full-end];
    padding-top: 40px;
    font-size: 18px;
    line-height: 1.7;
}
.gh-content > * { grid-column: main-start / main-end; min-width: 0; margin: 0; }
.gh-content > * + * { margin-top: 1.5em; }
.gh-content > .kg-width-wide { grid-column: wide-start / wide-end; }
.gh-content > .kg-width-full { grid-column: full-start / full-end; }
.gh-content > .kg-width-full img { width: 100%; border-radius: 0; border-left: 0; border-right: 0; }

.gh-content > h2 { margin-top: 2.1em; font-size: 28px; }
.gh-content > h3 { margin-top: 1.9em; font-size: 22px; }
.gh-content > h4 { margin-top: 1.7em; font-size: 18px; }
.gh-content > h2 + *, .gh-content > h3 + *, .gh-content > h4 + * { margin-top: 0.7em; }

.gh-content a { color: var(--copper-bright); text-decoration: underline; text-decoration-color: var(--copper-deep); text-underline-offset: 3px; }
.gh-content a:hover { text-decoration-color: var(--copper-bright); }
.gh-content strong { font-weight: 600; color: #e6ddd1; }

.gh-content ul, .gh-content ol { padding-left: 1.3em; }
.gh-content li + li { margin-top: 0.45em; }
.gh-content li::marker { color: var(--copper); }

.gh-content blockquote { margin-left: 0; margin-right: 0; padding: 2px 0 2px 20px; border-left: 2px solid var(--copper); color: var(--text); }
.gh-content blockquote p + p { margin-top: 0.8em; }

.gh-content hr { width: 100%; height: 1px; border: 0; background: var(--border); margin-top: 2.4em; margin-bottom: 0.9em; }

.gh-content :not(pre) > code { font-family: var(--font-mono); font-size: 0.86em; padding: 0.12em 0.38em; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.gh-content pre { overflow-x: auto; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font-mono); font-size: 14.5px; line-height: 1.6; tab-size: 4; }
.gh-content pre code { font-family: inherit; }

.gh-content img { border: 1px solid var(--border); border-radius: var(--radius); }
.gh-content figure img { margin: 0 auto; }

.gh-content table { display: block; overflow-x: auto; width: 100%; border-collapse: collapse; font-size: 15.5px; font-variant-numeric: tabular-nums; }
.gh-content th, .gh-content td { padding: 9px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.gh-content th { font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }

/* Koenig cards, restyled in outline */

.gh-content .kg-card { --kg-border: var(--border); }
.gh-content .kg-callout-card { background: var(--surface) !important; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.gh-content .kg-bookmark-container { background: var(--surface); border: 1px solid var(--border) !important; border-radius: var(--radius) !important; color: var(--text) !important; text-decoration: none; }
.gh-content .kg-bookmark-container:hover { border-color: var(--copper-deep) !important; }
.gh-content .kg-bookmark-title { color: var(--text); }
.gh-content .kg-bookmark-description, .gh-content .kg-bookmark-metadata { color: var(--muted); }
.gh-content .kg-btn, .gh-content .kg-btn-accent { background: transparent !important; color: var(--copper-bright) !important; border: 1px solid var(--copper); border-radius: var(--radius); text-decoration: none; }
.gh-content .kg-btn:hover { background: var(--copper) !important; color: var(--bg) !important; opacity: 1; }
.gh-content .kg-toggle-card { background: transparent; border: 1px solid var(--border) !important; border-radius: var(--radius) !important; box-shadow: none; }
.gh-content .kg-toggle-card h4.kg-toggle-heading-text { color: var(--text); }
.gh-content .kg-toggle-card svg { color: var(--copper); }
.gh-content .kg-code-card pre { margin: 0; }
.gh-content .kg-embed-card, .gh-content .kg-video-card { border-radius: var(--radius); overflow: hidden; }

/* Article footer */

.article-foot { max-width: calc(var(--measure) + var(--gutter) * 2); margin: 48px auto 0; padding: 0 var(--gutter); }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 20px; border-top: 1px solid var(--border); }
.chip { font-family: var(--font-mono); font-size: 12.5px; padding: 4px 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; }
.chip:hover { color: var(--copper-bright); border-color: var(--copper-deep); }

.read-next { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 40px; margin-bottom: 64px; }
.read-next-link { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius); }
.read-next-link.next { text-align: right; }
.read-next-link:hover { border-color: var(--copper-deep); }
.read-next-title { font-weight: 600; line-height: 1.3; }

/* Footer */

.site-foot { margin-top: auto; border-top: 1px solid var(--border); }
.foot-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; min-height: 64px; font-size: 14px; color: var(--muted); }
.foot-nav { margin-left: auto; }
.site-foot a:hover { color: var(--text); }

/* Small screens */

@media (max-width: 640px) {
    body { font-size: 16px; }
    .head-inner { gap: 12px; }
    .site-nav { max-width: 55%; overflow-x: auto; scrollbar-width: none; }
    .site-nav .nav { flex-wrap: nowrap; gap: 16px; white-space: nowrap; }
    .hero-inner { padding-top: 48px; padding-bottom: 48px; }
    .hero::before { opacity: 0.5; }
    .card-link { flex-direction: column-reverse; align-items: stretch; gap: 16px; padding: 24px 0; }
    .card-image { width: 100%; }
    .article-head { padding-top: 40px; }
    .gh-content { font-size: 17px; }
    .read-next { grid-template-columns: 1fr; }
    .read-next-link.next { text-align: left; }
    .foot-nav { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
