/* ===== 基础变量 ===== */
:root {
    --bg-color: #f7f4ed;
    --card-bg: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --accent-primary: #ff6b6b;
    --accent-secondary: #4ecdc4;
    --accent-tertiary: #ffe66d;
    --border-color: #e8e8e8;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 深色模式变量 ===== */
[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --card-bg: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --border-color: #3a3a3a;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

/* ===== 重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== 日夜模式切换按钮 ===== */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    z-index: 1000;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle svg {
    width: 22px;
    height: 22px;
    position: absolute;
    transition: var(--transition);
}

.theme-icon-sun {
    opacity: 1;
    transform: rotate(0deg);
}

.theme-icon-moon {
    opacity: 0;
    transform: rotate(-90deg);
}

[data-theme="dark"] .theme-icon-sun {
    opacity: 0;
    transform: rotate(90deg);
}

[data-theme="dark"] .theme-icon-moon {
    opacity: 1;
    transform: rotate(0deg);
}

html, body {
    height: 100%;
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

.app {
    min-height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

/* ===== 页面切换 ===== */
.page {
    display: none;
    min-height: 100vh;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
    will-change: opacity, transform;
    contain: layout style;
}

/* 隐藏的页面不进行渲染 */
.page:not(.active) {
    content-visibility: hidden;
}

.page.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== 欢迎页 ===== */
.welcome-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
}

.logo-section {
    position: relative;
    margin-bottom: 24px;
}

.logo-icon {
    font-size: 72px;
    line-height: 1;
}

.logo-badge {
    position: absolute;
    top: -8px;
    right: -16px;
    background: var(--accent-primary);
    color: white;
    font-size: 14px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
}

.title {
    font-size: 32px;
    font-weight: 900;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* 特性展示 */
.features {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}

.feature-item {
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    min-width: 80px;
}

.feature-num {
    display: block;
    font-size: 28px;
    font-weight: 900;
    color: var(--accent-primary);
    line-height: 1;
}

.feature-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 介绍文字 */
.intro-text {
    margin-bottom: 40px;
}

.intro-text p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.highlight {
    color: var(--accent-primary);
    font-weight: 700;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 32px;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--text-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 12px 16px;
}

.btn-text:hover {
    color: var(--text-primary);
}

.btn-text:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-full {
    width: 100%;
}

.btn .arrow {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.btn:hover .arrow {
    transform: translateX(4px);
}

.btn svg {
    width: 18px;
    height: 18px;
}

/* ===== 测试页 ===== */
.quiz-header {
    padding: 20px 0;
}

.progress-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 3px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    width: 3%;
}

.progress-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: right;
}

.quiz-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.question-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.4s ease;
}

@keyframes slideIn {
    from { opacity: 0.5; transform: translate3d(10px, 0, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.dimension-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-tertiary));
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.question-title {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.5;
    margin-bottom: 24px;
}

/* 选项 */
.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #f8f8f8;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.option:hover {
    background: #f0f0f0;
    border-color: var(--accent-primary);
    transform: translate3d(4px, 0, 0);
}

.option.selected {
    background: var(--text-primary);
    color: white;
    border-color: var(--text-primary);
}

.option-emoji {
    font-size: 24px;
    flex-shrink: 0;
}

.option-text {
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
}

.quiz-footer {
    padding: 20px 0;
    display: flex;
    justify-content: flex-start;
}

/* ===== 结果页 ===== */
.result-container {
    padding: 20px 0;
}

.result-header {
    text-align: center;
    margin-bottom: 24px;
}

.result-emoji {
    font-size: 80px;
    line-height: 1;
    margin-bottom: 12px;
}

.result-name {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 8px;
}

.result-type {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 16px;
}

.result-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.tag {
    background: linear-gradient(135deg, var(--accent-tertiary), #ffd93d);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
}

.result-desc-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.result-desc-card p {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-secondary);
}

/* 维度分析 */
.dimension-section {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

.dimension-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dimension-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dimension-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
}

.dimension-letter {
    font-family: 'Courier New', monospace;
    color: var(--accent-primary);
    font-weight: 700;
}

.bar-container {
    height: 8px;
    background: #e8e8e8;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease;
}

.bar-fill.high {
    background: linear-gradient(90deg, var(--accent-primary), #ff8e8e);
}

.bar-fill.low {
    background: linear-gradient(90deg, var(--accent-secondary), #6dd5d0);
}

.dimension-extremes {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.result-footer {
    padding-bottom: 20px;
}

/* ===== 彩纸动画 (GPU加速) ===== */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: 0;
    animation: confetti-fall 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    z-index: 9999;
    pointer-events: none;
    will-change: transform, opacity;
    contain: layout style paint;
}

@keyframes confetti-fall {
    0% {
        transform: translate3d(0, -10px, 0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate3d(0, 100vh, 0) rotate(720deg);
        opacity: 0;
    }
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
    .page {
        padding: 16px;
    }

    .title {
        font-size: 28px;
    }

    .features {
        gap: 12px;
    }

    .feature-item {
        padding: 12px 16px;
        min-width: 70px;
    }

    .feature-num {
        font-size: 24px;
    }

    .question-card {
        padding: 24px 20px;
    }

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

    .option {
        padding: 14px;
    }

    .option-emoji {
        font-size: 20px;
    }

    .option-text {
        font-size: 14px;
    }

    .result-emoji {
        font-size: 64px;
    }

    .result-name {
        font-size: 24px;
    }
}

/* ===== 按钮组 ===== */
.welcome-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 280px;
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ===== 人格类型总览页 ===== */
.types-container {
    padding: 20px 0;
}

.types-header {
    margin-bottom: 24px;
    text-align: center;
}

.types-header .btn-text {
    position: absolute;
    left: 0;
    top: 20px;
}

.types-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.types-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.types-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.type-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 16px 12px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    border: 2px solid transparent;
}

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

.type-card-emoji {
    font-size: 36px;
    line-height: 1;
    margin-bottom: 8px;
}

.type-card-code {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.type-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.type-card-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}

.type-card-tag {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--bg-color);
    color: var(--text-secondary);
    border-radius: 10px;
}

/* ===== 人格详情页 ===== */
.type-detail-container {
    padding: 20px 0;
}

.type-detail-header {
    margin-bottom: 20px;
}

.type-detail-content {
    text-align: center;
}

.type-detail-emoji {
    font-size: 80px;
    line-height: 1;
    margin-bottom: 12px;
}

.type-detail-name {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 8px;
}

.type-detail-code {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 16px;
}

.type-detail-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.type-detail-desc {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    text-align: left;
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.type-detail-desc strong {
    color: var(--text-primary);
    font-weight: 700;
}

.type-detail-dimensions {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: left;
}

.type-detail-dimensions h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
}

.type-detail-dimension-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.type-detail-dimension-item:last-child {
    border-bottom: none;
}

.type-detail-dimension-letter {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-primary);
    min-width: 24px;
}

.type-detail-dimension-info {
    flex: 1;
}

.type-detail-dimension-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.type-detail-dimension-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== 响应式调整 ===== */
@media (min-width: 480px) {
    .types-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== 深色模式组件样式 ===== */
[data-theme="dark"] .option {
    background: #333333;
}

[data-theme="dark"] .option:hover {
    background: #404040;
}

[data-theme="dark"] .progress-bar {
    background: #3a3a3a;
}

[data-theme="dark"] .bar-container {
    background: #3a3a3a;
}

[data-theme="dark"] .btn-primary {
    background: #ffffff;
    color: #1a1a1a;
}

[data-theme="dark"] .btn-secondary {
    background: #2a2a2a;
    color: #ffffff;
    border-color: #3a3a3a;
}

[data-theme="dark"] .type-card {
    background: #2a2a2a;
}

[data-theme="dark"] .type-card-tag {
    background: #1a1a1a;
}

[data-theme="dark"] .type-detail-desc,
[data-theme="dark"] .type-detail-dimensions {
    background: #2a2a2a;
}

/* ===== 系统深色模式适配（当没有手动设置时） ===== */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg-color: #1a1a1a;
        --card-bg: #2a2a2a;
        --text-primary: #ffffff;
        --text-secondary: #b0b0b0;
        --text-muted: #808080;
        --border-color: #3a3a3a;
        --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
        --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
        --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    }

    :root:not([data-theme]) .option {
        background: #333333;
    }

    :root:not([data-theme]) .option:hover {
        background: #404040;
    }

    :root:not([data-theme]) .progress-bar {
        background: #3a3a3a;
    }

    :root:not([data-theme]) .bar-container {
        background: #3a3a3a;
    }

    :root:not([data-theme]) .btn-primary {
        background: #ffffff;
        color: #1a1a1a;
    }

    :root:not([data-theme]) .btn-secondary {
        background: #2a2a2a;
        color: #ffffff;
        border-color: #3a3a3a;
    }

    :root:not([data-theme]) .type-card {
        background: #2a2a2a;
    }

    :root:not([data-theme]) .type-card-tag {
        background: #1a1a1a;
    }

    :root:not([data-theme]) .type-detail-desc,
    :root:not([data-theme]) .type-detail-dimensions {
        background: #2a2a2a;
    }
}
