/* ==========================================================================
   Spread — a quiet editorial theme for Ghost
   Black on white, grotesk type, image-led grid, notes between the stories.
   ========================================================================== */

:root {
    --color-bg: #fff;
    --color-text: #111;
    --color-muted: #6b6b6b;
    --color-line: #e2e2e2;
    --color-line-strong: #111;
    --color-surface: #f4f4f4;
    --color-accent: var(--ghost-accent-color, #111);

    --font-sans: var(--gh-font-body, "Helvetica Neue", Helvetica, Arial, "Inter", system-ui, -apple-system, sans-serif);
    --font-heading: var(--gh-font-heading, var(--font-sans));
    --font-condensed: "Helvetica Neue Condensed Bold", "Arial Narrow", "Roboto Condensed", var(--font-sans);
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --gutter: clamp(16px, 2.5vw, 32px);
    --max: 1440px;
    --measure: 680px;
    --measure-wide: 1080px;

    --t-meta: 11px;
    --t-small: 14px;
    --t-body: 17px;
    --t-card: clamp(18px, 1.5vw, 22px);
    --t-hero: clamp(32px, 4.5vw, 64px);
    --t-title: clamp(34px, 5vw, 68px);
}

html.dark-mode {
    --color-bg: #0f0f0f;
    --color-text: #f2f2f2;
    --color-muted: #9a9a9a;
    --color-line: #2a2a2a;
    --color-line-strong: #f2f2f2;
    --color-surface: #1a1a1a;
}
@media (prefers-color-scheme: dark) {
    html.auto-color {
        --color-bg: #0f0f0f;
        --color-text: #f2f2f2;
        --color-muted: #9a9a9a;
        --color-line: #2a2a2a;
        --color-line-strong: #f2f2f2;
        --color-surface: #1a1a1a;
    }
}

/* Reset ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--t-body);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
img, video, svg { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--color-accent); }
h1, h2, h3, h4, h5, h6 { margin: 0; font-family: var(--font-heading); font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; }
::selection { background: var(--color-text); color: var(--color-bg); }
.u-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Type helpers ----------------------------------------------------------- */
.meta,
.card-meta, .hero-meta, .note-meta, .article-meta,
.feed-head-links, .archive-head-kicker, .article-byline, .pagination,
.site-foot-inner, .site-head-nav, .site-head-actions, .site-head-burger {
    font-size: var(--t-meta);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1.4;
}

/* 1 Granary style titles */
.has-caps-titles .card-title,
.has-caps-titles .hero-title,
.has-caps-titles .article-title,
.has-caps-titles .archive-head-title,
.has-caps-titles .feed-head-title,
.has-caps-titles .site-foot-signup-title {
    font-family: var(--font-condensed);
    font-stretch: condensed;
    text-transform: uppercase;
    letter-spacing: 0;
    line-height: 1;
}

/* Layout ----------------------------------------------------------------- */
.viewport { min-height: 100vh; display: flex; flex-direction: column; }
.site-content { flex: 1; }
.site-main { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }

/* Header ----------------------------------------------------------------- */
.site-head {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-line);
}
.site-head-inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 var(--gutter);
    height: 64px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}
.site-head-nav { display: flex; }
.site-head-nav ul, .site-head-drawer ul { list-style: none; display: flex; gap: 28px; }
.site-head-nav a { display: inline-block; padding: 4px 0; border-bottom: 1px solid transparent; }
.site-head-nav a:hover, .site-head-nav a.is-current { color: inherit; border-bottom-color: currentColor; }
.site-head-logo {
    justify-self: center;
    display: inline-flex;
    align-items: center;
}
.site-head-logo img { max-height: 34px; width: auto; }
.site-head-logo.is-text {
    font-family: var(--font-condensed);
    font-stretch: condensed;
    font-weight: 900;
    font-size: 30px;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    line-height: 1;
}
.site-head-logo:hover { color: inherit; }
.site-head-actions { justify-self: end; display: flex; align-items: center; gap: 24px; }
.site-head-search { padding: 4px 0; display: inline-flex; align-items: center; }
.site-head-search-icon { display: none; }
.site-head-search:hover { color: var(--color-accent); }
.site-head-subscribe {
    padding: 9px 14px;
    background: var(--color-text);
    color: var(--color-bg);
    border-radius: 999px;
    transition: background 0.15s;
}
.site-head-subscribe:hover { background: var(--color-accent); color: #fff; }

.site-head-burger { display: none; justify-self: start; }
.burger-label-close { display: none; }
.is-open .burger-label { display: none; }
.is-open .burger-label-close { display: inline; }

.site-head-drawer {
    display: none;
    border-top: 1px solid var(--color-line);
    padding: 24px var(--gutter) 32px;
}
.site-head-drawer ul { flex-direction: column; gap: 0; }
.site-head-drawer-nav a {
    display: block;
    padding: 10px 0;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    border-bottom: 1px solid var(--color-line);
}
.site-head-drawer-secondary { margin-top: 20px; }
.site-head-drawer-secondary a { display: block; padding: 6px 0; font-size: var(--t-small); color: var(--color-muted); }

@media (max-width: 899px) {
    .site-head-inner { height: 56px; }
    .site-head-nav { display: none; }
    .site-head-burger { display: inline-block; }
    .site-head-logo.is-text { font-size: 24px; }
    .site-head-actions { gap: 14px; }
    .site-head-search-label { display: none; }
    .site-head-search-icon { display: block; }
    .site-head-subscribe { padding: 7px 11px; }
    .site-head.is-open .site-head-drawer { display: block; }
    html.is-drawer-open { overflow: hidden; }
}

/* Hero ------------------------------------------------------------------- */
.hero {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: var(--gutter);
    padding: var(--gutter) 0;
    border-bottom: 1px solid var(--color-line-strong);
}
.hero-image { display: block; background: var(--color-surface); overflow: hidden; }
.hero-image img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.hero-body { display: flex; flex-direction: column; justify-content: flex-end; gap: 20px; padding-bottom: 8px; }
.hero-meta { display: flex; gap: 16px; color: var(--color-muted); }
.hero-tag { color: var(--color-text); }
.hero-title { font-size: var(--t-hero); }
.hero-title a:hover { color: inherit; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.hero-excerpt { font-size: var(--t-body); color: var(--color-muted); max-width: 44ch; }
.hero-authors { font-size: var(--t-small); }
@media (max-width: 899px) {
    .hero { grid-template-columns: 1fr; }
    .hero-body { justify-content: flex-start; }
}

/* Feed ------------------------------------------------------------------- */
.feed-section { padding: 36px 0 56px; }
.feed-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 16px;
    margin-bottom: 8px;
}
.feed-head-title { font-size: clamp(26px, 3vw, 40px); }
.feed-head-page .feed-head-title { font-size: var(--t-title); }
.feed-head-links { display: flex; gap: 20px; color: var(--color-muted); }
.feed-head-link:hover { color: var(--color-text); }

.feed {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--gutter);
    row-gap: 48px;
}
@media (max-width: 1099px) { .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 599px) { .feed { grid-template-columns: 1fr; row-gap: 40px; } }

/* Card ------------------------------------------------------------------- */
.card { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-image { display: block; overflow: hidden; background: var(--color-surface); }
.card-image img {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.card:hover .card-image img { transform: scale(1.02); }
.card-body { display: flex; flex-direction: column; gap: 8px; }
.card-meta { display: flex; gap: 12px; color: var(--color-muted); }
.card-meta::before { content: none; }
.card-tag { color: var(--color-text); }
.card-tag::after { content: "—"; margin-left: 12px; color: var(--color-muted); }
.card-title { font-size: var(--t-card); }
.card-title a:hover { color: inherit; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.card-excerpt { font-size: var(--t-small); color: var(--color-muted); }
.card-authors { font-size: var(--t-small); color: var(--color-muted); }

/* List layout: one column, image left */
.has-list-feed .feed { grid-template-columns: 1fr; row-gap: 0; }
.has-list-feed .card {
    flex-direction: row;
    gap: var(--gutter);
    padding: 28px 0;
    border-top: 1px solid var(--color-line);
}
.has-list-feed .card-image { flex: 0 0 280px; }
.has-list-feed .card-image img { aspect-ratio: 4 / 3; }
.has-list-feed .card-title { font-size: clamp(22px, 2.6vw, 36px); }
@media (max-width: 599px) {
    .has-list-feed .card { flex-direction: column; }
    .has-list-feed .card-image { flex-basis: auto; }
}

/* Note — the microblog entry between articles ---------------------------- */
/* In the grid a note is a text-only cell: accent square, date, a few lines.
   In list layout, on the /notes/ channel and on phones it runs full width. */
.note {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 16px;
    align-content: start;
    padding-top: 14px;
    border-top: 1px solid var(--color-line-strong);
    min-width: 0;
}
.note-mark, .note-single .note-mark {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 7px;
    background: var(--color-accent);
    transition: transform 0.2s;
}
.note-mark:hover { transform: rotate(6deg); }
.note-body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.note-meta { display: flex; gap: 12px; color: var(--color-muted); }
.note-label { color: var(--color-text); }
.note-date:hover { color: var(--color-accent); }
.note-content { font-size: 18px; line-height: 1.45; }
.note-content > * + * { margin-top: 0.8em; }
.note-content a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--color-muted); }
.note-content a:hover { text-decoration-color: currentColor; }
.note-content figure, .note-content .kg-card { margin: 0.8em 0 0; }
.note-content img { border-radius: 4px; }

/* Full-width note rows: list layout, notes channel, single column */
.has-list-feed .note,
.feed-notes .note {
    grid-column: 1 / -1;
    grid-template-columns: 40px minmax(0, var(--measure));
    gap: 20px;
    padding: 28px 0;
    border-top: 1px solid var(--color-line);
}
.has-list-feed .note .note-mark,
.feed-notes .note .note-mark { width: 40px; height: 40px; border-radius: 8px; }
.has-list-feed .note .note-content,
.feed-notes .note .note-content { font-size: clamp(17px, 1.6vw, 21px); }
.feed-notes { row-gap: 0; }
.feed-notes .note:first-child { border-top: 1px solid var(--color-line-strong); }
.feed-notes .note:last-child { border-bottom: 1px solid var(--color-line-strong); }

@media (max-width: 599px) {
    .note { grid-template-columns: 28px 1fr; gap: 14px; padding: 18px 0 0; }
    .note-mark, .note-single .note-mark { width: 28px; height: 28px; border-radius: 6px; }
    .has-list-feed .note, .feed-notes .note { grid-template-columns: 28px 1fr; gap: 14px; padding: 22px 0; }
    .has-list-feed .note .note-mark, .feed-notes .note .note-mark { width: 28px; height: 28px; }
}

/* Note single page */
.note-single { max-width: var(--measure); margin: 0 auto; padding: 72px 0 96px; }
.note-single-head { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.note-single-meta { display: flex; gap: 12px; font-size: var(--t-meta); text-transform: uppercase; letter-spacing: 0.12em; color: var(--color-muted); }
.note-single-body { font-size: clamp(19px, 2vw, 24px); line-height: 1.45; }
.note-single-body > * + * { margin-top: 0.9em; }
.note-single-foot { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--color-line); font-size: var(--t-small); }
.note-single-foot a { text-decoration: underline; text-underline-offset: 3px; }

/* Archive head (tag/author) ---------------------------------------------- */
.archive-head { padding: 56px 0 24px; border-bottom: 1px solid var(--color-line-strong); }
.archive-head-author { display: flex; gap: 24px; align-items: flex-start; }
.archive-head-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; flex: none; }
.archive-head-kicker { color: var(--color-muted); margin-bottom: 12px; }
.archive-head-title { font-size: var(--t-title); }
.archive-head-text { margin-top: 16px; max-width: 60ch; color: var(--color-muted); }
.archive-head-links { margin-top: 12px; font-size: var(--t-small); display: flex; gap: 16px; }
.archive-head-links a { text-decoration: underline; text-underline-offset: 3px; }

/* Pagination ------------------------------------------------------------- */
.pagination {
    max-width: var(--max);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 24px 0 64px;
    border-top: 1px solid var(--color-line);
}
.pagination.is-single { display: none; }
.pagination-count { color: var(--color-muted); }
.pagination-older { justify-self: end; }
.pagination a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* Article ---------------------------------------------------------------- */
.article { padding: 56px 0 72px; }
.gh-canvas {
    display: grid;
    grid-template-columns:
        [full-start] minmax(0, 1fr)
        [wide-start] minmax(0, calc((var(--measure-wide) - var(--measure)) / 2))
        [main-start] min(var(--measure), 100%) [main-end]
        minmax(0, calc((var(--measure-wide) - var(--measure)) / 2)) [wide-end]
        minmax(0, 1fr) [full-end];
}
.gh-canvas > * { grid-column: main-start / main-end; }
.gh-canvas > .kg-width-wide, .gh-canvas > .article-image { grid-column: wide-start / wide-end; }
.gh-canvas > .kg-width-full { grid-column: full-start / full-end; }

.article-head > * { grid-column: main-start / main-end; }
.article-meta { display: flex; gap: 16px; color: var(--color-muted); margin-bottom: 20px; }
.article-tag { color: var(--color-text); }
.article-title { font-size: var(--t-title); margin-bottom: 20px; }
.article-excerpt { font-size: clamp(18px, 1.8vw, 22px); line-height: 1.4; color: var(--color-muted); margin-bottom: 24px; max-width: 40ch; }
.article-byline { display: flex; gap: 16px; align-items: baseline; padding: 14px 0; border-top: 1px solid var(--color-line-strong); border-bottom: 1px solid var(--color-line); margin-bottom: 40px; }
.article-byline-label { color: var(--color-muted); }
.article-authors a:hover { text-decoration: underline; text-underline-offset: 3px; }
.article-reading { margin-left: auto; color: var(--color-muted); }
.article-image { margin: 0 0 40px; }
.article-image img { width: 100%; }
.article-image figcaption, .gh-content figcaption {
    margin-top: 10px;
    font-size: 12px;
    letter-spacing: 0.02em;
    color: var(--color-muted);
    text-align: left;
}

/* Post content ----------------------------------------------------------- */
.gh-content { font-size: clamp(17px, 1.4vw, 19px); line-height: 1.6; }
.gh-content > * + * { margin-top: 1.2em; }
.gh-content > [id]:not(:first-child) { margin-top: 2em; }
.gh-content h2 { font-size: clamp(24px, 2.4vw, 32px); }
.gh-content h3 { font-size: clamp(20px, 2vw, 24px); }
.gh-content h4 { font-size: 18px; }
.gh-content h2 + *, .gh-content h3 + *, .gh-content h4 + * { margin-top: 0.6em; }
.gh-content a { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.gh-content a:hover { color: var(--color-accent); }
.gh-content strong { font-weight: 700; }
.gh-content ul, .gh-content ol { padding-left: 1.4em; }
.gh-content li + li { margin-top: 0.4em; }
.gh-content blockquote {
    margin: 2em 0;
    padding: 0;
    border: 0;
    font-size: clamp(22px, 2.4vw, 30px);
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.gh-content blockquote.kg-blockquote-alt { font-style: normal; text-align: left; font-size: clamp(22px, 2.4vw, 30px); }
.gh-content hr { margin: 3em auto; width: 40px; border: 0; border-top: 2px solid var(--color-text); }
.gh-content pre { padding: 20px; background: var(--color-surface); overflow-x: auto; font-family: var(--font-mono); font-size: 14px; line-height: 1.5; }
.gh-content code { font-family: var(--font-mono); font-size: 0.9em; background: var(--color-surface); padding: 0.1em 0.3em; }
.gh-content pre code { background: none; padding: 0; }
.gh-content table { width: 100%; border-collapse: collapse; font-size: var(--t-small); }
.gh-content th, .gh-content td { padding: 10px 0; border-bottom: 1px solid var(--color-line); text-align: left; vertical-align: top; }
.gh-content th { font-size: var(--t-meta); text-transform: uppercase; letter-spacing: 0.1em; }
.gh-content .kg-image-card img, .gh-content .kg-gallery-image img { width: 100%; }
.gh-content .kg-card { margin-top: 2em; }
.gh-content .kg-card + .kg-card { margin-top: 2em; }
.gh-content .kg-bookmark-container { border: 1px solid var(--color-line); border-radius: 0; }
.gh-content .kg-button-card .kg-btn { border-radius: 999px; }
.gh-content .kg-callout-card { border-radius: 0; }
.gh-content .kg-toggle-card { border-radius: 0; border: 1px solid var(--color-line); }
.gh-content .kg-header-card { border-radius: 0; }
.gh-content .kg-product-card-container { border-radius: 0; }
.responsive-embed { position: relative; padding-bottom: 56.25%; height: 0; }
.responsive-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Article footer */
.article-foot { margin-top: 56px; }
.article-foot-tags { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 20px; border-top: 1px solid var(--color-line-strong); }
.article-foot-tags a {
    font-size: var(--t-meta);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 6px 10px;
    border: 1px solid var(--color-line);
    border-radius: 999px;
}
.article-foot-tags a:hover { border-color: var(--color-text); color: var(--color-text); }
.article-foot-authors { margin-top: 32px; display: flex; flex-direction: column; gap: 16px; }
.article-foot-author { display: flex; gap: 14px; align-items: center; }
.article-foot-author img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.article-foot-author span { display: flex; flex-direction: column; font-size: var(--t-small); }
.article-foot-author em { font-style: normal; color: var(--color-muted); }
.article-comments { margin-top: 48px; }
.feed-section-related { border-top: 1px solid var(--color-line-strong); }

/* Error ------------------------------------------------------------------ */
.error-page { padding: 120px 0 160px; text-align: left; }
.error-code { font-size: var(--t-meta); letter-spacing: 0.12em; color: var(--color-muted); margin-bottom: 12px; }
.error-title { font-size: var(--t-title); }
.error-text { margin-top: 24px; }
.error-text a { text-decoration: underline; text-underline-offset: 4px; }

/* Footer ----------------------------------------------------------------- */
.site-foot { border-top: 1px solid var(--color-line-strong); margin-top: auto; }
.site-foot-signup {
    max-width: var(--max);
    margin: 0 auto;
    padding: 64px var(--gutter);
    border-bottom: 1px solid var(--color-line);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px var(--gutter);
    align-items: start;
}
.site-foot-signup-title { font-size: clamp(26px, 3vw, 40px); grid-row: 1; }
.site-foot-signup-text { color: var(--color-muted); max-width: 48ch; grid-row: 2; }
.signup-form { grid-column: 2; grid-row: 1 / span 2; position: relative; display: flex; border-bottom: 1px solid var(--color-text); }
.signup-form-input { flex: 1; min-width: 0; border: 0; background: none; padding: 10px 0; color: inherit; outline: none; font-size: var(--t-body); }
.signup-form-input::placeholder { color: var(--color-muted); }
.signup-form-button { padding: 10px 0 10px 16px; font-size: var(--t-meta); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 500; }
.signup-form-button:hover { color: var(--color-accent); }
.signup-form-button-loading { display: none; }
.signup-form.loading .signup-form-button-default { display: none; }
.signup-form.loading .signup-form-button-loading { display: inline; }
.signup-form-message { display: none; position: absolute; top: 100%; left: 0; margin-top: 10px; font-size: var(--t-small); color: var(--color-muted); }
.signup-form.success .signup-form-success { display: block; }
.signup-form.error .signup-form-error { display: block; color: #c0392b; }
@media (max-width: 699px) {
    .site-foot-signup { grid-template-columns: 1fr; }
    .signup-form { grid-column: 1; grid-row: auto; }
}
.site-foot-inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: 24px var(--gutter) 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px 40px;
    align-items: center;
    color: var(--color-muted);
}
.site-foot-col { display: flex; gap: 12px; }
.site-foot-title { color: var(--color-text); }
.site-foot-nav ul, .site-foot-social { list-style: none; display: flex; flex-wrap: wrap; gap: 20px; }
.site-foot-nav a:hover, .site-foot-social a:hover { color: var(--color-text); }
.site-foot-powered { margin-left: auto; }

/* Ghost portal + search buttons should inherit nothing weird */
.gh-portal-triggerbtn-wrapper { display: none !important; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
    html { scroll-behavior: auto; }
}
