/* The NACA Collective — Ghost theme
   1. Tokens   2. Base   3. Header/Footer   4. Components   5. Archive & feed
   6. Post     7. Koenig cards   8. Subscribe   9. Lightbox   10. Responsive */

/* 1. Tokens ------------------------------------------------------------- */
:root {
    --font-display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    --bg: #e3e2de;
    --surface: #eeede9;
    --text: #151517;
    --muted: #61626a;
    --line: #c9c7c0;
    --header-bg: rgba(227, 226, 222, 0.88);
    --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.25 0 0 0 0 0.23 0 0 0 0 0.2 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --accent: #e8431c;
    --on-accent: #ffffff;

    --wrap: 1360px;
    --wrap-narrow: 760px;
    --gutter: clamp(20px, 4vw, 48px);
    --chamfer: 18px;
    --header-h: 72px;
    color-scheme: light;
}

[data-scheme="Dark"] {
    --bg: #0c0c0d;
    --surface: #151517;
    --text: #ededee;
    --muted: #8e8f96;
    --line: #26262a;
    --header-bg: rgba(12, 12, 13, 0.85);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    [data-scheme="Auto"] {
        --bg: #0c0c0d;
        --surface: #151517;
        --text: #ededee;
        --muted: #8e8f96;
        --line: #26262a;
        --header-bg: rgba(12, 12, 13, 0.85);
        color-scheme: dark;
    }
}

/* 2. Base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg) var(--noise);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 700; line-height: 1; text-transform: uppercase; letter-spacing: 0.01em; }
p { margin: 0; }
::selection { background: var(--accent); color: var(--on-accent); }

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

.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 8px 14px; }
.skip-link:focus { left: 8px; top: 8px; }

.site { min-height: 100vh; display: flex; flex-direction: column; }
.site-main { flex: 1; }

.wrap { width: 100%; max-width: calc(var(--wrap) + var(--gutter) * 2); margin: 0 auto; padding-inline: var(--gutter); }
.wrap-narrow { width: 100%; max-width: calc(var(--wrap-narrow) + var(--gutter) * 2); margin: 0 auto; padding-inline: var(--gutter); }

.chamfer { clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, 0 100%); }

.eyebrow {
    display: inline-flex; align-items: center; gap: 10px;
    font-family: var(--font-display); font-weight: 600; font-size: 14px;
    letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent);
}
.eyebrow::before { content: ""; width: 18px; height: 2px; background: currentColor; }

.meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
    font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px 26px; border: 0; cursor: pointer;
    background: var(--accent); color: var(--on-accent);
    font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: 0.12em; text-transform: uppercase;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
    transition: filter 0.2s ease, transform 0.2s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn-small { padding: 9px 18px; font-size: 14px; }

/* 3. Header / Footer ---------------------------------------------------- */
.nav-mobile-secondary { display: none; }
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}
.site-header::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--accent) 0 72px, transparent 72px); }

.header-inner { display: flex; align-items: center; gap: 32px; height: var(--header-h); }

.brand { display: inline-flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-logo { max-height: 36px; width: auto; }
.brand-word { font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: 0.08em; text-transform: uppercase; line-height: 1; }
.naca-mark { color: var(--text); flex-shrink: 0; }

.site-nav { margin-left: auto; }
.site-nav ul { display: flex; gap: 30px; }
.site-nav a, .footer-nav a {
    font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--muted); transition: color 0.2s;
}
.site-nav a:hover, .site-nav .nav-current a, .footer-nav a:hover { color: var(--text); }
.site-nav .nav-current a { box-shadow: 0 2px 0 var(--accent); padding-bottom: 4px; }

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

.menu-toggle { display: none; width: 40px; height: 40px; padding: 0; background: none; border: 0; cursor: pointer; position: relative; }
.menu-toggle span { position: absolute; left: 9px; right: 9px; height: 2px; background: var(--text); transition: transform 0.25s, top 0.25s; }
.menu-toggle span:first-child { top: 15px; }
.menu-toggle span:last-child { top: 23px; }
.menu-open .menu-toggle span:first-child { top: 19px; transform: rotate(45deg); }
.menu-open .menu-toggle span:last-child { top: 19px; transform: rotate(-45deg); }

.site-footer { margin-top: 120px; border-top: 1px solid var(--line); padding-top: 56px; }
.footer-inner { display: flex; justify-content: space-between; gap: 40px; flex-wrap: wrap; }
.footer-brand p { margin-top: 16px; max-width: 420px; color: var(--muted); font-size: 14px; }
.footer-nav ul { display: flex; flex-wrap: wrap; gap: 14px 28px; }
.footer-base { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding-block: 40px; font-size: 12px; letter-spacing: 0.05em; color: var(--muted); }
.footer-base a:hover { color: var(--text); }

/* 4. Components --------------------------------------------------------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 28px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.section-title { font-size: 20px; letter-spacing: 0.16em; color: var(--muted); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 56px 32px; }

.card-media { display: block; position: relative; aspect-ratio: 3 / 2; background: var(--surface); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
.card:hover .card-media img { transform: scale(1.04); }
.card-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--line); }
.card-placeholder .naca-mark { width: 64px; height: 64px; color: var(--muted); opacity: 0.4; }

.card-body { padding-top: 18px; }
.card-body .meta { margin-bottom: 10px; }
.card-body .eyebrow { font-size: 13px; }
.card-title { font-size: clamp(26px, 2.4vw, 34px); line-height: 1.02; }
.card-title a { background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 2px no-repeat; transition: background-size 0.35s ease; }
.card:hover .card-title a { background-size: 100% 2px; }

/* Hero */
.hero { position: relative; display: grid; align-items: end; min-height: min(78vh, 760px); color: #fff; overflow: hidden; background: var(--surface); }
.hero-media, .hero-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.35) 45%, rgba(0,0,0,0.1) 100%); }
.hero-body { position: relative; padding-block: 56px 64px; }
.hero .meta { color: rgba(255,255,255,0.75); margin-bottom: 16px; }
.hero .eyebrow { color: #fff; }
.hero .eyebrow::before { background: var(--accent); width: 28px; }
.hero-title { font-size: clamp(48px, 8vw, 112px); line-height: 0.92; max-width: 14ch; }
.hero-title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.hero-excerpt { margin: 22px 0 28px; max-width: 54ch; font-size: 17px; color: rgba(255,255,255,0.85); }
.hero .btn { position: relative; z-index: 2; }

/* 5. Feed & archives ---------------------------------------------------- */
.feed { padding-top: 64px; }

.archive-header { position: relative; padding-block: 72px 56px; border-bottom: 1px solid var(--line); margin-bottom: 0; overflow: hidden; }
.archive-header.has-image { color: #fff; padding-block: 120px 64px; border-bottom: 0; }
.archive-media, .archive-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.archive-media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0.3)); }
.archive-body { position: relative; }
.archive-header.has-image .eyebrow { color: #fff; }
.archive-title { font-size: clamp(54px, 9vw, 120px); line-height: 0.9; margin-top: 14px; }
.archive-desc { margin-top: 20px; max-width: 60ch; font-size: 18px; color: var(--muted); }
.has-image .archive-desc { color: rgba(255,255,255,0.85); }
.archive-count { margin-top: 18px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.has-image .archive-count { color: rgba(255,255,255,0.7); }
.archive-count a { text-decoration: underline; text-underline-offset: 3px; }
.author-body { display: flex; align-items: center; gap: 32px; }
.author-avatar { width: 112px; height: 112px; border-radius: 50%; object-fit: cover; }
.archive-header + .feed { padding-top: 56px; }

.tile { position: relative; display: block; aspect-ratio: 3 / 2; background: var(--surface); overflow: hidden; color: #fff; }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
.tile:hover img { transform: scale(1.05); }
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.78), rgba(0,0,0,0.05) 70%); }
.tile-body { position: absolute; left: 22px; right: 22px; bottom: 20px; z-index: 1; display: flex; flex-direction: column; gap: 6px; }
.tile-name { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1; text-transform: uppercase; }
.tile-count { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.75; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding-top: 72px; }
.pagination-link { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: 0.12em; text-transform: uppercase; padding-bottom: 4px; border-bottom: 2px solid var(--accent); }
.pagination-link:hover { color: var(--accent); }
.pagination-count { font-size: 12px; letter-spacing: 0.12em; color: var(--muted); }

.error-page { padding-block: 120px 40px; }
.error-page .post-title { margin-top: 14px; }
.error-page .btn { margin-top: 32px; }

/* 6. Post --------------------------------------------------------------- */
.post-header { padding-block: 72px 40px; }
.post-header .meta { margin-bottom: 20px; }
.post-header .eyebrow { font-size: 15px; }
.post-title { font-size: clamp(46px, 8vw, 104px); line-height: 0.92; max-width: 16ch; }
.post-excerpt { margin-top: 24px; max-width: 56ch; font-size: clamp(18px, 2vw, 22px); line-height: 1.5; color: var(--muted); }

.post-feature { margin: 16px auto 0; max-width: calc(1400px + var(--gutter) * 2); padding-inline: var(--gutter); }
.post-feature img { width: 100%; height: auto; max-height: 86vh; object-fit: cover; }
.post-feature figcaption, .gh-content figcaption { margin-top: 12px; font-size: 13px; color: var(--muted); text-align: left; }

.gh-content {
    --main: 720px; --wide: 1240px;
    display: grid;
    grid-template-columns:
        [full-start] minmax(var(--gutter), 1fr)
        [wide-start] minmax(0, calc((var(--wide) - var(--main)) / 2))
        [main-start] min(var(--main), calc(100% - var(--gutter) * 2))
        [main-end] minmax(0, calc((var(--wide) - var(--main)) / 2))
        [wide-end] minmax(var(--gutter), 1fr)
        [full-end];
    padding-top: 56px;
    font-size: 18px; line-height: 1.75;
}
.gh-content > * { grid-column: main-start / main-end; margin-top: 0; margin-bottom: 1.6em; min-width: 0; }
.gh-content > .kg-width-wide { grid-column: wide-start / wide-end; }
.gh-content > .kg-width-full { grid-column: full-start / full-end; }
.gh-content > .kg-width-full img { width: 100%; }

.gh-content h2 { font-size: clamp(34px, 4vw, 48px); margin-top: 1.4em; margin-bottom: 0.5em; }
.gh-content h3 { font-size: clamp(26px, 3vw, 34px); margin-top: 1.2em; margin-bottom: 0.4em; }
.gh-content h4 { font-size: 22px; margin-top: 1em; margin-bottom: 0.4em; }
.gh-content a { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.gh-content a:hover { color: var(--accent); }
.gh-content ul, .gh-content ol { padding-left: 1.3em; }
.gh-content ul { list-style: disc; }
.gh-content li { margin-bottom: 0.4em; }
.gh-content blockquote:not([class]) { padding-left: 24px; border-left: 3px solid var(--accent); font-size: 1.15em; font-style: italic; }
.gh-content hr { border: 0; border-top: 1px solid var(--line); width: 100%; }
.gh-content code { font-size: 0.88em; background: var(--surface); padding: 2px 6px; }
.gh-content pre { overflow-x: auto; background: var(--surface); padding: 20px; font-size: 14px; }
.gh-content pre code { background: none; padding: 0; }
.gh-content img { cursor: zoom-in; }
.gh-content a img, .gh-content .kg-bookmark-card img { cursor: auto; }

.post-footer { padding-top: 32px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-list a { display: inline-block; padding: 6px 14px; border: 1px solid var(--line); font-family: var(--font-display); font-weight: 600; font-size: 14px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); transition: all 0.2s; }
.tag-list a:hover { border-color: var(--accent); color: var(--accent); }
.post-comments { padding-top: 56px; }

.read-next { padding-top: 96px; }

/* 7. Koenig cards ------------------------------------------------------- */
.kg-card figcaption { text-align: left; }
.kg-image-card img, .kg-gallery-image img { width: 100%; }
.kg-width-wide img, .kg-width-full img { margin-inline: auto; }
.kg-gallery-container { display: flex; flex-direction: column; gap: 8px; }
.kg-gallery-row { display: flex; flex-direction: row; justify-content: center; gap: 8px; }
.kg-gallery-image { flex: 1 1 0; }
.kg-gallery-image img { display: block; width: 100%; height: 100%; object-fit: cover; margin: 0; }
.kg-embed-card { display: flex; flex-direction: column; align-items: center; }
.kg-embed-card iframe { max-width: 100%; }
.kg-bookmark-card { width: 100%; }
.kg-bookmark-container { display: flex; border: 1px solid var(--line); color: inherit; text-decoration: none !important; background: var(--surface); }
.kg-bookmark-content { flex: 1; padding: 20px; min-width: 0; }
.kg-bookmark-title { font-family: var(--font-display); font-weight: 700; font-size: 22px; text-transform: uppercase; line-height: 1.1; }
.kg-bookmark-description { margin-top: 8px; font-size: 14px; line-height: 1.5; color: var(--muted); max-height: 4.5em; overflow: hidden; }
.kg-bookmark-metadata { margin-top: 12px; display: flex; align-items: center; font-size: 12px; color: var(--muted); }
.kg-bookmark-icon { width: 18px; height: 18px; margin-right: 8px; }
.kg-bookmark-thumbnail { position: relative; flex: 0 0 33%; }
.kg-bookmark-thumbnail img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.kg-callout-card { display: flex; padding: 20px 24px; background: var(--surface); border-left: 3px solid var(--accent); }
.kg-callout-emoji { margin-right: 14px; }
.kg-button-card { display: flex; }
.kg-button-card.kg-align-center { justify-content: center; }
.kg-btn { display: inline-block; padding: 14px 26px; background: var(--accent); color: var(--on-accent) !important; text-decoration: none !important; font-family: var(--font-display); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }

/* 8. Subscribe ---------------------------------------------------------- */
.subscribe { margin-top: 96px; padding-block: 80px; border-block: 1px solid var(--line); background: var(--surface); text-align: center; }
.subscribe .wrap-narrow { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.subscribe h2 { font-size: clamp(34px, 5vw, 56px); max-width: 16ch; }
.subscribe-form { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; max-width: 520px; }
.subscribe-form input { flex: 1 1 240px; padding: 14px 16px; background: var(--bg); border: 1px solid var(--line); color: var(--text); font: inherit; border-radius: 0; }
.subscribe-form input:focus { outline: 0; border-color: var(--accent); }
.subscribe-form .message { display: none; width: 100%; font-size: 14px; color: var(--muted); }
.subscribe-form.success .message-success, .subscribe-form.error .message-error { display: block; }
.subscribe-form .label-loading { display: none; }
.subscribe-form.loading .label-default { display: none; }
.subscribe-form.loading .label-loading { display: inline; }

/* 9. Lightbox ----------------------------------------------------------- */
.lightbox { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; background: rgba(5,5,6,0.96); padding: 4vh 4vw; }
.lightbox.is-open { display: flex; }
.lightbox img { max-width: 100%; max-height: 92vh; width: auto; height: auto; object-fit: contain; cursor: zoom-out; }
.lightbox button { position: absolute; background: none; border: 0; color: #fff; cursor: pointer; font-size: 34px; line-height: 1; padding: 16px; opacity: 0.7; transition: opacity 0.2s; }
.lightbox button:hover { opacity: 1; }
.lightbox .lb-close { top: 8px; right: 12px; }
.lightbox .lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lightbox.single .lb-prev, .lightbox.single .lb-next { display: none; }
body.lb-lock { overflow: hidden; }

/* 10. Responsive -------------------------------------------------------- */
@media (max-width: 1000px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
    .menu-toggle { display: block; }
        .site-nav .nav-mobile-secondary { display: flex; flex-direction: column; margin-top: 8px; }
    .nav-mobile-secondary a { font-size: 15px !important; color: var(--muted); }
    .header-inner { gap: 16px; }
    .header-actions { margin-left: auto; }
    .site-nav {
        position: fixed; inset: var(--header-h) 0 auto 0; margin: 0;
        background: var(--bg); border-bottom: 1px solid var(--line);
        padding: 12px var(--gutter) 28px;
        transform: translateY(-8px); opacity: 0; visibility: hidden; transition: all 0.25s ease;
    }
    .menu-open .site-nav { transform: none; opacity: 1; visibility: visible; }
    .site-nav ul { flex-direction: column; gap: 0; }
    .site-nav li { border-bottom: 1px solid var(--line); }
    .site-nav a { display: block; padding: 16px 0; font-size: 22px; }
    .site-nav .nav-current a { box-shadow: none; color: var(--accent); }
    .author-body { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 620px) {
    :root { --header-h: 64px; }
    .grid { grid-template-columns: 1fr; gap: 44px; }
    .brand-word { font-size: 20px; }
    .hero { min-height: 70vh; }
    .hero-body { padding-block: 40px; }
    .post-header { padding-top: 48px; }
    .gh-content { font-size: 17px; padding-top: 36px; }
    .site-footer { margin-top: 80px; }
    .kg-bookmark-container { flex-direction: column-reverse; }
    .kg-bookmark-thumbnail { flex-basis: 160px; }
    .kg-gallery-row { flex-direction: column; }
}

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