/* ==========================================================================
   Festina Lente — Ghost theme
   Brand: "Stone" light theme is the default; "Charcoal" is opt-in via the
   sun/moon switch in the header (the choice is saved per browser).
   Type: Cormorant Garamond (display) + DM Sans (text).
   ========================================================================== */

/* ----- Tokens ---------------------------------------------------------- */

:root {
    /* Colour — light "Stone" */
    --surface: #ECE9E3;
    --surface-raised: #F7F5F1;
    --line: #D5D1C9;
    --ink: #1E1E1C;
    --ink-muted: #5C5A55;
    --terracotta: #A0442A;
    --on-terracotta: #FFFFFF;
    --terracotta-soft: #F2E2DA;
    --deep: #1E1E1C;
    --on-deep: #ECE9E3;
    --on-deep-accent: #E09A7E;

    /* Type */
    --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
    --font-text: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    /* Spacing scale (px) */
    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s6: 24px;
    --s8: 32px;
    --s12: 48px;
    --s18: 72px;

    /* Layout */
    --container: 1120px;
    --reading: 680px;

    /* Radius */
    --r-input: 4px;
    --r-card: 6px;
    --r-full: 999px;
}

/* Dark "Charcoal" — opt-in via the sun/moon switch */
:root[data-theme="dark"] {
    /* Colour — dark "Charcoal" */
    --surface: #1E1E1C;
    --surface-raised: #282826;
    --line: #3A3936;
    --ink: #ECE9E3;
    --ink-muted: #A9A59D;
    --terracotta: #E09A7E;
    --on-terracotta: #1E1E1C;
    --terracotta-soft: #3B241B;
    --deep: #33322F;
    --on-deep: #ECE9E3;
    --on-deep-accent: #E09A7E;
}

/* ----- Base ------------------------------------------------------------ */

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

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

body {
    margin: 0;
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-text);
    font-weight: 400;
    font-size: 17px;
    line-height: 28px;
    -webkit-font-smoothing: antialiased;
}

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

a {
    color: var(--terracotta);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.15;
    margin: 0;
    letter-spacing: 0;
    text-transform: none;
}

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 var(--s6);
}

.reading-column {
    max-width: var(--reading);
    margin: 0 auto;
}

/* Labels: 12/16 DM Sans 500, uppercase, 0.16em, ink_muted */
.label {
    font-family: var(--font-text);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin: 0 0 var(--s3);
}

/* Buttons: DM Sans 600, full radius, terracotta */
.button {
    display: inline-block;
    font-family: var(--font-text);
    font-size: 15px;
    font-weight: 600;
    line-height: 24px;
    color: var(--on-terracotta);
    background: var(--terracotta);
    border: 0;
    border-radius: var(--r-full);
    padding: 10px var(--s6);
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.button:hover {
    opacity: 0.88;
    text-decoration: none;
}

.button-small {
    font-size: 14px;
    padding: 8px var(--s4);
}

/* ----- Wordmark --------------------------------------------------------- */

.site-wordmark {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 28px;
    line-height: 1.1;
    color: var(--ink);
    letter-spacing: 0;
}

.site-wordmark em {
    font-style: italic;
    font-weight: 500;
    color: var(--terracotta);
}

.site-wordmark-reversed {
    color: var(--on-deep);
}

.site-wordmark-reversed em {
    color: var(--on-deep-accent);
}

/* ----- Header ----------------------------------------------------------- */

.site-header {
    border-bottom: 1px solid var(--line);
}

.site-header-inner {
    display: flex;
    align-items: center;
    gap: var(--s6);
    min-height: 72px;
    flex-wrap: wrap;
    padding-top: var(--s2);
    padding-bottom: var(--s2);
}

.site-logo img {
    height: 32px;
    width: auto;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: var(--s6);
    flex-wrap: wrap;
    margin-right: auto;
}

.nav-link {
    font-family: var(--font-text);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.nav-link:hover {
    color: var(--ink);
    text-decoration: none;
}

.nav-link-current,
.nav-link-current:hover {
    color: var(--terracotta);
    text-decoration: none;
}

/* ----- Theme switch (sun and moon side by side) ---------------------------- */

.theme-switch {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--r-full);
    overflow: hidden;
}

.theme-switch-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 36px;
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--ink-muted);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.theme-switch-option:hover {
    color: var(--ink);
}

.theme-switch-option svg {
    width: 18px;
    height: 18px;
}

.theme-switch-option[aria-pressed="true"] {
    color: var(--ink);
    background: var(--surface-raised);
}

/* ----- Hero -------------------------------------------------------------- */

.hero {
    padding: var(--s18) 0 var(--s6);
}

.hero-inner {
    text-align: center;
    max-width: 720px;
    margin: 0 auto;
}

/* Subscribe, placed under the hero text at the right */
.hero-cta {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--s6);
}

.hero-wordmark {
    font-size: 56px;
    line-height: 60px;
    margin: 0;
}

.hero-tagline {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: 20px;
    line-height: 32px;
    color: var(--ink-muted);
    margin: var(--s3) 0 0;
}

.hero-description {
    font-size: 17px;
    line-height: 28px;
    color: var(--ink-muted);
    max-width: 46ch;
    margin: var(--s4) auto var(--s6);
}

/* ----- Subscribe form ----------------------------------------------------- */

.subscribe-form {
    margin: 0;
    text-align: left;
}

.subscribe-fields {
    display: flex;
    gap: var(--s2);
    flex-wrap: wrap;
    align-items: stretch;
}

.subscribe-input {
    flex: 1 1 200px;
    font-family: var(--font-text);
    font-size: 15px;
    line-height: 24px;
    color: var(--ink);
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--r-input);
    padding: 10px var(--s4);
    min-width: 0;
}

.subscribe-input::placeholder {
    color: var(--ink-muted);
}

.subscribe-input:focus {
    outline: 2px solid var(--terracotta);
    outline-offset: 1px;
    border-color: var(--terracotta);
}

.subscribe-message {
    font-size: 13px;
    line-height: 20px;
    color: var(--ink-muted);
    margin: var(--s2) 0 0;
}

/* ----- Latest (quiet italic list) --------------------------------------------- */

.latest {
    padding: var(--s18) 0;
}

.latest-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.latest-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s4);
    padding: var(--s4) 0;
    border-top: 1px solid var(--line);
}

.latest-item:last-child {
    border-bottom: 1px solid var(--line);
}

.latest-title {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: 26px;
    line-height: 32px;
    color: var(--ink);
}

.latest-title:hover {
    color: var(--terracotta);
    text-decoration: none;
}

.latest-meta {
    font-size: 13px;
    line-height: 20px;
    color: var(--ink-muted);
    white-space: nowrap;
}

.latest-empty {
    color: var(--ink-muted);
    font-style: italic;
    padding: var(--s6) 0;
    margin: 0;
}

/* ----- Pillar sections and post grid ---------------------------------------- */

.pillar {
    padding: var(--s12) 0;
    border-top: 1px solid var(--line);
}

.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--s6);
}

/* ----- Posts gallery: colour panels as tags ------------------------------------ */

.post-card {
    background: var(--surface-raised);
    border-radius: var(--r-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.post-card-visual {
    min-height: 140px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-card-visual .post-card-image {
    display: block;
    width: 100%;
    min-height: 140px;
}

.post-card-visual .post-card-image img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.post-card-visual-fallback {
    display: block;
    width: 100%;
    min-height: 140px;
}

.post-card-visual--essay {
    background: var(--deep);
}

.post-card-visual--tools {
    background: var(--surface-raised);
    border-bottom: 1px solid var(--line);
}

.post-card-visual--analog,
.post-card-visual--notebooks {
    background: var(--terracotta);
}

.post-card-body {
    padding: var(--s6);
    display: flex;
    flex-direction: column;
    gap: var(--s2);
}

.post-card-title {
    font-size: 26px;
    line-height: 30px;
}

.post-card-title a {
    color: var(--ink);
}

.post-card-excerpt {
    font-size: 15px;
    line-height: 24px;
    color: var(--ink-muted);
    margin: 0;
}

.post-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s2);
    font-size: 13px;
    line-height: 20px;
    color: var(--ink-muted);
    margin-top: auto;
}

.post-card-meta-line {
    margin: 0;
}

/* Tag chip in the card's bottom-right corner: pill-shaped button,
   pillar-coloured, terracotta fill on hover so it reads as clickable. */

.post-card-tag {
    flex: none;
    font-family: var(--font-text);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    padding: 4px 12px;
    border-radius: 7px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink-muted);
    white-space: nowrap;
    transition: background-color 160ms ease,
        border-color 160ms ease,
        color 160ms ease;
}

.post-card-tag:hover {
    background: var(--terracotta);
    border-color: var(--terracotta);
    color: var(--on-terracotta);
    text-decoration: none;
}

.post-card-tag--essay {
    background: var(--deep);
    border-color: var(--deep);
    color: var(--on-deep);
}

.post-card-tag--essay:hover {
    background: var(--terracotta);
    border-color: var(--terracotta);
    color: var(--on-terracotta);
}

.post-card-tag--tools {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink-muted);
}

.post-card-tag--tools:hover {
    background: var(--terracotta);
    border-color: var(--terracotta);
    color: var(--on-terracotta);
}

.post-card-tag--analog,
.post-card-tag--notebooks {
    background: var(--terracotta);
    border-color: var(--terracotta);
    color: var(--on-terracotta);
}

.post-card-tag--analog:hover,
.post-card-tag--notebooks:hover {
    background: var(--deep);
    border-color: var(--deep);
    color: var(--on-deep);
}

/* ----- Koenig bookmark cards (required by Ghost) ------------------------------- */

.kg-bookmark-card {
    margin: var(--s6) 0;
}

.kg-bookmark-container {
    display: flex;
    gap: var(--s4);
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    padding: var(--s4);
    color: var(--ink);
    text-decoration: none;
}

.kg-bookmark-container:hover {
    border-color: var(--ink-muted);
    text-decoration: none;
}

.kg-bookmark-content {
    display: flex;
    flex-direction: column;
    gap: var(--s1);
    flex: 1 1 auto;
    min-width: 0;
    order: 1;
}

.kg-bookmark-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 20px;
    line-height: 26px;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
}

.kg-bookmark-description {
    font-size: 14px;
    line-height: 20px;
    color: var(--ink-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kg-bookmark-metadata {
    display: flex;
    align-items: center;
    gap: var(--s2);
    font-size: 12px;
    line-height: 16px;
    color: var(--ink-muted);
    margin-top: auto;
}

.kg-bookmark-icon {
    width: 22px;
    height: 22px;
    border-radius: var(--r-input);
    object-fit: cover;
}

.kg-bookmark-author,
.kg-bookmark-publisher {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kg-bookmark-thumbnail {
    flex: 0 0 140px;
    min-height: 140px;
    order: 2;
}

.kg-bookmark-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--r-input);
}

@media (max-width: 640px) {
    .kg-bookmark-container {
        flex-direction: column-reverse;
    }

    .kg-bookmark-thumbnail {
        flex-basis: auto;
        width: 100%;
        min-height: 120px;
    }
}

/* ----- Koenig wide and full-bleed images --------------------------------------- */

.kg-width-wide {
    width: min(calc(100vw - 2 * var(--s6)), var(--container));
    margin-left: 50%;
    transform: translateX(-50%);
}

.kg-width-full {
    width: calc(100vw - 2 * var(--s6));
    margin-left: 50%;
    transform: translateX(-50%);
}

/* ----- Koenig gallery cards (required by Ghost) -------------------------------- */

.kg-gallery-container {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    margin: var(--s6) 0;
}

.kg-gallery-row {
    display: flex;
    align-items: stretch;
    gap: var(--s2);
}

.kg-gallery-image {
    min-width: 0;
}

.kg-gallery-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--r-input);
    display: block;
}

/* ----- Closing CTA ----------------------------------------------------------- */

.closing-cta {
    border-top: 1px solid var(--line);
    padding: var(--s18) 0;
}

.closing-cta-inner {
    text-align: center;
    max-width: 720px;
}

.closing-cta-line {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: 34px;
    line-height: 38px;
    margin: 0 0 var(--s6);
}

.closing-cta .subscribe-form {
    max-width: 420px;
    margin: 0 auto;
}

/* ----- Post (single) ----------------------------------------------------------- */

.post-header {
    padding: var(--s12) 0 var(--s8);
    text-align: center;
}

.post-title {
    font-size: 34px;
    line-height: 38px;
    margin: var(--s2) 0 var(--s3);
}

/* Static pages get the same large title as tag archives */

.page-title {
    font-size: 56px;
    line-height: 60px;
}

.post-meta {
    font-size: 13px;
    line-height: 20px;
    color: var(--ink-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    flex-wrap: wrap;
    margin: 0;
}

.post-meta-avatar {
    width: 24px;
    height: 24px;
    border-radius: var(--r-full);
    object-fit: cover;
}

.post-image {
    margin: 0 auto var(--s8);
    max-width: var(--container);
}

.post-image img {
    width: 100%;
}

.post-image figcaption {
    font-size: 13px;
    line-height: 20px;
    color: var(--ink-muted);
    text-align: center;
    margin-top: var(--s2);
}

/* Reading column: 680px, max ~68 characters per line */
.post-content {
    font-size: 17px;
    line-height: 28px;
    padding-bottom: var(--s18);
}

.post-content > * + * {
    margin-top: var(--s4);
}

.post-content h2 {
    font-size: 34px;
    line-height: 38px;
    margin-top: var(--s12);
}

.post-content h3 {
    font-size: 26px;
    line-height: 30px;
    margin-top: var(--s8);
}

.post-content h4 {
    font-size: 20px;
    line-height: 26px;
}

.post-content a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.post-content blockquote {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: 26px;
    line-height: 32px;
    margin: var(--s8) 0;
    padding-left: var(--s6);
    border-left: 1px solid var(--line);
    color: var(--ink);
}

.post-content hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: var(--s8) 0;
}

.post-content img {
    width: 100%;
}

.post-content code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.85em;
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--r-input);
    padding: 1px var(--s2);
}

.post-content pre {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    padding: var(--s4);
    overflow-x: auto;
    font-size: 14px;
    line-height: 22px;
}

.post-content figcaption {
    font-size: 13px;
    line-height: 20px;
    color: var(--ink-muted);
    text-align: center;
    margin-top: var(--s2);
}

.post-cta {
    border-top: 1px solid var(--line);
    padding: var(--s12) 0 var(--s18);
    text-align: center;
}

.post-cta-line {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: 26px;
    line-height: 32px;
    margin: 0 0 var(--s2);
}

.post-cta-note {
    font-size: 15px;
    line-height: 24px;
    color: var(--ink-muted);
    margin: 0 0 var(--s4);
}

.post-cta .subscribe-form,
.post-cta .subscribe-fields {
    justify-content: center;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

/* ----- Tag archives and error ------------------------------------------------- */

.tag-header {
    padding: var(--s12) 0 var(--s8);
    text-align: center;
}

.tag-title {
    font-size: 56px;
    line-height: 60px;
    margin: var(--s2) 0;
}

.tag-description {
    color: var(--ink-muted);
    max-width: 46ch;
    margin: 0 auto;
}

.tag-archive {
    padding-bottom: var(--s18);
}

.tag-archive .post-grid {
    max-width: var(--container);
}

.tag-header .button {
    margin-top: var(--s4);
}

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

.pagination,
.gh-pagination {
    display: flex;
    justify-content: center;
    gap: var(--s3);
    margin-top: var(--s12);
    font-family: var(--font-text);
    font-size: 13px;
    line-height: 20px;
}

.pagination a,
.gh-pagination a {
    color: var(--ink-muted);
}

.pagination a:hover,
.gh-pagination a:hover {
    color: var(--terracotta);
    text-decoration: none;
}

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

.site-footer {
    background: var(--deep);
    color: var(--on-deep);
    margin-top: var(--s12);
}

.site-footer-inner {
    padding: var(--s12) var(--s6) var(--s8);
}

.site-footer .label {
    color: var(--on-deep-accent);
}

.site-footer-tagline {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: 20px;
    line-height: 32px;
    color: var(--ink-muted);
    margin: var(--s2) 0 var(--s8);
}

.site-footer-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--s8);
    border-top: 1px solid var(--line);
    padding-top: var(--s8);
}

.site-footer-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s2);
}

.site-footer-nav,
.site-footer .site-footer-column nav {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
}

/* The {{navigation}} helper emits .nav-link anchors; give them the
   quieter footer look inside the footer. */

.site-footer-nav .nav-link {
    font-size: 15px;
    font-weight: 400;
    line-height: 24px;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ink-muted);
}

.site-footer-nav .nav-link:hover {
    color: var(--on-deep);
    text-decoration: none;
}

.footer-link {
    font-size: 15px;
    line-height: 24px;
    color: var(--ink-muted);
}

.footer-link:hover {
    color: var(--on-deep);
    text-decoration: none;
}

.site-footer-note {
    font-size: 13px;
    line-height: 20px;
    color: var(--ink-muted);
    margin: 0;
}

.site-footer .subscribe-input {
    background: var(--surface);
}

.site-footer-bottom {
    border-top: 1px solid var(--line);
    margin-top: var(--s8);
    padding-top: var(--s4);
}

/* ----- Responsive ------------------------------------------------------------------ */

@media (max-width: 640px) {
    body {
        font-size: 15px;
        line-height: 24px;
    }

    .hero-wordmark,
    .tag-title,
    .page-title {
        font-size: 44px;
        line-height: 48px;
    }

    .hero {
        padding: var(--s12) 0;
    }

    .site-header-inner {
        gap: var(--s4);
    }

    .latest-item {
        flex-direction: column;
        gap: var(--s1);
    }

    .latest-meta {
        white-space: normal;
    }

    .subscribe-fields .button {
        flex: 1 1 100%;
    }

    .subscribe-fields .button {
        width: 100%;
    }
}
