/* ============================================
   BLOG HUB - COMPLETELY NEW DESIGN
   Magazine-Style Modern Layout
   ============================================ */

/* Design Tokens - CLAUDE.md Compliant */
:root {
    --bg: #FFFFFF;
    --surface: #F8F9FB;
    --card: #FFFFFF;
    --text-primary: #0F1724;
    --text-muted: #6B7280;
    --accent: #0EA5E9;
    --border: #E5E7EB;

    /* Extended palette */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;

    /* Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;

    /* Shadows - subtle only */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    /* Transitions - Per CLAUDE.md */
    --transition: 240ms cubic-bezier(0.22, 1, 0.36, 1);
    --transition-slow: 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Dark mode application */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0B1220;
        --surface: #0F1724;
        --card: #111827;
        --text-primary: #E5E7EB;
        --text-muted: #9CA3AF;
        --accent: #38BDF8;
        --border: #1F2937;
        --gray-100: #1F2937;
    }
}

/* Explicit theme classes scoped to blog only (header unaffected) */
#blog-theme-scope.blog-dark {
    --bg: #0B1220;
    --surface: #0F1724;
    --card: #111827;
    --text-primary: #E5E7EB;
    --text-muted: #9CA3AF;
    --accent: #38BDF8;
    --border: #1F2937;
    --gray-100: #1F2937;
}

#blog-theme-scope.blog-light {
    --bg: #FFFFFF;
    --surface: #F8F9FB;
    --card: #FFFFFF;
    --text-primary: #0F1724;
    --text-muted: #6B7280;
    --accent: #0EA5E9;
    --border: #E5E7EB;
    --gray-100: #F3F4F6;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    background: var(--surface);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container-wide {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

/* ============================================
   HERO SECTION
   ============================================ */
.blog-hero {
    position: relative;
    padding: var(--space-20) 0 var(--space-16);
    background: var(--bg);
    overflow: hidden;
    scroll-margin-top: 100px; /* Account for sticky header */
}

/* Wait for header to load, then adjust spacing */
#header-placeholder:not(:empty) ~ .blog-hero {
    padding-top: calc(var(--space-20) + 100px);
}

.hero-grid {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-6);
    position: relative;
}

.hero-main {
    max-width: 700px;
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.eyebrow-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

.eyebrow-text {
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hero-heading {
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-6);
    color: var(--text-primary);
}

.hero-lead {
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: var(--space-10);
    max-width: 600px;
}

.hero-stats {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    padding: var(--space-6) 0;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: var(--space-2);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: var(--border);
}

/* Decorative Cards */
.hero-decoration {
    position: absolute;
    top: 50%;
    right: 5%;
    transform: translateY(-50%);
    width: 400px;
    height: 400px;
    pointer-events: none;
}

.deco-card {
    position: absolute;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    opacity: 0.9;
    transition: transform var(--transition-slow);
}

.deco-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.deco-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.15;
    z-index: 0;
}

.deco-card i {
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.deco-1 {
    width: 200px;
    height: 250px;
    top: 0;
    right: 0;
    animation: float 6s ease-in-out infinite;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.05) 0%, rgba(14, 165, 233, 0.15) 100%);
}

.deco-1::before {
    background-image: url('https://images.unsplash.com/photo-1456324504439-367cee3b3c32?w=400&q=80');
}

.deco-1 i {
    font-size: 4rem;
    background: linear-gradient(135deg, var(--accent) 0%, #0284c7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.deco-2 {
    width: 150px;
    height: 180px;
    top: 50%;
    right: 30%;
    animation: float 8s ease-in-out infinite reverse;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05) 0%, rgba(245, 158, 11, 0.15) 100%);
}

.deco-2::before {
    background-image: url('https://images.unsplash.com/photo-1502920917128-1aa500764cbd?w=400&q=80');
}

.deco-2 i {
    font-size: 3rem;
    color: #F59E0B;
}

.deco-3 {
    width: 120px;
    height: 140px;
    bottom: 0;
    right: 10%;
    animation: float 7s ease-in-out infinite;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(16, 185, 129, 0.15) 100%);
}

.deco-3::before {
    background-image: url('https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=400&q=80');
}

.deco-3 i {
    font-size: 2.5rem;
    color: #10B981;
}

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

/* ============================================
   ARTICLES CONTROLS (Moved to Articles Section)
   ============================================ */
.articles-controls {
    margin-bottom: var(--space-8);
    padding: var(--space-6);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
}

.search-container {
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
    margin: 0 auto;
    position: relative;
    width: 75%;
    margin-bottom: var(--space-4);
}

.search-field {
    width: 100%;
    padding: var(--space-3) var(--space-4) var(--space-3) var(--space-10);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg);
    transition: all var(--transition);
}

.search-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.search-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.controls-row {
    display: flex;
    gap: var(--space-4);
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.filter-tabs {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    flex: 1;
}

.tab-btn {
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition);
    position: relative;
}

.tab-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
}

/* Sort Dropdown */
.sort-container {
    position: relative;
    min-width: 160px;
}

.sort-select {
    width: 100%;
    padding: var(--space-2) var(--space-8) var(--space-2) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg);
    cursor: pointer;
    appearance: none;
    transition: all var(--transition);
}

.sort-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.sort-icon {
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 0.75rem;
}

/* ============================================
   FEATURED SECTION
   ============================================ */
.featured-section {
    padding: var(--space-16) 0;
    background: var(--bg);
}

.featured-wrapper {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-2xl);
    overflow: hidden;
    transition: all var(--transition-slow);
}

.featured-wrapper:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.featured-badge {
    position: absolute;
    top: var(--space-6);
    left: var(--space-6);
    z-index: 10;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    box-shadow: var(--shadow-md);
}

.featured-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 0;
}

.featured-visual {
    position: relative;
    overflow: hidden;
}

.featured-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.featured-wrapper:hover .featured-visual img {
    transform: scale(1.05);
}

.featured-body {
    padding: var(--space-10);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.featured-meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    font-size: 0.875rem;
}

.meta-category {
    color: var(--text-primary);
    font-weight: 600;
}

.meta-dot {
    color: var(--text-muted);
}

.meta-read {
    color: var(--text-muted);
}

.featured-title {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-4);
    color: var(--text-primary);
}

.featured-description {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-muted);
    margin-bottom: var(--space-8);
}

.featured-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.author-block {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.author-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.author-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.author-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.featured-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    background: var(--accent);
    color: var(--bg);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9375rem;
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.featured-btn:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.featured-btn i {
    transition: transform var(--transition);
}

.featured-btn:hover i {
    transform: translateX(4px);
}

/* ============================================
   ARTICLES SECTION
   ============================================ */
.articles-section {
    padding: var(--space-16) 0 var(--space-20);
    background: var(--surface);
}

.section-header {
    text-align: center;
    margin-bottom: var(--space-12);
}

.section-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: var(--space-3);
    color: var(--text-primary);
}

.section-subtitle {
    font-size: 1.125rem;
    color: var(--text-muted);
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--space-8);
    perspective: 1000px;
}

.article-item {
    opacity: 0;
    transform: translateY(30px);
    transition: all var(--transition-slow);
}

.article-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.article-link {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: all var(--transition-slow);
    height: 100%;
    transform-style: preserve-3d;
    position: relative;
}

.article-link::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.05) 0%, rgba(14, 165, 233, 0) 50%);
    opacity: 0;
    transition: opacity var(--transition);
    z-index: 1;
    pointer-events: none;
}

.article-link:hover {
    transform: translateY(-12px) rotateX(5deg) rotateY(-3deg) scale(1.02);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.15),
        0 0 0 1px var(--accent);
    border-color: var(--accent);
}

.article-link:hover::before {
    opacity: 1;
}

.article-thumb {
    position: relative;
    aspect-ratio: 16/10;
    overflow: hidden;
}

.article-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
    transform-origin: center center;
}

.article-link:hover .article-thumb img {
    transform: scale(1.15) translateZ(20px);
}

.thumb-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.3) 0%, transparent 50%);
}

.article-content {
    padding: var(--space-6);
    position: relative;
    z-index: 2;
    transition: transform var(--transition-slow);
}

.article-link:hover .article-content {
    transform: translateZ(30px);
}

.article-tag {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    background: var(--gray-100);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-3);
    transition: all var(--transition);
}

.article-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: var(--space-3);
    color: var(--text-primary);
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-excerpt {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-readtime {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
}

.article-readtime::before {
    content: '\f017'; /* Font Awesome clock icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: var(--accent);
}

.article-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
}

.meta-date {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-muted);
}

.meta-arrow {
    color: var(--accent);
    transition: transform var(--transition);
}

.article-link:hover .meta-arrow {
    transform: translateX(4px) translateZ(10px);
}

.article-link:hover .article-tag {
    transform: translateZ(15px);
    background: var(--accent);
    color: var(--bg);
}

/* Hover Indicator - Gradient Mask with Arrow Circle */
.hover-indicator {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
                rgba(14, 165, 233, 0.15) 0%,
                rgba(14, 165, 233, 0.05) 40%,
                transparent 70%);
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
    z-index: 3;
}

.article-link:hover .hover-indicator {
    opacity: 1;
}

.indicator-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    transition: transform var(--transition-slow);
}

.article-link:hover .indicator-circle {
    transform: translate(-50%, -50%) scale(1);
}

.indicator-circle i {
    color: var(--accent);
    font-size: 1.25rem;
}

/* Author Info */
.article-footer {
    margin-top: auto;
}

.article-author {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.author-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border);
}

.author-details {
    flex: 1;
}

.author-name-small {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.author-date-small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Hidden State */
.article-item.hidden {
    display: none;
}

/* ============================================
   NO RESULTS
   ============================================ */
.no-results {
    text-align: center;
    padding: var(--space-16) var(--space-4);
}

.no-results-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-6);
    background: var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 2rem;
}

.no-results-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-2);
    color: var(--text-primary);
}

.no-results-text {
    color: var(--text-muted);
    font-size: 1rem;
}

/* ============================================
   SCROLL REVEAL ANIMATIONS
   ============================================ */
[data-scroll-reveal] {
    opacity: 0;
    transform: translateY(30px);
    transition: all var(--transition-slow);
}

[data-scroll-reveal].revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    .hero-decoration {
        display: none;
    }

    .featured-grid {
        grid-template-columns: 1fr;
    }

    .featured-visual {
        min-height: 300px;
    }

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

/* Mobile */
@media (max-width: 768px) {
    .container-wide {
        padding: 0 var(--space-4);
    }

    .blog-hero {
        padding: var(--space-12) 0 var(--space-10);
        scroll-margin-top: 80px;
    }

    #header-placeholder:not(:empty) ~ .blog-hero {
        padding-top: calc(var(--space-12) + 80px);
    }

    .hero-heading {
        font-size: 2.5rem;
    }

    .hero-lead {
        font-size: 1.125rem;
    }

    .hero-stats {
        gap: var(--space-4);
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .controls-inner {
        flex-direction: column;
        gap: var(--space-4);
    }

    .search-container {
        max-width: 100%;
    }

    .filter-tabs {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        flex-shrink: 0;
    }

    .featured-body {
        padding: var(--space-6);
    }

    .featured-title {
        font-size: 1.5rem;
    }

    .featured-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-title {
        font-size: 2rem;
    }

    .articles-grid {
        grid-template-columns: 1fr;
    }
}

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

.search-field:focus,
.tab-btn:focus,
.featured-btn:focus,
.article-link:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================
   THEME TOGGLE (Floating Button)
   ============================================ */
.theme-toggle {
    position: fixed;
    left: 16px;
    bottom: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2.5px solid black;
    background: #ffe066;
    color: black;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
    z-index: 1000;
}

.theme-toggle:hover {
    transform: translateY(-4px) scale(1.2);
    box-shadow: 0 8px 16px rgba(15, 23, 36, 0.12) scale(1.2);
}

.theme-toggle i {
    font-size: 1rem;
}

/* Larger touch target on mobile */
@media (max-width: 768px) {
    .theme-toggle {
        width: 48px;
        height: 48px;
        left: 10px;
        bottom: 10px;
    }
}