/* ============================================================
   QiSpace — 细节优化层 / Design Polish Layer
   ------------------------------------------------------------
   定位：只在原有样式之后追加「细节修正」，不改信息结构、不动 JS 逻辑、
        不碰 data-i18n / <form> / fetch('/api/…')。
   移除方式：删掉各页面 <head> 里指向本文件的那行 <link> 即可完全回退。

   四类改动：
   ① 对比度与可读性      ② 键盘 / 触控可达性
   ③ 状态反馈与动效      ④ 排版与响应式细节
   ============================================================ */

/* ─────────────────────────────────────────────────────────
   ① 新增 token（不改旧值）
   --muted 的对比度修正在 index.html / landing.html 的 :root 里就地改过：
   原 #7A7268 在页面底 #06090F 上 4.21:1、在卡片 #121825 上 3.75:1，都低于
   WCAG AA 4.5:1，全站 79 处小字都挂在这个色上；改为 #94897C 后为
   5.82:1 / 5.18:1，与正文 #E8E0D0（9.2:1）仍保持清晰层级。
   浅色纸感页面（guides / lp-bedroom）自带 #6E7268，未受影响。
   ───────────────────────────────────────────────────────── */
:root {
  --muted-strong: #B0A697;   /* 比弱化文字再重一档的场合 */
  --focus: #F0D080;          /* 键盘焦点环：与高光金同源 */
  --ring: rgba(240, 208, 128, .22);
}

/* ─────────────────────────────────────────────────────────
   ② 键盘焦点：全站补齐 :focus-visible
   原样式只有 :hover，键盘 Tab 时焦点不可见（WCAG 2.4.7 失败项）。
   用 :where() 保持 0 权重，页面原有规则仍可覆盖。
   ───────────────────────────────────────────────────────── */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
/* 语言切换器是 overflow:hidden 的胶囊，外描边会被裁掉，改为内嵌环 */
.lang-switch .lang-btn:focus-visible {
  outline-offset: -3px;
  outline-width: 2px;
}
/* 输入框：统一「聚焦 = 金色细边 + 柔光」，与按钮语言一致 */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: rgba(201, 168, 76, .55) !important;
  box-shadow: 0 0 0 3px var(--ring);
}

/* ─────────────────────────────────────────────────────────
   ③ 触控目标：按输入方式区分
   鼠标端保持精致的小字排版；触屏端（pointer:coarse）把可点区域撑到
   ≥40–44px，符合 WCAG 2.5.8 与移动端 44px 惯例。
   ───────────────────────────────────────────────────────── */
@media (pointer: coarse) {
  .nav-links a,
  footer .f-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  .lang-btn { min-height: 40px; padding: 10px 16px; }
  .shop-tab { min-height: 40px; }
  .pb-add { min-height: 44px; }
  .hero-help-btn,
  .hero-alt {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  .btn-next,
  .btn-prev { min-height: 48px; }
}

/* 鼠标端：文字链用伪元素外扩热区，视觉尺寸不变但更好点中 */
.nav-links a,
footer .f-links a,
.hero-alt,
.hero-help-btn { position: relative; }
.nav-links a::after,
footer .f-links a::after,
.hero-alt::after,
.hero-help-btn::after {
  content: '';
  position: absolute;
  inset: -12px 0;
}

/* ─────────────────────────────────────────────────────────
   ④ 移动端导航：把主 CTA 拉回来
   原规则在 ≤768px 把 .nav-links 里所有 <a> 都藏了，只剩语言切换，
   手机上首屏看完就没有任何通往问卷的入口。这里保留第四个链接
   （Get Started →）作为常驻 CTA，其余三个次要链接仍然隐藏。
   ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  nav { padding: 10px 16px; gap: 10px; }
  .logo { font-size: 19px; letter-spacing: 2.6px; }
  .nav-links { gap: 8px; flex-shrink: 0; }

  .nav-links > a { display: none; }
  .nav-links > a:last-of-type {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    margin: 0;
    padding: 0 10px;
    font-size: 10px;
    letter-spacing: .6px;
    white-space: nowrap;
  }
  /* 手机端语言按钮必须水平不折行，否则「繁中」会竖排 */
  .lang-switch { margin-left: 0; flex-shrink: 0; }
  .lang-btn {
    min-height: 34px;
    padding: 8px 11px;
    font-size: 11px;
    white-space: nowrap;
  }
  /* 手机上字母标识的副标题会和 CTA 抢位置，先收起 */
  .logo-sub { display: none; }

  /* 徽标一行放不下：缩字距与内边距，避免圆点独占一行 */
  .hero-badge {
    letter-spacing: 1.1px;
    font-size: 9px;
    padding: 7px 13px;
    gap: 6px;
    max-width: 100%;
  }
  .hero-badge .dot { flex: 0 0 auto; }
}

/* 360px 及以下：三个元素挤不下，收回导航 CTA（首屏九宫格本身就在第一屏） */
@media (max-width: 380px) {
  .nav-links > a:last-of-type { display: none; }
}

/* ─────────────────────────────────────────────────────────
   ⑤ 九宫格「未解锁」格：可读性
   原样式把「locked」压到 opacity .38 @8.5px，在暗底上几乎看不见，
   用户读不出「这格被锁了」，付费墙的说服力反而被削弱。
   现在：虚线描边 + 淡化问号加圈 + 标签回到可读阈值，保留「不可点」的克制感。
   ───────────────────────────────────────────────────────── */
.fsg-cell.locked {
  border-style: dashed !important;
  border-color: rgba(255, 255, 255, .14) !important;
  background: rgba(255, 255, 255, .015) !important;
}
.fsg-cell.locked .star-num {
  width: 26px;
  height: 26px;
  margin: 0 auto 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed rgba(240, 208, 128, .34);
  border-radius: 50%;
  opacity: .95;
  /* 桌面与结果页两处原有规则都给了 17–26px，会把问号顶出圆圈；
     这里统一收到 12px 并锁死，避免出现「字被裁掉」的观感 */
  font-size: 12px !important;
  line-height: 1 !important;
  letter-spacing: 0 !important;
  padding-bottom: 1px;
}
.fsg-cell.locked .star-eff {
  font-size: 9px;
  letter-spacing: .4px;
  opacity: .8;
  text-transform: uppercase;
  color: var(--muted-strong);
}
.fsg-cell.locked .star-dir { opacity: .72; }

/* 已解锁格的判语是结果页最该被读到的信息，原来压到 opacity .72 @10px，
   手机上基本看不清，抬到 .88 */
.fsg-cell .star-eff { opacity: .88; }

/* 「五黄」是这一屏的主角（今年最重的一颗星），
   原红色 #E74C3C 叠在 rgba(231,76,60,.15) 的底上只有 4.33:1，未达 AA。
   换成 #FF7262（6.18:1），语义仍是警示红，但数字和判语更「烧」。 */
.fsg-cell.fatal { color: #FF7262; }
.fsg-cell.fatal .star-num { text-shadow: 0 0 22px rgba(231, 76, 60, .5); }

/* 一优一劣两张判语卡：长段落居中会两头参差，改为左对齐
   （标签 / 标题 / 正文同一条左边线，仍是卡片式排版，不影响整体居中节奏） */
.rs-card { text-align: left; }
.rs-card .rs-body { color: #C4BBA9; }   /* 比 --text-dim 再清晰一点，长段更好读 */
.rs-do { padding-top: 2px; }

/* 四格数据条：原来 flex-wrap 在 1440 会断成 3+1，第四个（HK 主体）孤零零掉下来。
   宽屏改 4 等分栅格，永远一行；窄屏保持两列。 */
@media (min-width: 900px) {
  .stats-inner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
    max-width: 980px;
  }
  /* 标签比栏宽时会被顶到边线上，收字距 + 允许换行，四格才真正对齐 */
  .stats-inner .stat-item { min-width: 0; padding: 0 8px; }
  .stats-inner .stat-label {
    font-size: 10.5px;
    letter-spacing: .5px;
    line-height: 1.5;
    white-space: normal;
  }
}
@media (max-width: 899px) and (min-width: 641px) {
  .stats-inner { display: grid; grid-template-columns: repeat(2, 1fr); gap: 28px; }
}

/* ─────────────────────────────────────────────────────────
   ⑥ 状态反馈：按下 / 悬停 / 禁用
   按钮只有 hover 没有 active，触摸端「按了没反应」；补一层 pressed 反馈。
   ───────────────────────────────────────────────────────── */
.cta-primary:active,
.btn-next:active,
.qs-locked-cta:active,
.pb-add:active,
.hero-dir:active {
  transform: translateY(0) scale(.985);
}
.cta-primary,
.btn-next,
.qs-locked-cta,
.shop-tab,
.pb-add,
.hero-dir,
.opt-btn {
  -webkit-tap-highlight-color: transparent;
}
.btn-next:disabled,
.qs-locked-cta:disabled,
.pb-add:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}
/* 已被选中的选项再点一次不应有 hover 位移，避免抖动 */
.opt-btn.selected:hover { transform: none; }

/* ─────────────────────────────────────────────────────────
   ⑦ 排版细节
   ───────────────────────────────────────────────────────── */
/* 标题字体：英文标题是 Playfair Display（高对比 Didone 衬线），但 Playfair
   没有汉字，繁体版标题整个掉进系统黑体，品牌气质断裂。
   这里补一条 CJK 衬线回退链（宋体系），拉丁字符仍走 Playfair，
   且不加载任何字体文件 —— 0 KB 成本。缺失字体时自动降级，无副作用。 */
h1,
.section-title,
.quiz-question,
.rs-hero-title {
  font-family: 'Playfair Display', 'Songti TC', 'Songti SC', 'STSong',
    'Noto Serif TC', 'Noto Serif CJK TC', 'Source Han Serif TC', 'SimSun',
    Georgia, serif;
}

/* 标题断行更均匀（Chrome/Safari 支持，其余浏览器自动忽略） */
h1, .section-title, .rs-hero-title { text-wrap: balance; }
.hero-sub, .section-desc, .pain-card span { text-wrap: pretty; }

/* 正文行长：首屏副标题 540px 在 18px 字号下约 60 字/行，偏宽，收一档 */
.hero-sub { max-width: 50ch; }

/* 数字：价格、统计、进度统一等宽，跳动时不抖 */
.stat-num,
.pb-price,
.pp-was,
.pp-now,
.qs-locked-price,
.rec-price,
.countdown { font-variant-numeric: tabular-nums; }

/* 输入占位符原本几乎看不见，提到与弱化文字同级 */
::placeholder { color: var(--muted) !important; opacity: 1; }

::selection {
  background: rgba(201, 168, 76, .28);
  color: #fff;
}

/* 深色页面滚动条（Windows / Linux 上原来的浅色滚动条很出戏） */
@supports (scrollbar-color: auto) {
  html { scrollbar-color: rgba(201, 168, 76, .35) transparent; scrollbar-width: thin; }
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 76, .28);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(201, 168, 76, .45); background-clip: content-box; }

/* 图片：避免非等比拉伸，也不允许撑破容器 */
img, video, canvas, svg { max-width: 100%; height: auto; }
.fsg-cell, .cell, .rec-img { overflow: hidden; }

/* ─────────────────────────────────────────────────────────
   ⑧ 动效：尊重系统「减少动态效果」
   原站有 scroll-behavior:smooth、脉冲圆点、卡片位移，眩晕敏感用户无出口。
   ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .fsg-cell:hover,
  .cell:hover,
  .cta-primary:hover,
  .btn-next:hover {
    transform: none !important;
  }
}

/* ─────────────────────────────────────────────────────────
   ⑨ 打印：报告与结果页打出来别一片黑
   ───────────────────────────────────────────────────────── */
@media print {
  nav, footer, .lang-switch, .dir-badge, .no-print, .hero-badge { display: none !important; }
  body { background: #fff !important; color: #111 !important; }
  .quiz-container, .rec-card, .pain-card, .stat-item {
    border-color: #ccc !important;
    background: #fff !important;
    box-shadow: none !important;
  }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 10px; color: #666; }
}
