/* ============================================
   CSS Variables & Reset
   ============================================ */

:root {
    --color-primary: #2563eb;
    --color-text: #1e293b;
    --color-muted: #64748b;
    --color-bg: #f8fafc;
    --color-card: #ffffff;
    --color-border: #e2e8f0;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --max-width: 1200px;
    --content-width: 720px;
}

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

body {
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.7;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    opacity: 0.8;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================
   Layout
   ============================================ */

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   Header
   ============================================ */

.site-header {
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-link {
    color: var(--color-text);
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1rem;
}

.nav-dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    min-width: 200px;
    padding: 8px 0;
    margin-top: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.nav-dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--color-text);
}

.dropdown-menu a:hover {
    background: var(--color-bg);
}

.search-icon {
    color: var(--color-muted);
}

/* ============================================
   Hero
   ============================================ */

.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 80px 0;
    text-align: center;
}

.hero-content h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
}

/* ============================================
   Content Section
   ============================================ */

.content-section {
    padding: 60px 0;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 60px;
}

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

/* ============================================
   Posts Grid
   ============================================ */

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
}

.post-card {
    background: var(--color-card);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.post-thumbnail {
    display: block;
    width: 100%;
    height: 220px;
    overflow: hidden;
    flex-shrink: 0;
}

.post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
}

.post-card-content {
    padding: 24px;
}

.post-meta-tags {
    margin-bottom: 12px;
}

.category-badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--color-primary);
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.post-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.post-card-title a {
    color: var(--color-text);
}

.post-excerpt {
    color: var(--color-muted);
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-meta {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
    color: var(--color-muted);
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.sidebar-widget {
    background: var(--color-card);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.widget-title {
    font-size: 1.25rem;
    margin-bottom: 16px;
}

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

.category-list li {
    margin-bottom: 8px;
}

.category-list a {
    color: var(--color-text);
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-input {
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
}

.search-button {
    padding: 12px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.search-button:hover {
    opacity: 0.9;
}

/* ============================================
   Post Detail
   ============================================ */

.post-hero {
    width: 100%;
    height: 400px;
    overflow: hidden;
    margin-bottom: 40px;
}

.post-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.post-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 60px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 80px;
}

.post-header {
    margin-bottom: 40px;
}

.post-categories {
    margin-bottom: 16px;
}

.post-title {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 20px;
}

.post-meta {
    display: flex;
    gap: 20px;
    color: var(--color-muted);
    font-size: 0.9rem;
}

.video-embed {
    background: var(--color-bg);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 40px;
}

.video-embed h3 {
    margin-bottom: 16px;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-link {
    display: inline-block;
    padding: 12px 24px;
    background: var(--color-primary);
    color: white;
    border-radius: 8px;
    font-weight: 600;
}

.post-content {
    max-width: var(--content-width);
    font-size: 1.125rem;
    line-height: 1.8;
}

.post-content h2 {
    font-size: 1.875rem;
    margin: 40px 0 20px;
}

.post-content h3 {
    font-size: 1.5rem;
    margin: 32px 0 16px;
}

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

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

.post-content li {
    margin-bottom: 8px;
}

.post-content img {
    margin: 32px 0;
    border-radius: 8px;
}

.post-content code {
    background: var(--color-bg);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9em;
}

.post-content pre {
    background: var(--color-text);
    color: white;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 24px 0;
}

.post-content pre code {
    background: none;
    padding: 0;
}

.post-tags {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}

.tag-link {
    display: inline-block;
    margin: 4px 8px 4px 0;
    color: var(--color-primary);
    font-weight: 500;
}

.related-posts {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 2px solid var(--color-border);
}

.related-posts h2 {
    margin-bottom: 24px;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
}

.related-card {
    background: var(--color-card);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.related-thumbnail {
    aspect-ratio: 16/9;
    overflow: hidden;
}

.related-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

.related-card h3 {
    padding: 16px;
    font-size: 1rem;
}

.related-card h3 a {
    color: var(--color-text);
}

/* Table of Contents */
.post-sidebar {
    position: relative;
}

.toc-wrapper {
    background: var(--color-card);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.toc-wrapper.sticky {
    position: sticky;
    top: 90px;
}

.toc-wrapper h3 {
    font-size: 1.125rem;
    margin-bottom: 16px;
}

.toc ul {
    list-style: none;
}

.toc li {
    margin-bottom: 8px;
}

.toc a {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.toc a:hover {
    color: var(--color-primary);
}

.toc-level-2 {
    padding-left: 0;
}

.toc-level-3 {
    padding-left: 16px;
    font-size: 0.85rem;
}

/* ============================================
   Archive Pages
   ============================================ */

.archive-page {
    padding: 60px 0;
}

.archive-header {
    text-align: center;
    margin-bottom: 60px;
}

.archive-header h1 {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

.archive-description {
    color: var(--color-muted);
    font-size: 1.125rem;
}

/* ============================================
   Search Page
   ============================================ */

.search-page {
    padding: 60px 0;
}

.search-header {
    text-align: center;
    margin-bottom: 60px;
}

.search-header h1 {
    font-size: 2.5rem;
    margin-bottom: 32px;
}

.search-form-large {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    gap: 12px;
}

.search-input-large {
    flex: 1;
    padding: 16px 20px;
    border: 2px solid var(--color-border);
    border-radius: 12px;
    font-size: 1.125rem;
}

.search-button-large {
    padding: 16px 32px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.125rem;
    cursor: pointer;
}

.search-results-count {
    margin-bottom: 32px;
    color: var(--color-muted);
}

.no-results {
    text-align: center;
    color: var(--color-muted);
    font-size: 1.125rem;
    padding: 60px 0;
}

/* ============================================
   Error Page
   ============================================ */

.error-page {
    padding: 100px 0;
}

.error-content {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.error-code {
    font-size: 8rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    margin-bottom: 20px;
}

.error-content h2 {
    font-size: 2rem;
    margin-bottom: 16px;
}

.error-content p {
    color: var(--color-muted);
    font-size: 1.125rem;
    margin-bottom: 40px;
}

.error-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.button-primary,
.button-secondary {
    padding: 14px 28px;
    border-radius: 8px;
    font-weight: 600;
}

.button-primary {
    background: var(--color-primary);
    color: white;
}

.button-secondary {
    background: var(--color-bg);
    color: var(--color-text);
}

/* ============================================
   Footer
   ============================================ */

.site-footer {
    background: var(--color-text);
    color: #94a3b8;
    padding: 60px 0 30px;
    margin-top: 80px;
}

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 60px;
    margin-bottom: 40px;
}

.footer-brand h3 {
    color: white;
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.footer-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.footer-column h4 {
    color: white;
    margin-bottom: 16px;
}

.footer-column a {
    display: block;
    color: #94a3b8;
    margin-bottom: 8px;
}

.footer-bottom {
    padding-top: 30px;
    border-top: 1px solid #334155;
    text-align: center;
    font-size: 0.875rem;
}

/* ============================================
   Utilities
   ============================================ */

.no-content {
    text-align: center;
    color: var(--color-muted);
    padding: 60px 0;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 968px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .post-layout {
        grid-template-columns: 1fr;
    }
    
    .post-sidebar {
        display: none;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .post-hero {
        height: 260px;
        margin-bottom: 24px;
    }

    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .posts-grid {
        grid-template-columns: 1fr;
    }
    
    .post-title {
        font-size: 2rem;
    }
    
    .main-nav {
        display: none;
    }
    
    .search-form-large {
        flex-direction: column;
    }
    
    .error-code {
        font-size: 5rem;
    }
}
