/* --- 1. VARIABLES & THEME --- */
:root {
    --font-main: 'Outfit', sans-serif;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-sub: #6b7280;
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.3);
    --border: #e5e7eb;
    --header-bg: rgba(255, 255, 255, 0.85);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-body: #0b0f19;
    --bg-card: #151b2b;
    --text-main: #f3f4f6;
    --text-sub: #9ca3af;
    --primary: #60a5fa;
    --primary-glow: rgba(96, 165, 250, 0.2);
    --border: #2d3748;
    --header-bg: rgba(11, 15, 25, 0.85);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

/* --- 2. BASE & RESET --- */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

a { 
    text-decoration: none; 
    color: inherit; 
}

/* --- 3. HEADER (GLASSMORPHISM) --- */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
}

.header-top {
    width: 100%;
    max-width: 1400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-weight: 800;
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--text-main), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.03em;
}

/* Theme Button */
.theme-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 40px; 
    height: 40px;
    border-radius: 50%;
    display: flex; 
    align-items: center; 
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
    font-size: 1.2rem;
}

.theme-btn:hover { 
    transform: rotate(15deg) scale(1.1); 
}

/* --- 4. FILTERS SCROLLABLE --- */
.filters-container {
    width: 100%;
    max-width: 1400px;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: none; 
    -ms-overflow-style: none;
}

.filters-container::-webkit-scrollbar { 
    display: none; 
}

.nav-pills {
    display: flex;
    gap: 10px;
    white-space: nowrap;
}

.pill {
    padding: 8px 20px;
    border-radius: 100px;
    background: var(--bg-card);
    color: var(--text-sub);
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid var(--border);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: pointer;
}

.pill:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* --- 5. GRID & CARDS --- */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 20px;
    flex: 1;
    width: 100%;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    opacity: 0; 
    animation: slideUp 0.6s ease-out forwards;
}

/* Cascade animation delays */
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.card-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg-body);
    overflow: hidden;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card:hover .card-img { 
    transform: scale(1.05); 
}

.card-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    color: white;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    z-index: 2;
}

.card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-date {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.4;
    margin-bottom: 12px;
    color: var(--text-main);
    display: -webkit-box; 
    -webkit-line-clamp: 3; 
    -webkit-box-orient: vertical; 
    overflow: hidden;
}

.card-desc {
    font-size: 0.95rem;
    color: var(--text-sub);
    line-height: 1.6;
    margin-bottom: 20px;
    flex-grow: 1;
    display: -webkit-box; 
    -webkit-line-clamp: 4; 
    -webkit-box-orient: vertical; 
    overflow: hidden;
}

.card-source {
    padding-top: 15px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-sub);
}

/* --- 6. LOADING SKELETON --- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--border) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading { 
    0% { background-position: 200% 0; } 
    100% { background-position: -200% 0; } 
}

@keyframes slideUp { 
    from { opacity: 0; transform: translateY(20px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* --- 7. FOOTER --- */
footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-sub);
    font-size: 0.9rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

/* --- 8. EMPTY STATE --- */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 2px dashed var(--border);
}

.empty-state h3 {
    margin-bottom: 10px;
    color: var(--text-main);
}

.empty-state p {
    color: var(--text-sub);
}

/* --- 9. LOADING INDICATOR --- */
.loading-indicator {
    position: fixed;
    top: 70px;
    right: 20px;
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 4px 12px var(--primary-glow);
    z-index: 99;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s;
}

.loading-indicator.show {
    opacity: 1;
    transform: translateY(0);
}

/* --- 10. RESPONSIVE --- */
@media (max-width: 768px) {
    h1 {
        font-size: 1.4rem;
    }
    
    .news-grid {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 20px 15px;
    }
}
