/**
 * 《绛唇解语花》皮肤主题系统
 * Theme System for Lips Aesthetics Book
 *
 * 三种女性化风格主题 + 字体/字号设置
 */

/* ========================================
   主题 1: 玫瑰金裸粉 (Rose Gold - 默认)
   ======================================== */
:root,
[data-theme="rose-gold"] {
    /* 主色调 */
    --theme-primary: #B76E79;
    --theme-primary-light: #D4A5A5;
    --theme-primary-dark: #8B5A5A;
    --theme-secondary: #C4858E;
    --theme-accent: #C9A86C;

    /* 背景色 */
    --theme-bg: #FDF8F8;
    --theme-bg-alt: #FAF5F5;
    --theme-surface: #FFFFFF;

    /* 柔和色 */
    --theme-blush: #F5E6E8;
    --theme-cream: #FDF8F8;
    --theme-nude: #E8D5D5;

    /* 渐变 */
    --theme-gradient: linear-gradient(135deg, #B76E79 0%, #D4A5A5 100%);
    --theme-gradient-soft: linear-gradient(180deg, #FDF8F8 0%, #F5E6E8 100%);
    --theme-gradient-hero: linear-gradient(180deg, #FDF8F8 0%, #FAF0F0 50%, #F5E6E8 100%);

    /* 阴影 */
    --theme-shadow-color: 183, 110, 121;
    --theme-shadow-soft: 0 4px 20px rgba(183, 110, 121, 0.08);
    --theme-shadow-medium: 0 8px 30px rgba(183, 110, 121, 0.12);

    /* 边框 */
    --theme-border: #E8D5D5;
    --theme-border-light: rgba(183, 110, 121, 0.15);

    /* 卡片渐变色系 - 12种变化 */
    --card-gradient-1: linear-gradient(135deg, #B76E79 0%, #C48A92 100%);
    --card-gradient-2: linear-gradient(135deg, #C4858E 0%, #D4A5A5 100%);
    --card-gradient-3: linear-gradient(135deg, #9A5B65 0%, #B76E79 100%);
    --card-gradient-4: linear-gradient(135deg, #D4A5A5 0%, #E8C8C8 100%);
    --card-gradient-5: linear-gradient(135deg, #A86B75 0%, #C4858E 100%);
    --card-gradient-6: linear-gradient(135deg, #C9A86C 0%, #D9C090 100%);
    --card-gradient-7: linear-gradient(135deg, #8B5A5A 0%, #A86B75 100%);
    --card-gradient-8: linear-gradient(135deg, #D4A5A5 0%, #C4858E 100%);
    --card-gradient-9: linear-gradient(135deg, #B76E79 0%, #9A5B65 100%);
    --card-gradient-10: linear-gradient(135deg, #C4858E 0%, #B76E79 100%);
    --card-gradient-11: linear-gradient(135deg, #A86B75 0%, #8B5A5A 100%);
    --card-gradient-12: linear-gradient(135deg, #9A5B65 0%, #C4858E 100%);
}

/* ========================================
   主题 2: 薰衣草紫 (Lavender)
   ======================================== */
[data-theme="lavender"] {
    /* 主色调 */
    --theme-primary: #9B7BB8;
    --theme-primary-light: #C4B0D4;
    --theme-primary-dark: #6B4D82;
    --theme-secondary: #B396C7;
    --theme-accent: #D4A5C9;

    /* 背景色 */
    --theme-bg: #FAF8FC;
    --theme-bg-alt: #F5F0FA;
    --theme-surface: #FFFFFF;

    /* 柔和色 */
    --theme-blush: #F0E8F5;
    --theme-cream: #FAF8FC;
    --theme-nude: #E5DCF0;

    /* 渐变 */
    --theme-gradient: linear-gradient(135deg, #9B7BB8 0%, #C4B0D4 100%);
    --theme-gradient-soft: linear-gradient(180deg, #FAF8FC 0%, #F0E8F5 100%);
    --theme-gradient-hero: linear-gradient(180deg, #FAF8FC 0%, #F5F0FA 50%, #F0E8F5 100%);

    /* 阴影 */
    --theme-shadow-color: 155, 123, 184;
    --theme-shadow-soft: 0 4px 20px rgba(155, 123, 184, 0.08);
    --theme-shadow-medium: 0 8px 30px rgba(155, 123, 184, 0.12);

    /* 边框 */
    --theme-border: #E5DCF0;
    --theme-border-light: rgba(155, 123, 184, 0.15);

    /* 卡片渐变色系 - 12种变化 */
    --card-gradient-1: linear-gradient(135deg, #9B7BB8 0%, #AD90C5 100%);
    --card-gradient-2: linear-gradient(135deg, #B396C7 0%, #C4B0D4 100%);
    --card-gradient-3: linear-gradient(135deg, #7A5F9A 0%, #9B7BB8 100%);
    --card-gradient-4: linear-gradient(135deg, #C4B0D4 0%, #D9CCE8 100%);
    --card-gradient-5: linear-gradient(135deg, #8A6BA5 0%, #B396C7 100%);
    --card-gradient-6: linear-gradient(135deg, #D4A5C9 0%, #E0B8D6 100%);
    --card-gradient-7: linear-gradient(135deg, #6B4D82 0%, #8A6BA5 100%);
    --card-gradient-8: linear-gradient(135deg, #C4B0D4 0%, #B396C7 100%);
    --card-gradient-9: linear-gradient(135deg, #9B7BB8 0%, #7A5F9A 100%);
    --card-gradient-10: linear-gradient(135deg, #B396C7 0%, #9B7BB8 100%);
    --card-gradient-11: linear-gradient(135deg, #8A6BA5 0%, #6B4D82 100%);
    --card-gradient-12: linear-gradient(135deg, #7A5F9A 0%, #B396C7 100%);
}

/* ========================================
   主题 3: 蜜桃珊瑚 (Peach Coral)
   ======================================== */
[data-theme="peach-coral"] {
    /* 主色调 */
    --theme-primary: #E8967A;
    --theme-primary-light: #F5C4B8;
    --theme-primary-dark: #C96F53;
    --theme-secondary: #F0A896;
    --theme-accent: #FFB5A0;

    /* 背景色 */
    --theme-bg: #FFFAF8;
    --theme-bg-alt: #FFF5F0;
    --theme-surface: #FFFFFF;

    /* 柔和色 */
    --theme-blush: #FFF0EB;
    --theme-cream: #FFFAF8;
    --theme-nude: #FFE5DD;

    /* 渐变 */
    --theme-gradient: linear-gradient(135deg, #E8967A 0%, #F5C4B8 100%);
    --theme-gradient-soft: linear-gradient(180deg, #FFFAF8 0%, #FFF0EB 100%);
    --theme-gradient-hero: linear-gradient(180deg, #FFFAF8 0%, #FFF5F0 50%, #FFF0EB 100%);

    /* 阴影 */
    --theme-shadow-color: 232, 150, 122;
    --theme-shadow-soft: 0 4px 20px rgba(232, 150, 122, 0.08);
    --theme-shadow-medium: 0 8px 30px rgba(232, 150, 122, 0.12);

    /* 边框 */
    --theme-border: #FFE5DD;
    --theme-border-light: rgba(232, 150, 122, 0.15);

    /* 卡片渐变色系 - 12种变化 */
    --card-gradient-1: linear-gradient(135deg, #E8967A 0%, #EDA88E 100%);
    --card-gradient-2: linear-gradient(135deg, #F0A896 0%, #F5C4B8 100%);
    --card-gradient-3: linear-gradient(135deg, #D57A5E 0%, #E8967A 100%);
    --card-gradient-4: linear-gradient(135deg, #F5C4B8 0%, #FFD9CF 100%);
    --card-gradient-5: linear-gradient(135deg, #DE8A6E 0%, #F0A896 100%);
    --card-gradient-6: linear-gradient(135deg, #FFB5A0 0%, #FFC9B8 100%);
    --card-gradient-7: linear-gradient(135deg, #C96F53 0%, #DE8A6E 100%);
    --card-gradient-8: linear-gradient(135deg, #F5C4B8 0%, #F0A896 100%);
    --card-gradient-9: linear-gradient(135deg, #E8967A 0%, #D57A5E 100%);
    --card-gradient-10: linear-gradient(135deg, #F0A896 0%, #E8967A 100%);
    --card-gradient-11: linear-gradient(135deg, #DE8A6E 0%, #C96F53 100%);
    --card-gradient-12: linear-gradient(135deg, #D57A5E 0%, #F0A896 100%);
}

/* ========================================
   主题变量映射到全局变量
   ======================================== */
:root {
    /* 将主题变量映射到现有的全局变量 */
    --rose-gold: var(--theme-primary);
    --rose-gold-light: var(--theme-primary-light);
    --rose-gold-dark: var(--theme-primary-dark);
    --nude-pink: var(--theme-nude);
    --blush: var(--theme-blush);
    --cream: var(--theme-cream);
    --gradient-rose: var(--theme-gradient);
    --gradient-blush: var(--theme-gradient-soft);
    --gradient-hero: var(--theme-gradient-hero);
    --shadow-soft: var(--theme-shadow-soft);
    --shadow-medium: var(--theme-shadow-medium);
}

/* ========================================
   字体系统
   ======================================== */
:root {
    /* 默认字体栈 */
    --font-sans: 'PingFang SC', 'Microsoft YaHei', 'Source Han Sans CN', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Noto Serif SC', 'Source Han Serif CN', 'Songti SC', 'SimSun', serif;
    --font-elegant: 'LXGW WenKai', 'Kaiti SC', 'STKaiti', cursive;
}

/* 字体选择 */
[data-font="system"] {
    --font-body: var(--font-sans);
    --font-heading: var(--font-sans);
}

[data-font="serif"] {
    --font-body: var(--font-serif);
    --font-heading: var(--font-serif);
}

[data-font="elegant"] {
    --font-body: var(--font-elegant);
    --font-heading: var(--font-elegant);
}

/* 应用字体 */
body {
    font-family: var(--font-body, var(--font-sans));
}

h1, h2, h3, h4, h5, h6,
.hero-title, .chapter-title, .section-title {
    font-family: var(--font-heading, var(--font-serif));
}

/* ========================================
   字号系统
   ======================================== */
:root {
    --font-size-base: 16px;
    --font-size-scale: 1;
}

[data-font-size="small"] {
    --font-size-base: 14px;
    --font-size-scale: 0.875;
}

[data-font-size="medium"] {
    --font-size-base: 16px;
    --font-size-scale: 1;
}

[data-font-size="large"] {
    --font-size-base: 18px;
    --font-size-scale: 1.125;
}

[data-font-size="xlarge"] {
    --font-size-base: 20px;
    --font-size-scale: 1.25;
}

/* 应用字号 */
body {
    font-size: var(--font-size-base);
}

/* 内容区域字号调整 */
.markdown-content {
    font-size: calc(1.0625rem * var(--font-size-scale));
    line-height: calc(1.9 + (var(--font-size-scale) - 1) * 0.2);
}

.markdown-content h1 {
    font-size: calc(2rem * var(--font-size-scale));
}

.markdown-content h2 {
    font-size: calc(1.625rem * var(--font-size-scale));
}

.markdown-content h3 {
    font-size: calc(1.375rem * var(--font-size-scale));
}

.markdown-content h4 {
    font-size: calc(1.25rem * var(--font-size-scale));
}

/* ========================================
   设置面板样式
   ======================================== */
.settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    max-width: 90vw;
    height: 100vh;
    background: var(--theme-surface);
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.settings-panel.active {
    right: 0;
}

.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.settings-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 设置面板头部 */
.settings-header {
    padding: 1.5rem;
    background: var(--theme-gradient);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 500;
    letter-spacing: 0.05em;
}

.settings-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* 设置面板内容 */
.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.settings-section {
    margin-bottom: 2rem;
}

.settings-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--theme-primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--theme-border);
}

/* 主题选择器 */
.theme-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.theme-option {
    position: relative;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.theme-option.active {
    border-color: var(--theme-primary);
}

.theme-option:hover {
    transform: translateY(-2px);
    box-shadow: var(--theme-shadow-medium);
}

.theme-preview {
    height: 80px;
    position: relative;
}

.theme-preview-gradient {
    height: 50%;
}

.theme-preview-content {
    height: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.theme-preview-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* 主题 1 预览 */
.theme-option[data-value="rose-gold"] .theme-preview-gradient {
    background: linear-gradient(135deg, #B76E79 0%, #D4A5A5 100%);
}
.theme-option[data-value="rose-gold"] .theme-preview-dot:nth-child(1) { background: #B76E79; }
.theme-option[data-value="rose-gold"] .theme-preview-dot:nth-child(2) { background: #D4A5A5; }
.theme-option[data-value="rose-gold"] .theme-preview-dot:nth-child(3) { background: #F5E6E8; }

/* 主题 2 预览 */
.theme-option[data-value="lavender"] .theme-preview-gradient {
    background: linear-gradient(135deg, #9B7BB8 0%, #C4B0D4 100%);
}
.theme-option[data-value="lavender"] .theme-preview-dot:nth-child(1) { background: #9B7BB8; }
.theme-option[data-value="lavender"] .theme-preview-dot:nth-child(2) { background: #C4B0D4; }
.theme-option[data-value="lavender"] .theme-preview-dot:nth-child(3) { background: #F0E8F5; }

/* 主题 3 预览 */
.theme-option[data-value="peach-coral"] .theme-preview-gradient {
    background: linear-gradient(135deg, #E8967A 0%, #F5C4B8 100%);
}
.theme-option[data-value="peach-coral"] .theme-preview-dot:nth-child(1) { background: #E8967A; }
.theme-option[data-value="peach-coral"] .theme-preview-dot:nth-child(2) { background: #F5C4B8; }
.theme-option[data-value="peach-coral"] .theme-preview-dot:nth-child(3) { background: #FFF0EB; }

.theme-name {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-medium);
    background: var(--theme-bg-alt);
}

.theme-option.active .theme-name {
    color: var(--theme-primary);
    font-weight: 600;
}

/* 选中标记 */
.theme-option.active::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: var(--theme-primary);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 字体选择器 */
.font-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.font-option {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--theme-bg-alt);
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.font-option:hover {
    background: var(--theme-blush);
}

.font-option.active {
    border-color: var(--theme-primary);
    background: white;
}

.font-option-radio {
    width: 18px;
    height: 18px;
    border: 2px solid var(--theme-border);
    border-radius: 50%;
    margin-right: 1rem;
    position: relative;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.font-option.active .font-option-radio {
    border-color: var(--theme-primary);
}

.font-option.active .font-option-radio::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: var(--theme-primary);
    border-radius: 50%;
}

.font-option-info {
    flex: 1;
}

.font-option-name {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.font-option-preview {
    font-size: 0.875rem;
    color: var(--text-light);
}

.font-option[data-value="system"] .font-option-preview {
    font-family: var(--font-sans);
}

.font-option[data-value="serif"] .font-option-preview {
    font-family: var(--font-serif);
}

.font-option[data-value="elegant"] .font-option-preview {
    font-family: var(--font-elegant);
}

/* 字号选择器 */
.font-size-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.font-size-option {
    padding: 0.875rem 0.5rem;
    text-align: center;
    background: var(--theme-bg-alt);
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.font-size-option:hover {
    background: var(--theme-blush);
}

.font-size-option.active {
    border-color: var(--theme-primary);
    background: white;
}

.font-size-option-label {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.font-size-option-value {
    font-size: 0.75rem;
    color: var(--text-light);
}

.font-size-option[data-value="small"] .font-size-option-label { font-size: 0.875rem; }
.font-size-option[data-value="medium"] .font-size-option-label { font-size: 1rem; }
.font-size-option[data-value="large"] .font-size-option-label { font-size: 1.125rem; }
.font-size-option[data-value="xlarge"] .font-size-option-label { font-size: 1.25rem; }

/* 设置面板底部 */
.settings-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--theme-border);
    background: var(--theme-bg-alt);
}

.settings-reset-btn {
    width: 100%;
    padding: 0.875rem;
    background: transparent;
    border: 2px solid var(--theme-border);
    color: var(--text-medium);
    border-radius: 10px;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.settings-reset-btn:hover {
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}

/* 设置按钮（触发器） */
.settings-trigger {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--theme-gradient);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--theme-shadow-medium);
    z-index: 998;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(var(--theme-shadow-color), 0.3);
}

/* ========================================
   响应式设计
   ======================================== */

/* 防止移动端水平滚动 */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw;
    }

    .settings-panel {
        width: 100%;
        max-width: 100%;
        right: 0 !important; /* 固定在右侧 */
        transform: translateX(100%); /* 使用 transform 移出屏幕 */
        visibility: hidden; /* 完全隐藏 */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0s linear 0.3s; /* visibility 延迟变化 */
    }

    .settings-panel.active {
        transform: translateX(0); /* 滑入屏幕 */
        visibility: visible;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0s linear 0s; /* 立即显示 */
    }

    .theme-options {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .theme-preview {
        height: 60px;
    }

    .font-size-options {
        grid-template-columns: repeat(2, 1fr);
    }

    .settings-trigger {
        bottom: 80px;
        right: 20px;
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
}

/* ========================================
   打印样式
   ======================================== */
@media print {
    .settings-panel,
    .settings-overlay,
    .settings-trigger {
        display: none !important;
    }
}
