/* ========================================
   Home Journal - Modern SOTA Design
   ======================================== */

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

:root {
    /* Modern Color Palette */
    --bg: #fafbfc;
    --fg: #1a1a2e;
    --accent: #3182ce;
    --accent-hover: #2b6cb0;
    --accent-light: #63b3ed;
    --muted: #6b7280;
    --muted-light: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.08);
    
    /* 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);
    --shadow-accent: 0 4px 14px 0 rgba(99, 102, 241, 0.25);
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg: #0a0a0f;
    --fg: #f4f4f5;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-light: #6366f1;
    --muted: #a1a1aa;
    --muted-light: #71717a;
    --border: #27272a;
    --border-light: #1f1f23;
    --card-bg: #18181b;
    --card-border: rgba(255, 255, 255, 0.08);
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    --shadow-accent: 0 4px 14px 0 rgba(129, 140, 248, 0.3);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0a0a0f;
        --fg: #f4f4f5;
        --accent: #818cf8;
        --accent-hover: #a5b4fc;
        --accent-light: #6366f1;
        --muted: #a1a1aa;
        --muted-light: #71717a;
        --border: #27272a;
        --border-light: #1f1f23;
        --card-bg: #18181b;
        --card-border: rgba(255, 255, 255, 0.08);
    }
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg);
    color: var(--fg);
    line-height: 1.65;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

p {
    margin-bottom: 1.25rem;
}

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

a:hover {
    color: var(--accent-hover);
}

/* Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ========================================
   Header - Modern Navigation
   ======================================== */
body > header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(250, 251, 252, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 0;
    transition: all 0.3s ease;
}

[data-theme="dark"] body > header {
    background: rgba(10, 10, 15, 0.85);
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--fg);
    text-decoration: none;
    letter-spacing: -0.03em;
    white-space: nowrap;
}

.logo-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.header-actions a {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
    position: relative;
}

.header-actions a:hover,
.header-actions a.active {
    color: var(--fg);
}

.header-actions a.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

/* Theme Toggle */
#theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 0.5rem;
    cursor: pointer;
    color: var(--muted);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#theme-toggle:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: scale(1.05);
}

#theme-toggle svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   Hero Section
   ======================================== */
.hero {
    padding: 5rem 0 3rem;
    max-width: 800px;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.04em;
    margin-bottom: 1rem;
    color: var(--fg);
}

.hero-subtitle {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--muted);
    line-height: 1.6;
    max-width: 600px;
}

/* ========================================
   Controls & Filters
   ======================================== */
.controls-container {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.tag-filter-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-btn {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tag-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.tag-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: var(--shadow-accent);
}

/* Search */
.search-container {
    position: relative;
    max-width: 300px;
}

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

#article-search {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    color: var(--fg);
    font-family: inherit;
    transition: all 0.2s ease;
}

#article-search::placeholder {
    color: var(--muted-light);
}

#article-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ========================================
   Articles Grid - SOTA Cards
   ======================================== */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.article-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.article-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

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

.article-meta {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.article-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.article-card h3 a {
    color: var(--fg);
    text-decoration: none;
    transition: color 0.2s ease;
}

.article-card h3 a:hover {
    color: var(--accent);
}

.article-card p {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.read-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    margin-top: auto;
    transition: gap 0.2s ease;
}

.read-link:hover {
    gap: 0.75rem;
}

/* ========================================
   Section Headers
   ======================================== */
.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.section-title::after {
    content: '';
    height: 1px;
    flex: 1;
    background: linear-gradient(90deg, var(--border), transparent);
}

/* ========================================
   Post/Article Pages
   ======================================== */
.post-header {
    padding: 4rem 0 2rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 3rem;
}

.post-header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.03em;
    margin: 1rem 0;
    color: var(--fg);
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.post-meta .date {
    font-weight: 500;
}

.post-content {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 0 4rem;
    font-size: 1.1rem;
    line-height: 1.8;
}

.post-content h2 {
    font-size: 1.75rem;
    margin: 2.5rem 0 1rem;
    color: var(--fg);
}

.post-content h3 {
    font-size: 1.35rem;
    margin: 2rem 0 0.75rem;
    color: var(--fg);
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 1rem 1.5rem;
    margin: 2rem 0;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
    color: var(--muted);
}

.post-content img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    margin: 2rem 0;
}

.post-content ul,
.post-content ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

.post-content code {
    background: rgba(99, 102, 241, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    font-family: 'SF Mono', Monaco, monospace;
}

.post-footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

/* ========================================
   About Page
   ======================================== */
.about-hero {
    padding: 4rem 0;
}

.about-hero h1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.04em;
    margin-bottom: 1.5rem;
    color: var(--fg);
}

.about-content {
    max-width: 700px;
    font-size: 1.15rem;
    line-height: 1.75;
    color: var(--fg);
}

.about-content p {
    margin-bottom: 1.5rem;
}

/* ========================================
   Footer
   ======================================== */
footer {
    padding: 3rem 0;
    border-top: 1px solid var(--border-light);
    margin-top: 4rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--muted);
    transition: color 0.2s ease;
}

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

.footer-links svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Reading Progress Bar
   ======================================== */
.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 1000;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    width: 0%;
    transition: width 0.1s ease-out;
}

/* ========================================
   Buttons
   ======================================== */
#load-more-btn {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--fg);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

#load-more-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-accent);
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.article-card {
    animation: fadeIn 0.4s ease-out;
    animation-fill-mode: both;
}

.article-card:nth-child(1) { animation-delay: 0.05s; }
.article-card:nth-child(2) { animation-delay: 0.1s; }
.article-card:nth-child(3) { animation-delay: 0.15s; }
.article-card:nth-child(4) { animation-delay: 0.2s; }
.article-card:nth-child(5) { animation-delay: 0.25s; }
.article-card:nth-child(6) { animation-delay: 0.3s; }

/* ========================================
   Mobile Responsive
   ======================================== */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    nav {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .header-actions {
        gap: 1rem;
    }
    
    .hero {
        padding: 3rem 0 2rem;
    }
    
    .hero h1 {
        font-size: 1.75rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .articles-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .article-card {
        padding: 1.5rem;
    }
    
    .article-card h3 {
        font-size: 1.1rem;
    }
    
    .post-header {
        padding: 2rem 0 1.5rem;
    }
    
    .post-header h1 {
        font-size: 1.75rem;
    }
    
    .post-content {
        font-size: 1rem;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .tag-filter-scroll {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .tag-btn {
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.25rem;
    }
    
    .header-actions a {
        font-size: 0.8rem;
    }
    
    .hero h1 {
        font-size: 1.5rem;
    }
    
    .controls-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-container {
        max-width: 100%;
    }
}

/* ========================================
   Utility Classes
   ======================================== */
.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;
}

/* Focus States */
a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ========================================
   Post Metadata Box
   ======================================== */
.post-meta-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.post-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.post-meta-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.post-meta-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--fg);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.post-meta-value a {
    color: var(--accent);
    text-decoration: none;
}

.post-meta-value a:hover {
    text-decoration: underline;
}

/* Related Posts */
.related-posts {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.related-posts h3 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--fg);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 768px) {
    .related-grid {
        grid-template-columns: 1fr;
    }
}

.related-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: all 0.2s ease;
}

.related-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.related-card h4 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.related-card h4 a {
    color: var(--fg);
    text-decoration: none;
}

.related-card h4 a:hover {
    color: var(--accent);
}

.related-card .date {
    font-size: 0.8rem;
    color: var(--muted);
}
