/* ============================================================
   琢玉轩
   ============================================================ */

/* ---------- CSS 变量 ---------- */
:root {
    --bg: #FBF9F5;
    --paper: #F5F2EB;
    --primary: #7BA38F;
    --primary-light: rgba(123, 163, 143, 0.12);
    --primary-dark: #5C8A75;
    --text: #4A4A4A;
    --text-light: #8A8A8A;
    --accent: #C75B39;
    --accent-light: rgba(199, 91, 57, 0.08);
    --gold: #C8A76A;
    --gold-light: rgba(200, 167, 106, 0.15);
    --border: rgba(123, 163, 143, 0.25);
    --card-shadow: 0 2px 16px rgba(0, 0, 0, 0.04);
    --card-hover-shadow: 0 6px 28px rgba(0, 0, 0, 0.08);
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-serif: 'ZCOOL XiaoWei', 'Noto Serif SC', 'Source Han Serif SC', 'STSong', serif;
    --font-sans: 'Noto Sans SC', 'Source Han Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* ---------- 全局重置 ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg);
    font-family: var(--font-sans);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 32px 20px;
    position: relative;
    overflow-x: hidden;
    line-height: 1.7;
}

/* 宣纸纹理叠加层 */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.04;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(180, 160, 140, 0.3) 2px,
        rgba(180, 160, 140, 0.3) 3px
    );
}

/* 主容器 */
.main-container {
    position: relative;
    z-index: 1;
    max-width: 860px;
    width: 100%;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(18px);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(200, 167, 106, 0.2);
    padding: 40px 44px;
}

/* ---------- 顶部题匾 ---------- */
.header {
    text-align: center;
    margin-bottom: 36px;
}

.header-title {
    font-family: var(--font-serif);
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 6px;
    position: relative;
    display: inline-block;
}

.header-title::after {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.header-subtitle {
    font-size: 13px;
    color: var(--text-light);
    letter-spacing: 3px;
    margin-top: 8px;
}

/* ---------- Tab 导航 ---------- */
.tab-nav {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 10px 22px;
    font-family: var(--font-serif);
    font-size: 15px;
    color: var(--text-light);
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
    letter-spacing: 2px;
    position: relative;
}

.tab-btn:hover {
    color: var(--primary-dark);
    background: var(--primary-light);
}

.tab-btn.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(123, 163, 143, 0.3);
}

/* ---------- 内容区 ---------- */
.tab-content {
    display: none;
    animation: fadeSlideIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- 表单元素 ---------- */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-sans);
    color: var(--text);
    background: rgba(255, 255, 255, 0.7);
    transition: var(--transition);
    outline: none;
    resize: vertical;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
    min-height: 180px;
    line-height: 1.8;
}

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    border: none;
    border-radius: 30px;
    font-family: var(--font-serif);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 2px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 10px rgba(123, 163, 143, 0.25);
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(123, 163, 143, 0.35);
}

.btn:active {
    transform: scale(0.97);
}

.btn-accent {
    background: var(--accent);
    box-shadow: 0 2px 10px rgba(199, 91, 57, 0.25);
}

.btn-accent:hover {
    background: #B04A2E;
    box-shadow: 0 6px 20px rgba(199, 91, 57, 0.35);
}

.btn-block {
    width: 100%;
}

/* ---------- 结果展示区 ---------- */
.result-box {
    margin-top: 24px;
    padding: 28px;
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    white-space: pre-wrap;
    line-height: 2;
    font-size: 14px;
    max-height: 520px;
    overflow-y: auto;
    display: none;
    transition: var(--transition);
}

.result-box.show {
    display: block;
}

/* 自定义滚动条 */
.result-box::-webkit-scrollbar {
    width: 6px;
}

.result-box::-webkit-scrollbar-track {
    background: transparent;
}

.result-box::-webkit-scrollbar-thumb {
    background: rgba(200, 167, 106, 0.4);
    border-radius: 3px;
}

/* ---------- 加载动画 ---------- */
.loading-overlay {
    display: none;
    text-align: center;
    padding: 32px;
    color: var(--text-light);
}

.loading-overlay.show {
    display: block;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 13px;
    color: var(--primary);
    letter-spacing: 1px;
}

/* ---------- 出题卡片 ---------- */
.question-card {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px 24px;
    margin-bottom: 16px;
}

.question-card .q-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 10px;
    color: var(--text);
}

.question-card .q-answer {
    background: var(--primary-light);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.question-card .q-analysis {
    border-left: 3px solid var(--gold);
    padding-left: 14px;
    color: var(--text-light);
    font-size: 13px;
}

/* ---------- 提问链卡片 ---------- */
.chain-card {
    background: #fff;
    border-radius: 60px;
    border: 1px solid var(--border);
    padding: 16px 28px;
    margin-bottom: 12px;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

.chain-card:hover {
    box-shadow: var(--card-hover-shadow);
    transform: translateX(4px);
}

.chain-card .chain-num {
    display: inline-block;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    text-align: center;
    line-height: 28px;
    font-size: 13px;
    font-weight: 600;
    margin-right: 12px;
}

.chain-card .chain-intent {
    font-size: 12px;
    color: var(--gold);
    margin-top: 6px;
    font-style: italic;
}

/* ---------- 音乐控制按钮 ---------- */
.music-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--gold);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    color: var(--gold);
}

.music-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.music-btn.playing {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(199, 91, 57, 0.4);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(199, 91, 57, 0);
    }
}

/* ---------- 底部名言 ---------- */
.footer-quote {
    text-align: center;
    margin-top: 36px;
    font-family: var(--font-serif);
    font-size: 13px;
    color: var(--text-light);
    opacity: 0.6;
    letter-spacing: 2px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
    .main-container {
        padding: 24px 18px;
    }
    .tab-nav {
        gap: 4px;
    }
    .tab-btn {
        padding: 8px 14px;
        font-size: 13px;
        letter-spacing: 1px;
    }
    .header-title {
        font-size: 24px;
    }
}

/* ============================================================
   动态意境层 —— 随Tab切换的侧边水印
   ============================================================ */

/* 意境层容器 */
.visual-layer {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 0;
    pointer-events: none;  /* 不阻挡任何点击 */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.visual-layer.active {
    opacity: 1;
}

.visual-left {
    left: 0;
    width: 18vw;
    max-width: 220px;
}

.visual-right {
    right: 0;
    width: 18vw;
    max-width: 220px;
}

/* 意境层内的SVG */
.visual-layer svg {
    width: 100%;
    height: 60vh;
    max-height: 500px;
}

/* 玉沙闪烁动画 */
@keyframes shimmer {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

.shimmer-dot {
    animation: shimmer 3s ease-in-out infinite;
}

.shimmer-dot:nth-child(1) { animation-delay: 0s; }
.shimmer-dot:nth-child(2) { animation-delay: 0.6s; }
.shimmer-dot:nth-child(3) { animation-delay: 1.2s; }
.shimmer-dot:nth-child(4) { animation-delay: 1.8s; }
.shimmer-dot:nth-child(5) { animation-delay: 2.4s; }

/* 声波涟漪动画 */
@keyframes ripple {
    0% { r: 8; opacity: 0.5; }
    100% { r: 55; opacity: 0; }
}

.ripple-ring {
    animation: ripple 3s ease-out infinite;
}

.ripple-ring:nth-child(1) { animation-delay: 0s; }
.ripple-ring:nth-child(2) { animation-delay: 0.8s; }
.ripple-ring:nth-child(3) { animation-delay: 1.6s; }

/* 响应式：小屏幕隐藏意境层 */
@media (max-width: 900px) {
    .visual-layer {
        display: none;
    }
}

/* ============================================================
   粒子动画 —— 飘落的光点
   ============================================================ */
#particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, rgba(200, 167, 106, 0.6), transparent);
    border-radius: 50%;
    animation: particleFall linear infinite;
    opacity: 0;
    box-shadow: 0 0 6px rgba(200, 167, 106, 0.3);
}

@keyframes particleFall {
    0% {
        transform: translateY(-20px) translateX(0) scale(0.5);
        opacity: 0;
    }
    10% {
        opacity: 0.7;
    }
    90% {
        opacity: 0.4;
    }
    100% {
        transform: translateY(100vh) translateX(var(--drift)) scale(1);
        opacity: 0;
    }
}

/* ============================================================
   AI互动导师 - 模拟课堂对话框
   ============================================================ */
.chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10vh;
    animation: fadeIn 0.3s ease;
}

.chat-modal.show {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chat-modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(200, 167, 106, 0.3);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 700px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary-light), transparent);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-title {
    font-family: var(--font-serif);
    font-size: 18px;
    color: var(--primary-dark);
    letter-spacing: 2px;
}

/* 醒目的退出按钮 - 红色胶囊形 */
.chat-exit-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border: none;
    padding: 10px 24px;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    cursor: pointer;
    border-radius: 25px;
    transition: var(--transition);
    font-family: var(--font-sans);
    letter-spacing: 2px;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    animation: exitPulse 2s ease-in-out infinite;
}

@keyframes exitPulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    }
    50% {
        box-shadow: 0 4px 25px rgba(231, 76, 60, 0.7);
    }
}

.chat-exit-btn:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6);
}

.chat-exit-btn:active {
    transform: scale(0.95);
}

.chat-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
}

.chat-close:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(123, 163, 143, 0.3);
    border-radius: 3px;
}

.chat-welcome {
    background: var(--gold-light);
    padding: 16px 20px;
    border-radius: var(--radius);
    border-left: 3px solid var(--gold);
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text);
    line-height: 1.8;
}

.chat-message {
    margin-bottom: 16px;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.ai {
    text-align: left;
}

.chat-message.user {
    text-align: right;
}

.message-bubble {
    display: inline-block;
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.7;
}

.chat-message.ai .message-bubble {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-message.user .message-bubble {
    background: var(--primary);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.chat-message.user .message-feedback,
.chat-message.user .message-question {
    color: #ffffff !important;
}

.message-feedback {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 6px;
    font-style: italic;
}

.message-question {
    font-weight: 600;
    color: var(--primary-dark);
    margin-top: 8px;
}

.chat-input-area {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.8);
}

.chat-input {
    flex: 1;
    padding: 12px 18px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    font-family: var(--font-sans);
    outline: none;
    transition: var(--transition);
    background: #fff;
}

.chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.chat-input:disabled {
    background: #f5f5f5;
    color: var(--text-light);
    cursor: not-allowed;
}

.chat-send-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 24px;
    background: var(--primary);
    color: #fff;
    font-family: var(--font-serif);
    font-size: 14px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: var(--transition);
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--primary-dark);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-status {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.5);
}

.chat-status.finished {
    color: var(--gold);
    font-weight: 600;
}
