/* CSS Variables for Themes */
:root {
    /* Theme: 春樱 (Spring Sakura) - Default */
    --bg-primary: #faf7f5;
    --bg-secondary: #f5ebe6;
    --bg-tertiary: #fff9f5;
    --text-primary: #4a4a4a;
    --text-secondary: #7a7a7a;
    --accent-color: #e8b4b8;
    --accent-dark: #d4a5a9;
    --border-color: #e8ddd8;
    --shadow: rgba(232, 180, 184, 0.15);
    --progress-bg: #f0e6e1;
    --progress-fill: #e8b4b8;
    --card-bg: #ffffff;
    --hover-bg: #fff5f2;
}

[data-theme="summer"] {
    /* Theme: 夏荷 (Summer Lotus) */
    --bg-primary: #f5f9f7;
    --bg-secondary: #e8f4f0;
    --bg-tertiary: #f0f9f5;
    --text-primary: #3d5a52;
    --text-secondary: #6b8a7f;
    --accent-color: #7db9a8;
    --accent-dark: #5a9a89;
    --border-color: #d4e5de;
    --shadow: rgba(125, 185, 168, 0.15);
    --progress-bg: #e0ece6;
    --progress-fill: #7db9a8;
    --card-bg: #ffffff;
    --hover-bg: #e8f5f0;
}

[data-theme="autumn"] {
    /* Theme: 秋枫 (Autumn Maple) */
    --bg-primary: #fdf8f3;
    --bg-secondary: #f5ebe0;
    --bg-tertiary: #faf3eb;
    --text-primary: #5d4e37;
    --text-secondary: #8b7355;
    --accent-color: #d4a373;
    --accent-dark: #b88a5e;
    --border-color: #e8ddd0;
    --shadow: rgba(212, 163, 115, 0.15);
    --progress-bg: #f0e6d8;
    --progress-fill: #d4a373;
    --card-bg: #ffffff;
    --hover-bg: #faf3eb;
}

[data-theme="winter"] {
    /* Theme: 冬梅 (Winter Plum) */
    --bg-primary: #f8f9fa;
    --bg-secondary: #e9ecef;
    --bg-tertiary: #f1f3f5;
    --text-primary: #495057;
    --text-secondary: #868e96;
    --accent-color: #9fa8da;
    --accent-dark: #7986cb;
    --border-color: #dee2e6;
    --shadow: rgba(159, 168, 218, 0.15);
    --progress-bg: #e9ecef;
    --progress-fill: #9fa8da;
    --card-bg: #ffffff;
    --hover-bg: #e9ecef;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.8;
    overflow-x: hidden;
    transition: all 0.4s ease;
}

/* Custom Scrollbar - Hidden but functional */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 3px;
    opacity: 0.5;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-dark);
}

/* Layout Grid using grid-template-areas */
.container {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
                "header"
                "main"
                "footer";
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Header Section */
.header {
    grid-area: header;
    padding: 2rem 1.5rem;
    background: linear-gradient(to bottom, var(--bg-secondary), var(--bg-primary));
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.2em;
    position: relative;
}

.site-title::after {
    content: "";
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--accent-color);
}

/* Theme Switcher */
.theme-switcher {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-tertiary);
    padding: 0.5rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.theme-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.theme-btn:hover {
    transform: scale(1.1);
}

.theme-btn.active {
    border-color: var(--text-primary);
    transform: scale(1.15);
}

.theme-btn[data-theme="spring"] { background: #e8b4b8; }
.theme-btn[data-theme="summer"] { background: #7db9a8; }
.theme-btn[data-theme="autumn"] { background: #d4a373; }
.theme-btn[data-theme="winter"] { background: #9fa8da; }

/* Navigation */
.nav-tabs {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.nav-tab {
    cursor: pointer;
    padding: 0.5rem 0;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    position: relative;
    font-size: 1rem;
}

.nav-tab:hover {
    color: var(--text-primary);
}

.nav-tab.active {
    color: var(--accent-dark);
    font-weight: 600;
}

.nav-tab.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-color);
}

/* Main Content Area */
.main {
    grid-area: main;
    padding: 2rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Section Visibility */
.section {
    display: none;
    animation: fadeIn 0.5s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Poetry Collection Grid Layout */
.poetry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.poetry-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
}

.poetry-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.poetry-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px var(--shadow);
    background: var(--hover-bg);
}

.poetry-card:hover::before {
    opacity: 1;
}

.poetry-number {
    font-size: 0.85rem;
    color: var(--accent-dark);
    margin-bottom: 0.5rem;
    font-family: "Courier New", monospace;
}

.poetry-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.poetry-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.poetry-preview {
    margin-top: 1rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-style: italic;
}

/* Full-width Article Layout for Poetry Detail */
.article-full {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 1000;
    overflow-y: auto;
    padding: 2rem;
    animation: slideIn 0.4s ease;
}

.article-full.active {
    display: block;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.article-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow);
    min-height: calc(100vh - 4rem);
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    cursor: pointer;
    margin-bottom: 2rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.poetry-content h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--text-primary);
}

.poetry-content .author {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    font-size: 1.1rem;
}

.poetry-content .verses {
    font-size: 1.2rem;
    line-height: 2.2;
    text-align: center;
    color: var(--text-primary);
    white-space: pre-wrap;
    margin-bottom: 3rem;
}

.poetry-content .annotation {
    background: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 3px solid var(--accent-color);
    margin-top: 2rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Progress Section Layout */
.progress-header {
    margin-bottom: 2rem;
    padding: 2rem;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 12px var(--shadow);
}

.progress-overview {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    align-items: center;
}

.total-progress-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: conic-gradient(var(--accent-color) calc(var(--progress) * 1%), var(--progress-bg) 0);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0 auto;
}

.total-progress-circle::before {
    content: "";
    position: absolute;
    width: 120px;
    height: 120px;
    background: var(--card-bg);
    border-radius: 50%;
}

.total-progress-text {
    position: relative;
    z-index: 1;
    text-align: center;
}

.total-percentage {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-dark);
}

.total-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-dark);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Progress Items Grid */
.progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.progress-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow);
}

.progress-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow);
}

.progress-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.progress-item-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.05rem;
}

.progress-item-status {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.progress-item-status.completed {
    background: var(--accent-color);
    color: white;
}

.progress-item-status.in-progress {
    background: var(--bg-tertiary);
    color: var(--accent-dark);
    border: 1px solid var(--accent-color);
}

.progress-bar-container {
    background: var(--progress-bg);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-dark));
    border-radius: 4px;
    transition: width 0.6s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
            90deg,
            transparent,
            rgba(255,255,255,0.3),
            transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Footer */
.footer {
    grid-area: footer;
    padding: 2rem;
    text-align: center;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .site-title::after {
        left: 50%;
        transform: translateX(-50%);
    }

    .nav-tabs {
        justify-content: center;
        gap: 1rem;
    }

    .poetry-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .progress-overview {
        grid-template-columns: 1fr;
    }

    .progress-grid {
        grid-template-columns: 1fr;
    }

    .article-container {
        padding: 1.5rem;
    }

    .poetry-content h1 {
        font-size: 1.5rem;
    }

    .poetry-content .verses {
        font-size: 1.1rem;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease;
}