/* ==========================================================================
   DangerousFacts.com - Main Stylesheet
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens
   -------------------------------------------------------------------------- */
:root {
    /* Color System - Slate Scale */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    /* Semantic Colors */
    --red-50: #fef2f2;
    --red-100: #fee2e2;
    --red-500: #ef4444;
    --red-600: #dc2626;

    --green-50: #f0fdf4;
    --green-100: #dcfce7;
    --green-500: #22c55e;
    --green-600: #16a34a;

    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;

    --amber-50: #fffbeb;
    --amber-100: #fef3c7;
    --amber-500: #f59e0b;
    --amber-600: #d97706;

    --purple-50: #faf5ff;
    --purple-100: #f3e8ff;
    --purple-500: #a855f7;
    --purple-600: #9333ea;

    --teal-500: #14b8a6;
    --teal-600: #0d9488;

    /* Category Colors */
    --cat-demographics: #3b82f6;
    --cat-economics: #22c55e;
    --cat-geopolitics: #ef4444;
    --cat-environment: #14b8a6;
    --cat-health: #a855f7;
    --cat-politics: #f59e0b;

    /* Glow Effects */
    --red-glow: rgba(239, 68, 68, 0.25);
    --blue-glow: rgba(59, 130, 246, 0.25);
    --amber-glow: rgba(245, 158, 11, 0.25);
    --purple-glow: rgba(168, 85, 247, 0.25);
    --green-glow: rgba(34, 197, 94, 0.25);

    /* Spacing Scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 32px;
    --space-4xl: 40px;

    /* Typography Scale */
    --text-xs: clamp(0.7rem, 0.65rem + 0.25vw, 0.75rem);
    --text-sm: clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);
    --text-base: clamp(0.9rem, 0.85rem + 0.25vw, 1rem);
    --text-lg: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
    --text-xl: clamp(1.125rem, 1rem + 0.5vw, 1.25rem);
    --text-2xl: clamp(1.25rem, 1rem + 1vw, 1.5rem);
    --text-3xl: clamp(1.5rem, 1.25rem + 1.25vw, 1.875rem);
    --text-hero: clamp(2rem, 1.5rem + 2vw, 3rem);

    /* Letter Spacing */
    --tracking-tight: -0.03em;
    --tracking-normal: 0;
    --tracking-wide: 0.05em;
    --tracking-wider: 0.1em;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);

    /* Layout */
    --max-width: 1200px;
    --content-width: 800px;
    --header-height: 60px;

    /* Safe Areas */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* --------------------------------------------------------------------------
   2. Base Reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(180deg, var(--slate-900) 0%, var(--slate-800) 100%);
    color: var(--slate-200);
    line-height: 1.65;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Gradient mesh background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(at 20% 30%, var(--blue-500) 0px, transparent 50%),
        radial-gradient(at 80% 10%, var(--purple-500) 0px, transparent 50%),
        radial-gradient(at 50% 80%, var(--blue-600) 0px, transparent 50%);
    filter: blur(120px);
    opacity: 0.15;
    pointer-events: none;
    z-index: -1;
}

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

a {
    color: var(--blue-500);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--blue-400);
}

/* Focus styles */
:focus-visible {
    outline: 2px solid var(--blue-500);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   3. Skip Link (Accessibility)
   -------------------------------------------------------------------------- */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--blue-600);
    color: white;
    padding: var(--space-sm) var(--space-lg);
    z-index: 1000;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 var(--radius-sm) 0;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid var(--amber-500);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   4. Site Header
   -------------------------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
}

/* Logo */
.site-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: white;
    text-decoration: none;
    font-weight: 800;
    font-size: var(--text-lg);
    letter-spacing: var(--tracking-tight);
}

.site-logo:hover {
    color: white;
}

.logo-icon {
    font-size: 1.5em;
}

/* Navigation */
.site-nav {
    display: none;
    gap: var(--space-xs);
}

@media (min-width: 768px) {
    .site-nav {
        display: flex;
    }
}

.nav-link {
    padding: var(--space-sm) var(--space-md);
    color: var(--slate-400);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: white;
    background: var(--blue-600);
}

/* Header actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Mobile menu button */
.mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--slate-400);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.mobile-menu-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

@media (min-width: 768px) {
    .mobile-menu-btn {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   5. Theme Toggle
   -------------------------------------------------------------------------- */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--slate-400);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
    transform: rotate(15deg);
}

/* Icon visibility - default dark mode (sun visible) */
.theme-toggle .icon-sun {
    display: block;
}

.theme-toggle .icon-moon {
    display: none;
}

/* Light mode: show moon */
[data-theme="light"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
    display: block;
}

/* --------------------------------------------------------------------------
   6. Main Content Area
   -------------------------------------------------------------------------- */
.main-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-lg);
}

/* --------------------------------------------------------------------------
   7. Article Cards
   -------------------------------------------------------------------------- */
.article-card {
    background: var(--slate-800);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.article-card a {
    display: block;
    padding: var(--space-2xl);
    color: inherit;
    text-decoration: none;
}

.card-category {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    background: rgba(59, 130, 246, 0.15);
    color: var(--blue-400);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
}

/* Category-specific colors */
.card-category.demographics { background: rgba(59, 130, 246, 0.15); color: var(--cat-demographics); }
.card-category.economics { background: rgba(34, 197, 94, 0.15); color: var(--cat-economics); }
.card-category.geopolitics { background: rgba(239, 68, 68, 0.15); color: var(--cat-geopolitics); }
.card-category.environment { background: rgba(20, 184, 166, 0.15); color: var(--cat-environment); }
.card-category.health { background: rgba(168, 85, 247, 0.15); color: var(--cat-health); }
.card-category.politics { background: rgba(245, 158, 11, 0.15); color: var(--cat-politics); }

.card-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: white;
    margin-bottom: var(--space-sm);
    line-height: 1.3;
    letter-spacing: var(--tracking-tight);
}

.card-excerpt {
    font-size: var(--text-base);
    color: var(--slate-400);
    line-height: 1.6;
    margin-bottom: var(--space-lg);
}

.card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: var(--text-sm);
    color: var(--slate-500);
}

.card-meta time {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Article grid */
.articles-grid {
    display: grid;
    gap: var(--space-2xl);
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .articles-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* --------------------------------------------------------------------------
   8. Featured Article
   -------------------------------------------------------------------------- */
.featured-article {
    background: linear-gradient(135deg, var(--slate-800) 0%, var(--slate-900) 100%);
    border-radius: var(--radius-xl);
    padding: var(--space-3xl);
    margin-bottom: var(--space-3xl);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.featured-article .card-category {
    font-size: var(--text-sm);
}

.featured-article .card-title {
    font-size: var(--text-3xl);
    margin-bottom: var(--space-lg);
}

.featured-article .card-excerpt {
    font-size: var(--text-lg);
    max-width: 600px;
}

.featured-article .read-more {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-xl);
    padding: var(--space-md) var(--space-xl);
    background: var(--blue-600);
    color: white;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: background 0.2s ease;
}

.featured-article .read-more:hover {
    background: var(--blue-500);
    color: white;
}

/* --------------------------------------------------------------------------
   9. Category Pills
   -------------------------------------------------------------------------- */
.category-nav {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-3xl);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

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

.category-pill {
    flex-shrink: 0;
    padding: var(--space-sm) var(--space-lg);
    background: var(--slate-800);
    color: var(--slate-400);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-xl);
    border: 1px solid var(--slate-700);
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.category-pill:hover {
    color: white;
    border-color: var(--slate-600);
}

.category-pill.active {
    background: var(--blue-600);
    color: white;
    border-color: var(--blue-600);
}

/* --------------------------------------------------------------------------
   10. Section Headers
   -------------------------------------------------------------------------- */
.section-header {
    margin-bottom: var(--space-2xl);
}

.section-title {
    font-size: var(--text-2xl);
    font-weight: 800;
    color: white;
    letter-spacing: var(--tracking-tight);
    margin-bottom: var(--space-xs);
}

.section-subtitle {
    font-size: var(--text-base);
    color: var(--slate-500);
}

/* --------------------------------------------------------------------------
   11. Newsletter Signup
   -------------------------------------------------------------------------- */
.newsletter-section {
    background: linear-gradient(135deg, var(--slate-800) 0%, var(--slate-900) 100%);
    border-radius: var(--radius-xl);
    padding: var(--space-3xl);
    margin-top: var(--space-4xl);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.newsletter-section h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: white;
    margin-bottom: var(--space-sm);
}

.newsletter-section p {
    color: var(--slate-400);
    margin-bottom: var(--space-xl);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.newsletter-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    max-width: 400px;
    margin: 0 auto;
}

@media (min-width: 480px) {
    .newsletter-form {
        flex-direction: row;
    }
}

.newsletter-form input[type="email"] {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    background: var(--slate-700);
    border: 1px solid var(--slate-600);
    border-radius: var(--radius-md);
    color: white;
    font-size: var(--text-base);
}

.newsletter-form input[type="email"]::placeholder {
    color: var(--slate-500);
}

.newsletter-form input[type="email"]:focus {
    outline: none;
    border-color: var(--blue-500);
}

.newsletter-form button {
    padding: var(--space-md) var(--space-xl);
    background: var(--blue-600);
    color: white;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.newsletter-form button:hover {
    background: var(--blue-500);
}

/* Disabled/coming soon state */
.newsletter-section.coming-soon {
    opacity: 0.7;
}

.newsletter-section.coming-soon input,
.newsletter-section.coming-soon button {
    pointer-events: none;
    opacity: 0.5;
}

.coming-soon-badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    background: var(--amber-500);
    color: var(--slate-900);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-lg);
}

/* --------------------------------------------------------------------------
   12. Site Footer
   -------------------------------------------------------------------------- */
.site-footer {
    margin-top: var(--space-4xl);
    padding: var(--space-3xl) var(--space-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xl);
    text-align: center;
}

.footer-nav {
    display: flex;
    gap: var(--space-xl);
}

.footer-nav a {
    color: var(--slate-500);
    font-size: var(--text-sm);
    transition: color 0.2s ease;
}

.footer-nav a:hover {
    color: white;
}

.footer-text {
    color: var(--slate-600);
    font-size: var(--text-sm);
}

.footer-tagline {
    color: var(--slate-500);
    font-size: var(--text-xs);
    font-style: italic;
}

/* --------------------------------------------------------------------------
   13. Light Mode Overrides
   -------------------------------------------------------------------------- */
[data-theme="light"] body {
    background: linear-gradient(180deg, var(--slate-100) 0%, var(--slate-200) 100%);
    color: var(--slate-700);
}

[data-theme="light"] body::before {
    opacity: 0.3;
}

[data-theme="light"] .site-header {
    background: rgba(248, 250, 252, 0.95);
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .site-logo {
    color: var(--slate-900);
}

[data-theme="light"] .site-logo:hover {
    color: var(--slate-900);
}

[data-theme="light"] .nav-link {
    color: var(--slate-600);
}

[data-theme="light"] .nav-link:hover {
    color: var(--slate-900);
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .theme-toggle {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--slate-600);
}

[data-theme="light"] .theme-toggle:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--slate-900);
}

[data-theme="light"] .article-card {
    background: white;
    box-shadow: var(--shadow-md);
}

[data-theme="light"] .card-title {
    color: var(--slate-900);
}

[data-theme="light"] .card-excerpt {
    color: var(--slate-600);
}

[data-theme="light"] .featured-article {
    background: white;
    border-color: rgba(0, 0, 0, 0.05);
    box-shadow: var(--shadow-lg);
}

[data-theme="light"] .category-pill {
    background: white;
    border-color: var(--slate-200);
    color: var(--slate-600);
}

[data-theme="light"] .category-pill:hover {
    color: var(--slate-900);
    border-color: var(--slate-300);
}

[data-theme="light"] .newsletter-section {
    background: white;
    border-color: rgba(0, 0, 0, 0.05);
    box-shadow: var(--shadow-lg);
}

[data-theme="light"] .newsletter-form input[type="email"] {
    background: var(--slate-100);
    border-color: var(--slate-300);
    color: var(--slate-900);
}

[data-theme="light"] .section-title {
    color: var(--slate-900);
}

[data-theme="light"] .site-footer {
    border-top-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .footer-nav a {
    color: var(--slate-600);
}

[data-theme="light"] .footer-nav a:hover {
    color: var(--slate-900);
}

/* --------------------------------------------------------------------------
   14. Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --------------------------------------------------------------------------
   15. Utilities
   -------------------------------------------------------------------------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
