/*
Theme Name: AI NewsPulse
Theme URI: https://example.com/ai-newspulse
Author: AI NewsPulse
Author URI: https://example.com
Description: A New York Times-inspired WordPress theme for automated AI news aggregation. Features classic newspaper typography, editorial grid layouts, and a clean black-and-white aesthetic.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: ai-newspulse
Tags: news, magazine, one-column, two-columns, grid-layout, custom-header, custom-menu, featured-images, full-width-template, theme-options
*/

/* =====================================================
   CSS RESET & ROOT VARIABLES
   ===================================================== */
:root {
    /* NYT-inspired palette: almost entirely black/white/gray */
    --nyt-black: #121212;
    --nyt-dark: #333333;
    --nyt-body: #363636;
    --nyt-gray: #666666;
    --nyt-light-gray: #999999;
    --nyt-rule: #c7c7c7;
    --nyt-light-rule: #e2e2e2;
    --nyt-bg: #ffffff;
    --nyt-off-white: #f7f7f7;
    --nyt-paper: #fbfbfb;

    /* Accent — used sparingly, just like NYT uses red for "LIVE" */
    --nyt-accent: #d0021b;
    --nyt-blue: #326891;

    /* Typography scale */
    --font-headline: 'nyt-cheltenham', 'Georgia', 'Times New Roman', serif;
    --font-body: 'nyt-imperial', 'Georgia', 'Times New Roman', serif;
    --font-sans: 'nyt-franklin', 'Helvetica Neue', 'Arial', sans-serif;
    --font-label: 'nyt-franklin', 'Helvetica Neue', 'Arial', sans-serif;

    /* Spacing */
    --gutter: 20px;
    --max-width: 1200px;
    --content-width: 720px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--nyt-body);
    background: var(--nyt-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--nyt-black); text-decoration: none; }
a:hover { color: var(--nyt-gray); }
img { max-width: 100%; height: auto; display: block; }

/* =====================================================
   GOOGLE FONTS LOAD — closest free match to NYT's
   Cheltenham (headline) → Libre Baskerville
   Imperial (body) → Source Serif 4
   Franklin (sans) → Source Sans 3
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:wght@400;700&family=Source+Sans+3:wght@300;400;600;700&family=Source+Serif+4:ital,wght@0,300;0,400;0,600;0,700;1,400&display=swap');

:root {
    --font-headline: 'Libre Baskerville', Georgia, serif;
    --font-body: 'Source Serif 4', Georgia, serif;
    --font-sans: 'Source Sans 3', 'Helvetica Neue', Arial, sans-serif;
    --font-label: 'Source Sans 3', 'Helvetica Neue', Arial, sans-serif;
}

/* =====================================================
   HEADER / MASTHEAD
   Classic NYT: thin top rule, centered logo, date + nav
   ===================================================== */
.site-header {
    border-bottom: 2px solid var(--nyt-black);
    background: var(--nyt-bg);
}

.header-top-rule {
    height: 3px;
    background: var(--nyt-black);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* Top bar: date left, subscribe right */
.header-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--nyt-rule);
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--nyt-gray);
}

.header-top-bar .top-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-top-bar .edition-label {
    color: var(--nyt-light-gray);
    font-weight: 400;
}

/* Masthead — large centered name */
.masthead {
    text-align: center;
    padding: 12px 0 10px;
    position: relative;
}

.site-title {
    font-family: 'Old English Text MT', 'UnifrakturMaguntia', 'Libre Baskerville', Georgia, serif;
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--nyt-black);
    margin: 0;
    line-height: 1.1;
}

/* Using Libre Baskerville bold as a stand-in, styled elegantly */
.site-title a {
    color: var(--nyt-black);
    text-decoration: none;
}

.site-subtitle {
    font-family: var(--font-sans);
    font-size: 0.65rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--nyt-light-gray);
    margin-top: 2px;
}

/* Navigation bar */
.main-nav {
    border-top: 1px solid var(--nyt-rule);
    padding: 6px 0;
    display: flex;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
}

.main-nav a {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--nyt-dark);
    padding: 6px 14px;
    transition: color 0.15s;
    white-space: nowrap;
}

.main-nav a:hover {
    color: var(--nyt-accent);
}

.main-nav a.active {
    color: var(--nyt-accent);
    border-bottom: 2px solid var(--nyt-accent);
    margin-bottom: -2px;
}

/* =====================================================
   LAYOUT — NYT-STYLE GRID
   Main content uses asymmetric newspaper columns
   with thin vertical/horizontal rule dividers
   ===================================================== */
.site-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* The "above the fold" hero area — 3-column like NYT */
.hero-grid {
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    gap: 0;
    border-bottom: 1px solid var(--nyt-rule);
    padding-bottom: 24px;
    margin-bottom: 24px;
}

.hero-grid .col-left {
    padding-right: var(--gutter);
    border-right: 1px solid var(--nyt-light-rule);
}

.hero-grid .col-center {
    padding: 0 var(--gutter);
}

.hero-grid .col-right {
    padding-left: var(--gutter);
    border-left: 1px solid var(--nyt-light-rule);
}

/* Main article grid — 3 equal columns */
.articles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0;
    margin-bottom: 32px;
}

.articles-grid .article-cell {
    padding: 16px var(--gutter);
    border-right: 1px solid var(--nyt-light-rule);
}

.articles-grid .article-cell:last-child {
    border-right: none;
}

.articles-grid .article-cell:first-child {
    padding-left: 0;
}

/* Horizontal rule divider between sections */
.section-rule {
    border: none;
    border-top: 1px solid var(--nyt-rule);
    margin: 24px 0;
}

.section-rule.heavy {
    border-top: 2px solid var(--nyt-black);
}

/* =====================================================
   ARTICLE CARDS — NYT STYLE
   No cards/shadows. Clean type hierarchy with rules.
   ===================================================== */

/* Category / section label — NYT uses small caps sans */
.article-category {
    font-family: var(--font-sans);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--nyt-gray);
    margin-bottom: 6px;
    display: block;
}

.article-category.accent {
    color: var(--nyt-accent);
}

/* Breaking / Live badge */
.badge-live {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-sans);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--nyt-accent);
    margin-bottom: 6px;
}

.badge-live::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--nyt-accent);
    border-radius: 50%;
    animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Headlines */
.headline-xl {
    font-family: var(--font-headline);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--nyt-black);
    margin: 0 0 10px;
}

.headline-lg {
    font-family: var(--font-headline);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--nyt-black);
    margin: 0 0 8px;
}

.headline-md {
    font-family: var(--font-headline);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--nyt-black);
    margin: 0 0 6px;
}

.headline-sm {
    font-family: var(--font-headline);
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--nyt-black);
    margin: 0 0 4px;
}

.headline-xl a,
.headline-lg a,
.headline-md a,
.headline-sm a {
    color: inherit;
    text-decoration: none;
}

.headline-xl a:hover,
.headline-lg a:hover,
.headline-md a:hover,
.headline-sm a:hover {
    color: var(--nyt-gray);
}

/* Article summary / excerpt */
.article-summary {
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 300;
    line-height: 1.55;
    color: var(--nyt-gray);
    margin: 0 0 8px;
}

/* Byline / timestamp */
.article-meta {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--nyt-light-gray);
    margin-top: 6px;
}

.article-meta .source {
    font-weight: 600;
    color: var(--nyt-gray);
}

.article-meta .timestamp {
    color: var(--nyt-light-gray);
}

/* Article image with caption style */
.article-image {
    margin-bottom: 10px;
}

.article-image img {
    width: 100%;
    display: block;
}

/* =====================================================
   SIDEBAR ITEMS — small stacked links like NYT right col
   ===================================================== */
.sidebar-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--nyt-light-rule);
}

.sidebar-item:first-child {
    padding-top: 0;
}

.sidebar-item:last-child {
    border-bottom: none;
}

.sidebar-item .headline-sm {
    margin-bottom: 2px;
}

.sidebar-section-title {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--nyt-black);
    padding-bottom: 8px;
    margin-bottom: 4px;
    border-bottom: 2px solid var(--nyt-black);
}

/* =====================================================
   SECTION HEADERS — like NYT's "MORE IN..." headers
   ===================================================== */
.section-header {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--nyt-black);
    padding: 10px 0;
    border-top: 2px solid var(--nyt-black);
    border-bottom: 1px solid var(--nyt-rule);
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header .count {
    font-weight: 400;
    color: var(--nyt-light-gray);
    font-size: 0.68rem;
}

/* =====================================================
   FOOTER — NYT-style with columns
   ===================================================== */
.site-footer {
    border-top: 2px solid var(--nyt-black);
    margin-top: 48px;
    padding: 24px 0 48px;
    background: var(--nyt-bg);
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.footer-brand {
    text-align: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--nyt-rule);
    margin-bottom: 16px;
}

.footer-brand .site-title {
    font-size: 1.6rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.footer-links a {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--nyt-gray);
}

.footer-links a:hover { color: var(--nyt-black); }

.footer-info {
    text-align: center;
    font-family: var(--font-sans);
    font-size: 0.68rem;
    color: var(--nyt-light-gray);
}

/* =====================================================
   FILTER / CATEGORY NAV — inline buttons NYT-style
   ===================================================== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
    flex-wrap: wrap;
}

.filter-bar .filter-label {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--nyt-light-gray);
    margin-right: 8px;
}

.filter-bar button {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 12px;
    border: 1px solid var(--nyt-light-rule);
    background: transparent;
    color: var(--nyt-dark);
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.02em;
}

.filter-bar button:hover {
    border-color: var(--nyt-dark);
    background: var(--nyt-off-white);
}

.filter-bar button.active {
    background: var(--nyt-black);
    color: var(--nyt-bg);
    border-color: var(--nyt-black);
}

/* =====================================================
   STATUS BAR
   ===================================================== */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-family: var(--font-sans);
    font-size: 0.68rem;
    color: var(--nyt-light-gray);
    border-bottom: 1px solid var(--nyt-light-rule);
    margin-bottom: 20px;
}

.status-bar .pulse {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-bar .pulse-dot {
    width: 6px;
    height: 6px;
    background: #2ecc71;
    border-radius: 50%;
    animation: livePulse 2s ease-in-out infinite;
}

.status-bar .refresh-btn {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    padding: 3px 10px;
    border: 1px solid var(--nyt-light-rule);
    background: transparent;
    color: var(--nyt-light-gray);
    cursor: pointer;
}

.status-bar .refresh-btn:hover {
    border-color: var(--nyt-dark);
    color: var(--nyt-dark);
}

/* =====================================================
   EMPTY / LOADING STATES
   ===================================================== */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    font-family: var(--font-sans);
    color: var(--nyt-light-gray);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--nyt-light-rule);
    border-top: 2px solid var(--nyt-black);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 48px 20px;
}

.empty-state h3 {
    font-family: var(--font-headline);
    font-size: 1.2rem;
    color: var(--nyt-dark);
    margin-bottom: 8px;
}

.empty-state p {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--nyt-light-gray);
}

/* =====================================================
   SINGLE ARTICLE PAGE
   ===================================================== */
.single-article {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 32px var(--gutter);
}

.single-article .article-category {
    margin-bottom: 8px;
}

.single-article .headline-xl {
    font-size: 2.4rem;
    margin-bottom: 12px;
}

.single-article .article-summary {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--nyt-dark);
    margin-bottom: 16px;
    font-family: var(--font-body);
}

.single-article .article-body {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--nyt-body);
}

.single-article .article-body p {
    margin-bottom: 16px;
}

/* =====================================================
   RESPONSIVE — Graceful collapse like NYT
   ===================================================== */
@media (max-width: 1024px) {
    .hero-grid {
        grid-template-columns: 1fr 1fr;
    }
    .hero-grid .col-right {
        display: none;
    }
}

@media (max-width: 768px) {
    .hero-grid {
        grid-template-columns: 1fr;
    }
    .hero-grid .col-left,
    .hero-grid .col-center,
    .hero-grid .col-right {
        padding: 0;
        border: none;
        border-bottom: 1px solid var(--nyt-light-rule);
        padding-bottom: 16px;
        margin-bottom: 16px;
    }
    .hero-grid .col-right {
        display: block;
    }

    .articles-grid {
        grid-template-columns: 1fr;
    }
    .articles-grid .article-cell {
        padding: 14px 0;
        border-right: none;
        border-bottom: 1px solid var(--nyt-light-rule);
    }

    .site-title {
        font-size: 2rem;
    }

    .headline-xl {
        font-size: 1.5rem;
    }

    .main-nav {
        overflow-x: auto;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .main-nav::-webkit-scrollbar {
        display: none;
    }

    .header-top-bar {
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    :root {
        --gutter: 14px;
    }
    .site-title {
        font-size: 1.6rem;
    }
    .headline-xl {
        font-size: 1.3rem;
    }
    .headline-lg {
        font-size: 1.1rem;
    }
}

/* =====================================================
   WORDPRESS SPECIFICS
   ===================================================== */
.wp-admin-bar-fix {
    margin-top: 32px;
}

.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

/* Pagination */
.pagination {
    text-align: center;
    padding: 24px 0;
    border-top: 1px solid var(--nyt-rule);
    margin-top: 24px;
}

.pagination a,
.pagination span {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    padding: 6px 14px;
    color: var(--nyt-dark);
}

.pagination .current {
    font-weight: 700;
    color: var(--nyt-black);
}
