/* =====================================================
   玄学运势 · 模块样式（自包含）
   主题：深紫夜空 + 金色点缀，Bento 模块卡片
   ===================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #17122B;
  --bg-2: #1E1738;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.1);
  --ink: #EDE9FE;
  --ink-dim: #A99FC9;
  --ink-faint: #6E6392;
  --gold: #E9C46A;
  --gold-2: #F4D58D;
  --mystic: #8B5CF6;
  --mystic-2: #C084FC;
  --radius: 24px;
  --gap: 16px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
    "Segoe UI", "Microsoft YaHei", sans-serif;
}

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

body {
  min-height: 100vh;
  background:
    radial-gradient(800px 500px at 80% -10%, rgba(139, 92, 246, 0.25), transparent 60%),
    radial-gradient(600px 400px at 0% 100%, rgba(233, 196, 106, 0.08), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 640px; margin: 0 auto; padding: 28px 18px 40px; }

.screen { display: none; }
.screen.active { display: block; animation: screenIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both; }

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

.bento { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); }

.tile {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 26px 22px;
  box-shadow: var(--shadow);
}

.eyebrow {
  text-align: center;
  color: var(--ink-dim);
  font-size: 14px;
  letter-spacing: 4px;
  margin-bottom: 14px;
}

/* ---------- 首页 ---------- */
.hero { text-align: center; margin-bottom: var(--gap); }
.hero-emoji { font-size: 58px; }
.hero h1 { font-size: 34px; letter-spacing: 4px; margin: 10px 0 8px; }
.sub { color: var(--ink-dim); font-size: 14.5px; line-height: 1.7; }

.form-tile { margin-bottom: var(--gap); }
.form-label { display: block; font-size: 14px; color: var(--ink-dim); margin-bottom: 8px; }

#birth {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1.5px solid var(--card-border);
  border-radius: 14px;
  color: var(--ink);
  padding: 13px 16px;
  font-size: 16px;
  font-family: inherit;
  color-scheme: dark;
}
#birth:focus { outline: none; border-color: var(--mystic); }

.form-hint { font-size: 12px; color: var(--ink-faint); margin: 8px 0 14px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.form-err { color: #FCA5A5; font-size: 13px; margin-top: 10px; }

.btn-primary {
  display: inline-block;
  border: none; cursor: pointer;
  font-size: 15.5px; font-weight: 600;
  color: #2B1B00;
  padding: 14px 36px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  box-shadow: 0 6px 20px rgba(233, 196, 106, 0.3);
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary:hover { transform: scale(1.02); box-shadow: 0 10px 28px rgba(233, 196, 106, 0.4); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 14.5px;
  padding: 13px 24px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s ease;
  font-family: inherit;
  text-decoration: none;
  display: inline-block;
}
.btn-ghost:hover { border-color: var(--mystic-2); transform: scale(1.02); }
.btn-small { padding: 11px 24px; font-size: 14px; }

.invite-banner { margin-top: var(--gap); text-align: center; }
.invite-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.invite-desc { color: var(--ink-dim); font-size: 13.5px; }

.note-tile {
  margin-top: var(--gap);
  text-align: center;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.8;
  background: linear-gradient(120deg, rgba(139, 92, 246, 0.12), rgba(233, 196, 106, 0.07));
}

/* ---------- 每日运势 ---------- */
.result-wrap { animation: screenIn 0.5s ease both; }

.hero-tile { text-align: center; margin-bottom: var(--gap); }
.zodiac { color: var(--ink-dim); font-size: 14px; margin-bottom: 8px; }
.tier {
  display: inline-block;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 6px;
  background: linear-gradient(100deg, var(--gold), var(--mystic-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  margin-bottom: 14px;
}
.sign-text { font-size: 16.5px; line-height: 1.9; color: var(--ink); margin-bottom: 10px; }
.sign-highlights { color: var(--ink-dim); font-size: 13.5px; }

h3 { font-size: 15px; color: var(--ink-dim); font-weight: 600; margin-bottom: 14px; }

.dim-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 44px; align-items: center; gap: 10px; margin-bottom: 12px; }
.dim-row:last-child { margin-bottom: 0; }
.dim-label { font-size: 13.5px; white-space: nowrap; }
.dim-track { height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.09); overflow: hidden; }
.dim-fill {
  height: 100%; width: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--mystic), var(--gold));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.dim-pct { font-size: 12.5px; color: var(--ink-dim); text-align: right; }
.dim-row.hot .dim-label { color: var(--gold); font-weight: 700; }
.dim-row.low .dim-fill { background: linear-gradient(90deg, #64748B, #94A3B8); }

.lucky-line { font-size: 15px; line-height: 2; }
.lucky-line b { color: var(--gold); }
.lucky-tile { grid-column: 1 / -1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--card-border);
}
.chip.dont { color: #FDA4AF; background: rgba(253, 164, 175, 0.08); }
.chip.do { color: #A7F3D0; background: rgba(167, 243, 208, 0.08); }

/* ---------- PK / 分享 ---------- */
.cmp-box { margin: var(--gap) 0; }
.cmp-box h3 { margin-bottom: 6px; }
.cmp-box p { color: var(--ink-dim); font-size: 13.5px; margin-bottom: 12px; }
#cmp-out { margin-top: 14px; text-align: center; }
.qr-figure svg { width: 128px; height: 128px; }
.pk-link-row { display: flex; gap: 8px; margin-top: 12px; }
.pk-link-row input {
  flex: 1; min-width: 0;
  background: rgba(0, 0, 0, 0.25);
  border: 1.5px solid var(--card-border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--ink-dim);
  font-family: inherit;
}

.share-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 24px 0; }

.share-card-area { text-align: center; }
.share-card-area canvas {
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  margin: 0 auto 16px;
  display: block;
}

/* ---------- 塔罗 ---------- */
.tarot-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: var(--gap); }
#tarot-meanings { display: flex; flex-direction: column; gap: 12px; margin-bottom: var(--gap); }
.tarot-meaning p { text-align: left; }

.tcard { perspective: 800px; cursor: pointer; }
.tcard-inner {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3.4;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.tcard.flipped .tcard-inner { transform: rotateY(180deg); }

.tface {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid var(--card-border);
  padding: 8px;
  text-align: center;
}
.tback {
  background:
    radial-gradient(120px 120px at 50% 30%, rgba(139, 92, 246, 0.35), transparent 70%),
    linear-gradient(160deg, #2A1F4D, #1A1430);
  font-size: 34px;
}
.tfront {
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
  transform: rotateY(180deg);
}
.tfront.reversed-card { outline: 2px solid rgba(233, 196, 106, 0.55); outline-offset: -6px; }
.tcard-pos { font-size: 11px; color: var(--ink-faint); margin-bottom: 6px; }
.tcard-name { font-size: 14px; font-weight: 700; line-height: 1.4; }
.tcard-rev { font-size: 10px; color: var(--gold); margin-top: 4px; letter-spacing: 2px; }

.tarot-meaning { margin-bottom: 10px; }
.tarot-meaning .tm-head { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.tarot-meaning .tm-kw { font-size: 12.5px; color: var(--gold); margin-bottom: 6px; }
.tarot-meaning .tm-hint { font-size: 12px; color: var(--ink-faint); margin-top: 8px; }
.tarot-meaning .tm-head small { color: var(--ink-faint); font-weight: 400; margin-left: 6px; }
.tarot-meaning p { color: var(--ink-dim); font-size: 13.5px; line-height: 1.7; }

.tarot-note-tile { color: var(--ink-dim); font-size: 13.5px; line-height: 1.8; text-align: center; }

/* ---------- 对比 ---------- */
.cmp-card { text-align: center; }
.cmp-who { font-size: 14px; color: var(--ink-dim); margin-bottom: 4px; }
.cmp-tier { font-size: 30px; font-weight: 800; letter-spacing: 3px; }
.cmp-avg { font-size: 13px; color: var(--ink-dim); margin: 6px 0 14px; }
.cmp-winner {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 15.5px;
  padding: 20px;
}
.cmp-winner b { color: var(--gold); }

/* ---------- 其他 ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 60px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 23, 56, 0.95);
  border: 1px solid var(--card-border);
  color: var(--ink);
  font-size: 14px;
  padding: 11px 22px;
  border-radius: 999px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 99;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer { text-align: center; font-size: 12px; color: var(--ink-faint); padding: 20px 0 30px; }
.footer-home { color: inherit; text-decoration: none; }
.footer-home:hover { color: var(--mystic-2); }

:focus-visible { outline: 3px solid var(--mystic-2); outline-offset: 2px; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 420px) {
  .hero h1 { font-size: 28px; }
  .tile { padding: 22px 18px; }
  .cmp-meter { grid-template-columns: 64px minmax(0, 1fr) 40px !important; }
}

/* ---------- 方法论弹窗 ---------- */
.link-btn { border: none; background: none; cursor: pointer; font: inherit; color: inherit; text-decoration: underline; padding: 0; }
.method-dialog { border: none; border-radius: 20px; padding: 26px 24px; max-width: 420px; width: calc(100% - 40px); box-shadow: 0 20px 60px rgba(0,0,0,.5); font-family: inherit; background: var(--bg-2, #1E1738); color: var(--ink, #EDE9FE); }
.method-dialog::backdrop { background: rgba(0,0,0,.55); }
.method-dialog h3 { font-size: 18px; margin-bottom: 12px; }
.method-dialog ol { padding-left: 20px; font-size: 14px; line-height: 1.9; color: var(--ink-dim, #A99FC9); }
.method-dialog .btn-ghost { margin-top: 14px; }

/* ===================== 桌面增强（≥1024px） ===================== */
@media (min-width: 1024px) {
  #app { max-width: 860px; }
  .bento { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hero { grid-column: 1 / -1; }
  .form-tile { grid-column: 1 / 2; margin-bottom: 0; }
  .note-tile { grid-column: 2 / 3; margin-top: 0; display: flex; flex-direction: column; justify-content: center; }
  .bento .tile:nth-child(3) { margin-bottom: 0; }
  .hero-tile { padding: 44px 30px; }
  .dim-row { max-width: 560px; margin-left: auto; margin-right: auto; }
  .tarot-row { max-width: 620px; margin-left: auto; margin-right: auto; gap: 20px; }
  .tcard-inner { aspect-ratio: 2 / 3; }
  .tarot-meaning p, .tarot-note-tile { max-width: 620px; margin-left: auto; margin-right: auto; }
}

/* ---------- 双语切换（全站共用） ---------- */
html[lang="en"] .lang-zh { display: none !important; }
html:not([lang="en"]) .lang-en { display: none !important; }
.lang-toggle {
  border: 1px solid var(--line, #D2D2D7); background: transparent; cursor: pointer;
  font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 999px;
  color: var(--ink-dim, #6E6E73);
}
.lang-toggle[aria-pressed="true"] { background: var(--accent, #0071E3); color: #fff; border-color: var(--accent, #0071E3); }
.lang-toggle-group { display: inline-flex; gap: 4px; align-items: center; }

/* =====================================================
   英文排版（html[lang="en"] 时生效）
   中文参数（行高 1.9-2.0、为汉字准备的 letter-spacing、宽栏）
   不适合英文：行高收到 1.6-1.75、字距归零、标题均衡断行、
   允许长词折行。切换回中文时这些规则完全不生效。
   ===================================================== */
html[lang="en"] {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei",
               "Noto Sans SC", sans-serif;
}
html[lang="en"] body {
  font-family: var(--font-sans);
  line-height: 1.65;
  overflow-wrap: break-word;
}
/* 标题：去掉汉字字距、收紧行高、均衡断行（避免孤词） */
html[lang="en"] h1, html[lang="en"] h2, html[lang="en"] h3 {
  letter-spacing: normal;
  line-height: 1.28;
  text-wrap: balance;
}
/* 正文段落与列表：英文行高 1.7（中文是 1.9-2.0） */
html[lang="en"] p, html[lang="en"] li, html[lang="en"] dd, html[lang="en"] dt {
  line-height: 1.7;
}
/* 英文应用名更长，禁止折行会撑破卡片 */
html[lang="en"] .app-name { white-space: normal; text-wrap: balance; }

/* ---------- 英文排版 ---------- */
html[lang="en"] .hero h1 { letter-spacing: normal; }
html[lang="en"] .hero-sub, html[lang="en"] .zodiac { letter-spacing: normal; }
html[lang="en"] .tier { letter-spacing: normal; }
html[lang="en"] .sign-text { line-height: 1.7; }
html[lang="en"] .lucky-line { line-height: 1.7; }
html[lang="en"] .tcard-rev { letter-spacing: 0.08em; }

/* ---------- 英文排版补充 ---------- */
/* .eyebrow 的 4px 字距为汉字准备，英文（如 2026.09.13 · Gemini）会被拉散 */
html[lang="en"] .eyebrow { letter-spacing: 0.08em; }
/* EN 胶囊更长、易折成两行：收内边距与行高，让内容在卡内留出呼吸空间 */
html[lang="en"] .chip { font-size: 12.5px; padding: 6px 12px; line-height: 1.45; }
html[lang="en"] .chips { gap: 7px; }
html[lang="en"] .sign-text { line-height: 1.7; }

/* 数字等宽：分数/日期/计数不抖动 */
body { font-variant-numeric: tabular-nums; }

/* EN 胶囊再上移：收卡片上内边距、标题下间距、胶囊内边距 */
html[lang="en"] .tile:has(> .chips) { padding-top: 17px; padding-bottom: 17px; }
html[lang="en"] .tile:has(> .chips) h3 { margin-bottom: 9px; }
html[lang="en"] .chip { padding: 5px 11px; font-size: 12px; line-height: 1.4; }
html[lang="en"] .chips { gap: 6px; }

/* =====================================================
   人机功效 · 无声的关心（与平台 tokens.css 同源副本）
   ===================================================== */
body { -webkit-tap-highlight-color: transparent; }
a, button, input, select, textarea, label, [role="button"], summary {
  touch-action: manipulation;
}
@media (hover: none) {
  *:hover { transform: none !important; }
}
::selection { background: color-mix(in srgb, var(--accent, #0071E3) 22%, transparent); }
input, textarea { caret-color: var(--accent, #0071E3); }
body { text-autospace: normal; line-break: strict; overflow-wrap: break-word; }
@media (pointer: coarse) {
  input, textarea { font-size: max(16px, 1em); }
}
html { scrollbar-gutter: stable; }

/* =====================================================
   交互打磨 · 入场与反馈（各 app 副本共用）
   全部纯 CSS、动画短促且 reduced-motion 由全局规则兜底。
   ===================================================== */
/* 页面首帧：极短抬升淡入，遮住字体回退与排版微调瞬间 */
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
body { animation: pageIn 0.28s var(--ease, ease-out) both; }

/* 页面内锚点滚动丝滑 */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* 选项选中：推进前的轻微弹跳——「已收到」的触觉化确认 */
@keyframes pickPulse { 0% { transform: scale(1); } 45% { transform: scale(1.03); } 100% { transform: scale(1); } }
.option.picked { animation: pickPulse 0.26s var(--ease, ease-out); }

/* 结果区逐项入场：emoji 弹入 → 名称 → 标签行 → 描述/引用 → 特质 chips 阶梯 */
@keyframes popIn { 0% { opacity: 0; transform: scale(0.5); } 55% { opacity: 1; transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.result-emoji, #r-emoji { animation: popIn 0.5s var(--ease, ease-out) 0.08s both; }
.result-name, #r-name { animation: riseIn 0.4s var(--ease, ease-out) 0.2s both; }
.result-tagline, #r-tagline { animation: riseIn 0.4s var(--ease, ease-out) 0.3s both; }
.result-desc, .result-quote, .classical, #r-desc, #r-quote { animation: riseIn 0.45s var(--ease, ease-out) 0.4s both; }
.trait { animation: riseIn 0.35s var(--ease, ease-out) 0.45s both; }
.trait:nth-child(2) { animation-delay: 0.52s; }
.trait:nth-child(3) { animation-delay: 0.59s; }
.trait:nth-child(4) { animation-delay: 0.66s; }
.trait:nth-child(n+5) { animation-delay: 0.7s; }
.tile-read, #r-read { animation: riseIn 0.4s var(--ease, ease-out) 0.72s both; }

/* 卡片/链接按压反馈：tap-highlight 已关，:active 是触屏唯一的「按到了」信号 */
.app-card:active, .acard:active, .btn-ghost:active { transform: scale(0.98); }

/* 跨页导航默认交叉淡入淡出（渐进增强，不支持的浏览器自动忽略） */
@view-transition { navigation: auto; }

/* 分享卡渲染后浮出（display:none→block 时动画自动播放） */
#share-card-area { animation: riseIn 0.4s var(--ease, ease-out) both; }
