/* ============================================================
   JUNQUA — a minimal editorial Ghost theme
   Grayscale + monospace accents + one warm note (#b04a2f)
   Translated from the supplied wireframe design tokens.
   ============================================================ */

:root {
    --ink:    #2a2a2a;   /* primary text */
    --ink2:   #5c5c5c;   /* secondary text (AA-contrast on paper) */
    --line:   #d6d6d6;   /* hairline borders */
    --line2:  #1f1f1f;   /* emphasis borders */
    --bar2:   #ededed;   /* faint fill */
    --paper:  #ffffff;   /* background */
    --accent: #b04a2f;   /* warm accent, used sparingly */
    --accent-soft: #f3e7e2;
    --field-bg: #ffffff; /* form inputs */
    --pre-bg:   #2a2a2a; /* code blocks */
    --pre-fg:   #f5f5f5;
    --on-accent:#ffffff; /* text on the accent color */

    --sans: "Helvetica Neue", Helvetica, system-ui, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

    --wrap: 1080px;
    --narrow: 720px;
    --pad: 24px;
}

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
    --ink:    #ededec;
    --ink2:   #a4a19b;
    --line:   #36332e;
    --line2:  #c9c6c0;
    --bar2:   #2b2825;
    --paper:  #17150f;
    --accent: #cf6a47;
    --accent-soft: #2c211c;
    --field-bg: #201d18;
    --pre-bg:   #0e0d0b;
    --pre-fg:   #ededec;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--gh-font-body, var(--sans));
    font-size: 17px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color 0.2s ease, color 0.2s ease;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
hr { border: 0; }

.skip-link {
    position: absolute; left: -9999px; top: 0;
    background: var(--ink); color: var(--paper); padding: 10px 16px;
    font-family: var(--mono); font-size: 12px; z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--pad); }
.wrap-narrow { width: 100%; max-width: var(--narrow); margin: 0 auto; padding: 0 var(--pad); }

.rule { height: 1px; background: var(--line); margin: 0; }
.rule--dark { height: 2px; background: var(--line2); }

/* ---------- Brand / typographic primitives ---------- */
.brand {
    font-family: var(--mono);
    font-size: 14px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--ink);
}
.brand--sm { font-size: 12px; }
.brand__logo { display: block; height: 30px; width: auto; }
.brand__logo--dark { display: none; }
:root[data-theme="dark"] .brand__logo--light { display: none; }
:root[data-theme="dark"] .brand__logo--dark { display: block; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
    background: none; border: 0; cursor: pointer; color: var(--ink2);
    padding: 4px; line-height: 0; display: inline-flex; align-items: center;
    transition: color 0.15s ease;
}
.theme-toggle:hover { color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.list-label,
.hero__kicker {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink2);
    margin: 0 0 22px;
}

/* ---------- Site header ---------- */
.site-head { padding-top: 26px; }
.site-head__inner {
    display: flex; align-items: center; justify-content: space-between;
    gap: 20px; padding-bottom: 22px;
}
.site-nav { display: flex; gap: 26px; flex-wrap: wrap; }
.nav-item {
    font-size: 14px; color: var(--ink2); position: relative; padding-bottom: 2px;
    transition: color 0.15s ease;
}
.nav-item:hover { color: var(--ink); }
.nav-item.is-active { color: var(--ink); }
.nav-item.is-active::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -2px;
    height: 2px; background: var(--accent);
}

/* ---------- Hero (home) ---------- */
.hero { padding: 44px 0 36px; }
.hero__title {
    font-size: clamp(30px, 5vw, 46px);
    line-height: 1.08;
    letter-spacing: -0.02em;
    font-weight: 700;
    margin: 0 0 20px;
    max-width: 18ch;
}
.hero__sub {
    font-size: 18px; color: var(--ink2); max-width: 56ch; margin: 0;
}

/* ---------- Featured post (home, page 1) ---------- */
.feature { margin: 0; }
.feature__link { display: block; padding: 8px 0 36px; }
.feature__link:hover .feature__title { color: var(--accent); }
.feature__link:hover .card__more { color: var(--accent); gap: 10px; }
.feature__meta {
    font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--ink2);
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px;
}
.feature__flag {
    display: inline-flex; align-items: center; height: 20px; padding: 0 9px;
    background: var(--accent); color: var(--on-accent); border-radius: 2px; letter-spacing: 0.06em;
}
.feature__title {
    font-size: clamp(30px, 4.4vw, 42px); line-height: 1.1; letter-spacing: -0.02em;
    font-weight: 700; margin: 0 0 16px; color: var(--ink); transition: color 0.15s ease;
}
.feature__excerpt {
    font-size: 19px; line-height: 1.55; color: var(--ink2); margin: 0 0 20px; max-width: 60ch;
}

/* ---------- Post list ---------- */
.post-list { padding: 52px 0 24px; counter-reset: postnum; }
.home .post-list { padding-top: 0; }
.feature, .card { counter-increment: postnum; }
.feature__meta::before, .card__meta::before {
    content: counter(postnum, decimal-leading-zero);
    color: var(--accent); font-weight: 700;
}

.card { margin: 0; }
.card__link { display: block; padding: 30px 0; transition: transform 0.18s ease; }
.card:first-of-type .card__link { padding-top: 0; }
.card__link:hover .card__title { color: var(--accent); }
.card__link:hover .card__more { color: var(--accent); gap: 10px; }

.card__meta,
.post__meta {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink2);
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    margin-bottom: 14px;
}
.card__tag, .post__tag {
    display: inline-flex; align-items: center; height: 20px; padding: 0 9px;
    border: 1px solid var(--line); border-radius: 2px;
    color: var(--ink2);
}

.card__title {
    font-size: 26px; line-height: 1.18; letter-spacing: -0.015em;
    font-weight: 700; margin: 0 0 12px; color: var(--ink);
    transition: color 0.15s ease;
}
.card__excerpt { color: var(--ink2); font-size: 16px; margin: 0 0 16px; max-width: 64ch; }
.card__more {
    font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--ink);
    display: inline-flex; align-items: center; gap: 6px;
    transition: gap 0.18s ease, color 0.15s ease;
}

/* ---------- Single post ---------- */
.post { padding-top: 56px; }
.post__head { text-align: left; }
.post__meta { justify-content: flex-start; margin-bottom: 18px; }
.post__title {
    font-size: clamp(30px, 4.6vw, 44px);
    line-height: 1.1; letter-spacing: -0.02em; font-weight: 700;
    margin: 0 0 18px;
}
.post__lede {
    font-size: 20px; line-height: 1.5; color: var(--ink2); margin: 0;
    padding-left: 16px; border-left: 2px solid var(--accent);
}

.post__hero { margin: 44px auto; }
.post__hero img { width: 100%; border-radius: 3px; }
.post__hero figcaption {
    font-family: var(--mono); font-size: 11px; color: var(--ink2);
    text-align: center; margin-top: 10px; letter-spacing: 0.02em;
}

.post__content { margin-top: 44px; }
.post__foot { margin: 56px auto 0; padding-bottom: 8px; }
.post__tags {
    font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--ink2); margin: 22px 0;
}
.post__tags a { color: var(--ink2); }
.post__tags a:hover { color: var(--accent); }
.post__author { padding: 8px 0 0; }
.post__byline {
    font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--ink);
}
.post__bio { color: var(--ink2); font-size: 15px; margin: 8px 0 0; max-width: 60ch; }

/* ---------- Long-form content (Koenig output) ---------- */
.gh-content { font-size: 18px; line-height: 1.72; color: var(--ink); }
.gh-content > * + * { margin-top: 1.5em; }
.gh-content h2 {
    font-size: 27px; line-height: 1.2; letter-spacing: -0.015em; font-weight: 700;
    color: var(--ink); margin-top: 2em; margin-bottom: 0.1em;
}
.gh-content h3 {
    font-size: 20px; line-height: 1.25; font-weight: 700; color: var(--ink);
    margin-top: 1.7em; margin-bottom: 0.1em;
}
.gh-content h4 {
    font-family: var(--mono); font-size: 13px; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--ink2);
    margin-top: 1.7em; margin-bottom: 0;
}
.gh-content a {
    color: var(--ink); text-decoration: underline;
    text-decoration-color: var(--accent); text-underline-offset: 3px;
    text-decoration-thickness: 1.5px; transition: color 0.15s ease;
}
.gh-content a:hover { color: var(--accent); }
.gh-content strong { font-weight: 700; color: var(--ink); }
.gh-content ul, .gh-content ol { padding-left: 1.3em; }
.gh-content li + li { margin-top: 0.4em; }
.gh-content blockquote {
    margin-left: 0; padding-left: 22px; border-left: 2px solid var(--accent);
    font-size: 20px; line-height: 1.5; color: var(--ink); font-style: normal;
}
.gh-content hr { height: 1px; background: var(--line); margin: 2.4em 0; }
.gh-content figure { margin: 2em 0; }
.gh-content img, .gh-content .kg-image { border-radius: 3px; }
.gh-content figcaption {
    font-family: var(--mono); font-size: 11px; color: var(--ink2);
    text-align: center; margin-top: 10px;
}
.gh-content code {
    font-family: var(--mono); font-size: 0.86em; background: var(--bar2);
    padding: 2px 6px; border-radius: 3px;
}
.gh-content pre {
    background: var(--pre-bg); color: var(--pre-fg); padding: 20px 22px;
    border-radius: 4px; overflow-x: auto; font-family: var(--mono);
    font-size: 14px; line-height: 1.6;
}
.gh-content pre code { background: none; padding: 0; font-size: inherit; color: inherit; }

/* Koenig width cards */
.gh-content .kg-width-wide { max-width: 1040px; margin-left: 50%; transform: translateX(-50%); }
.gh-content .kg-width-full { max-width: 100vw; margin-left: 50%; transform: translateX(-50%); }

/* ---------- Heading font (consumes Ghost custom-font setting) ---------- */
.hero__title, .post__title, .card__title, .archive-title,
.gh-content h1, .gh-content h2, .gh-content h3,
.error__title {
    font-family: var(--gh-font-heading, var(--sans));
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 42px; padding: 0 22px; background: var(--ink); color: var(--paper);
    border: 0; border-radius: 3px; font-size: 13px; font-weight: 600;
    letter-spacing: 0.02em; cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--accent); color: var(--on-accent); }
.btn-ghost {
    display: inline-flex; align-items: center; justify-content: center;
    height: 42px; padding: 0 20px; background: var(--paper); color: var(--ink);
    border: 1.5px solid var(--line2); border-radius: 3px;
    font-size: 13px; font-weight: 600; transition: border-color 0.15s ease, color 0.15s ease;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Archives ---------- */
.archive-head { padding: 64px 0 8px; }
.archive-title { font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.02em; margin: 0 0 14px; }
.archive-desc { color: var(--ink2); max-width: 60ch; margin: 0 0 14px; font-size: 17px; }
.archive-count { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink2); margin: 0; }

/* ---------- Pagination ---------- */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 36px 0 80px; font-family: var(--mono);
    font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
}
.pagination a { color: var(--ink); padding: 8px 0; }
.pagination a:hover { color: var(--accent); }
.pagination .page-number { color: var(--ink2); }

/* ---------- Error ---------- */
.error { text-align: center; padding: 100px 0 120px; }
.error__code { font-family: var(--mono); font-size: 13px; letter-spacing: 0.1em; color: var(--accent); margin: 0 0 12px; }
.error__title { font-size: clamp(26px, 4vw, 38px); letter-spacing: -0.02em; margin: 0 0 14px; }
.error__msg { color: var(--ink2); margin: 0 0 28px; }

/* ---------- Footer ---------- */
.site-foot { margin-top: 80px; }
.site-foot__inner {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; padding: 28px var(--pad) 56px;
    max-width: var(--wrap); margin: 0 auto; width: 100%;
}
.foot-nav { display: flex; gap: 22px; flex-wrap: wrap; }
.foot-nav .nav-item { font-size: 13px; }
.foot-copy { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--ink2); }

/* ---------- Comments ---------- */
.post-comments { margin: 56px auto 0; }

/* ---------- Subscribe ---------- */
.subscribe { border-top: 2px solid var(--line2); margin-top: 80px; }
.subscribe__inner { padding: 56px var(--pad) 64px; }
.subscribe__label {
    font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em;
    text-transform: uppercase; color: var(--accent); margin: 0 0 12px;
}
.subscribe__title {
    font-size: clamp(22px, 3vw, 30px); line-height: 1.2; letter-spacing: -0.015em;
    font-weight: 700; margin: 0 0 24px; max-width: 24ch;
}
.subscribe__form { max-width: 440px; }
.subscribe__field {
    display: flex; align-items: stretch;
    border: 1.5px solid var(--line2); border-radius: 3px; overflow: hidden;
}
.subscribe__field:focus-within { border-color: var(--accent); }
.subscribe__input {
    flex: 1 1 auto; min-width: 0; height: 46px; padding: 0 16px;
    border: 0; background: var(--field-bg);
    font-family: var(--mono); font-size: 14px; color: var(--ink);
}
.subscribe__input:focus { outline: none; }
.subscribe__input::placeholder { color: #a3a3a3; }
.subscribe__submit {
    flex: 0 0 auto; width: 46px; height: 46px; border: 0;
    background: transparent; color: var(--ink); cursor: pointer;
    font-size: 18px; line-height: 1; transition: color 0.15s ease;
    border-left: 1.5px solid var(--line);
}
.subscribe__submit:hover { color: var(--accent); }
.subscribe__success,
.subscribe__error { margin: 10px 0 0; font-size: 14px; }
.subscribe__success { display: none; color: var(--ink); }
.subscribe__error { color: var(--accent); }
.subscribe__form.success .subscribe__field { display: none; }
.subscribe__form.success .subscribe__success { display: block; }
.subscribe__form.loading .subscribe__submit { opacity: 0.5; pointer-events: none; }

/* ---------- Reading progress bar ---------- */
.reading-progress {
    position: fixed; top: 0; left: 0; right: 0; height: 3px;
    background: transparent; z-index: 200; pointer-events: none;
}
.reading-progress__bar {
    display: block; height: 100%; width: 0; background: var(--accent);
    transition: width 0.08s linear;
}

/* ---------- Footnotes / margin sidenotes ---------- */
.gh-content .footnote-ref a {
    color: var(--accent); text-decoration: none; font-weight: 700;
}
.gh-content .footnotes-sep { display: none; }
.gh-content .footnotes.is-hoisted { display: none; }

.sidenote {
    display: none;                /* mobile default: collapsed until tapped */
    font-size: 14px; line-height: 1.55; color: var(--ink2);
    border-left: 2px solid var(--accent); padding-left: 12px;
    margin: 12px 0;
}
.sidenote.is-open { display: block; }
.sidenote__num { color: var(--accent); font-weight: 700; margin-right: 6px; }
.sidenote p { margin: 0; }
.sidenote p + p { margin-top: 0.5em; }

@media (min-width: 1240px) {
    .sidenote {
        display: block;           /* always visible in the margin on wide screens */
        float: right; clear: right;
        width: 210px; margin: 4px -242px 4px 0;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    body { font-size: 16px; }
    .site-head { padding-top: 20px; }
    .site-head__inner { flex-direction: column; align-items: flex-start; gap: 14px; }
    .site-nav { gap: 18px; }
    .hero { padding: 32px 0 28px; }
    .hero__sub { font-size: 16px; }
    .post-list { padding: 36px 0 16px; }
    .feature__title { font-size: clamp(26px, 7vw, 34px); }
    .feature__excerpt { font-size: 17px; }
    .card__title { font-size: 22px; }
    .post { padding-top: 36px; }
    .gh-content { font-size: 17px; }
    .gh-content .kg-width-wide, .gh-content .kg-width-full {
        max-width: 100%; margin-left: 0; transform: none;
    }
    .subscribe { margin-top: 56px; }
    .subscribe__inner { padding: 40px var(--pad) 48px; }
    .subscribe__form { max-width: 100%; }
    .site-foot__inner { flex-direction: column; align-items: flex-start; }
}
