@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --secondary: #a855f7;
    --bg: #0b0f1a;
    --card-bg: rgba(23, 28, 41, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --success: #10b981;
    --bg-dark: #0f172a;
    --accent-primary: #6366f1;
    --accent-secondary: #a855f7;
    --text-light: #f8fafc;
    --text-dim: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --font-main: 'Nunito', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: radial-gradient(circle at 50% -20%, #1e1b4b 0%, var(--bg) 80%);
    color: var(--text);
    font-family: 'Outfit', 'Inter', system-ui, sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 4rem;
    position: relative;
}

h1 {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: -0.06em;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #a5b4fc 0%, #c084fc 50%, #818cf8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 30px rgba(129, 140, 248, 0.2));
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.25rem;
    font-weight: 400;
    opacity: 0.8;
}

.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 3rem;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
}

.filter-select {
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 0.9rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    outline: none;
}

.filter-select:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
}

.filter-select option {
    background: #0f172a;
    color: white;
}

.kg-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none !important;
    font-weight: 600;
}

.filter-btn {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 0.6rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    backdrop-filter: blur(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-size: 0.9rem;
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
}

#news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 2.5rem;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.article-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    backdrop-filter: blur(16px);
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.article-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 100%);
    pointer-events: none;
}

.article-card:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(99, 102, 241, 0.1);
}

.source-badge {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
    border: 1px solid rgba(165, 180, 252, 0.1);
    color: #a5b4fc;
    padding: 0.4rem 1rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
    display: inline-block;
}

.article-title {
    font-size: 1.4rem;
    margin-bottom: 1.25rem;
    font-weight: 800;
    line-height: 1.3;
}

.article-description {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 2rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.consensus-meter {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.consensus-fill {
    height: 100%;
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

/* Modal Improvements */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    inset: 0;
    background: rgba(5, 8, 15, 0.85);
    backdrop-filter: blur(12px);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.modal.show {
    display: block;
    opacity: 1;
}

.modal-content {
    background: rgba(15, 20, 35, 0.95);
    margin: 4vh auto;
    padding: 3rem;
    border: 1px solid var(--glass-border);
    width: 90%;
    max-width: 1000px;
    border-radius: 32px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
    transform: translateY(30px);
    transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.modal.show .modal-content {
    transform: translateY(0);
}

.common-facts {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(168, 85, 247, 0.05) 100%);
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    margin-bottom: 3rem;
}

.fact-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.fact-item::before {
    content: '✦';
    color: var(--primary);
    font-weight: bold;
}

.source-item {
    background: rgba(255, 255, 255, 0.02);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    margin-top: 1rem;
    transition: background 0.3s ease;
}

.source-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.source-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(99, 102, 241, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 4rem auto;
}

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

/* Splash Screen */
#loading-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #05080f;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-splash.hidden {
    opacity: 0;
    visibility: hidden;
}

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

    h1 {
        font-size: 2.8rem;
    }

    #news-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }

    .modal-content {
        padding: 1.5rem;
        border-radius: 20px;
    }
}