/* ============================================================
   三国版人格测试 H5 — UI 样式
   ============================================================ */

/* ---------- 色彩 Token ---------- */
:root {
  --paper: #F5EFE0;        /* 页面底色宣纸 */
  --paper-deep: #EDE3CB;   /* 卡片底、过场页底 */
  --ink: #2B2622;          /* 主文字墨黑 */
  --ink-soft: #6B6257;     /* 次要文字 */
  --cinnabar: #B03A2E;     /* 主色朱砂 */
  --azure: #3D5A5C;        /* 辅助黛青 */
  --gold: #C9A063;         /* 点缀鎏金 */
  --white: #FFFDF7;        /* 选项卡底 */

  --font-title: "Kaiti SC", "STKaiti", "KaiTi", serif;
  --font-body: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-num: Georgia, serif;
}

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

/* hidden 属性始终生效，防止组件 display 规则覆盖 UA 默认样式 */
[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  /* safe-area 适配 */
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  padding-bottom: env(safe-area-inset-bottom);
}

ul,
ol {
  list-style: none;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

canvas {
  display: block;
  max-width: 100%;
}

/* ---------- 布局骨架 ---------- */
#app-header {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 0 8px;
  text-align: center;
}

#app-title {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 2px;
}

#app-main {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* 视图切换容器 */
.view {
  width: 100%;
  padding-bottom: 40px;
}

.view[hidden] {
  display: none;
}

/* 页面切换动画：fade + translateY(12px) 入场 */
.view-enter {
  animation: viewEnter 250ms ease-out both;
}

@keyframes viewEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- 印章字徽 ---------- */
.seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--cinnabar);
  color: var(--white);
  font-family: var(--font-title);
  font-weight: 700;
  border-radius: 6px;
  transform: rotate(-3deg);
  box-shadow: inset 0 0 0 2px var(--white); /* 2px 内白边 */
  text-align: center;
  line-height: 1;
  padding-top: 2px; /* 楷体字形在大字号下垂直偏上，微调居中 */
  user-select: none;
}

.seal-lg {
  width: 96px;
  height: 96px;
  font-size: 40px;
}

.seal-md {
  width: 48px;
  height: 48px;
  font-size: 22px;
}

.seal-sm {
  width: 40px;
  height: 40px;
  font-size: 18px;
}

/* 印章入场动画：scale 0.6→1 + 旋转归位，400ms 弹性
   注意：只定义 from 帧，to 自动取元素自身 transform（含 .result-card .seal 的
   translateX(-50%)），避免写死 to 覆盖悬挂印章的水平居中导致右偏 */
.seal-enter {
  animation: sealEnter 400ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes sealEnter {
  from {
    opacity: 0;
    transform: scale(0.6) rotate(-45deg);
  }
}

/* ---------- 主按钮 ---------- */
.btn-primary,
#btn-start {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  background-color: var(--cinnabar);
  color: var(--white);
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  border-radius: 8px;
  transition: transform 120ms ease-out, opacity 120ms ease-out;
}

.btn-primary:active,
#btn-start:active {
  transform: scale(0.97);
}

.btn-primary[disabled] {
  opacity: 0.5;
}

/* 次级按钮（上一题等） */
.btn-secondary,
#btn-prev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  color: var(--ink-soft);
  font-size: 14px;
  border-radius: 8px;
  transition: transform 120ms ease-out;
}

.btn-secondary:active,
#btn-prev:active {
  transform: scale(0.97);
}

/* ---------- 首页 ---------- */
.home-title {
  text-align: center;
  padding: 24px 0 8px;
}

.home-main-title {
  font-family: var(--font-title);
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 4px;
  line-height: 1.4;
}

.home-sub-title {
  margin-top: 8px;
  font-family: var(--font-title);
  font-size: 16px;
  color: var(--ink-soft);
  letter-spacing: 2px;
}

.home-intro {
  margin: 20px 0;
  padding: 16px;
  background-color: var(--paper-deep);
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.8;
}

.home-counter {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 20px 0 28px;
}

#counter-num {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 32px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.counter-text {
  font-size: 14px;
  color: var(--ink-soft);
}

.home-actions {
  padding: 0 8px;
}

/* ---------- 答题视图 ---------- */
.quiz-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 16px;
}

.progress-track {
  flex: 1;
  height: 4px;
  background-color: rgba(61, 90, 92, 0.2); /* 黛青 20% */
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background-color: var(--cinnabar);
  border-radius: 2px;
  transition: width 300ms ease-out;
}

#progress-text {
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 700;
  color: var(--azure);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 章节过场页 */
.quiz-chapter {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background-color: var(--paper-deep);
  border-radius: 12px;
  padding: 40px 24px;
  margin-bottom: 20px;
}

.quiz-chapter.is-active {
  display: flex;
}

.chapter-name {
  font-family: var(--font-title);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 3px;
}

/* 上下 1px 鎏金分隔线 */
.chapter-divider {
  width: 64px;
  height: 1px;
  background-color: var(--gold);
  margin: 16px 0;
  border: none;
}

.chapter-quote {
  font-family: var(--font-title);
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.9;
  margin-bottom: 24px;
}

.chapter-continue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 160px;
  padding: 0 32px;
  background-color: var(--cinnabar);
  color: var(--white);
  font-family: var(--font-title);
  font-size: 16px;
  letter-spacing: 2px;
  border-radius: 8px;
  transition: transform 120ms ease-out;
}

.chapter-continue:active {
  transform: scale(0.97);
}

/* 题目区 */
.quiz-question {
  padding-top: 4px;
}

#question-text {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.6;
  margin-bottom: 20px;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

/* 选项卡 */
.option-btn {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 16px;
  background-color: var(--white);
  border: 1px solid var(--azure);
  border-radius: 10px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  text-align: left;
  transition: border-color 300ms ease-out, background-color 300ms ease-out;
  overflow: hidden;
}

/* 左侧 4px 朱砂竖条（选中态出现） */
.option-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--cinnabar);
  opacity: 0;
  transition: opacity 300ms ease-out;
}

.option-btn.is-selected {
  border-color: var(--cinnabar);
}

.option-btn.is-selected::before {
  opacity: 1;
}

/* 选项反馈高亮（300ms 后跳题） */
.option-btn.is-flash {
  background-color: rgba(176, 58, 46, 0.08);
}

#btn-prev {
  margin-top: 4px;
}

/* ---------- 结果视图 ---------- */
/* 人设卡：竖版卷轴式（padding-top 容纳悬挂印章：96px 印身 - 24px 悬出 = 72px + 20px 间距） */
.result-card {
  position: relative;
  background-color: var(--white);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 92px 24px 28px;
  margin-top: 40px;
  text-align: center;
}

/* 顶部悬挂印章字徽 */
.result-card .seal {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
}

.result-person-name {
  font-family: var(--font-title);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.result-person-title {
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: 1px;
}

/* 匹配度数字：鎏金加粗 */
.result-match-num,
.match-num {
  font-family: var(--font-num);
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* 雷达图 */
.radar-canvas {
  width: 100%;
  margin: 24px auto 0;
}

/* 11 个区块 */
.result-blocks {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.result-block {
  background-color: var(--paper-deep);
  border-radius: 10px;
  padding: 16px;
}

.result-block-title,
.block-title {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}

.result-block-body,
.block-body {
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
}

.result-block .block-sub {
  font-size: 13px;
  color: var(--ink-soft);
}

/* 标签（黛青） */
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 12px;
  border: 1px solid var(--azure);
  border-radius: 14px;
  color: var(--azure);
  font-size: 13px;
  line-height: 1.4;
  margin: 4px 6px 4px 0;
}

/* ---------- 图鉴格 ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.gallery-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* 点亮态 */
.gallery-cell.is-unlocked {
  background-color: var(--white);
  border: 1px solid var(--gold);
}

.gallery-cell .gallery-name {
  font-family: var(--font-title);
  font-size: 14px;
  color: var(--ink);
}

/* 未点亮态：黛青 15% 底 + 墨点剪影 + "???" */
.gallery-cell.is-locked {
  background-color: rgba(61, 90, 92, 0.15);
}

.gallery-cell.is-locked::before {
  content: "";
  width: 40px;
  height: 40px;
  border-radius: 50% 50% 46% 54% / 56% 48% 52% 44%;
  background-color: var(--ink);
  opacity: 0.35;
}

.gallery-cell .gallery-unknown {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: 1px;
}

/* ---------- 分享弹层 ---------- */
.modal-share {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: rgba(43, 38, 34, 0.85);
  padding: 24px;
}

.modal-share[hidden] {
  display: none;
}

.share-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}

.share-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background-color: var(--cinnabar);
  color: var(--white);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}

.share-close:active {
  transform: scale(0.94);
}

.share-canvas {
  max-width: 100%;
  max-height: 76vh;
  border-radius: 10px;
}

.share-tip {
  margin-top: 16px;
  color: var(--white);
  font-size: 14px;
  letter-spacing: 1px;
}

/* ---------- 访问验证码门 ---------- */
body.gate-locked {
  overflow: hidden;
}

.gate-access {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--paper);
  padding: 24px;
}

.gate-access[hidden] {
  display: none;
}

.gate-panel {
  width: 100%;
  max-width: 340px;
  background-color: var(--paper-deep);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 36px 28px 24px;
  text-align: center;
}

/* 锁形装饰：朱砂锁身 + 鎏金白边 */
.gate-lock {
  position: relative;
  width: 56px;
  height: 66px;
  margin: 0 auto 16px;
}

.gate-lock-shackle {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 34px;
  border: 5px solid var(--cinnabar);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  display: block;
}

.gate-lock-body {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 56px;
  height: 38px;
  background-color: var(--cinnabar);
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px var(--white);
  display: block;
}

.gate-lock-body::after {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--white);
}

.gate-title {
  font-family: var(--font-title);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 6px;
}

.gate-desc {
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-soft);
}

.gate-input {
  width: 180px;
  height: 56px;
  margin-top: 20px;
  text-align: center;
  font-family: var(--font-num);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 10px;
  text-indent: 10px; /* 抵消 letter-spacing 导致的视觉偏移 */
  color: var(--ink);
  background-color: var(--white);
  border: 1px solid var(--azure);
  border-radius: 10px;
  outline: none;
}

.gate-input:focus {
  border-color: var(--cinnabar);
}

.gate-btn {
  width: 180px;
  margin: 16px auto 0;
  letter-spacing: 6px;
}

.gate-error {
  min-height: 22px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--cinnabar);
}

/* ---------- 结果页新增区块 ---------- */
.radar-caption {
  margin-top: 8px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
}

.result-evidence {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.evidence-card {
  background-color: var(--white);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
}

.evidence-head {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  color: var(--cinnabar);
}

.evidence-quote {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink);
}

.evidence-insight {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink-soft);
}

.disclaimer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- 动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  .view-enter,
  .seal-enter {
    animation: none;
  }

  .progress-bar,
  .option-btn,
  .option-btn::before {
    transition: none;
  }
}

/* ---------- 六维选择倾向横向条形图 ---------- */
.tendency-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0 8px;
}
.tendency-item { text-align: left; }
.tendency-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.tendency-name {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.tendency-value {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 14px;
  color: var(--gold);
}
.tendency-track {
  height: 8px;
  border-radius: 4px;
  background-color: rgba(61, 90, 92, 0.2);
  overflow: hidden;
}
.tendency-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background-color: var(--cinnabar);
  transition: width 300ms ease-out;
}
