/* ==========================================================================
   1. GLOBAL VARIABLES & RESET
   ========================================================================== */
:root {
    --bg-main: #0a0a0a;
    --bg-card: #121212;
    --border-color: #262626;
    --text-primary: #e5e5e5;
    --text-muted: #a3a3a3;
    --accent-hazard: #f59e0b;
    --accent-red: #dc2626;
    
    --font-mono: 'JetBrains Mono', monospace;
    --font-serif: 'Lora', serif;
    --font-sans: 'Space Grotesk', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-serif);
    line-height: 1.6;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ==========================================================================
   GLOBAL MEDIA & LAYOUT FLUIDITY CONSTRAINTS (PREVENTS GRID OVERFLOW)
   ========================================================================== */

/* Force grid items to strictly respect column widths instead of expanding */
main > *,
#main-feed-column,
.sidebar {
    min-width: 0;
}

/* Prevent any image or media element from blowing out parent containers */
img, 
picture, 
video, 
canvas, 
svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Prevent long un-broken strings from stretching containers */
.lead-story,
.sidebar-story,
.article-body {
    max-width: 100%;
    overflow-wrap: break-word;
}

/* ==========================================================================
   2. HEADER & NAVIGATION
   ========================================================================== */
header {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.site-branding {
    text-align: center;
    margin-bottom: 15px;
}

.site-branding h1 {
    font-family: var(--font-sans);
    font-size: 2.5rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.logo-link {
    color: var(--text-primary);
    text-decoration: none;
}

.site-branding p {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-hazard);
    letter-spacing: 1px;
}

nav ul {
    display: flex;
    justify-content: center;
    gap: 20px;
    list-style: none;
    flex-wrap: wrap;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: bold;
    transition: color 0.2s ease;
}

nav a:hover {
    color: var(--accent-hazard);
}

/* ==========================================================================
   3. BREAKING NEWS TICKER
   ========================================================================== */
.ticker-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    overflow: hidden;
    height: 40px;
}

.ticker-badge {
    background-color: var(--accent-red);
    color: #ffffff;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: bold;
    padding: 0 15px;
    height: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
    z-index: 2;
}

.ticker-wrapper {
    overflow: hidden;
    white-space: nowrap;
    width: 100%;
}

.ticker-content {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    animation: ticker-scroll linear infinite;
}

/* Seamless infinite ticker loop from 0 to -50% offset */
@keyframes ticker-scroll {
    0% { 
        transform: translateX(0); 
    }
    100% { 
        transform: translateX(-50%); 
    }
}

/* ==========================================================================
   4. MAIN LAYOUT GRID
   ========================================================================== */
main {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    align-items: start !important; /* Decouples sidebar height from lead story height */
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   5. FEATURED STORY & DOSSIER PREVIEW EXPANSION
   ========================================================================== */
.lead-story {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 25px;
}

.meta-tag {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-hazard);
    margin-right: 10px;
    margin-bottom: 10px;
}

/* Collapsible Preview Wrapper */
.featured-preview-wrapper {
    position: relative;
    max-height: 480px; /* Cutoff height for preview */
    overflow: hidden;
    transition: max-height 0.4s ease-in-out;
}

.featured-preview-wrapper.expanded {
    max-height: 5000px; /* Unlimited expansion */
}

/* Gradient Mask overlay for preview cutoff */
.featured-preview-wrapper::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 90px;
    background: linear-gradient(to bottom, rgba(18, 18, 18, 0), var(--bg-card));
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.featured-preview-wrapper.expanded::after {
    opacity: 0;
}

/* Article images within injected payload */
.featured-preview-wrapper img,
.lead-story img {
    margin: 15px 0;
    border: 1px solid var(--border-color);
}

.featured-preview-wrapper p {
    margin-bottom: 15px;
}

/* Toggle link styled at the container bottom */
.featured-toggle-btn {
    display: inline-block;
    cursor: pointer;
    color: var(--accent-hazard);
    font-family: var(--font-mono);
    font-weight: bold;
    margin-top: 15px;
    user-select: none;
    transition: color 0.2s ease;
}

.featured-toggle-btn:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* ==========================================================================
   6. SIDEBAR DISPATCHES
   ========================================================================== */
.sidebar {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 20px;
}

.sidebar h3 {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    color: var(--accent-hazard);
}

.sidebar-story {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-story:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.sidebar-story h4 {
    font-family: var(--font-sans);
    font-size: 1rem;
    margin-bottom: 8px;
}

.sidebar-story p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.4;
}

.sidebar-story .read-more {
    font-size: 0.8rem;
    color: var(--accent-hazard);
    font-family: var(--font-mono);
    font-weight: bold;
    text-decoration: none;
}

.sidebar-story .read-more:hover {
    text-decoration: underline;
}

/* ==========================================================================
   7. FOOTER
   ========================================================================== */
footer {
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

footer nav {
    margin-top: 10px;
}

footer nav a {
    color: var(--text-muted);
    text-decoration: none;
    margin: 0 5px;
}

footer nav a:hover {
    color: var(--accent-hazard);
}