/* ==============================================
 * style.css — MBTI 性格测试全站样式
 * 深色渐变主题,响应式适配,交互动画
 * ============================================== */

/* ---------- 设计变量 ---------- */
:root {
  /* 品牌主色(按钮主色按项目规范 #4a90d9) */
  --primary: #4a90d9;
  --primary-hover: #5ba3e8;
  --accent: #9b6cff;

  /* 文字与背景 */
  --bg: #0b1220;
  --text: #e7ecf5;
  --text-muted: #93a1b8;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.12);

  /* 风险色 */
  --danger: #e05252;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 32px 16px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  /* 深色渐变底:右上与左下两团柔光叠在深底上 */
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(74, 144, 217, 0.22), transparent 70%),
    radial-gradient(900px 520px at -10% 110%, rgba(155, 108, 255, 0.16), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

h1, h2 {
  font-weight: 600;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- 视图切换 ---------- */
.view {
  display: none;
  width: 100%;
  max-width: 640px;
}

.view.active {
  display: block;
  animation: fade-up 0.35s ease both;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- 卡片容器 ---------- */
.card {
  padding: 32px 28px;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: var(--card-bg);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

/* ---------- 工具类 ---------- */
.muted {
  color: var(--text-muted);
}

.small {
  font-size: 13px;
}

.center {
  text-align: center;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

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

/* 主按钮:统一使用主色 */
.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 24px rgba(74, 144, 217, 0.35);
}

.btn.primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 10px 28px rgba(74, 144, 217, 0.45);
}

.btn.ghost {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn.danger {
  border: 1px solid rgba(224, 82, 82, 0.35);
  background: rgba(224, 82, 82, 0.08);
  color: #f0a3a3;
}

.btn.danger:hover {
  background: rgba(224, 82, 82, 0.18);
}

.btn.big {
  width: 100%;
  padding: 15px;
  font-size: 17px;
  margin-top: 22px;
}

.btn.small {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 9px;
}

/* ---------- 首页 ---------- */
.hero {
  text-align: center;
}

.logo-badge {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  /* 品牌渐变徽标 */
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 12px 30px rgba(74, 144, 217, 0.4);
}

.hero h1 {
  font-size: 30px;
  letter-spacing: 2px;
}

.hero .subtitle {
  margin-top: 10px;
  color: var(--text-muted);
}

/* 免责说明 */
.disclaimer {
  margin-top: 20px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: #d8c9a8;
  border: 1px solid rgba(230, 190, 120, 0.25);
  border-radius: 12px;
  background: rgba(230, 190, 120, 0.07);
}

/* ---------- 历史记录 ---------- */
.history {
  margin-top: 30px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-head h2 {
  font-size: 17px;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  text-align: left;
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.history-item:hover {
  border-color: rgba(74, 144, 217, 0.6);
  background: rgba(74, 144, 217, 0.08);
  transform: translateX(3px);
}

.history-type {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--primary-hover);
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
}

.history-name {
  font-size: 15px;
}

.history-date {
  margin-left: auto;
  white-space: nowrap;
}

/* ---------- 测试页 ---------- */
.test-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* 进度条 */
.progress-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 30px;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 3px;
  /* 渐变进度条 + 宽度过渡动画 */
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.question {
  min-height: 76px;
  font-size: 22px;
  line-height: 1.5;
  margin-bottom: 26px;
}

/* 题干只作焦点落点(切题后承接焦点),不显示焦点环 */
.question:focus {
  outline: none;
}

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

.opt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  font-size: 16px;
  line-height: 1.6;
  text-align: left;
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.opt:hover {
  border-color: var(--primary);
  background: rgba(74, 144, 217, 0.12);
  transform: translateX(4px);
}

.opt .opt-tag {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-hover);
  border: 1px solid rgba(74, 144, 217, 0.5);
  border-radius: 50%;
  transition: background 0.15s ease, color 0.15s ease;
}

/* 选项文字占满剩余宽度,让整行可点击 */
.opt > span:last-child {
  flex: 1;
}

.opt:hover .opt-tag {
  background: var(--primary);
  color: #fff;
}

/* 已作答/正被点击的选项:高亮边框与徽标 */
.opt.picked {
  border-color: var(--primary);
  background: rgba(74, 144, 217, 0.16);
}

.opt.picked .opt-tag {
  background: var(--primary);
  color: #fff;
}

/* 禁用按钮(如第一题的"上一题"):弱化且不可点 */
.btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* ---------- 触屏设备:禁用悬停效果 ----------
 * 触屏的"点击"会被浏览器当成悬停并粘在按钮上,
 * 若悬停样式可见,切题后会残留成选项高亮,像"光标还停在上一题";
 * 触屏改用 :active 做真实的按压反馈 */
@media (hover: none) {
  .opt:hover,
  .btn:hover {
    transform: none;
  }

  .opt:hover:not(.picked) {
    border-color: var(--card-border);
    background: rgba(255, 255, 255, 0.04);
  }

  .opt:hover:not(.picked) .opt-tag {
    background: transparent;
    color: var(--primary-hover);
  }

  /* 按压反馈:按下瞬间变亮,抬手即消失 */
  .opt:active {
    border-color: var(--primary);
    background: rgba(74, 144, 217, 0.16);
  }
}

.test-hint {
  margin-top: 20px;
  text-align: center;
}

/* ---------- 结果页 ---------- */
#view-result {
  text-align: center;
}

/* 四字母大字:品牌渐变文字 */
.result-letters {
  margin: 10px 0 6px;
  font-size: 64px;
  font-weight: 800;
  letter-spacing: 10px;
  line-height: 1.15;
  background: linear-gradient(120deg, var(--primary) 20%, var(--accent) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result-letters span {
  display: inline-block;
  opacity: 0;
  animation: letter-in 0.45s ease forwards;
}

@keyframes letter-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0 18px;
}

/* 类型名称胶囊 */
.type-chip {
  padding: 6px 18px;
  font-size: 16px;
  color: #fff;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 6px 18px rgba(74, 144, 217, 0.35);
}

.result-desc {
  font-size: 16px;
  line-height: 1.9;
  color: #c6d2e4;
  margin-bottom: 30px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* ---------- 响应式:手机宽度 ---------- */
@media (max-width: 520px) {
  body {
    padding: 14px 10px;
  }

  .card {
    padding: 24px 18px;
    border-radius: 16px;
  }

  .hero h1 {
    font-size: 24px;
  }

  .logo-badge {
    width: 60px;
    height: 60px;
    font-size: 15px;
  }

  .question {
    font-size: 19px;
    min-height: 64px;
  }

  .opt {
    padding: 14px;
    font-size: 15px;
  }

  .result-letters {
    font-size: 44px;
    letter-spacing: 6px;
  }

  .history-date {
    display: none; /* 窄屏隐藏日期,让类型与名称更舒展 */
  }
}
