/* ─── TOKENS ─── */
:root {
    --red:          #C8102E;
    --red-dark:     #9E0C22;
    --red-tint:     #FEF2F4;
    --red-border:   rgba(200, 16, 46, 0.15);

    --ink:          #141210;
    --ink-2:        #3A3633;
    --ink-3:        #6B6560;
    --ink-4:        #9C9691;

    --paper:        #F5F1EB;
    --white:        #FFFFFF;
    --border:       #E2DDD5;
    --border-light: #EDE9E2;

    --surface-inverse:      #141210;
    --text-on-inverse:      rgba(255, 255, 255, 0.65);
    --text-on-inverse-dim:  rgba(255, 255, 255, 0.35);

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-serif:   'Source Serif 4', Georgia, serif;
    --font-sans:    'DM Sans', system-ui, sans-serif;

    --max-w:  1260px;
    --pad-x:  clamp(20px, 5vw, 72px);
    --radius: 3px;
}

/* ─── DARK MODE TOKENS ─── */
[data-theme="dark"] {
    --ink:          #E8E4DE;
    --ink-2:        #C4BFB8;
    --ink-3:        #8A8480;
    --ink-4:        #5C5854;

    --paper:        #1A1816;
    --white:        #242220;
    --border:       #2E2C29;
    --border-light: #272523;

    --red-tint:     rgba(200, 16, 46, 0.12);
    --red-border:   rgba(200, 16, 46, 0.25);

    --surface-inverse:      #0D0B0A;
    --text-on-inverse:      rgba(255, 255, 255, 0.55);
    --text-on-inverse-dim:  rgba(255, 255, 255, 0.28);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ink:          #E8E4DE;
        --ink-2:        #C4BFB8;
        --ink-3:        #8A8480;
        --ink-4:        #5C5854;

        --paper:        #1A1816;
        --white:        #242220;
        --border:       #2E2C29;
        --border-light: #272523;

        --red-tint:     rgba(200, 16, 46, 0.12);
        --red-border:   rgba(200, 16, 46, 0.25);

        --surface-inverse:      #0D0B0A;
        --text-on-inverse:      rgba(255, 255, 255, 0.55);
        --text-on-inverse-dim:  rgba(255, 255, 255, 0.28);
    }
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    line-height: 1.6;
    transition: background 0.2s ease, color 0.2s ease;
}


/* ─── TICKER ─── */

.ticker-bar {
    height: 34px;
    background: var(--red);
    display: flex;
    align-items: stretch;
    overflow: hidden;
    position: sticky;
    top: 0;
    z-index: 200;
}

.ticker-label {
    background: var(--surface-inverse);
    color: var(--text-on-inverse);
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 0 18px;
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
    padding-right: 28px;
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--red);
    flex-shrink: 0;
    animation: pulse-dot 1.4s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.7); }
}

.ticker-track {
    overflow: hidden;
    flex: 1;
    display: flex;
    align-items: center;
    mask-image: linear-gradient(90deg, transparent 0%, black 3%, black 97%, transparent 100%);
}

.ticker-scroll {
    display: flex;
    align-items: center;
    white-space: nowrap;
    gap: 0;
    animation: ticker-move 80s linear infinite;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.01em;
}

.ticker-scroll:hover { animation-play-state: paused; }

@keyframes ticker-move {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

.ticker-item { padding: 0 4px; }

.ticker-cat {
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.7;
    margin-right: 6px;
}

.ticker-sep {
    margin: 0 20px;
    opacity: 0.35;
}


/* ─── THEME TOGGLE ─── */

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 4px 8px;
    cursor: pointer;
    color: var(--ink-3);
    display: flex;
    align-items: center;
    transition: color 0.14s, border-color 0.14s, background 0.14s;
    line-height: 0;
}

.theme-toggle:hover {
    color: var(--ink);
    border-color: var(--ink-3);
}

.theme-icon { width: 14px; height: 14px; }

/* Light mode: show moon (click to go dark). Dark mode: show sun (click to go light). */
.theme-icon--sun  { display: none; }
.theme-icon--moon { display: block; }

[data-theme="dark"] .theme-icon--sun  { display: block; }
[data-theme="dark"] .theme-icon--moon { display: none; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon--sun  { display: block; }
    :root:not([data-theme="light"]) .theme-icon--moon { display: none; }
}


/* ─── HEADER ─── */

header {
    background: var(--white);
    padding: 0 var(--pad-x);
    border-bottom: 1px solid var(--border);
}

.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 8px;
    border-bottom: 1px solid var(--border-light);
    font-family: var(--font-sans);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-4);
}

.edition-label {
    font-weight: 600;
    color: var(--ink-3);
    letter-spacing: 0.16em;
}

.header-masthead {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 28px 0 20px;
}

.rule-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

header h1 {
    font-family: var(--font-display);
    font-size: clamp(54px, 8.5vw, 110px);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1;
    color: var(--ink);
    white-space: nowrap;
}

.tagline {
    font-family: var(--font-sans);
    font-size: 10px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--ink-4);
    text-align: center;
    padding-bottom: 20px;
}

.header-red-bar {
    height: 3px;
    background: var(--red);
    margin: 0 calc(-1 * var(--pad-x));
}


/* ─── FILTER NAV ─── */

.filter-nav {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 var(--pad-x);
    position: sticky;
    top: 34px; /* below ticker */
    z-index: 100;
}

.filter-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 0;
    flex-wrap: wrap;
}

.filter-eyebrow {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-4);
    padding-right: 8px;
    border-right: 1px solid var(--border);
    line-height: 1;
}

.filter-pills {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.filter-btn {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--ink-3);
    background: none;
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 5px 16px;
    cursor: pointer;
    transition: all 0.14s ease;
    line-height: 1.5;
}

.filter-btn:hover {
    color: var(--red);
    border-color: var(--red-border);
    background: var(--red-tint);
}

.filter-btn.active {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.total-count {
    margin-left: auto;
    font-family: var(--font-sans);
    font-size: 11px;
    color: var(--ink-4);
    letter-spacing: 0.04em;
}


/* ─── SEARCH ─── */

.search-wrap {
    margin-left: auto;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    width: 14px;
    height: 14px;
    color: var(--ink-4);
    pointer-events: none;
    flex-shrink: 0;
}

.search-input {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 400;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 5px 14px 5px 30px;
    width: 200px;
    outline: none;
    transition: border-color 0.14s ease, box-shadow 0.14s ease, width 0.2s ease;
    -webkit-appearance: none;
}

.search-input::placeholder { color: var(--ink-4); }

.search-input:focus {
    border-color: var(--red-border);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
    width: 260px;
}

/* hide browser's native clear button */
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }


/* ─── NO RESULTS ─── */

.no-results {
    text-align: center;
    padding: 80px 20px;
}

.no-results-icon {
    font-family: var(--font-display);
    font-size: 48px;
    color: var(--border);
    line-height: 1;
    margin-bottom: 14px;
}

.no-results-msg {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--ink-4);
    letter-spacing: 0.04em;
}


/* ─── MAIN ─── */

main {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 40px var(--pad-x) 80px;
}

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


/* ─── LOADING ─── */

.loading-state {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 100px 0;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
    animation: loading-bounce 1.2s ease-in-out infinite;
}
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes loading-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}


/* ─── CATEGORY CARD ─── */

.category-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-top: 3px solid var(--red);
    overflow: hidden;
    transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.2s ease;
    animation: card-in 0.45s ease both;
}

.category-card:nth-child(1) { animation-delay: 0.05s; }
.category-card:nth-child(2) { animation-delay: 0.12s; }
.category-card:nth-child(3) { animation-delay: 0.19s; }
.category-card:nth-child(4) { animation-delay: 0.26s; }

@keyframes card-in {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 44px rgba(20, 18, 16, 0.10);
}


/* ─── CARD HEADER ─── */

.card-head {
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 10px;
}

.cat-icon { font-size: 17px; line-height: 1; }

.cat-label {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--red);
}

.story-count {
    margin-left: auto;
    font-family: var(--font-sans);
    font-size: 10px;
    color: var(--ink-4);
    letter-spacing: 0.04em;
}


/* ─── NEWS ITEMS ─── */

.card-body { padding: 4px 0; }

.news-item {
    display: grid;
    grid-template-columns: 26px 1fr;
    gap: 8px;
    padding: 11px 22px;
    border-bottom: 1px solid var(--border-light);
    align-items: start;
    transition: background 0.12s;
    cursor: pointer;
}

.news-item:last-child { border-bottom: none; }
.news-item:hover { background: var(--red-tint); }

.item-num {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
    color: var(--red);
    padding-top: 3px;
    letter-spacing: 0.03em;
}

.news-item a {
    font-family: var(--font-serif);
    font-size: 13.5px;
    font-weight: 400;
    line-height: 1.52;
    color: var(--ink);
    text-decoration: none;
    transition: color 0.12s;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.news-item:hover a { color: var(--red); }

.link-arrow {
    flex-shrink: 0;
    font-size: 10px;
    color: var(--ink-4);
    padding-top: 3px;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.12s, transform 0.12s;
    display: inline-block;
}

.news-item:hover .link-arrow {
    opacity: 1;
    transform: translateX(0);
}


/* ─── ERROR STATE ─── */

.error-state {
    text-align: center;
    padding: 100px 20px;
}

.error-code {
    font-family: var(--font-display);
    font-size: 72px;
    font-weight: 700;
    color: var(--border);
    line-height: 1;
    margin-bottom: 12px;
}

.error-msg {
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--ink-3);
    margin-bottom: 14px;
}

.error-state code {
    display: inline-block;
    font-size: 12px;
    background: var(--border-light);
    padding: 6px 14px;
    border-radius: 4px;
    color: var(--ink-2);
    font-family: 'DM Mono', monospace;
}

.hidden { display: none !important; }


/* ─── FOOTER ─── */

footer {
    background: var(--surface-inverse);
    padding: 22px var(--pad-x);
}

.footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-family: var(--font-sans);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-on-inverse-dim);
}

.footer-brand {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-on-inverse);
    text-transform: none;
}


/* ─── RESPONSIVE ─── */

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

@media (max-width: 640px) {
    .news-grid { grid-template-columns: 1fr; }
    .header-top-row .header-refresh { display: none; }
    header h1 { font-size: clamp(44px, 13vw, 68px); }
    .footer-inner { flex-direction: column; text-align: center; gap: 8px; }
    .search-input { width: 140px; }
    .search-input:focus { width: 180px; }
}
