/* ===== PERFORMANCE OPTIMIZATION ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    max-width: 100vw;
}

/* Wrapping all content to prevent horizontal scroll instead of root body */
.site-wrapper {
    overflow-x: clip;
    width: 100%;
}

/* ===== CSS VARIABLES FOR THEMING ===== */
:root[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --accent-primary: #2563eb;
    --accent-secondary: #3b82f6;
    --border-color: #e5e7eb;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
}

:root[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    /* Solid color for Hard Colour look */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-secondary: #60a5fa;
    --border-color: #334155;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ===== BASE STYLES ===== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: transparent;
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== HEADER ===== */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    height: auto;
    width: 150px;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-decoration: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--accent-primary);
    color: white;
}

/* ===== HERO SECTION ===== */
.hero {
    background: transparent;
    padding: 4rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Optional subtle overlay for better text readability */
.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 0;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    color: white;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    word-wrap: break-word;
}

.hero p {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 2rem;
}

/* ===== SEARCH & FILTER SECTION ===== */
.search-filter-section {
    background-color: var(--bg-card) !important;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    position: -webkit-sticky;
    position: sticky;
    top: 183px;
    /* Measured height of header on desktop */
    z-index: 995;
}

@media (max-width: 768px) {
    .search-filter-section {
        top: 84px;
        /* Measured height of ultra-slim header on mobile */
        padding: 1rem;
    }
}

.search-filter-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 100px;
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.search-box input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

.search-box button {
    padding: 0.75rem 1.5rem;
    background: var(--accent-primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
}

.search-box button:hover {
    background: var(--accent-secondary);
}

.category-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .category-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }

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

    .filter-btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

.filter-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* ===== MAIN CONTENT ===== */
.main-container {
    max-width: 1400px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
}

/* ===== FEATURED ARTICLE ===== */
.featured-article {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    transition: all 0.3s;
}

.featured-article:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.featured-thumbnail {
    width: 100%;
    height: 300px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.featured-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.featured-badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: var(--accent-primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    z-index: 2;
    pointer-events: none;
    /* Don't block clicks */
}

/* Make featured thumbnail link clickable */
.featured-thumbnail a {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

/* Make featured title link clickable and preserve styling */
.featured-content a {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

.featured-content a:hover {
    opacity: 0.8;
}

.featured-content {
    padding: 2rem;
}

.featured-category {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.featured-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.featured-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.7;
}

.read-more-btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: var(--accent-primary);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s;
}

.read-more-btn:hover {
    background: var(--accent-secondary);
    transform: translateX(4px);
}

/* ===== ARTICLES GRID ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.article-card {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    .article-card:hover {
        box-shadow: var(--shadow-hover);
        transform: translateY(-4px);
    }
}

.article-thumbnail {
    width: 100%;
    height: 180px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
}

.article-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-body {
    padding: 1.25rem;
}

.article-category {
    color: var(--accent-primary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.article-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.article-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.article-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: gap 0.3s;
}

.article-link:hover {
    gap: 0.5rem;
}

/* ===== SIDEBAR ===== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-widget {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.widget-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.category-list {
    list-style: none;
}

.category-list li {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
}

@media (hover: hover) and (pointer: fine) {
    .category-list li:hover {
        background: var(--bg-secondary);
        padding-left: 1rem;
    }
}

.category-list li:last-child {
    border-bottom: none;
}

.category-name {
    color: var(--text-primary);
    font-weight: 500;
}

.category-count {
    background: var(--accent-primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr;
    }

    /* Target sidebar explicitly: keep articles first by NOT using order: -1 */
    .sidebar {
        margin-top: 2rem;
    }

    .articles-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: row;
        justify-content: space-between;
        gap: 0.25rem;
        padding: 0.25rem 1rem;
        /* Quartered top/bottom padding for ultra-slim height */
        width: 100%;
        box-sizing: border-box;
    }

    .logo {
        max-width: 75px;
        /* Further reduced logo size on mobile */
        height: auto;
    }

    .site-title {
        display: none;
        /* Logo already has the text on mobile */
    }

    .theme-text {
        display: none;
        /* Just show icon */
    }

    .theme-toggle {
        padding: 0.5rem;
        /* Tighter padding for icon-only */
    }

    .header-actions {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .hero {
        padding: 3rem 1.5rem;
        width: 100%;
        box-sizing: border-box;
    }

    .search-filter-container {
        flex-direction: column;
        width: 100%;
        box-sizing: border-box;
    }

    .search-box {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .main-container {
        padding: 0 1rem;
        width: 100%;
        box-sizing: border-box;
    }

    .articles-grid {
        grid-template-columns: 1fr;
        width: 100%;
        box-sizing: border-box;
    }

    .featured-thumbnail {
        height: 200px;
    }
}

/* ===== LOADING ANIMATION ===== */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

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

/* ===== NO RESULTS ===== */
.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.no-results.hidden {
    display: none;
}

.article-container {
    max-width: 800px;
    width: 100%;
    margin: 2rem auto;
    padding: 3rem;
    background-color: var(--bg-card);
    /* Dark blue sheet in dark mode */
    border-radius: 12px;
    box-shadow: var(--shadow);
    color: var(--text-primary);
    position: relative;
    z-index: 10;
}

@media (max-width: 768px) {
    .article-container {
        padding: 1.5rem;
        margin: 1rem auto;
        border-radius: 8px;
        max-width: 100%;
        box-sizing: border-box;
    }
}

.article-content {
    line-height: 1.8;
    font-size: 1.1rem;
}

@media (max-width: 768px) {
    .article-content {
        font-size: 1.05rem;
    }
}

/* ===== CUSTOM CURSOR ===== */
@media (hover: hover) and (pointer: fine) {
    body {
        cursor: none;
    }

    a,
    button,
    input,
    textarea,
    select,
    .clickable {
        cursor: none;
    }

    .custom-cursor {
        position: fixed;
        top: -100px;
        left: -100px;
        width: 20px;
        height: 20px;
        border: 2px solid var(--accent-primary);
        border-radius: 50%;
        transform: translate(-50%, -50%);
        pointer-events: none;
        z-index: 9999;
        transition: width 0.2s, height 0.2s, background-color 0.2s;
        mix-blend-mode: difference;
    }

    .custom-cursor.clicking {
        width: 15px;
        height: 15px;
        background-color: var(--accent-secondary);
        border-color: transparent;
    }

    .custom-cursor.hovering {
        width: 40px;
        height: 40px;
        background-color: rgba(59, 130, 246, 0.1);
        border-color: var(--accent-secondary);
        border-width: 1px;
    }

    .cursor-trail {
        position: fixed;
        width: 8px;
        height: 8px;
        background-color: var(--accent-primary);
        border-radius: 50%;
        pointer-events: none;
        transform: translate(-50%, -50%);
        z-index: 9998;
        mix-blend-mode: screen;
        transition: opacity 0.1s;
    }
}

/* ===== HAMBURGER MENU ===== */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 250px;
    height: 100vh;
    background: var(--bg-card);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    padding: 2rem;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-close {
    align-self: flex-end;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.mobile-menu a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Base styles adjustments for header links */
.header-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.header-links a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.header-links a:hover {
    color: var(--accent-primary);
}

@media (max-width: 768px) {
    .hamburger {
        display: block;
    }

    .header-links {
        display: none;
    }
}