/* ==========================================================================
   CTO Swarm — Ghost theme
   Tokens lifted verbatim from ctoswarm.com so the members area and the
   public site read as one product.
   ========================================================================== */

@font-face { font-family: Geist; src: url("../fonts/Geist-Regular.woff2") format("woff2");  font-weight: 400; font-display: swap; }
@font-face { font-family: Geist; src: url("../fonts/Geist-Medium.woff2") format("woff2");   font-weight: 500; font-display: swap; }
@font-face { font-family: Geist; src: url("../fonts/Geist-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: Geist; src: url("../fonts/Geist-Bold.woff2") format("woff2");     font-weight: 700; font-display: swap; }
@font-face { font-family: Geist; src: url("../fonts/Geist-Black.woff2") format("woff2");    font-weight: 800; font-display: swap; }

:root {
    --bg:         #1c2231;
    --bg-dark:    #151c27;
    --bg-card:    #222a3e;
    --bg-card2:   #28324a;
    --accent:     #FFD700;
    --accent-dk:  #e6c200;
    --text:       #f0f0f5;
    --text-muted: #8b8d9e;
    --border:     #2e3a52;
    --radius:     12px;

    --font: Geist, -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --wrap: 1180px;
    --narrow: 720px;

    /* faint honeycomb watermark, matches the hero on the main site */
    --hex: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="56" height="64" viewBox="0 0 56 64"><path d="M28 1 52 15v30L28 59 4 45V15Z" fill="none" stroke="%23ffffff" stroke-opacity="0.05" stroke-width="1.5"/></svg>');
}

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    /* --gh-font-* let the Ghost admin font pickers override Geist */
    font-family: var(--gh-font-body, var(--font));
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.hero-title, .post-title, .card-title, .cover-title, .archive-title, .section-title {
    font-family: var(--gh-font-heading, var(--font));
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
.gold { color: var(--accent); }
.muted { color: var(--text-muted); }

.wrap        { width: 100%; max-width: var(--wrap);   margin-inline: auto; padding-inline: 24px; }
.wrap-narrow { width: 100%; max-width: var(--narrow); margin-inline: auto; padding-inline: 24px; }

.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 100;
    background: var(--accent); color: #151c27; padding: 10px 16px; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

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

/* --------------------------------------------------------------- buttons */

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 600; font-size: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform .12s ease, background-color .12s ease, border-color .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-gold  { background: var(--accent); color: #151c27; }
.btn-gold:hover  { background: var(--accent-dk); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); }

.link-quiet { color: var(--text-muted); font-size: 14px; font-weight: 500; }
.link-quiet:hover { color: var(--text); }

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

.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(21, 28, 39, .85);
    backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 64px; }

.brand { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.brand-mark { width: 28px; height: 28px; }
.brand-name { font-weight: 800; letter-spacing: -.02em; font-size: 17px; }

.site-nav { margin-inline-start: auto; }
.site-nav ul { display: flex; gap: 22px; list-style: none; margin: 0; padding: 0; }
.site-nav a { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.site-nav a:hover, .site-nav .nav-current a { color: var(--text); }

.header-actions { display: flex; align-items: center; gap: 14px; flex: none; }

.nav-toggle { display: none; background: none; border: 0; padding: 8px; cursor: pointer; }
.nav-toggle span { display: block; width: 20px; height: 2px; background: var(--text); margin: 4px 0; }

/* ------------------------------------------------------------ library hero */

.library-hero { padding: 40px 0 8px; }

.hero-panel {
    position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
    padding: 48px 44px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background:
        var(--hex),
        radial-gradient(120% 140% at 88% 40%, rgba(255,215,0,.10) 0%, rgba(255,215,0,0) 55%),
        linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-card) 100%);
}
.hero-eyebrow {
    margin: 0 0 10px;
    font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
    color: var(--text-muted);
}
.hero-title {
    margin: 0;
    font-size: clamp(30px, 5vw, 46px);
    font-weight: 800; line-height: 1.08; letter-spacing: -.03em;
}
.hero-mark { width: 72px; height: 72px; opacity: .95; flex: none; }

/* --------------------------------------------------------------- filters */

.library { padding: 28px 0 72px; }

.filters {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin: 0 0 26px;
}
.chip {
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-family: inherit; font-size: 13.5px; font-weight: 500;
    cursor: pointer;
    transition: color .12s ease, border-color .12s ease, background-color .12s ease;
}
.chip:hover { color: var(--text); border-color: #3b4a68; }
.chip.is-active {
    background: var(--accent); border-color: var(--accent);
    color: #151c27; font-weight: 600;
}
.chip-static { cursor: default; }
a.chip-static:hover { color: var(--text); }

/* ------------------------------------------------------------------ grid */

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

.card {
    display: flex; flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-3px); border-color: #3b4a68; }
.card[hidden] { display: none; }

/* --- cover ------------------------------------------------------------- */

/* 2:1 matches the 600x300 covers exported from Circle, so imported artwork
   is never cropped. Generated covers use the same ratio for consistency. */
.card-cover {
    position: relative;
    display: block;
    aspect-ratio: 2 / 1;
    background-color: var(--bg-dark);
    background-image: var(--cover);
    background-size: cover;
    background-position: center;
}

/* generated cover, used when a post has no feature image */
.card-cover-generated {
    display: grid; place-items: center;
    padding: 30px 26px;
    background-image:
        var(--hex),
        radial-gradient(120% 120% at 78% 20%, rgba(255,215,0,.12) 0%, rgba(255,215,0,0) 60%),
        linear-gradient(150deg, #10151f 0%, var(--bg-card2) 100%);
}
.cover-title {
    font-size: clamp(19px, 2.2vw, 25px);
    font-weight: 800; line-height: 1.18; letter-spacing: -.02em;
    text-align: center; text-wrap: balance;
    color: var(--accent);
}
.cover-mark { position: absolute; right: 16px; bottom: 14px; width: 30px; height: 30px; opacity: .9; }

/* corner ribbon showing the primary tag */
.card-ribbon {
    position: absolute; top: 0; left: 0; z-index: 2;
    max-width: 72%;
    padding: 6px 16px 6px 14px;
    background: rgba(21, 28, 39, .92);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) 0 var(--radius) 0;
    font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--accent);
}

.lock-badge {
    position: absolute; top: 12px; right: 12px; z-index: 2;
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    background: rgba(21, 28, 39, .92);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 11px; font-weight: 600;
}
.card-locked .cover-title { opacity: .55; }

/* --- body -------------------------------------------------------------- */

.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.32; letter-spacing: -.015em; }
.card-title a:hover { color: var(--accent); }
.card-excerpt { margin: 0; font-size: 14px; color: var(--text-muted); line-height: 1.55;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { margin: auto 0 0; display: flex; flex-wrap: wrap; gap: 7px; font-size: 12.5px; color: var(--text-muted); }

.empty-state { text-align: center; color: var(--text-muted); padding: 56px 0; }

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

.archive-head { padding: 52px 0 8px; }
.archive-title { margin: 0 0 8px; font-size: clamp(30px, 4.5vw, 42px); font-weight: 800; letter-spacing: -.03em; }
.archive-desc { margin: 0 0 6px; max-width: 60ch; }

.section-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 20px; }
.related { padding: 12px 0 72px; border-top: 1px solid var(--border); margin-top: 56px; padding-top: 44px; }

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

.post-header { padding: 56px 0 22px; text-align: center; }
.post-tags { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.post-title {
    margin: 0 0 14px;
    font-size: clamp(30px, 5vw, 46px);
    font-weight: 800; line-height: 1.1; letter-spacing: -.03em; text-wrap: balance;
}
.post-standfirst { margin: 0 auto 18px; max-width: 56ch; font-size: 18px; color: var(--text-muted); line-height: 1.55; }
.post-meta { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 9px; font-size: 13.5px; color: var(--text-muted); }
.avatar { border-radius: 50%; }

.post-figure { margin: 26px auto 8px; }
.post-figure img { border-radius: var(--radius); border: 1px solid var(--border); width: 100%; }
.post-figure figcaption { margin-top: 10px; text-align: center; font-size: 13px; color: var(--text-muted); }

.post-content { padding: 34px 24px 64px; font-size: 17.5px; line-height: 1.75; }
.post-content > * { margin: 0 0 1.35em; }
.post-content h2 { font-size: 27px; font-weight: 800; letter-spacing: -.02em; margin: 2em 0 .55em; }
.post-content h3 { font-size: 21px; font-weight: 700; letter-spacing: -.015em; margin: 1.7em 0 .5em; }
.post-content a  { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.post-content ul, .post-content ol { padding-left: 1.3em; }
.post-content li { margin-bottom: .5em; }
.post-content img, .post-content figure img { border-radius: var(--radius); }
.post-content blockquote {
    margin-inline: 0; padding: 4px 0 4px 22px;
    border-left: 3px solid var(--accent);
    color: var(--text-muted); font-style: italic;
}
.post-content pre {
    background: var(--bg-dark); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; overflow-x: auto; font-size: 14.5px; line-height: 1.6;
}
.post-content code { background: var(--bg-dark); border-radius: 5px; padding: .15em .4em; font-size: .9em; }
.post-content pre code { background: none; padding: 0; }
.post-content hr { border: 0; border-top: 1px solid var(--border); margin: 2.4em 0; }
.post-content table { width: 100%; border-collapse: collapse; font-size: 15px; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 10px 12px; text-align: left; }
.post-content th { background: var(--bg-card); font-weight: 600; }

/* ------------------------------------------------- koenig editor cards */

.post-content :is(.kg-card, figure) { margin-block: 1.8em; }

.kg-width-wide {
    position: relative;
    width: calc(100vw - 48px);
    max-width: var(--wrap);
    margin-inline: auto;
    left: 50%;
    transform: translateX(-50%);
}
.kg-width-full {
    position: relative;
    width: 100vw;
    max-width: 100vw;
    margin-inline: 0;
    left: 50%;
    transform: translateX(-50%);
}
.kg-width-full img { border-radius: 0; width: 100%; }
.kg-width-wide img { width: 100%; }

.kg-image-card figcaption,
.kg-embed-card figcaption,
.kg-gallery-card figcaption {
    margin-top: 10px; text-align: center; font-size: 13px; color: var(--text-muted);
}

.kg-gallery-container { display: flex; flex-direction: column; gap: 10px; }
.kg-gallery-row { display: flex; gap: 10px; }
.kg-gallery-image img { width: 100%; height: 100%; object-fit: cover; }

/* Responsive 16:9 video embeds (Circle exported these as raw iframes) */
.kg-embed-card { margin-inline: 0; }
.kg-embed-card iframe {
    display: block; width: 100%; aspect-ratio: 16 / 9; height: auto;
    border: 1px solid var(--border); border-radius: var(--radius);
}

/* `card_assets.exclude: ["bookmark"]` in package.json stops Ghost's own
   light-themed bookmark CSS from loading and overriding these. */
.kg-bookmark-card a.kg-bookmark-container {
    display: flex; text-decoration: none; color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-card); overflow: hidden;
}
.kg-bookmark-card a.kg-bookmark-container:hover { border-color: var(--accent); }
.kg-bookmark-content { flex: 1; padding: 18px 20px; }
.kg-bookmark-title { font-weight: 700; }
.kg-bookmark-description { color: var(--text-muted); font-size: 14.5px; margin-top: 6px; }
.kg-bookmark-metadata { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--text-muted); }
.kg-bookmark-icon { width: 18px; height: 18px; }
/* Required once card_assets excludes "bookmark" — Ghost no longer ships these. */
.kg-bookmark-publisher {
    color: var(--text-muted); font-size: 13px; line-height: 1.4;
    max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kg-bookmark-author {
    color: var(--text-muted); font-size: 13px; line-height: 1.4;
}
.kg-bookmark-author::after { content: "•"; margin: 0 6px; opacity: .6; }
.kg-bookmark-thumbnail { flex: 0 0 33%; }
.kg-bookmark-thumbnail img { width: 100%; height: 100%; object-fit: cover; }

.kg-callout-card { display: flex; gap: 12px; padding: 18px 20px; border-radius: var(--radius); background: var(--bg-card); border: 1px solid var(--border); }
.kg-toggle-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; }
.kg-button-card a.kg-btn {
    display: inline-flex; padding: 11px 22px; border-radius: 999px;
    background: var(--accent); color: #151c27; font-weight: 600; text-decoration: none;
}

@media (max-width: 780px) {
    .kg-width-wide, .kg-width-full { width: 100%; left: 0; transform: none; }
    .kg-gallery-row { flex-direction: column; }
    .kg-bookmark-card a.kg-bookmark-container { flex-direction: column-reverse; }
    .kg-bookmark-thumbnail { flex: none; max-height: 180px; }
}

/* --------------------------------------------------------------- paywall */

/* Ghost injects its own upgrade CTA inside {{content}} when access is denied.
   We render a branded one in post.hbs instead, so suppress the default. */
.gh-post-upgrade-cta { display: none !important; }

.paywall {
    text-align: center;
    margin: 8px auto 72px;
    padding: 44px 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background:
        var(--hex),
        linear-gradient(160deg, var(--bg-card) 0%, var(--bg-dark) 100%);
}
.paywall-mark { margin: 0 auto 14px; }
.paywall h2 { margin: 0 0 10px; font-size: 25px; font-weight: 800; letter-spacing: -.02em; }
.paywall p { margin: 0 auto 22px; max-width: 46ch; }
.paywall .link-quiet { display: block; margin-top: 14px; }

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

.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 48px; font-size: 14px; }
.pagination a { color: var(--text-muted); font-weight: 500; }
.pagination a:hover { color: var(--accent); }
.page-number { color: var(--text-muted); }

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

.site-footer { border-top: 1px solid var(--border); background: var(--bg-dark); padding: 52px 0 26px; margin-top: auto; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 36px; }
.footer-brand .brand { margin-bottom: 12px; }
.footer-brand p { margin: 0; max-width: 34ch; font-size: 14px; }
.footer-col h4 { margin: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.footer-col a { font-size: 14px; color: var(--text-muted); }
.footer-col a:hover { color: var(--accent); }
.footer-legal { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 13px; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 860px) {
    .site-nav { display: none; }
    .site-nav.is-open {
        display: block; position: absolute; inset: 64px 0 auto;
        background: var(--bg-dark); border-bottom: 1px solid var(--border); padding: 18px 24px;
    }
    .site-nav.is-open ul { flex-direction: column; gap: 14px; }
    .nav-toggle { display: block; margin-inline-start: auto; order: 3; }
    .header-actions { order: 2; margin-inline-start: auto; }
    .hero-panel { padding: 34px 26px; }
    .hero-mark { width: 52px; height: 52px; }
    .footer-grid { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 520px) {
    .grid { grid-template-columns: 1fr; }
    .header-actions .link-quiet { display: none; }
    .post-content { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
    .card:hover, .btn:hover { transform: none; }
}
