/* ============================================================
   落夕运筹 · tarot.css
   本页专属样式：金紫配色令牌、方面选择、牌阵与翻牌动画、
   解读报告、牌义图鉴与弹层
   （base.css / components.css 与星夕工具箱保持一致，本文件只做叠加）
   ============================================================ */

/* ---------- 专属配色令牌 ---------- */
html[data-theme="dark"] {
  --gold: #d9b34a;
  --gold-soft: rgba(217, 179, 74, .16);
  --violet: #8a5cff;
  --violet-soft: rgba(138, 92, 255, .16);
  --card-face-bg: #f7f2e6;
}

html[data-theme="light"] {
  --gold: #9a7420;
  --gold-soft: rgba(154, 116, 32, .14);
  --violet: #6d3fe0;
  --violet-soft: rgba(109, 63, 224, .1);
  --card-face-bg: #fffdf6;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ============================================================
   方面选择
   ============================================================ */
.aspect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.aspect-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  text-align: left;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease), transform .12s var(--ease);
}
.aspect-card:hover { border-color: var(--accent); background: var(--bg-hover); transform: translateY(-1px); }
.aspect-card.active { border-color: var(--gold); background: var(--gold-soft); }
.aspect-card.active .ac-name { color: var(--gold); }

.ac-ico { font-size: 19px; line-height: 1.1; }
.ac-name { font-size: 13.5px; font-weight: 700; }
.ac-focus { font-size: 11.5px; color: var(--text-mute); line-height: 1.45; }

/* ============================================================
   牌阵选择
   ============================================================ */
.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-top: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.seg-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.seg-btn strong { font-size: 13.5px; }
.seg-btn small { font-size: 11px; color: var(--text-mute); }
.seg-btn:hover { background: var(--bg-hover); color: var(--text); }
.seg-btn.active { background: var(--accent-soft); color: var(--accent); }
.seg-btn.active small { color: var(--accent); opacity: .85; }

.reverse-toggle { cursor: pointer; }
.disclaimer-inline { margin-top: 10px; cursor: pointer; text-decoration: underline dotted 1px; }
.disclaimer-inline:hover { color: var(--gold); }

/* ============================================================
   牌面 / 翻牌
   ============================================================ */
.stage-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 20px;
  margin-bottom: 18px;
}
.stage-item { width: 188px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.stage-row.three .stage-item { width: 148px; }
.stage-label { font-size: 12.5px; color: var(--text-dim); text-align: center; }

.tarot-card-btn {
  display: block;
  width: 100%;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 14px;
  transition: transform .16s var(--ease);
}
.tarot-card-btn:hover { transform: translateY(-3px); }
.tarot-card-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.tarot-card {
  position: relative;
  width: 100%;
  aspect-ratio: 300 / 537;
  perspective: 1200px;
  border-radius: 14px;
}

.tarot-card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .72s cubic-bezier(.4, 0, .2, 1);
}
.tarot-card.revealed .tarot-card-inner { transform: rotateY(180deg); }

.tarot-card-face,
.tarot-card-back {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  overflow: hidden;
  backface-visibility: hidden;
}

.tarot-card-back {
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 90% at 20% 0%, var(--violet-soft), transparent 60%),
    linear-gradient(160deg, #1b2340, #2a1c46 55%, #131a2e);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.tarot-card-back::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid var(--gold-soft);
  border-radius: 9px;
}
.back-ornament { font-size: 30px; opacity: .75; filter: drop-shadow(0 0 12px var(--gold-soft)); }

.tarot-card-face {
  transform: rotateY(180deg);
  background: var(--card-face-bg);
  box-shadow: var(--shadow);
}
.tarot-card-face img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.tarot-card.reversed .tarot-card-face img { transform: rotate(180deg); }
.tarot-card.img-missing .tarot-card-face { display: grid; place-items: center; }
.card-fallback { font-size: 15px; font-weight: 700; letter-spacing: .12em; color: #4a3a12; }

/* 洗牌动画 */
.shuffle-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 26px 0 30px;
}
.shuffle-stage .tarot-card { width: 150px; }
.shuffle-stage.three .tarot-card { width: 118px; }
.shuffle-stage.animating .tarot-card { animation: shuffle-shake .72s var(--ease) both; }
.shuffle-stage.animating .tarot-card:nth-child(2) { animation-delay: .09s; }
.shuffle-stage.animating .tarot-card:nth-child(3) { animation-delay: .18s; }

@keyframes shuffle-shake {
  0% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-11px) rotate(-3deg); }
  50% { transform: translateY(5px) rotate(2.5deg); }
  75% { transform: translateY(-5px) rotate(-1.5deg); }
  100% { transform: none; }
}

/* ============================================================
   顺势指数
   ============================================================ */
.score-wrap {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.score-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.score-label { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute); }
.score-value { font-family: var(--font-mono); font-size: 24px; font-weight: 700; color: var(--gold); }
.score-verdict { font-size: 12.5px; color: var(--text-dim); }
.score-bar { position: relative; height: 8px; margin-top: 8px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; }
.score-bar .fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--violet), var(--gold)); }

.score-mini { display: flex; align-items: baseline; gap: 8px; margin: 10px 0 2px; }
.score-mini-value { font-family: var(--font-mono); font-weight: 700; color: var(--gold); }

/* ============================================================
   解读报告
   ============================================================ */
.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 250px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.result-card-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.result-card-meta { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rc-name { font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.rc-en { font-family: var(--font-mono); font-size: 12px; color: var(--text-mute); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
}

.report-head { margin-bottom: 6px; }
.rh-title { font-size: 16px; font-weight: 700; }

.r-section { margin-top: 14px; }
.r-title { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--text-dim); }
.r-ico { font-size: 15px; }
.r-text { margin-top: 6px; font-size: 13.5px; line-height: 1.78; color: var(--text); }
.r-text p + p { margin-top: 9px; }
.r-list { display: flex; flex-direction: column; gap: 7px; margin-top: 7px; }
.r-list li { position: relative; padding-left: 17px; font-size: 13.5px; line-height: 1.72; }
.r-list li::before { content: "◆"; position: absolute; left: 0; top: 1px; font-size: 8.5px; color: var(--gold); }

.summary-block { margin-top: 4px; }

.spread-grid { margin-bottom: 16px; }
.spread-col { display: flex; flex-direction: column; gap: 6px; margin-bottom: 0; }
.spread-col-head { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }

.report-foot { margin-top: 4px; }

/* ============================================================
   牌义图鉴
   ============================================================ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 12px;
}
.gallery-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  text-align: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: inherit;
  cursor: pointer;
  transition: transform .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.gallery-card:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: var(--shadow-sm); }
.gallery-thumb { aspect-ratio: 300 / 537; border-radius: 6px; overflow: hidden; background: var(--bg-input); }
.gallery-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gc-name { font-size: 12.5px; font-weight: 650; }
.gc-en {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.gallery-big { display: block; width: 100%; border-radius: 10px; box-shadow: var(--shadow-sm); }

.kw-block { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.kw-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

details.origin {
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
details.origin summary { cursor: pointer; font-size: 12.5px; color: var(--text-dim); }
.origin-text { margin-top: 9px; font-size: 12.5px; line-height: 1.72; color: var(--text-dim); }
.origin-text p + p { margin-top: 8px; }

/* ============================================================
   弹层（免责声明 / 牌面详情）
   ============================================================ */
body.modal-open { overflow: hidden; }

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 9, 16, .64);
  backdrop-filter: blur(3px);
  animation: fade-in .18s var(--ease);
}
.modal-mask[hidden] { display: none; }

.modal {
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: min(86vh, 900px);
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-body { padding: 16px; overflow: auto; }
.modal-text p { font-size: 13.5px; line-height: 1.78; }
.modal-text p + p { margin-top: 10px; }
.modal-note { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.modal-note p + p { margin-top: 6px; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 860px) {
  .result-grid { grid-template-columns: minmax(0, 1fr); }
  .stage-item { width: 152px; }
  .stage-row.three .stage-item { width: 118px; }
  .shuffle-stage .tarot-card { width: 124px; }
  .shuffle-stage.three .tarot-card { width: 100px; }
}

@media (max-width: 560px) {
  .aspect-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .seg { width: 100%; }
  .seg-btn { flex: 1; }
  .stage-row { gap: 12px; }
  .stage-item { width: 45%; }
  .stage-row.three .stage-item { width: 30%; }
  .stage-label { font-size: 11.5px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: 9px; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .modal-mask { padding: 10px; }
  .rc-name { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .tarot-card-inner { transition: none; }
  .shuffle-stage.animating .tarot-card { animation: none; }
  .gallery-card:hover, .tarot-card-btn:hover { transform: none; }
}
