/* ==========================================================================
   THE GLOBAL WIRE - Modern Editorial Design System
   Google Fonts: Plus Jakarta Sans (UI) & Newsreader (Editorial Serif)
   Curated HSL Color Tokens, Dark/Light Mode, Micro-Interactions
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,600;0,6..72,700;1,6..72,400;1,6..72,600&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    /* Color Palette - Light Theme (Default) */
    --bg-primary: #fbfbfd;
    --bg-surface: #ffffff;
    --bg-surface-subtle: #f3f4f7;
    --bg-elevated: #ffffff;
    --border-subtle: #e6e8ec;
    --border-strong: #d1d5db;

    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-inverted: #ffffff;

    /* Accent & Brand Colors */
    --brand-primary: #b91c1c; /* Editorial Crimson */
    --brand-primary-hover: #991b1b;
    --brand-accent: #2563eb;  /* Deep Royal Blue */
    --brand-accent-hover: #1d4ed8;
    --accent-gold: #d97706;
    --accent-emerald: #059669;

    /* Breaking News */
    --breaking-red: #dc2626;
    --breaking-bg: #fef2f2;
    --breaking-border: #fecaca;

    /* Shadows & Glassmorphism */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 20px rgba(185, 28, 28, 0.15);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Fonts */
    --font-serif: 'Newsreader', Georgia, serif;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Layout */
    --container-max: 1320px;
    --header-height: 72px;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme Tokens */
[data-theme="dark"] {
    --bg-primary: #0b0f17;
    --bg-surface: #111724;
    --bg-surface-subtle: #192233;
    --bg-elevated: #1e293d;
    --border-subtle: #232f42;
    --border-strong: #334155;

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-inverted: #0b0f17;

    --brand-primary: #ef4444;
    --brand-primary-hover: #f87171;
    --brand-accent: #3b82f6;
    --brand-accent-hover: #60a5fa;

    --breaking-red: #ef4444;
    --breaking-bg: rgba(239, 68, 68, 0.12);
    --breaking-border: rgba(239, 68, 68, 0.25);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 25px rgba(239, 68, 68, 0.25);
}

/* Base Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-fast);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button, input, select {
    font-family: inherit;
    font-size: inherit;
}

/* Global overflow and word break protection */
p, h1, h2, h3, h4, h5, h6, .site-title, .reader-headline, .article-card-title, .lead-story-title {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 768px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Top Bar: Live Date & Edition */
.top-bar {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.4rem 0;
}

.top-bar-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.live-indicator {
    width: 8px;
    height: 8px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px var(--accent-emerald);
    animation: pulse 2s infinite;
}

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

/* Main Header */
.site-header {
    background-color: var(--bg-surface);
    border-bottom: 2px solid var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-main {
    padding: 1.25rem 0;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.header-brand {
    text-align: center;
}

.site-title {
    font-family: var(--font-serif);
    font-size: clamp(1.4rem, 4vw, 2.75rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.05;
    color: var(--text-primary);
}

.site-title span {
    color: var(--brand-primary);
}

.site-motto {
    font-size: clamp(0.55rem, 1.5vw, 0.6875rem);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-top: 0.35rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
}

/* Mobile Offcanvas Drawer */
.mobile-offcanvas {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border-right: 1px solid var(--border-subtle) !important;
    max-width: 320px;
    width: 85% !important;
    z-index: 1050;
}

[data-theme="dark"] .mobile-offcanvas {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border-right-color: var(--border-subtle) !important;
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%);
}

.mobile-link {
    color: var(--text-primary) !important;
    padding: 0.65rem 0.75rem !important;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.mobile-link:hover, .mobile-link.active {
    background-color: var(--bg-surface-subtle) !important;
    color: var(--brand-primary) !important;
}

.mobile-nav-heading {
    letter-spacing: 0.08em;
    font-size: 0.7rem;
    margin-top: 0.5rem;
}

/* Nav Bar */
.main-nav {
    border-top: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
}

.nav-list {
    display: flex;
    list-style: none;
    overflow-x: auto;
    padding: 0;
    margin: 0;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

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

.nav-link {
    display: inline-block;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}

/* Theme Toggle & Buttons */
.icon-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background-color: var(--bg-surface-subtle);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* Search Trigger Button */
.search-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-full);
    background: var(--bg-surface-subtle);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.search-trigger:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.kbd-shortcut {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.7rem;
    font-family: var(--font-mono);
}

/* Main Content Wrapper */
.main-content {
    flex: 1;
    padding: 2rem 0 3.5rem;
}

/* Section Titles */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-subtle);
    position: relative;
}

.section-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background-color: var(--brand-primary);
}

.section-title {
    font-family: var(--font-serif);
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-more {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-primary);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.section-more:hover {
    color: var(--brand-primary-hover);
    transform: translateX(3px);
}

/* Footer */
.site-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    padding: 3.5rem 0 2rem;
    margin-top: auto;
    color: var(--text-secondary);
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
    gap: 2.5rem;
    margin-bottom: 3rem;
}

.footer-brand .site-title {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.footer-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.footer-title {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer-links a:hover {
    color: var(--brand-primary);
}

.footer-bottom {
    border-top: 1px solid var(--border-subtle);
    padding-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .header-main {
        grid-template-columns: 1fr auto;
    }
    .header-brand {
        text-align: left;
    }
    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
}

@media (max-width: 640px) {
    .site-title {
        font-size: 2rem;
    }
    .top-bar-inner {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-start;
    }
    .footer-grid {
        grid-template-columns: 1fr;
    }
    .footer-bottom {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
}

/* ==========================================================================
   Contrast & Theme Invariant Button & Form Styling
   Guarantees 100% legibility in both Light & Dark modes
   ========================================================================== */
.btn-outline-secondary,
a.btn-outline-secondary,
button.btn-outline-secondary {
    color: var(--text-primary) !important;
    border-color: var(--border-strong) !important;
    background-color: transparent !important;
    transition: all var(--transition-fast);
}

.btn-outline-secondary:hover,
a.btn-outline-secondary:hover,
button.btn-outline-secondary:hover {
    background-color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    color: #ffffff !important;
}

[data-theme="dark"] .btn-outline-secondary,
[data-theme="dark"] a.btn-outline-secondary,
[data-theme="dark"] button.btn-outline-secondary {
    color: #f8fafc !important;
    border-color: var(--border-strong) !important;
}

/* Ensure inputs and search controls adapt gracefully to current theme */
.form-control {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-strong) !important;
}

.form-control::placeholder {
    color: var(--text-muted) !important;
    opacity: 0.85;
}

.form-control:focus {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--brand-primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(185, 28, 28, 0.2) !important;
}

/* Fix accidental white-on-white text in light mode */
[data-theme="light"] .newsletter-widget .text-white,
body:not([data-theme="dark"]) .newsletter-widget .text-white {
    color: var(--text-primary) !important;
}

/* ==========================================================================
   Buy Us a Coffee - Header Button & Floating Widget (Live-Chat Style)
   ========================================================================== */

/* Top Bar Coffee Button */
.buy-coffee-btn-top {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff !important;
    font-weight: 700;
    font-size: 0.78rem;
    padding: 0.32rem 0.85rem;
    border-radius: 9999px;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, opacity 0.2s ease;
    animation: coffeeHeaderBlink 2.6s infinite ease-in-out;
    border: 1px solid rgba(255, 255, 255, 0.25);
    white-space: nowrap;
}

.buy-coffee-btn-top:hover {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.55);
    color: #ffffff !important;
    animation-play-state: paused;
}

@keyframes coffeeHeaderBlink {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6), 0 2px 8px rgba(217, 119, 6, 0.35);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0), 0 3px 12px rgba(217, 119, 6, 0.55);
        opacity: 0.9;
    }
}

/* Floating Circular Coffee Widget (Live Chat Style across entire site) */
.floating-coffee-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
    color: #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    box-shadow: 0 8px 24px rgba(180, 83, 9, 0.45), 0 2px 6px rgba(0, 0, 0, 0.2);
    z-index: 1060;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    animation: floatingWidgetFloat 3.2s infinite ease-in-out;
    border: 2px solid rgba(255, 255, 255, 0.35);
}

.floating-coffee-widget:hover {
    transform: scale(1.12) translateY(-2px);
    box-shadow: 0 12px 30px rgba(180, 83, 9, 0.6), 0 4px 12px rgba(0, 0, 0, 0.25);
    color: #ffffff !important;
    animation-play-state: paused;
}

.floating-coffee-widget .coffee-icon {
    font-size: 1.75rem;
    line-height: 1;
    display: inline-block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.floating-coffee-widget:hover .coffee-icon {
    transform: rotate(-12deg) scale(1.15);
}

/* Floating Label: Always visible by default; hides smoothly on hover (reverse) */
.floating-coffee-widget .coffee-label {
    position: absolute;
    right: 70px;
    background: #1e293b;
    color: #ffffff;
    font-size: 0.84rem;
    font-weight: 700;
    padding: 0.45rem 0.95rem;
    border-radius: 8px;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.25s;
    pointer-events: auto;
    font-family: var(--font-sans);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    animation: coffeeLabelPulse 3.2s infinite ease-in-out;
}

.floating-coffee-widget .coffee-label::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent transparent #1e293b;
}

/* On hover: The label slides away / disappears into the button (reverse behavior) */
.floating-coffee-widget:hover .coffee-label {
    opacity: 0;
    visibility: hidden;
    transform: translateX(14px) scale(0.92);
    pointer-events: none;
    animation-play-state: paused;
}

@keyframes coffeeLabelPulse {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(245, 158, 11, 0.35);
    }
    50% {
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35), 0 0 0 5px rgba(245, 158, 11, 0.12);
    }
}

/* Subtle Radar Pulse Ring */
.floating-coffee-widget .coffee-ripple {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid #f59e0b;
    animation: coffeeWidgetRadar 2.5s infinite cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
}

@keyframes coffeeWidgetRadar {
    0% {
        transform: scale(0.95);
        opacity: 0.85;
    }
    70% {
        transform: scale(1.45);
        opacity: 0;
    }
    100% {
        transform: scale(1.55);
        opacity: 0;
    }
}

@keyframes floatingWidgetFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

/* Responsive adjustment for floating widget on mobile */
@media (max-width: 576px) {
    .floating-coffee-widget {
        bottom: 18px;
        right: 16px;
        width: 50px;
        height: 50px;
    }
    .floating-coffee-widget .coffee-icon {
        font-size: 1.5rem;
    }
    .floating-coffee-widget .coffee-label {
        right: 60px;
        font-size: 0.76rem;
        padding: 0.35rem 0.7rem;
    }
}


