/**
 * MBTI测试 - 全局样式
 * 响应式布局 + 深浅主题 + 动画
 */

/* ======== CSS变量 ======== */
:root {
  --bg-primary: #f8f9fe;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f2f8;
  --text-primary: #1a1a2e;
  --text-secondary: #555;
  --text-tertiary: #888;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-dark: #5848d4;
  --border: #e8e8f0;
  --shadow: 0 4px 24px rgba(108, 92, 231, 0.08);
  --shadow-hover: 0 8px 32px rgba(108, 92, 231, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --header-h: 56px;
  --max-w: 680px;
  --success: #00b894;
  --warn: #f39c12;
  --danger: #e74c3c;
}

[data-theme="dark"] {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #232340;
  --text-primary: #f0f0f5;
  --text-secondary: #b0b0c0;
  --text-tertiary: #8080a0;
  --accent: #a29bfe;
  --accent-light: #6c5ce7;
  --accent-dark: #b8a6ff;
  --border: #2a2a45;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ======== 基础重置 ======== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }

/* ======== 通用按钮 ======== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 24px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; transition: all 0.25s;
  white-space: nowrap;
}
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 36px; font-size: 17px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(108,92,231,0.35); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-outline { border: 2px solid var(--accent); color: var(--accent); }
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-outline:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { color: var(--accent); }
.btn-ghost:disabled { opacity: 0.3; cursor: not-allowed; }

/* ======== 通用卡片 ======== */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: box-shadow 0.3s, transform 0.3s;
}

/* ======== 头部 ======== */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.header-inner {
  max-width: var(--max-w); margin: 0 auto;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}
.home-link {
  font-size: 14px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 4px;
  transition: color 0.2s;
}
.home-link:hover { color: var(--accent); }
.header-title {
  font-size: 18px; font-weight: 700;
  color: var(--accent); cursor: pointer;
}
.theme-toggle {
  font-size: 20px; padding: 4px 8px;
  border-radius: 8px; transition: background 0.2s;
}
.theme-toggle:hover { background: var(--bg-tertiary); }

/* ======== 页脚 ======== */
.app-footer {
  text-align: center; padding: 32px 20px;
  color: var(--text-tertiary); font-size: 13px;
  border-top: 1px solid var(--border); margin-top: 40px;
}
.app-footer p { margin: 4px 0; }
.footer-link { color: var(--accent); font-weight: 500; }

/* ======== 主容器 ======== */
.main-container {
  max-width: var(--max-w); margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ======== 首页 - Hero ======== */
.hero-section { text-align: center; padding: 40px 0 32px; }
.hero-icon { font-size: 56px; margin-bottom: 12px; }
.hero-title {
  font-size: 32px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 8px;
}
.hero-subtitle { font-size: 18px; color: var(--text-secondary); margin-bottom: 12px; }
.hero-desc { font-size: 14px; color: var(--text-tertiary); max-width: 520px; margin: 0 auto 24px; line-height: 1.8; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* ======== 首页 - 历史结果卡片 ======== */
.history-card {
  display: flex; align-items: center; gap: 16px;
  cursor: pointer; margin-bottom: 32px;
  border: 2px solid transparent;
}
.history-card:hover { border-color: var(--accent-light); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.history-badge {
  font-size: 12px; color: var(--accent);
  background: rgba(108,92,231,0.1);
  padding: 4px 10px; border-radius: 20px; white-space: nowrap;
}
.history-content { display: flex; align-items: center; gap: 12px; flex: 1; }
.history-emoji { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.history-emoji svg { width: 48px; height: auto; display: block; }
.history-info { display: flex; flex-direction: column; }
.history-type { font-size: 20px; font-weight: 800; color: var(--accent); }
.history-name { font-size: 14px; color: var(--text-secondary); }
.history-time { font-size: 12px; color: var(--text-tertiary); margin-left: auto; }
.history-arrow { font-size: 14px; color: var(--accent); white-space: nowrap; }

/* ======== 首页 - 特性网格 ======== */
.section-title {
  text-align: center; font-size: 22px; font-weight: 700;
  margin-bottom: 24px; color: var(--text-primary);
}
.features-section { margin-bottom: 40px; }
.features-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
.feature-card {
  background: var(--bg-secondary); border-radius: var(--radius);
  padding: 24px 16px; text-align: center;
  box-shadow: var(--shadow); transition: transform 0.25s, box-shadow 0.25s;
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.feature-icon { font-size: 36px; margin-bottom: 8px; }
.feature-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.feature-card p { font-size: 12px; color: var(--text-tertiary); line-height: 1.6; }

/* ======== 首页 - 维度卡片 ======== */
.dimensions-section { margin-bottom: 20px; }
.dimensions-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.dimension-card {
  background: var(--bg-secondary); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.dim-label { font-size: 12px; color: var(--accent); text-align: center; margin-bottom: 12px; font-weight: 600; }
.dim-poles { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dim-pole { display: flex; flex-direction: column; align-items: center; flex: 1; }
.dim-letter {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; margin-bottom: 4px;
  background: rgba(108,92,231,0.1); color: var(--accent);
}
.dim-name { font-size: 13px; font-weight: 600; }
.dim-desc { font-size: 11px; color: var(--text-tertiary); }
.dim-vs { font-size: 14px; color: var(--text-tertiary); font-weight: 600; }

/* ======== 答题页 ======== */
.quiz-container { padding-top: 8px; }
.quiz-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.quiz-progress-info { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.progress-bar-wrapper {
  height: 6px; background: var(--bg-tertiary); border-radius: 3px;
  margin-bottom: 24px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 3px; transition: width 0.4s ease;
}
.quiz-card {
  background: var(--bg-secondary); border-radius: var(--radius-lg);
  padding: 32px 24px; box-shadow: var(--shadow);
  margin-bottom: 24px; animation: fadeInUp 0.3s ease;
}
.quiz-dimension-tag {
  display: inline-block; font-size: 12px; font-weight: 600;
  color: var(--accent); background: rgba(108,92,231,0.1);
  padding: 4px 12px; border-radius: 20px; margin-bottom: 16px;
}
.quiz-question { font-size: 20px; font-weight: 600; margin-bottom: 24px; line-height: 1.6; }
.quiz-options { display: flex; flex-direction: column; gap: 12px; }
.quiz-option {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 20px; border-radius: var(--radius);
  border: 2px solid var(--border); background: var(--bg-secondary);
  transition: all 0.2s; text-align: left; width: 100%;
}
.quiz-option:hover { border-color: var(--accent-light); background: rgba(108,92,231,0.04); }
.quiz-option.selected { border-color: var(--accent); background: rgba(108,92,231,0.1); }
.option-label {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; flex-shrink: 0;
  background: var(--bg-tertiary); color: var(--text-tertiary);
  transition: all 0.2s;
}
.quiz-option.selected .option-label { background: var(--accent); color: #fff; }
.option-text { font-size: 15px; line-height: 1.6; padding-top: 4px; }
.quiz-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px;
}
.quiz-counter { font-size: 14px; color: var(--text-tertiary); }
.quiz-end-bar {
  text-align: center; margin-top: 20px;
  padding-top: 16px; border-top: 1px dashed var(--border);
}
.quiz-end-bar .btn { font-size: 13px; opacity: 0.6; }
.quiz-end-bar .btn:hover { opacity: 1; }

/* ======== 结果页 ======== */
.result-container { padding-top: 8px; }
.result-hero {
  text-align: center; padding: 40px 24px; border-radius: var(--radius-lg);
  margin-bottom: 24px; color: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  animation: fadeInUp 0.4s ease;
}
.result-emoji { display: flex; justify-content: center; margin-bottom: 8px; }
.result-emoji svg { width: 100px; height: auto; display: block; }
.result-type-code { font-size: 56px; font-weight: 900; letter-spacing: 4px; }
.result-type-name { font-size: 28px; font-weight: 700; margin-top: 4px; }
.result-type-subtitle { font-size: 14px; opacity: 0.8; margin-top: 4px; }
.result-tags { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.result-tag {
  font-size: 13px; padding: 4px 14px;
  background: rgba(255,255,255,0.2); border-radius: 20px;
}
.result-actions, .result-bottom-actions {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  margin-bottom: 24px;
}
.result-bottom-actions { margin-top: 32px; margin-bottom: 0; }

.result-section { margin-bottom: 16px; }
.section-heading { font-size: 18px; font-weight: 700; margin-bottom: 16px; color: var(--text-primary); }
.result-summary { font-size: 15px; line-height: 1.9; color: var(--text-secondary); }

/* 维度得分条 */
.dim-bars { display: flex; flex-direction: column; gap: 20px; }
.dim-bar-item {}
.dim-bar-labels {
  display: flex; justify-content: space-between; margin-bottom: 6px;
  font-size: 13px; color: var(--text-tertiary);
}
.dim-bar-labels .dim-active { font-weight: 700; color: var(--accent); }
.dim-bar-track {
  height: 10px; background: var(--bg-tertiary); border-radius: 5px;
  overflow: hidden;
}
.dim-bar-fill { height: 100%; border-radius: 5px; transition: width 0.6s ease; }
.dim-bar-pct {
  display: flex; justify-content: space-between; margin-top: 4px;
  font-size: 12px; color: var(--text-tertiary);
}
.dim-bar-pct .dim-active { font-weight: 700; color: var(--accent); }
.dim-bar-primary { font-weight: 700; color: var(--accent); font-size: 13px; }

/* 两列布局 */
.result-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* 列表 */
.result-list { list-style: none; }
.result-list li {
  position: relative; padding-left: 24px; margin-bottom: 10px;
  font-size: 14px; line-height: 1.7; color: var(--text-secondary);
}
.result-list li::before { content: '●'; position: absolute; left: 0; color: var(--success); font-size: 10px; top: 6px; }
.result-list-warn li::before { color: var(--warn); }
.result-list-growth li::before { content: '→'; color: var(--accent); font-size: 12px; top: 4px; }

/* 职业标签 */
.career-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.career-tag {
  font-size: 13px; padding: 6px 16px; border-radius: 20px;
  background: rgba(108,92,231,0.1); color: var(--accent); font-weight: 500;
}
.result-relationships { font-size: 14px; line-height: 1.9; color: var(--text-secondary); }

/* 匹配预览 */
.match-preview { margin-top: 16px; }
.match-preview-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.match-preview-col h4 { font-size: 14px; margin-bottom: 10px; color: var(--text-secondary); }
.match-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 6px; border-radius: var(--radius-sm);
  background: var(--bg-tertiary); cursor: pointer; transition: all 0.2s;
  margin-bottom: 6px;
}
.match-item:hover { background: rgba(108,92,231,0.12); transform: translateY(-1px); }
.match-type { font-size: 16px; font-weight: 800; color: var(--accent); }
.match-name { font-size: 11px; color: var(--text-tertiary); }

/* ======== 匹配页 ======== */
.match-container { padding-top: 16px; }
.page-title { text-align: center; font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.page-subtitle { text-align: center; font-size: 15px; color: var(--text-tertiary); margin-bottom: 32px; }

.match-selector {
  display: flex; align-items: center; gap: 16px; margin-bottom: 32px;
  background: var(--bg-secondary); padding: 24px; border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.match-select-group { flex: 1; }
.match-select-group label { display: block; font-size: 13px; color: var(--text-tertiary); margin-bottom: 8px; }
.match-select {
  width: 100%; padding: 12px 16px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--bg-secondary);
  color: var(--text-primary); font-size: 15px; transition: border-color 0.2s;
}
.match-select:focus { outline: none; border-color: var(--accent); }
.match-vs-icon { font-size: 32px; margin-top: 20px; }

.match-empty {
  text-align: center; padding: 48px 20px; color: var(--text-tertiary);
}
.match-empty-icon { font-size: 48px; margin-bottom: 12px; }
.match-empty-hint { font-size: 13px; margin-top: 4px; }

.match-result-card {
  background: var(--bg-secondary); border-radius: var(--radius-lg);
  padding: 32px 24px; box-shadow: var(--shadow);
  animation: fadeInUp 0.4s ease; margin-bottom: 24px;
}
.match-result-header { display: flex; align-items: center; justify-content: space-around; }
.match-profile { text-align: center; }
.match-profile-emoji { display: flex; justify-content: center; margin-bottom: 4px; }
.match-profile-emoji svg { width: 48px; height: auto; display: block; }
.match-profile-type { font-size: 24px; font-weight: 800; color: var(--accent); }
.match-profile-name { font-size: 13px; color: var(--text-tertiary); }
.match-score-display { text-align: center; }
.match-score-number { font-size: 48px; font-weight: 900; line-height: 1; }
.match-score-label { font-size: 14px; font-weight: 600; }
.match-relationship-tag {
  display: inline-block; font-size: 15px; font-weight: 600;
  color: #fff; padding: 6px 20px; border-radius: 20px;
  margin: 16px auto 0; display: block; width: fit-content; margin-left: auto; margin-right: auto;
}
.match-description { font-size: 15px; line-height: 1.9; color: var(--text-secondary); margin-top: 20px; text-align: center; }
.match-bar-wrapper { margin-top: 20px; }
.match-bar-track { height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; }
.match-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.match-bar-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }

.match-quick-section { margin-top: 32px; }
.match-quick-section h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; text-align: center; }
.match-back-home { text-align: center; margin-top: 40px; }

/* ======== 海报弹窗 ======== */
.poster-modal {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7); display: flex;
  align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn 0.2s ease;
}
.poster-modal-content {
  background: var(--bg-secondary); border-radius: var(--radius);
  max-width: 420px; width: 100%; max-height: 90vh;
  overflow-y: auto; padding: 20px;
}
.poster-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.poster-modal-header h3 { font-size: 18px; font-weight: 700; }
.poster-close { font-size: 24px; color: var(--text-tertiary); }
.poster-image-wrapper { text-align: center; margin-bottom: 16px; }
.poster-image-wrapper img { max-width: 100%; border-radius: var(--radius-sm); }
.poster-modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* ======== Toast提示 ======== */
.toast {
  position: fixed; bottom: 40px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary); color: var(--bg-primary);
  padding: 12px 28px; border-radius: 24px;
  font-size: 14px; font-weight: 500; z-index: 2000;
  opacity: 0; transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: var(--danger); color: #fff; }

/* ======== 异常兜底 ======== */
.error-fallback {
  text-align: center; padding: 60px 20px;
}
.error-fallback h2 { font-size: 20px; margin-bottom: 12px; }
.error-fallback p { color: var(--text-tertiary); margin-bottom: 20px; }

/* ======== 动画 ======== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ======== 响应式适配 ======== */
@media (max-width: 600px) {
  .hero-title { font-size: 26px; }
  .hero-subtitle { font-size: 16px; }
  .features-grid { grid-template-columns: 1fr; }
  .result-two-col { grid-template-columns: 1fr; }
  .match-preview-grid { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .match-item { padding: 8px 4px; }
  .match-type { font-size: 14px; }
  .match-name { font-size: 10px; }
  .quiz-card { padding: 24px 16px; }
  .quiz-question { font-size: 18px; }
  .result-type-code { font-size: 44px; }
  .result-type-name { font-size: 24px; }
  .match-selector { flex-direction: column; gap: 12px; }
  .match-vs-icon { margin-top: 0; }
  .match-score-number { font-size: 36px; }
  .match-profile-type { font-size: 20px; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { width: 100%; }
  .result-bottom-actions { flex-direction: column; }
  .result-bottom-actions .btn { width: 100%; }
}

@media (max-width: 380px) {
  .hero-title { font-size: 22px; }
  .quiz-question { font-size: 16px; }
  .option-text { font-size: 14px; }
  .match-preview-grid { grid-template-columns: 1fr; }
}

/* 微信内置浏览器适配 */
@media (min-resolution: 2dppx) {
  .quiz-option, .btn { -webkit-tap-highlight-color: transparent; }
}
