/* ===== NeuralPulse — Design System ===== */
/* Tokens */
:root {
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-display: 'Space Grotesk', var(--font-sans);

    /* Light palette */
    --bg: #f6f7f9;
    --bg-elev: #ffffff;
    --bg-subtle: #eef1f5;
    --border: #e2e6ec;
    --border-strong: #cfd6de;

    --fg: #0f172a;
    --fg-muted: #5b6575;
    --fg-faint: #8a94a3;

    --accent: #4f46e5;
    --accent-strong: #4338ca;
    --accent-soft: #eef2ff;

    --red: #dc2626;
    --red-soft: #fef2f2;
    --green: #059669;
    --amber: #d97706;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);

    --radius: 14px;
    --radius-sm: 8px;
    --maxw: 1200px;
    --header-h: 64px;
}

/* Dark palette */
[data-theme='dark'] {
    --bg: #0b0d12;
    --bg-elev: #141821;
    --bg-subtle: #1a1f2b;
    --border: #262c38;
    --border-strong: #333a48;

    --fg: #e6e9ef;
    --fg-muted: #9aa4b2;
    --fg-faint: #6b7484;

    --accent: #818cf8;
    --accent-strong: #a5b4fc;
    --accent-soft: #1e2740;

    --red: #f87171;
    --red-soft: #2a1618;
    --green: #34d399;
    --amber: #fbbf24;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
}

/* Accessibility helpers */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
.skip-link {
    position: absolute;
    top: -100px;
    left: 12px;
    background: var(--accent);
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    z-index: 100;
    font-weight: 600;
    transition: top 0.2s;
}
.skip-link:focus { top: 12px; }
.link-underline {
    color: inherit;
    text-decoration: none;
    position: relative;
    font-weight: 500;
}
.link-underline::after {
    content: '';
    position: absolute;
    bottom: -4px; left: 0;
    height: 2px; width: 0;
    background: var(--accent);
    transition: width 0.25s ease;
}
.link-underline:hover::after { width: 100%; }

/* ===== Base ===== */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--fg);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 {
    font-family: var(--font-display);
    line-height: 1.2;
    color: var(--fg);
    font-weight: 700;
}
.accent { color: var(--accent); }

/* ===== Header ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
.header-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 24px;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
    position: relative;
}
.brand-mark::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 5px;
    background: repeating-linear-gradient(45deg, transparent 0 4px, rgba(255,255,255,0.25) 4px 8px);
}
.brand-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}
.brand-accent { color: var(--accent); }
.main-nav { display: flex; align-items: center; }
.nav-list {
    list-style: none;
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 0;
}
.nav-link {
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--fg-muted);
    transition: all 0.15s;
}
.nav-link:hover { color: var(--fg); background: var(--bg-subtle); }
.nav-link.active { color: var(--accent); background: var(--accent-soft); }
.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--red);
    letter-spacing: 0.02em;
}
.live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--red);
    animation: pulse 1.6s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    50% { opacity: 0.6; box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
.theme-toggle {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 999px;
    width: 38px; height: 38px;
    display: grid; place-items: center;
    cursor: pointer;
    color: var(--fg);
    transition: all 0.2s;
}
.theme-toggle:hover { background: var(--border); }
.icon-moon { display: none; }
[data-theme='dark'] .icon-sun { display: none; }
[data-theme='dark'] .icon-moon { display: block; }

/* ===== Ticker ===== */
.ticker {
    background: var(--fg);
    color: #fff;
    overflow: hidden;
    padding: 0;
    font-size: 0.85rem;
}
.ticker-label {
    background: var(--red);
    padding: 8px 16px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-size: 0.72rem;
}
.ticker-track {
    display: flex;
    gap: 48px;
    white-space: nowrap;
    padding: 9px 0;
    animation: scroll-x 40s linear infinite;
}
.ticker-track span { flex: 0 0 auto; }
@keyframes scroll-x {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* ===== Masthead ===== */
.masthead {
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    padding: 32px 24px 40px;
}
.masthead-inner { max-width: var(--maxw); margin: 0 auto; }
.masthead-date {
    color: var(--fg-faint);
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-weight: 500;
}
.masthead-title {
    font-size: clamp(2rem, 5vw, 3.6rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    margin-top: 8px;
}

/* ===== Hero ===== */
.hero {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 44px 24px 56px;
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 48px;
    align-items: center;
}
.eyebrow {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 5px 12px;
    border-radius: 999px;
    margin-bottom: 18px;
}
.eyebrow--featured { color: var(--red); background: var(--red-soft); }
.hero-title {
    font-size: clamp(1.8rem, 4vw, 2.9rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0 0 16px;
}
.hero-title a { color: inherit; }
.hero-title a:hover { text-decoration: underline; }
.hero-lede {
    font-size: 1.2rem;
    color: var(--fg-muted);
    line-height: 1.6;
    margin: 0 0 24px;
}
.hero-meta { display: flex; align-items: center; gap: 20px; }
.read-more {
    font-weight: 600;
    color: var(--accent);
    transition: gap 0.2s;
}
.read-more:hover { gap: 8px; text-decoration: none; }
.source-tag {
    font-size: 0.82rem;
    color: var(--fg-faint);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 6px;
}
.hero-visual {
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}
.hero-graphic {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent), #7c3aed 50%, #a855f7);
    opacity: 0.9;
}
.hero-graphic::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.25), transparent 40%),
                      radial-gradient(circle at 70% 60%, rgba(0,0,0,0.2), transparent 45%);
}
.hero-graphic::after {
    content: 'AI';
    position: absolute;
    inset: 0;
    display: grid; place-items: center;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 8rem;
    color: rgba(255,255,255,0.14);
    letter-spacing: -0.05em;
}

/* ===== Sections ===== */
.section {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 40px 24px;
}
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 22px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 12px;
}
.section-title {
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    margin: 0;
}
.section--sources { background: var(--bg-subtle); max-width: none; }
.section--sources .section-head { max-width: var(--maxw); margin-left: 0; margin-right: 0; }

/* ===== Story cards ===== */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}
.stories-grid--compact { grid-template-columns: repeat(2, 1fr); }
.story-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
}
.story-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}
.story-thumb {
    aspect-ratio: 16 / 9;
    background: var(--bg-subtle);
    display: grid;
    place-items: center;
    position: relative;
}
.story-thumb svg { width: 48px; height: 48px; opacity: 0.35; }
.story-card:hover .story-thumb svg { opacity: 0.6; }
.story-body { padding: 18px 18px 20px; }
.story-cat {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 8px;
}
.story-title {
    font-family: var(--font-display);
    font-size: 1.12rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 10px;
    letter-spacing: -0.01em;
}
.story-card:hover .story-title { color: var(--accent); }
.story-lede {
    font-size: 0.92rem;
    color: var(--fg-muted);
    margin: 0 0 14px;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.story-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--fg-faint);
    margin-top: auto;
}
.story-source { font-weight: 600; }
.story-time { display: flex; align-items: center; gap: 5px; }
.story-time svg { width: 14px; height: 14px; }

/* ===== Sources grid ===== */
.sources-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    max-width: var(--maxw);
    margin: 0 auto;
    padding-top: 40px;
    padding-bottom: 80px;
}
.source-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.2s;
}
.source-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.source-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    margin-bottom: 6px;
}
.source-note { font-size: 0.88rem; color: var(--fg-muted); }

/* ===== Newsletter ===== */
.newsletter {
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    padding: 72px 24px;
    color: #fff;
}
.newsletter-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: center;
}
.newsletter-text h2 { color: #fff; margin: 0 0 12px; }
.newsletter-text p { color: rgba(255,255,255,0.85); margin: 0; }
.newsletter-form { display: flex; gap: 12px; }
.newsletter-form input {
    flex: 1;
    padding: 14px 16px;
    border-radius: 10px;
    border: none;
    font-size: 1rem;
    font-family: var(--font-sans);
}
.btn {
    padding: 14px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.98rem;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    font-family: var(--font-sans);
}
.btn--primary { background: #fff; color: var(--accent); }
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.25); }
.newsletter-msg { margin-top: 10px; font-size: 0.9rem; min-height: 20px; }
.newsletter-msg.ok { color: #fff; }
.newsletter-msg.err { color: #fecaca; }

/* ===== Footer ===== */
.site-footer {
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    padding: 56px 24px 32px;
}
.footer-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
}
.footer-brand p { color: var(--fg-muted); font-size: 0.92rem; margin: 12px 0 0; max-width: 320px; }
.footer-nav h3 {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-faint);
    margin-bottom: 14px;
}
.footer-nav a { display: block; color: var(--fg-muted); font-size: 0.92rem; padding: 5px 0; }
.footer-nav a:hover { color: var(--accent); }
.footer-copy {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border);
    padding-top: 24px;
    margin-top: 8px;
    color: var(--fg-faint);
    font-size: 0.85rem;
    text-align: center;
}

/* ===== Back to top ===== */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 46px; height: 46px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.25s;
    z-index: 90;
}
.back-to-top.show { opacity: 1; transform: translateY(0); }
.back-to-top:hover { background: var(--accent-strong); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .stories-grid { grid-template-columns: repeat(2, 1fr); }
    .stories-grid--compact { grid-template-columns: 1fr; }
    .sources-grid { grid-template-columns: repeat(2, 1fr); }
    .footer-inner { grid-template-columns: 1fr 1fr; }
    .hero { grid-template-columns: 1fr; }
    .hero-visual { max-width: 300px; }
    .newsletter-inner { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    :root { --header-h: 56px; }
    .nav-toggle { display: inline-flex; }
    .nav-list {
        position: fixed;
        top: var(--header-h);
        left: 0; right: 0; bottom: 0;
        background: var(--bg-elev);
        flex-direction: column;
        padding: 24px;
        gap: 8px;
        transform: translateX(100%);
        transition: transform 0.25s;
        box-shadow: var(--shadow-lg);
    }
    .nav-list.open { transform: translateX(0); }
    .nav-link { padding: 14px; font-size: 1.1rem; }
    .live-badge { display: none; }
    .stories-grid { grid-template-columns: 1fr; }
    .sources-grid { grid-template-columns: 1fr; }
    .footer-inner { grid-template-columns: 1fr; }
}
.nav-toggle {
    display: none;
    width: 42px; height: 42px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 8px;
    align-items: center;
    justify-content: center;
}
.nav-toggle-bar {
    width: 18px; height: 2px;
    background: var(--fg);
    position: relative;
}
.nav-toggle-bar::before,
.nav-toggle-bar::after {
    content: '';
    position: absolute;
    left: 0;
    width: 18px; height: 2px;
    background: var(--fg);
}
.nav-toggle-bar::before { top: -6px; }
.nav-toggle-bar::after { top: 6px; }
