/* ============================================================================
   editorial.css — "Premium Editorial" design layer for USA Content Hub
   Loaded LAST, after style.css + gfg.css. Strategy:
     1. Redefine design TOKENS so every var()-based rule inherits the new
        palette automatically (no need to touch each component).
     2. Layer a display serif (Fraunces) + refined type scale.
     3. Polish the key components: nav, hero, cards, article, footer.
   Quiet-luxury magazine feel: ivory canvas, deep ink, forest-green accents,
   hairline rules, generous whitespace. Green brand + dark mode preserved.
   ============================================================================ */

/* ── 1. Type families ─────────────────────────────────────────────────────── */
:root {
    --font-display: 'Fraunces', 'Georgia', 'Times New Roman', serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-serif: 'Merriweather', 'Georgia', serif;
}

/* ── 2. Light palette (quiet-luxury editorial) ────────────────────────────── */
:root:not([data-theme="dark"]) {
    --primary:        #2b7a44;   /* forest green */
    --primary-dark:   #1c5730;   /* deep evergreen */
    --primary-light:  #e9f4ec;   /* faint green wash */
    --accent:         #2b7a44;
    --accent-dark:    #1c5730;

    --text:        #1c1b18;      /* warm near-black ink */
    --text-light:  #55524b;
    --text-muted:  #8b8578;

    --bg:          #ffffff;
    --bg-light:    #faf8f3;      /* warm ivory */
    --bg-warm:     #f7f3ea;

    --border:       #e9e4d8;     /* warm hairline */
    --border-light: #f1ede3;

    --card-bg:   #ffffff;
    --header-bg: rgba(255,255,255,0.85);
    --code-bg:   #f4f1ea;

    --shadow-sm: 0 1px 2px rgba(28,27,24,0.04);
    --shadow-md: 0 6px 22px -12px rgba(28,27,24,0.18);
    --shadow-lg: 0 24px 60px -28px rgba(28,27,24,0.28);

    --radius:    10px;
    --radius-lg: 14px;

    --rule: #d9d3c5;             /* editorial hairline for dividers */
}

:root:not([data-theme="dark"]) body { background: var(--bg-light) !important; }

/* ── 3. Dark palette (deep charcoal-green, still premium) ──────────────────────
   NOTE: style.css sets dark tokens two ways — [data-theme="dark"] AND
   @media(prefers-color-scheme:dark){:root:not([data-theme="light"])} (0,2,0).
   To win in every case we must match/beat that selector AND repeat it inside
   the same media query (source order breaks the tie in our favour). */
:root[data-theme="dark"],
:root:not([data-theme="light"]) {
    --primary:        #6fd28d;
    --primary-dark:   #a7e6ba;
    --primary-light:  #15311f;
    --accent:         #6fd28d;
    --accent-dark:    #a7e6ba;

    --text:        #ece9e1;
    --text-light:  #b7b2a6;
    --text-muted:  #857f72;

    --bg:          #14150f;
    --bg-light:    #1a1c14;
    --bg-warm:     #201f16;

    --border:       #2c2e22;
    --border-light: #23251a;

    --card-bg:   #1b1d15;
    --header-bg: rgba(20,21,15,0.85);
    --code-bg:   #23251a;

    --rule: #2c2e22;
}
/* Guard: never let the non-toggled default (:not([data-theme="light"])) recolor
   an explicit LIGHT-preferring visitor. The light block above already handles
   :not([data-theme="dark"]); this only fires for dark or system-dark. */
:root[data-theme="light"] { color-scheme: light; }

@media (prefers-color-scheme: dark) {
    :root[data-theme="dark"],
    :root:not([data-theme="light"]) {
        --primary:        #6fd28d;
        --primary-dark:   #a7e6ba;
        --primary-light:  #15311f;
        --accent:         #6fd28d;
        --accent-dark:    #a7e6ba;
        --text:        #ece9e1;
        --text-light:  #b7b2a6;
        --text-muted:  #857f72;
        --bg:          #14150f;
        --bg-light:    #1a1c14;
        --bg-warm:     #201f16;
        --border:       #2c2e22;
        --border-light: #23251a;
        --card-bg:   #1b1d15;
        --header-bg: rgba(20,21,15,0.85);
        --code-bg:   #23251a;
        --rule: #2c2e22;
    }
}
:root[data-theme="dark"] body { background: var(--bg) !important; }

/* ── 4. Base typographic feel ─────────────────────────────────────────────── */
body {
    font-family: var(--font-sans);
    letter-spacing: -0.003em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4,
.home-hero h1,
.section-header h2,
.article-card h3, .article-card h3 a,
.featured-card-title,
.article-header h1,
.footer-brand-text h3 {
    font-family: var(--font-display) !important;
    font-optical-sizing: auto;
    letter-spacing: -0.012em;
}

::selection { background: var(--primary-light); color: var(--primary-dark); }

/* ── 5. Navigation — airy, hairline, refined ──────────────────────────────── */
.platform-bar {
    background: var(--header-bg) !important;
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--border) !important;
    box-shadow: none !important;
}
.nav-accent-line { height: 2px !important;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark)) !important; }

.platform-bar-inner { padding-top: 14px !important; padding-bottom: 14px !important; }

.nav-logo-text { font-family: var(--font-display) !important; font-weight: 600 !important;
    letter-spacing: -0.01em !important; font-size: 1.24rem !important; }
:root:not([data-theme="dark"]) .nav-logo-usa { color: var(--primary-dark) !important; }
.nav-logo-content { color: var(--text) !important; }
.nav-logo-sep { color: var(--rule) !important; font-weight: 300 !important; }
.nav-logo-mark {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
    box-shadow: 0 4px 14px -6px var(--primary) !important; }

.platform-links { gap: 4px !important; }
.nav-link {
    font-family: var(--font-sans) !important;
    font-weight: 500 !important; font-size: .92rem !important;
    letter-spacing: 0 !important; border-radius: 8px !important;
    padding: 7px 12px !important; transition: color .2s, background .2s !important;
}
:root:not([data-theme="dark"]) .nav-link { color: var(--text-light) !important; }
.nav-link:hover { background: var(--primary-light) !important; color: var(--primary-dark) !important; }

/* Buttons: filled = deep green, pill; outline/ghost = quiet */
.nav-btn { font-family: var(--font-sans) !important; font-weight: 600 !important;
    font-size: .88rem !important; letter-spacing: 0 !important; }
.nav-btn-filled {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
    color: #fff !important; border: none !important;
    box-shadow: 0 6px 18px -8px var(--primary) !important; }
.nav-btn-filled:hover { transform: translateY(-1px); filter: brightness(1.05); }
:root:not([data-theme="dark"]) .nav-btn-outline {
    border: 1px solid var(--border) !important; color: var(--text) !important; background: transparent !important; }
:root:not([data-theme="dark"]) .nav-btn-outline:hover {
    border-color: var(--primary) !important; color: var(--primary-dark) !important; background: var(--primary-light) !important; }

/* ── 6. Public hero — the editorial statement ─────────────────────────────── */
.home-hero {
    text-align: center;
    padding: clamp(2.6rem, 7vw, 5.5rem) 1rem clamp(1.4rem, 3vw, 2.4rem) !important;
    background: none !important; border: none !important;
    position: relative;
}
.home-hero h1 {
    font-family: var(--font-display) !important;
    font-weight: 500 !important;
    font-size: clamp(2.5rem, 6.2vw, 4.4rem) !important;
    line-height: 1.04 !important;
    letter-spacing: -0.025em !important;
    color: var(--text) !important;
    margin: 0 auto .9rem !important; max-width: 16ch;
}
.home-hero h1 .accent {
    display: inline; color: var(--primary-dark) !important;
    font-style: italic !important; font-weight: 400 !important;
    background: none !important; -webkit-text-fill-color: currentColor !important;
}
.home-hero p {
    font-family: var(--font-sans) !important;
    font-size: clamp(1rem, 1.6vw, 1.18rem) !important;
    color: var(--text-light) !important; line-height: 1.7 !important;
    max-width: 60ch; margin: 0 auto !important;
}
.home-hero::after {
    content: ""; display: block; width: 64px; height: 2px;
    margin: 1.9rem auto 0; background: var(--primary);
    border-radius: 2px; opacity: .85;
}

/* Category rail — refined pills */
.category-rail { border-bottom: 1px solid var(--border) !important; padding-bottom: 14px !important; }
.cat-chip {
    font-family: var(--font-sans) !important; font-weight: 500 !important;
    font-size: .86rem !important; border-radius: 999px !important;
    border: 1px solid var(--border) !important; background: var(--card-bg) !important;
    color: var(--text-light) !important; transition: all .2s !important;
}
.cat-chip:hover { border-color: var(--primary) !important; color: var(--primary-dark) !important; }
.cat-chip.active {
    background: var(--primary-dark) !important; color: #fff !important;
    border-color: var(--primary-dark) !important; }

/* ── 7. Section headers — serif + green rule ──────────────────────────────── */
.section-header { align-items: baseline !important; border-bottom: none !important; margin-bottom: 1.4rem !important; }
.section-header h2 {
    font-family: var(--font-display) !important; font-weight: 500 !important;
    font-size: clamp(1.4rem, 2.6vw, 1.9rem) !important; letter-spacing: -0.015em !important;
    color: var(--text) !important; position: relative; padding-left: 16px;
}
.section-header h2::before {
    content: ""; position: absolute; left: 0; top: .18em; bottom: .18em;
    width: 4px; border-radius: 3px;
    background: linear-gradient(var(--primary), var(--primary-dark));
}
.section-header a {
    font-family: var(--font-sans) !important; font-weight: 600 !important;
    font-size: .85rem !important; color: var(--primary-dark) !important; }
.section-header a:hover { color: var(--primary) !important; }

/* ── 8. Article cards — clean, hairline, gentle lift ──────────────────────── */
.articles-grid { gap: 30px 26px !important; }
:root:not([data-theme="dark"]) .article-card,
[data-theme="dark"] .article-card {
    background: var(--card-bg) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: none !important;
    overflow: hidden;
    transition: transform .28s cubic-bezier(.4,0,.2,1), box-shadow .28s, border-color .28s !important;
}
:root:not([data-theme="dark"]) .article-card:hover,
[data-theme="dark"] .article-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: var(--shadow-lg) !important;
    border-color: var(--rule) !important;
}
.card-image { overflow: hidden; }
.card-image img { transition: transform .5s cubic-bezier(.2,0,.2,1) !important; }
.article-card:hover .card-image img { transform: scale(1.05); }
.card-body { padding: 20px 20px 22px !important; }
.article-card h3 { font-weight: 560 !important; font-size: 1.24rem !important;
    line-height: 1.24 !important; letter-spacing: -0.015em !important; margin: 2px 0 8px !important; }
.article-card h3 a { color: var(--text) !important; transition: color .2s; }
.article-card h3 a:hover { color: var(--primary-dark) !important; }
.article-excerpt { font-family: var(--font-sans) !important; color: var(--text-light) !important;
    font-size: .93rem !important; line-height: 1.62 !important; }
.article-meta { font-size: .78rem !important; color: var(--text-muted) !important;
    letter-spacing: .01em; }

/* Read-more as an editorial text link with animated arrow */
.read-more {
    display: inline-flex !important; align-items: center; gap: 6px;
    background: none !important; padding: 0 !important; border: none !important;
    color: var(--primary-dark) !important; font-weight: 650 !important;
    font-size: .88rem !important; border-radius: 0 !important;
}
.read-more::after { content: "\2192"; transition: transform .25s; }
.read-more:hover { color: var(--primary) !important; }
.read-more:hover::after { transform: translateX(4px); }

/* Featured / Trending strip */
.featured-strip-title { font-family: var(--font-display) !important; font-weight: 500 !important;
    letter-spacing: -0.01em !important; }
.featured-card { border-radius: var(--radius-lg) !important; overflow: hidden;
    box-shadow: var(--shadow-md) !important; }
.featured-card-title { font-family: var(--font-display) !important; font-weight: 560 !important;
    letter-spacing: -0.01em !important; }
.hot-badge { background: var(--primary-dark) !important; font-family: var(--font-sans) !important;
    letter-spacing: .04em !important; }

/* ── 9. Article reading page — the crown jewel ────────────────────────────── */
main.container:has(.article-full) { max-width: 920px !important; }

.article-header { border-bottom: 1px solid var(--border); padding-bottom: 1.6rem; margin-bottom: 1.8rem; }
:root:not([data-theme="dark"]) .article-header h1,
[data-theme="dark"] .article-header h1 {
    font-family: var(--font-display) !important;
    font-weight: 500 !important;
    font-size: clamp(2rem, 4.6vw, 3.15rem) !important;
    line-height: 1.08 !important; letter-spacing: -0.022em !important;
    color: var(--text) !important; margin: .4rem 0 .5rem !important;
}
.article-subtitle {
    font-family: var(--font-serif) !important; font-style: italic;
    font-size: clamp(1.05rem, 2vw, 1.32rem) !important; line-height: 1.55 !important;
    color: var(--text-light) !important; font-weight: 400 !important;
    max-width: 62ch;
}
.pub-badge { font-family: var(--font-sans) !important; font-weight: 700 !important;
    text-transform: uppercase; letter-spacing: .08em !important; font-size: .74rem !important;
    color: var(--primary-dark) !important; }
.article-header .article-meta {
    font-family: var(--font-sans) !important; font-size: .8rem !important;
    color: var(--text-muted) !important; gap: 10px 16px !important;
    border: none; padding-top: .4rem;
}
.article-cover img { border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-md) !important; }

/* Body reading experience */
:root:not([data-theme="dark"]) .article-body,
[data-theme="dark"] .article-body {
    font-family: var(--font-serif) !important;
    font-size: 1.14rem !important; line-height: 1.85 !important;
    color: var(--text) !important; letter-spacing: -0.002em;
}
.article-body p { margin: 0 0 1.4rem !important; }
:root:not([data-theme="dark"]) .article-body h2,
[data-theme="dark"] .article-body h2 {
    font-family: var(--font-display) !important; font-weight: 560 !important;
    font-size: 1.7rem !important; letter-spacing: -0.015em !important;
    margin: 2.4rem 0 .9rem !important; padding-bottom: .35rem;
    border-bottom: 1px solid var(--border) !important; color: var(--text) !important;
}
:root:not([data-theme="dark"]) .article-body h3,
[data-theme="dark"] .article-body h3 {
    font-family: var(--font-display) !important; font-weight: 560 !important;
    font-size: 1.32rem !important; margin: 1.9rem 0 .6rem !important; color: var(--text) !important;
}
:root:not([data-theme="dark"]) .article-body a,
[data-theme="dark"] .article-body a {
    color: var(--primary-dark) !important;
    text-decoration: underline; text-decoration-color: var(--rule);
    text-underline-offset: 3px; text-decoration-thickness: 1px; transition: all .2s;
}
.article-body a:hover { text-decoration-color: var(--primary) !important; }

/* Editorial drop cap on the opening paragraph (desktop only) */
@media (min-width: 720px) {
    .article-body > p:first-of-type::first-letter {
        font-family: var(--font-display); float: left; font-weight: 600;
        font-size: 3.6rem; line-height: .72; padding: .06em .10em 0 0;
        color: var(--primary-dark);
    }
}

/* Blockquote — refined green rule + serif */
.article-body blockquote {
    border-left: 3px solid var(--primary) !important;
    background: var(--bg-warm) !important; border-radius: 0 10px 10px 0 !important;
    font-family: var(--font-serif) !important; font-style: italic;
    color: var(--text-light) !important; margin: 1.8rem 0 !important; padding: 1rem 1.4rem !important;
}

/* Author box — align to green brand (kill the old purple gradient) */
.author-box { border-radius: var(--radius-lg) !important; background: var(--bg-warm) !important;
    border: 1px solid var(--border) !important; }
.author-box > div[aria-hidden] {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
    font-family: var(--font-display) !important; }
.author-box p:nth-of-type(2) { font-family: var(--font-display) !important; }

/* Tags */
.tag-link { border: 1px solid var(--border) !important; background: var(--card-bg) !important;
    color: var(--text-light) !important; border-radius: 999px !important; font-size: .82rem !important;
    transition: all .2s !important; }
.tag-link:hover { border-color: var(--primary) !important; color: var(--primary-dark) !important;
    background: var(--primary-light) !important; }

/* Rating + feedback sections — quiet, on-brand */
.rating-section, .feedback-section {
    background: var(--bg-warm) !important; border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important; }
.rating-section h3, .feedback-section h3 { font-family: var(--font-display) !important;
    font-weight: 560 !important; font-size: 1.15rem !important; }
.fb-btn { transition: all .2s !important; }
.fb-btn:hover { border-color: var(--primary) !important; color: var(--primary-dark) !important;
    background: var(--primary-light) !important; transform: translateY(-1px); }

/* ── 10. Footer polish ────────────────────────────────────────────────────── */
.footer-brand-icon {
    background: linear-gradient(135deg, #2b7a44, #1c5730) !important;
    box-shadow: 0 8px 24px -10px rgba(43,122,68,.7) !important; }
.footer-status-dot { background: #6fd28d !important; }
.footer-brand-text h3 { font-family: var(--font-display) !important; font-weight: 500 !important; }
.footer-section h3 { font-family: var(--font-sans) !important; text-transform: uppercase;
    letter-spacing: .08em !important; font-size: .8rem !important; }

/* Deep green-black footer canvas (was navy + blue/purple glows) */
.site-footer::before {
    background: linear-gradient(135deg, #0e1a11 0%, #14271a 45%, #0e1a11 72%, #0a140d 100%) !important; }
.site-footer::after {
    background: radial-gradient(circle, rgba(43,122,68,.22) 0%, transparent 70%) !important; }
.footer-glow-2 { background: radial-gradient(circle, rgba(111,210,141,.14) 0%, transparent 70%) !important; }
.footer-glow-3 { background: radial-gradient(circle, rgba(43,122,68,.10) 0%, transparent 70%) !important; }
.footer-top-wave svg path { fill: #0e1a11 !important; }
.footer-newsletter button {
    background: linear-gradient(135deg, #2b7a44, #1c5730) !important; }
.footer-newsletter button:hover {
    background: linear-gradient(135deg, #339251, #23663b) !important;
    box-shadow: 0 4px 15px rgba(43,122,68,.35) !important; }
.footer-newsletter input[type="email"]:focus {
    border-color: #6fd28d !important; box-shadow: 0 0 0 3px rgba(43,122,68,.2) !important; }

/* ── 11. Newsletter box on articles ───────────────────────────────────────── */
.newsletter-box { background: var(--bg-warm) !important; border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important; }
.newsletter-box h3 { font-family: var(--font-display) !important; font-weight: 560 !important; }

/* ── 12. Small-screen refinements ─────────────────────────────────────────── */
@media (max-width: 640px) {
    .home-hero { padding-top: 2rem !important; }
    .article-body { font-size: 1.06rem !important; }
    .card-body { padding: 16px 16px 18px !important; }
}

/* ── 13. GitHub-changelog article layout (in the green editorial brand) ──────
   Centered hero (badge → caps meta → headline → hero image), a constrained
   reading column, and a sticky "On this page" TOC on the right. */

/* Widen the article container so the shell can breathe; beat gfg's 760 cap
   (same selector as gfg, later source order wins). */
main.container:has(.article-full):not(:has(.topic-sidebar)) { max-width: 1060px !important; }

.article-shell {
    display: grid;
    grid-template-columns: minmax(0, 720px);
    justify-content: center;
    gap: 56px;
    align-items: start;
    margin: 0 auto;
}
/* Reserve the right rail only when the TOC is actually shown (JS flips it to
   display:block once an article has ≥3 headings) — short posts stay centered. */
.article-shell:has(.toc-container[style*="block"]) {
    grid-template-columns: minmax(0, 720px) 240px;
}
/* col 1 = all article content (article-main), col 2 = sticky TOC rail. Putting
   comments/related/newsletter inside article-main keeps every section on the
   same left edge as the article body (no drift, no cramped grid). */
.article-shell > .article-main { min-width: 0; grid-column: 1 !important; grid-row: 1; }
.article-rail { grid-column: 2 !important; grid-row: 1; position: sticky; top: 92px; align-self: start; }
.article-shell:not(:has(.toc-container[style*="block"])) .article-rail { display: none; }

@media (max-width: 1024px) {
    .article-shell,
    .article-shell:has(.toc-container[style*="block"]) { grid-template-columns: minmax(0, 1fr); max-width: 760px; }
    .article-rail { display: none !important; }
}

/* Centered hero */
.gh-hero { text-align: center; border-bottom: 1px solid var(--border);
    padding-bottom: 1.9rem; margin-bottom: 2.1rem; }
.gh-hero .breadcrumbs { display: flex; justify-content: center; flex-wrap: wrap;
    gap: 2px; margin-bottom: 1.3rem; }
.gh-badge { display: inline-block; text-decoration: none;
    font-family: var(--font-sans); font-weight: 700; font-size: .72rem;
    text-transform: uppercase; letter-spacing: .09em;
    color: var(--primary-dark); background: var(--primary-light);
    padding: 5px 14px; border-radius: 999px; margin-bottom: 1.1rem; }
.gh-badge:hover { filter: brightness(.97); }
.gh-kicker { font-family: var(--font-sans); font-size: .78rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted);
    margin: 0 0 1rem; }
.gh-kicker .gh-dot { margin: 0 .35em; }
.gh-hero h1 { margin-left: auto; margin-right: auto; max-width: 20ch; text-wrap: balance; }
.gh-hero .article-subtitle { margin-left: auto; margin-right: auto; text-align: center; }
.gh-meta { justify-content: center !important; margin-top: 1.3rem !important; }

/* Hero cover framed to the reading column */
.article-shell .article-cover { margin: 0 0 2rem !important; }

/* Right rail — "On this page" (GitHub-style hairline list) */
.article-rail .toc-container {
    margin: 0 !important; padding: 0 0 0 20px !important; background: none !important;
    border: none !important; border-left: 1px solid var(--border) !important;
    border-radius: 0 !important; }
.article-rail .toc-header { cursor: default; margin: 0 0 .7rem !important; padding: 0 !important;
    display: block !important; }
.article-rail .toc-header h3 { font-family: var(--font-sans) !important; font-weight: 700 !important;
    font-size: .72rem !important; text-transform: uppercase; letter-spacing: .09em;
    color: var(--text-muted) !important; margin: 0 !important; }
.article-rail .toc-list { list-style: none !important; padding: 0 !important; margin: 0 !important;
    display: flex; flex-direction: column; gap: 1px; }
.article-rail .toc-list li { margin: 0 !important; }
.article-rail .toc-list a { display: block; padding: 5px 0 5px 12px; margin-left: -21px;
    font-size: .85rem; line-height: 1.4; color: var(--text-light) !important;
    text-decoration: none !important; border-left: 2px solid transparent;
    transition: color .15s, border-color .15s; }
.article-rail .toc-list a:hover { color: var(--primary-dark) !important;
    border-left-color: var(--primary) !important; }

/* Related grid inside the reading column: 2 across (not the homepage's 4) */
.article-main .related-articles .articles-grid {
    grid-template-columns: repeat(2, 1fr) !important; gap: 22px !important; }
@media (max-width: 560px) {
    .article-main .related-articles .articles-grid { grid-template-columns: 1fr !important; }
}
