/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --brand: #03a87c;
    --brand-dark: #028a65;
    --text: #292929;
    --muted: #757575;
    --border: #e6e6e6;
    --bg: #ffffff;
    --bg-alt: #fafafa;
    --card-bg: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.08);
    --header-shadow: rgba(0, 0, 0, 0.08);
    --input-bg: #ffffff;
    --code-bg: #f5f5f5;
}

[data-theme="dark"] {
    --brand: #03a87c;
    --brand-dark: #028a65;
    --text: #e0e0e0;
    --muted: #a0a0a0;
    --border: #333333;
    --bg: #121212;
    --bg-alt: #1e1e1e;
    --card-bg: #1e1e1e;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --header-shadow: rgba(0, 0, 0, 0.3);
    --input-bg: #2d2d2d;
    --code-bg: #2d2d2d;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
    font-size: 16px;
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header styles */
.site-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px var(--header-shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.site-branding {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-branding a {
    text-decoration: none;
    color: inherit;
}

.site-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
}

.site-title {
    font-family: 'Source Serif Pro', Georgia, Cambria, "Times New Roman", Times, serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.site-description {
    font-size: 14px;
    color: var(--muted);
    margin: 2px 0 0 0;
    font-weight: 400;
}

.site-navigation {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.nav-link {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    font-size: 15px;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background-color: var(--bg-alt);
    color: var(--text);
}

.nav-link.active {
    color: var(--brand);
}

.nav-link:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* Main content */
.main-content {
    min-height: calc(100vh - 200px);
    padding: 40px 0;
}

.legacy-warning {
    background: linear-gradient(90deg, rgba(255, 245, 204, 0.95), rgba(255, 236, 179, 0.95));
    border-bottom: 1px solid rgba(234, 179, 8, 0.3);
}

.legacy-warning__container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px;
    font-size: 15px;
    color: #78350f;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.legacy-warning__container a {
    color: #b45309;
    font-weight: 600;
    text-decoration: underline;
}

.featured-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 56px;
}

.featured-hero,
.featured-story {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background: #0f172a;
    color: #f8fafc;
    padding: 40px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.featured-hero::before,
.featured-story::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top left, rgba(3, 168, 124, 0.3), transparent 55%),
        radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.35), transparent 50%);
    opacity: 0.9;
}

.featured-story {
    background: var(--card-bg);
    color: var(--text);
    padding: 32px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.12);
}

.featured-story::before {
    opacity: 0.6;
}

.featured-content {
    position: relative;
    z-index: 1;
}

.featured-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
    margin-bottom: 20px;
    backdrop-filter: blur(5px);
}

.featured-story .featured-tag {
    background: rgba(15, 23, 42, 0.08);
}

.featured-title {
    font-family: 'Source Serif Pro', Georgia, Cambria, "Times New Roman", Times, serif;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 16px 0;
}

.featured-title a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.featured-title a:hover {
    opacity: 0.85;
}

.featured-description {
    font-size: 17px;
    line-height: 1.7;
    margin: 0 0 28px 0;
    color: inherit;
    opacity: 0.92;
}

.featured-story .featured-description {
    color: var(--muted);
    opacity: 1;
}

.featured-meta {
    display: flex;
    gap: 16px;
    font-size: 14px;
    align-items: center;
    color: inherit;
    opacity: 0.85;
}

.featured-story .featured-meta {
    color: var(--muted);
}

.featured-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    text-decoration: none;
    color: #f8fafc;
    font-size: 14px;
    margin-top: 24px;
}

.featured-link::after {
    content: '→';
    transition: transform 0.2s ease;
}

.featured-link:hover::after {
    transform: translateX(4px);
}

.featured-story .featured-link {
    color: #047857;
}

.featured-hero .featured-link {
    color: #f8fafc;
}

.featured-hero:hover,
.featured-story:hover {
    transform: translateY(-6px);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.3);
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 32px;
    margin-bottom: 60px;
}

/* Search Styles */
.search-container {
    margin: 40px 0;
    position: relative;
}

.search-header {
    display: flex;
    gap: 16px;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 16px 24px;
    font-size: 18px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: var(--input-bg) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23757575" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>') no-repeat calc(100% - 20px) center;
    color: var(--text);
}

.view-controls {
    display: flex;
    gap: 8px;
    background: var(--bg-alt);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.view-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.view-btn:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.05);
}

.view-btn.active {
    background: var(--bg);
    color: var(--brand);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* List View Styles */
.articles-grid.list-view {
    grid-template-columns: 1fr;
    gap: 24px;
}

.articles-grid.list-view .article-card {
    display: flex;
    gap: 24px;
    align-items: center;
    padding: 20px;
}

.articles-grid.list-view .article-card-image {
    width: 200px;
    height: 140px !important;
    margin-bottom: 0;
    flex-shrink: 0;
}

.articles-grid.list-view .article-content {
    flex: 1;
    min-width: 0;
    /* Prevent flex item from overflowing */
}

.articles-grid.list-view .article-title {
    font-size: 24px;
    margin-bottom: 8px;
}

.articles-grid.list-view .article-excerpt {
    margin-bottom: 12px;
    -webkit-line-clamp: 2;
}

@media (max-width: 768px) {
    .search-header {
        flex-direction: column;
        align-items: stretch;
    }

    .view-controls {
        justify-content: center;
    }

    .articles-grid.list-view .article-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .articles-grid.list-view .article-card-image {
        width: 100%;
        height: 160px !important;
        margin-bottom: 16px;
    }
}

.search-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(3, 168, 124, 0.1);
}

.search-results {
    margin-top: 20px;
}

.search-result-item {
    background: var(--card-bg);
    padding: 20px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s ease;
}

.search-result-item:first-child {
    border-top: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
}

.search-result-item:last-child {
    border-bottom: none;
    border-radius: 0 0 8px 8px;
}

.search-result-item:hover {
    background: var(--bg-alt);
}

.search-result-title {
    font-family: 'Source Serif Pro', serif;
    font-size: 20px;
    margin: 0 0 8px 0;
}

.search-result-title a {
    text-decoration: none;
    color: var(--text);
}

.search-result-title a:hover {
    color: var(--brand);
}

.search-result-excerpt {
    font-size: 15px;
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
}

/* Article cards */
.article-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 24px;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
    cursor: pointer;
}

.article-card-image {
    width: 100%;
    height: 160px !important;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 16px;
}

.article-card:hover {
    box-shadow: 0 4px 12px var(--card-shadow);
    transform: translateY(-2px);
}

.article-title {
    font-family: 'Source Serif Pro', Georgia, Cambria, "Times New Roman", Times, serif;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 12px 0;
}

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

.article-title a:hover {
    color: var(--brand);
}

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

.article-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--muted);
}

.article-date {
    font-weight: 500;
}

.article-reading-time {
    background: var(--code-bg);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

/* Footer */
.site-footer {
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
    padding: 40px 0;
    text-align: center;
}

.footer-text {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 16px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
}

.footer-link {
    text-decoration: none;
    color: var(--muted);
    font-size: 14px;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--text);
}

/* Responsive design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }

    .site-navigation {
        gap: 20px;
        justify-content: center;
    }

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

    .article-title {
        font-size: 20px;
    }

    .container {
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: 24px;
    }

    .article-title {
        font-size: 18px;
    }

    .article-excerpt {
        font-size: 15px;
    }

    .article-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* Article Page Styles */
.article-container {
    max-width: 740px;
    margin: 0 auto;
    padding: 0 20px;
}

.article-header {
    text-align: center;
    margin-bottom: 48px;
    padding: 32px 0 24px;
}

/* Override .article-title for the main page title */
.article-header .article-title {
    font-family: 'Source Serif Pro', Georgia, Cambria, "Times New Roman", Times, serif;
    font-size: 42px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
    margin: 0 0 24px 0;
}

.article-header .article-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-top: 24px;
    font-size: 14px;
    color: var(--muted);
}

.article-author {
    font-weight: 600;
    color: var(--text);
}

.article-content {
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;
    font-size: 20px;
    line-height: 1.8;
    color: var(--text);
}

.article-content h1,
.article-content h2,
.article-content h3 {
    font-family: 'Source Serif Pro', Georgia, Cambria, "Times New Roman", Times, serif;
    margin: 40px 0 24px 0;
    line-height: 1.3;
    color: var(--text);
}

.article-content h1 {
    font-size: 32px;
}

.article-content h2 {
    font-size: 28px;
}

.article-content h3 {
    font-size: 24px;
}

.article-content p {
    margin-bottom: 32px;
}

.article-content img {
    max-width: 100%;
    height: auto;
    margin: 24px 0;
    border-radius: 8px;
}

.back-to-blog {
    display: inline-block;
    margin: 40px 0;
    text-decoration: none;
    color: var(--brand);
    font-weight: 500;
    transition: color 0.2s ease;
}

.back-to-blog:hover {
    color: var(--brand-dark);
}

.article-footer {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 14px;
    color: var(--muted);
}

.article-footer a {
    color: var(--brand);
    text-decoration: none;
}

.article-footer a:hover {
    text-decoration: underline;
}

/* Fancy divider before comments */
.article-comments-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 64px 0 20px;
}

.article-comments-divider .line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.article-comments-divider .label {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
}

.loading {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    color: var(--muted);
}

.error {
    text-align: center;
    padding: 40px;
    color: #d32f2f;
    font-size: 16px;
}

.comment-box-compact {
    background: #fff;
    padding: 20px 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-top: 20px;
}

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

.compact-form label {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.compact-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.compact-field {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.compact-field input,
.compact-field textarea {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
}

.rating-field {
    max-width: 180px;
}

.stars {
    font-size: 1.3rem;
    color: #ccc;
    cursor: pointer;
}

.stars span.selected,
.stars.selected {
    color: #ffb400;
}

.compact-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.btn-submit {
    background: #32a86f;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
}

.btn-cancel {
    background: #eee;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    color: #333;
    cursor: pointer;
}

.compact-field textarea {
    resize: vertical;
    min-height: 70px;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px var(--card-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.3s ease;
    color: var(--text);
}

.theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--card-shadow);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}