/* ==========================================================================
   Wikipietia — a minimal, text-first Ghost theme.
   Palette and metrics follow darioamodei.com; dark mode is the default.
   ========================================================================== */

/* --------------------------------------------------------------- typeface */
/* Newsreader, variable (opsz 6–72, wght 200–800), OFL. Self-hosted: no
   third-party font requests. See assets/fonts/OFL.txt. */

@font-face {
    font-family: 'Newsreader';
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url('../fonts/newsreader-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
        U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
        U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Newsreader';
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url('../fonts/newsreader-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
        U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
        U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Newsreader';
    font-style: italic;
    font-weight: 200 800;
    font-display: swap;
    src: url('../fonts/newsreader-italic-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
        U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
        U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Newsreader';
    font-style: italic;
    font-weight: 200 800;
    font-display: swap;
    src: url('../fonts/newsreader-italic-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
        U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
        U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ----------------------------------------------------------------- tokens */

:root {
    /* Dark is the default: applies before any JS runs and to no-JS visitors. */
    --bg: #161514;
    --text: #e8e6dc;
    --muted: #8c8a82;
    /* Links are body-coloured and underlined, as on darioamodei.com — no blue anywhere. */
    --link: var(--text);
    --link-hover: var(--muted);
    --rule: #33322f;
    --surface: #1f1e1d;

    /* Newsreader is the design. The --gh-font-* vars are only set when a font is
       chosen in Ghost Admin → Design → Brand, which then wins — so fonts stay
       changeable without editing CSS. */
    --font-body: var(--gh-font-body, 'Newsreader');
    --font-heading: var(--gh-font-heading, 'Newsreader');
    --serif-stack: Iowan Old Style, Charter, Georgia, 'Times New Roman', serif;
    --font: var(--font-body), var(--serif-stack);
    --font-title: var(--font-heading), var(--serif-stack);
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

    --measure: 38.75rem;   /* 620px — the column everything sits in */
    --gutter: 1.5rem;
    --step: 1.6rem;        /* vertical rhythm unit */
}

:root[data-theme='light'] {
    --bg: #f0eee6;
    --text: #1f1e1d;
    --muted: #5e5d59;
    --link: var(--text);
    --link-hover: var(--muted);
    --rule: #d1cfc5;
    --surface: #e8e6dc;
}

/* ------------------------------------------------------------------- base */

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 1.25rem;
    font-weight: 400;
    line-height: 1.6;
    font-optical-sizing: auto;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* Plain hyperlinks: body colour, underlined, dimming on hover. Visited links are not
   distinguished — the colour is carrying no meaning here. */
a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 0.15em;
}

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

:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

img,
video,
iframe {
    max-width: 100%;
    height: auto;
}

hr {
    height: 0;
    margin: calc(var(--step) * 2) 0;
    border: 0;
    border-top: 1px solid var(--rule);
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
}

.skip-link:focus {
    left: var(--gutter);
    top: var(--gutter);
    z-index: 10;
    padding: 0.4em 0.8em;
    background: var(--bg);
    border: 1px solid var(--rule);
}

/* ----------------------------------------------------------------- layout */

.site-header,
.site-main,
.site-footer {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.site-main {
    padding-top: calc(var(--step) * 1.5);
    padding-bottom: calc(var(--step) * 3);
}

/* ----------------------------------------------------------------- header */

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    padding-top: calc(var(--step) * 1.75);
    padding-bottom: var(--step);
}

.site-title {
    font-family: var(--font-title);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    letter-spacing: 0.01em;
}

.site-title:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.1rem;
}

.nav {
    display: flex;
    gap: 1.1rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 1rem;
}

.nav a {
    color: var(--muted);
    text-decoration: none;
}

.nav a:hover,
.nav-current a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-thickness: 1px;
}

/* Padding cancelled by an equal negative margin: the tap target grows to ~52x44
   without the switch moving or the header spacing changing. */
.theme-toggle {
    display: block;
    padding: 0.75rem 0.5rem;
    margin: -0.75rem -0.5rem;
    border: 0;
    background: none;
    line-height: 0;
    cursor: pointer;
}

.theme-toggle-track {
    position: relative;
    display: block;
    width: 2.25rem;
    height: 1.25rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    transition: border-color 0.15s ease;
}

.theme-toggle:hover .theme-toggle-track {
    border-color: var(--muted);
}

.theme-toggle-knob {
    position: absolute;
    top: 50%;
    left: 0.1875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 50%;
    background: var(--muted);
    color: var(--bg);
    font-size: 0.55rem;
    line-height: 1;
    transform: translateY(-50%);
    transition: transform 0.18s ease, background-color 0.15s ease;
}

.theme-toggle:hover .theme-toggle-knob {
    background: var(--text);
}

:root[data-theme='light'] .theme-toggle-knob {
    transform: translate(1rem, -50%);
}

/* The knob carries the glyph for the mode you're currently in. */
.theme-toggle-light,
:root[data-theme='light'] .theme-toggle-dark {
    display: none;
}

:root[data-theme='light'] .theme-toggle-light {
    display: block;
}

/* ------------------------------------------------------------------ intro */

.intro {
    margin-bottom: calc(var(--step) * 2);
}

/* Content comes from a Ghost page, so it can be several paragraphs, a list, anything. */
.intro > * {
    margin: 0 0 var(--step);
}

.intro > *:last-child {
    margin-bottom: 0;
}

/* ---------------------------------------------------------------- archive */

.page-heading {
    margin: 0 0 var(--step);
    font-family: var(--font-title);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.2;
}

.list-header {
    margin-bottom: calc(var(--step) * 1.5);
}

.list-description {
    margin: -0.6rem 0 0;
    color: var(--muted);
    font-size: 1.05rem;
}

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

.archive-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.35em 0;
}

.archive-link {
    font-size: 1.15rem;
}

.archive-date {
    flex: none;
    color: var(--muted);
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Year headings are inserted by main.js; without JS the list is simply flat. */
.archive-year {
    padding: 0;
}

.archive-year h2 {
    margin: calc(var(--step) * 1.5) 0 0.4rem;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.archive-year:first-child h2 {
    margin-top: 0;
}

/* ------------------------------------------------------------------- post */

.post-header {
    margin-bottom: calc(var(--step) * 1.5);
}

.post-title {
    margin: 0 0 0.35rem;
    font-family: var(--font-title);
    font-size: 2.2rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.005em;
}

.post-date {
    display: block;
    color: var(--muted);
    font-size: 0.95rem;
}

.post-nav {
    margin-top: calc(var(--step) * 2.5);
    padding-top: var(--step);
    border-top: 1px solid var(--rule);
    font-size: 1rem;
}

/* --------------------------------------------------- post content (Koenig) */
/* These are scoped to .post-content so they outrank Ghost's cards.min.css,
   which ghost_head injects after this stylesheet. */

.post-content > * {
    margin: 0 0 var(--step);
}

.post-content > *:last-child {
    margin-bottom: 0;
}

.post-content h2,
.post-content h3,
.post-content h4 {
    margin: calc(var(--step) * 1.75) 0 0.5em;
    font-family: var(--font-title);
    line-height: 1.25;
    font-weight: 600;
}

.post-content h2 { font-size: 1.6rem; }
.post-content h3 { font-size: 1.25rem; }
.post-content h4 { font-size: 1.1rem; }

.post-content ul,
.post-content ol {
    padding-left: 1.3em;
}

.post-content li {
    margin-bottom: 0.35em;
}

.post-content blockquote {
    margin-left: 0;
    margin-right: 0;
    padding-left: 1.1em;
    border-left: 2px solid var(--rule);
    color: var(--muted);
    font-style: italic;
}

.post-content code {
    padding: 0.1em 0.3em;
    background: var(--surface);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.post-content pre {
    padding: 1em;
    overflow-x: auto;
    background: var(--surface);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.85em;
    line-height: 1.5;
}

.post-content pre code {
    padding: 0;
    background: none;
    font-size: 1em;
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}

.post-content th,
.post-content td {
    padding: 0.4em 0.6em;
    border-bottom: 1px solid var(--rule);
    text-align: left;
}

.post-content figure {
    margin-left: 0;
    margin-right: 0;
}

.post-content figcaption {
    margin-top: 0.5em;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

/* Flatten the cards: no shadows, no rounded chrome, no accent buttons. */
.post-content .kg-card {
    margin-bottom: var(--step);
}

.post-content .kg-width-wide,
.post-content .kg-width-full {
    width: 100%;
    max-width: 100%;
}

.post-content .kg-bookmark-card,
.post-content .kg-bookmark-container {
    display: block;
    padding: 1em;
    background: none;
    border: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: none;
    color: var(--text);
    text-decoration: none;
}

.post-content .kg-bookmark-title {
    color: var(--link);
    font-weight: 600;
}

.post-content .kg-bookmark-description,
.post-content .kg-bookmark-metadata {
    color: var(--muted);
    font-size: 0.95rem;
}

.post-content .kg-bookmark-thumbnail {
    display: none;
}

.post-content .kg-callout-card {
    padding: 1em;
    background: var(--surface);
    border-radius: 0;
}

.post-content .kg-toggle-card {
    padding: 0;
    background: none;
    border-bottom: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: none;
}

.post-content .kg-button-card .kg-btn {
    background: none;
    border: 1px solid var(--rule);
    border-radius: 0;
    color: var(--link);
    font-family: var(--font);
    font-weight: 500;
}

/* Ghost's own footnote markup from Markdown cards. */
.post-content .footnotes {
    padding-top: var(--step);
    border-top: 1px solid var(--rule);
    color: var(--muted);
    font-size: 1rem;
}

/* ------------------------------------------------- members / subscribe form */

.gate {
    margin-top: calc(var(--step) * 2);
    padding-top: var(--step);
    border-top: 1px solid var(--rule);
}

.gate > p:first-child {
    margin-top: 0;
    color: var(--muted);
}

.subscribe-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: 26rem;
    margin: 0 0 0.6rem;
}

.subscribe-input {
    flex: 1 1 16rem;
    min-width: 0;
    padding: 0.45em 0.6em;
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 0;
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.4;
}

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

.subscribe-input:focus {
    border-color: var(--muted);
    outline: none;
}

.subscribe-button {
    padding: 0.45em 1em;
    background: none;
    border: 1px solid var(--rule);
    border-radius: 0;
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.4;
    cursor: pointer;
}

.subscribe-button:hover {
    border-color: var(--muted);
}

.subscribe-note,
.subscribe-signed-in {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.subscribe-note + .subscribe-note {
    margin-top: 0.15rem;
}

/* Ghost's members script toggles .loading / .success / .error on the form. */
.subscribe-message {
    display: none;
    margin: 0.4rem 0 0;
    font-size: 0.95rem;
}

.subscribe-form.success ~ .subscribe-success,
.subscribe-form.error ~ .subscribe-error {
    display: block;
}

.subscribe-form.success ~ .subscribe-note {
    display: none;
}

.subscribe-form.loading .subscribe-button {
    opacity: 0.5;
    pointer-events: none;
}

.subscribe-error {
    color: var(--text);
}

/* --------------------------------------------------------------- comments */

.comments {
    margin-top: calc(var(--step) * 2.5);
    padding-top: var(--step);
    border-top: 1px solid var(--rule);
}

/* ----------------------------------------------------------------- footer */

.site-footer {
    padding-bottom: calc(var(--step) * 2.5);
}

/* Drawn inside the padding so the rule lines up with the text column rather than
   running the full width of the padding box. */
.site-footer::before {
    content: '';
    display: block;
    height: 1px;
    margin-bottom: var(--step);
    background: var(--rule);
}

.colophon {
    margin: var(--step) 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.colophon a {
    color: var(--muted);
}

/* -------------------------------------------------------------- pagination */

.pagination {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-top: calc(var(--step) * 2);
    font-size: 1rem;
}

.page-number {
    color: var(--muted);
}

/* ------------------------------------------------------------------ chrome */

/* Ghost's floating Portal button — pure clutter here. Also switch it off in
   Settings → Portal so it isn't loaded at all. */
.gh-portal-triggerbtn-iframe,
iframe[title='portal-trigger'] {
    display: none !important;
}

/* ------------------------------------------------------------ small screens */

@media (max-width: 34rem) {
    :root {
        --gutter: 1.25rem;
    }

    body {
        font-size: 1.15rem;
    }

    .post-title {
        font-size: 1.8rem;
    }

    .archive-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.1rem;
        padding: 0.5em 0;
    }
}

/* ------------------------------------------------------------ preferences */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    :root {
        --bg: #fff;
        --text: #000;
        --muted: #444;
        --link: #000;
        --rule: #ccc;
    }

    .site-header,
    .site-footer,
    .post-nav,
    .comments,
    .subscribe {
        display: none;
    }

    .site-main {
        max-width: none;
        padding: 0;
    }

    .post-content a::after {
        content: ' (' attr(href) ')';
        font-size: 0.85em;
        word-break: break-all;
    }
}
