/* ═══════════════════════════════════════════════════════════════════════
   Newslogger index (/blog/ and /blog/page/<n>/)
   Resource-hub layout: hero + search + category chips, Featured (1 large +
   2 stacked), subscribe band, one horizontal rail per category, then the
   paginated All posts grid. Tokens come from blog.css (light + dark).
   ═══════════════════════════════════════════════════════════════════════ */

.nl-index {
    --nl-gutter: 24px;
    --nl-gap: 24px;
    --nl-radius: 18px;
    --nl-ink: #17161a;
    overflow-x: clip;
}

[data-theme="dark"] .nl-index {
    --nl-ink: #f3eff8;
}

/* Softer page wash than the old capsule layout */
.nl-index::before {
    opacity: 0.7;
}

.nl-hero,
.nl-main {
    width: 100%;
    max-width: calc(var(--max-width) + 2 * var(--nl-gutter));
    margin-inline: auto;
    padding-inline: var(--nl-gutter);
}

.nl-main {
    padding-bottom: 96px;
}

/* ── Navbar: glass shell that grows a chip row when docked ───────────── */

.nl-nav {
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.62);
    -webkit-backdrop-filter: blur(22px) saturate(1.8);
    backdrop-filter: blur(22px) saturate(1.8);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow:
        0 10px 34px -16px rgba(61, 59, 64, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
    transition: border-radius 0.25s ease;
}

[data-theme="dark"] .nl-nav {
    background: rgba(24, 23, 28, 0.62);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow:
        0 10px 34px -16px rgba(0, 0, 0, 0.65),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Fade the strip above the floating bar so scrolled content doesn't peek */
.nl-nav::before {
    content: "";
    position: absolute;
    left: 50%;
    width: 100vw;
    transform: translateX(-50%);
    top: -13px;
    height: 13px;
    background: linear-gradient(var(--bg) 55%, transparent);
    z-index: -1;
    pointer-events: none;
}

.nl-nav .glass-nav-inner {
    background: none;
    border: 0;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.nl-nav-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    max-height: 0;
    opacity: 0;
    padding: 0 16px;
    border-top: 1px solid transparent;
    transition: max-height 0.28s ease, opacity 0.2s ease, padding 0.28s ease, border-color 0.28s ease;
    pointer-events: none;
}

.nl-nav-chips::-webkit-scrollbar {
    display: none;
}

.nl-nav.is-docked {
    border-radius: 22px;
}

.nl-nav.is-docked .nl-nav-chips {
    max-height: 64px;
    opacity: 1;
    padding: 10px 16px 12px;
    border-top-color: var(--border);
    pointer-events: auto;
}

/* ── Hero ────────────────────────────────────────────────────────────── */

.nl-hero {
    padding-top: clamp(48px, 8vw, 96px);
}

.nl-title {
    font-family: var(--font-display);
    font-size: clamp(44px, 6.2vw, 80px);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 0.95;
    color: var(--text-primary);
}

.nl-lede {
    max-width: 560px;
    margin-top: 18px;
    font-size: 17px;
    line-height: 1.55;
    color: var(--text-secondary);
}

.nl-lede em {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1.18em;
    color: var(--text-primary);
}

.nl-search {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 520px;
    height: 56px;
    margin-top: 32px;
    padding: 0 22px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--text-primary) 22%, transparent);
    background: color-mix(in srgb, var(--bg-secondary) 70%, transparent);
    cursor: text;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.nl-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

.nl-search svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--text-primary);
}

.nl-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: none;
    font: 400 16px/1 var(--font-sans);
    color: var(--text-primary);
}

.nl-search input::placeholder {
    color: var(--text-muted);
}

.nl-search input::-webkit-search-cancel-button {
    cursor: pointer;
}

.nl-chips {
    display: flex;
    gap: 6px;
    margin-top: 28px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: calc(-1 * var(--nl-gutter));
    padding-inline: var(--nl-gutter);
}

.nl-chips::-webkit-scrollbar {
    display: none;
}

.nl-chip {
    flex-shrink: 0;
    font: 500 14px/1 var(--font-sans);
    color: var(--text-primary);
    background: transparent;
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.nl-chip:hover {
    background: color-mix(in srgb, var(--text-primary) 7%, transparent);
}

.nl-chip.is-active {
    background: var(--nl-ink);
    color: var(--bg);
}

.nl-chip:focus-visible,
.nl-rail-btn:focus-visible,
.nl-viewall:focus-visible,
.nl-more:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── Sections ────────────────────────────────────────────────────────── */

.nl-section {
    margin-top: clamp(56px, 7vw, 88px);
}

.nl-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.nl-h2 {
    font-family: var(--font-display);
    font-size: clamp(28px, 3.2vw, 42px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: var(--text-primary);
}

.nl-h2-sub {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--text-muted);
    margin-left: 10px;
    vertical-align: middle;
}

/* ── Cards ───────────────────────────────────────────────────────────── */

.nl-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    color: var(--text-primary);
}

.nl-card-media {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: var(--nl-radius);
    overflow: hidden;
    background: var(--grey);
    isolation: isolate;
}

[data-theme="dark"] .nl-card-media {
    background: var(--bg-secondary);
}

.nl-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.nl-card:hover .nl-card-media img {
    transform: scale(1.035);
}

.nl-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.nl-card-title {
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.38;
    letter-spacing: -0.012em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.nl-card-arrow {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    margin-top: 1px;
    transition: transform 0.2s ease, color 0.2s ease;
}

.nl-card-arrow svg {
    width: 100%;
    height: 100%;
}

.nl-card:hover .nl-card-title,
.nl-card:hover .nl-card-arrow {
    color: var(--accent);
}

.nl-card:hover .nl-card-arrow {
    transform: translate(2px, -2px);
}

.nl-card:focus-visible {
    outline: none;
}

.nl-card:focus-visible .nl-card-media {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.nl-card-excerpt {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 62ch;
    margin-top: -4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.nl-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: -4px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
}

.nl-card-cat {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    color: var(--tag-text);
    background: var(--tag-bg);
    padding: 4px 10px;
    border-radius: 999px;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

/* Featured lead */
.nl-card--lg .nl-card-media {
    aspect-ratio: 16 / 9.6;
    border-radius: 22px;
}

.nl-card--lg .nl-card-title {
    font-family: var(--font-display);
    font-size: clamp(22px, 2.3vw, 30px);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
}

.nl-card--lg .nl-card-arrow {
    width: 30px;
    height: 30px;
}

/* ── Featured ────────────────────────────────────────────────────────── */

.nl-section--featured {
    margin-top: 56px;
}

.nl-featured {
    display: grid;
    grid-template-columns: minmax(0, 2.05fr) minmax(0, 1fr);
    gap: var(--nl-gap);
    align-items: start;
}

.nl-featured-side {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* ── Subscribe band ──────────────────────────────────────────────────── */

.nl-subscribe {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: center;
    gap: 32px;
    margin-top: clamp(56px, 7vw, 88px);
    padding: clamp(28px, 4vw, 48px);
    border-radius: 28px;
    background:
        radial-gradient(620px 300px at 92% -10%, rgba(82, 92, 235, 0.2), transparent 62%),
        radial-gradient(520px 280px at 0% 110%, rgba(251, 207, 217, 0.45), transparent 62%),
        #eef0fd;
    border: 1px solid rgba(82, 92, 235, 0.1);
}

[data-theme="dark"] .nl-subscribe {
    background:
        radial-gradient(620px 300px at 92% -10%, rgba(82, 92, 235, 0.3), transparent 62%),
        radial-gradient(520px 280px at 0% 110%, rgba(160, 90, 200, 0.14), transparent 62%),
        #1b1a21;
    border-color: var(--border);
}

.nl-subscribe-title {
    font-family: var(--font-display);
    font-size: clamp(26px, 3vw, 38px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.08;
    color: var(--text-primary);
}

.nl-subscribe-title em {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    letter-spacing: -0.01em;
}

.nl-subscribe-copy p {
    margin-top: 10px;
    font-size: 15px;
    color: var(--text-secondary);
}

.nl-subscribe .nl-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nl-subscribe .nl-form input[type="email"] {
    flex: 1 1 220px;
    min-width: 0;
    height: 52px;
    padding: 0 20px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--text-primary) 16%, transparent);
    background: var(--bg);
    color: var(--text-primary);
    font: 400 15px var(--font-sans);
    outline: none;
}

.nl-subscribe .nl-form input[type="email"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

.nl-subscribe .nl-form button {
    height: 52px;
    padding: 0 26px;
    border: 0;
    border-radius: 999px;
    background: var(--nl-ink);
    color: var(--bg);
    font: 600 15px var(--font-sans);
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.nl-subscribe .nl-form button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.nl-subscribe .nl-form button:disabled {
    opacity: 0.6;
    cursor: default;
}

.nl-subscribe .nl-status {
    flex-basis: 100%;
    min-height: 1.2em;
    padding-left: 20px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}

.nl-subscribe .nl-status[data-nl-kind="error"] {
    color: #d14343;
}

.nl-subscribe .nl-status[data-nl-kind="done"] {
    color: #1f9d55;
}

/* ── Category rails ──────────────────────────────────────────────────── */

.nl-rail-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.nl-rail-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.15s ease, opacity 0.15s ease;
}

.nl-rail-btn svg {
    width: 18px;
    height: 18px;
}

.nl-rail-btn:hover:not(:disabled) {
    border-color: var(--text-primary);
}

.nl-rail-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.nl-viewall {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 10px;
    padding-bottom: 2px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    border-bottom: 1.5px solid currentColor;
    white-space: nowrap;
}

.nl-viewall svg {
    width: 16px;
    height: 16px;
}

.nl-viewall:hover {
    color: var(--accent);
}

/* Full-bleed rail whose first card lines up with the container edge */
.nl-rail {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - 2 * var(--nl-gap)) / 2.3);
    gap: var(--nl-gap);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    margin-inline: calc(50% - 50vw);
    padding-inline: calc(50vw - 50%);
    /* % here would resolve against the rail itself, so spell the offset out */
    scroll-padding-inline: max(var(--nl-gutter), calc((100vw - var(--max-width)) / 2));
    padding-bottom: 6px;
}

.nl-rail::-webkit-scrollbar {
    display: none;
}

.nl-rail > .nl-card {
    scroll-snap-align: start;
}

/* ── All posts grid + results ────────────────────────────────────────── */

.nl-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 44px var(--nl-gap);
}

.nl-grid[aria-busy="true"] {
    opacity: 0.5;
}

.nl-results {
    margin-top: 48px;
}

.nl-results-count {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
    padding-bottom: 6px;
}

.nl-empty {
    grid-column: 1 / -1;
    padding: 72px 0;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-muted);
}

.nl-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 48px;
}

.nl-more {
    height: 48px;
    padding: 0 28px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--text-primary) 22%, transparent);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: 600 14px var(--font-sans);
    cursor: pointer;
}

.nl-more:hover {
    border-color: var(--text-primary);
}

.nl-main .pagination-container {
    margin-top: 48px;
}

.nl-main .post-archive {
    width: 100%;
    margin-top: 56px;
}

.nl-main .pagination-back {
    margin-top: 16px;
}

/* ── Intro reveal (sunrise overlay) ──────────────────────────────────── */

html.intro-active .nl-hero {
    opacity: 0;
}

html.intro-reveal .nl-hero {
    animation: revealUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.06s forwards;
}

html.intro-reveal .nl-main {
    opacity: 0;
    animation: cardSlideIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.14s forwards;
}

@media (prefers-reduced-motion: reduce) {
    html.intro-active .nl-hero {
        opacity: 1;
    }

    .nl-card-media img,
    .nl-card:hover .nl-card-media img,
    .nl-card-arrow {
        transition: none;
        transform: none;
    }

    .nl-nav,
    .nl-nav-chips {
        transition: none;
    }
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 960px) {
    .nl-featured {
        grid-template-columns: 1fr;
    }

    .nl-featured-side {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--nl-gap);
    }

    .nl-subscribe {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .nl-rail {
        grid-auto-columns: calc((100% - var(--nl-gap)) / 1.6);
    }

    .nl-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .nl-index {
        --nl-gutter: 16px;
        --nl-gap: 16px;
        --nl-radius: 14px;
    }

    .nl-nav .shell-links {
        gap: 14px;
    }

    .nl-search {
        height: 50px;
        margin-top: 24px;
    }

    .nl-featured-side {
        grid-template-columns: 1fr;
    }

    .nl-card-title {
        font-size: 17px;
    }

    .nl-rail-btn {
        display: none;
    }

    .nl-viewall {
        margin-left: 0;
        font-size: 14px;
    }

    .nl-rail {
        grid-auto-columns: 82%;
    }

    .nl-grid {
        grid-template-columns: 1fr;
        gap: 36px;
    }

    .nl-subscribe {
        border-radius: 22px;
    }
}
