/* ============================================================
   通玄 · 塔罗奥义 —— 深夜幕布 · 鎏金牌背 · 仪式三幕
   幕一 问与阵 → 幕二 仪式台（洗牌/扇形抽牌/桌布揭示） → 幕三 牌意
   ============================================================ */

/* ================= 夜幕基调 ================= */
.tr-night { background: #0a1020; }
.tr-hero { min-height: 46vh; padding-bottom: 90px; }
.tr-hero .page-hero-sub { color: rgba(237, 232, 216, 0.72); }

/* 悬浮灵光珠 */
.tr-hero-orbs { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.tr-hero-orbs i {
  position: absolute;
  border-radius: 50%;
  filter: blur(42px);
  opacity: 0.35;
  animation: tr-orb 16s ease-in-out infinite;
}
.tr-hero-orbs i:nth-child(1) { width: 260px; height: 260px; left: 12%; top: 30%; background: radial-gradient(circle, rgba(212,175,106,0.5), transparent 70%); }
.tr-hero-orbs i:nth-child(2) { width: 320px; height: 320px; right: 8%; top: 16%; background: radial-gradient(circle, rgba(122,90,214,0.4), transparent 70%); animation-delay: -5s; }
.tr-hero-orbs i:nth-child(3) { width: 200px; height: 200px; left: 46%; bottom: -8%; background: radial-gradient(circle, rgba(64,120,200,0.35), transparent 70%); animation-delay: -10s; }
@keyframes tr-orb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -28px) scale(1.12); }
  66% { transform: translate(-30px, 22px) scale(0.94); }
}

/* ================= 主体 ================= */
.tr-main {
  position: relative;
  padding: 24px 0 120px;
  background:
    radial-gradient(1100px 480px at 50% -80px, rgba(38, 52, 92, 0.5), transparent 70%),
    linear-gradient(180deg, #0a1020 0%, #0c1226 48%, #0a0e1d 100%);
  color: #ede8d8;
}
.tr-container { max-width: 1080px; }

.tr-act { margin-top: 56px; }
.tr-act-title {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--font-serif);
  font-size: 21px; font-weight: 700;
  letter-spacing: 0.3em; text-indent: 0.1em;
  color: var(--gold-300);
  margin-bottom: 26px;
}
.tr-act-title i {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid rgba(212, 175, 106, 0.45);
  border-radius: 10px;
  font-style: normal; font-size: 15px;
  letter-spacing: 0; text-indent: 0;
  color: var(--gold-500);
  background: rgba(212, 175, 106, 0.08);
}

/* ================= 幕一 · 问与阵 ================= */
.tr-ask { margin-bottom: 44px; }
.tr-ask-input {
  width: 100%;
  padding: 16px 20px;
  border: 1px solid rgba(212, 175, 106, 0.28);
  border-radius: var(--radius-md);
  background: rgba(16, 24, 46, 0.75);
  color: #ede8d8;
  font-family: inherit;
  font-size: 15px; letter-spacing: 0.05em;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.tr-ask-input::placeholder { color: rgba(237, 232, 216, 0.35); }
.tr-ask-input:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 4px rgba(212, 175, 106, 0.12), 0 0 34px rgba(212, 175, 106, 0.12);
}
.tr-ask-note { margin-top: 10px; font-size: 12.5px; letter-spacing: 0.06em; color: rgba(237, 232, 216, 0.45); }

.tr-spreads {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.tr-spread {
  position: relative;
  text-align: left;
  padding: 16px 18px 14px;
  border: 1px solid rgba(212, 175, 106, 0.2);
  border-radius: var(--radius-md);
  background: rgba(16, 24, 46, 0.6);
  transition: border-color 0.3s, background 0.3s, transform 0.3s var(--ease-out), box-shadow 0.3s;
}
.tr-spread:hover { transform: translateY(-4px); border-color: rgba(212, 175, 106, 0.55); }
.tr-spread-diagram {
  position: relative;
  height: 74px;
  margin-bottom: 12px;
  border: 1px dashed rgba(212, 175, 106, 0.2);
  border-radius: 8px;
  background: rgba(10, 16, 32, 0.5);
}
.tr-spread-diagram i {
  position: absolute;
  width: 9px; height: 14px;
  border-radius: 2px;
  background: rgba(212, 175, 106, 0.55);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px rgba(212, 175, 106, 0.35);
}
.tr-spread-diagram i.cross { transform: translate(-50%, -50%) rotate(90deg); opacity: 0.75; }
.tr-spread b {
  display: block;
  font-family: var(--font-serif);
  font-size: 16.5px; font-weight: 700;
  letter-spacing: 0.12em;
  color: #ede8d8;
}
.tr-spread i.tr-spread-sub {
  display: block; font-style: normal;
  margin-top: 4px;
  font-size: 11.5px; letter-spacing: 0.05em;
  color: rgba(237, 232, 216, 0.5);
}
.tr-spread.active {
  border-color: var(--gold-500);
  background: linear-gradient(160deg, rgba(212, 175, 106, 0.16), rgba(16, 24, 46, 0.8) 55%);
  box-shadow: 0 12px 34px rgba(212, 175, 106, 0.16);
}
.tr-spread.active b { color: var(--gold-300); }
.tr-spread.active .tr-spread-diagram i { background: var(--gold-300); }

.tr-begin-wrap { margin-top: 40px; text-align: center; }
.tr-begin { min-width: 300px; }

/* ================= 幕二 · 仪式台 ================= */
.tr-stage-wrap { margin-top: 64px; }
.tr-stage-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 14px;
}
.tr-stage-hint {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-serif);
  font-size: 15.5px; letter-spacing: 0.22em;
  color: var(--gold-300);
}
.tr-stage-hint i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold-500);
  box-shadow: 0 0 12px var(--gold-500);
  animation: tr-breath 2.2s ease-in-out infinite;
}
@keyframes tr-breath { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.tr-ghost-btn {
  padding: 8px 18px;
  border: 1px solid rgba(212, 175, 106, 0.35);
  border-radius: 999px;
  background: transparent;
  color: rgba(237, 232, 216, 0.75);
  font-size: 12.5px; letter-spacing: 0.14em;
  transition: border-color 0.3s, color 0.3s, background 0.3s;
}
.tr-ghost-btn:hover { border-color: var(--gold-500); color: var(--gold-300); background: rgba(212, 175, 106, 0.08); }

.tr-stage {
  position: relative;
  min-height: 420px;
  border: 1px solid rgba(212, 175, 106, 0.24);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(720px 340px at 50% 34%, rgba(52, 40, 86, 0.35), transparent 72%),
    radial-gradient(1200px 620px at 50% 110%, rgba(20, 30, 58, 0.8), transparent 70%),
    linear-gradient(180deg, #0e1530, #0a0f22);
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.55), 0 24px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
/* 星尘漂浮（两层背景位移） */
.tr-stage::before, .tr-stage::after {
  content: "";
  position: absolute; inset: -60px;
  pointer-events: none;
  background-image:
    radial-gradient(1.4px 1.4px at 22% 30%, rgba(237, 232, 216, 0.5), transparent 55%),
    radial-gradient(1px 1px at 68% 62%, rgba(212, 175, 106, 0.6), transparent 55%),
    radial-gradient(1.2px 1.2px at 84% 22%, rgba(237, 232, 216, 0.4), transparent 55%),
    radial-gradient(1px 1px at 40% 78%, rgba(212, 175, 106, 0.5), transparent 55%),
    radial-gradient(1.1px 1.1px at 10% 66%, rgba(237, 232, 216, 0.35), transparent 55%);
  background-size: 480px 420px;
  animation: tr-dust 46s linear infinite;
  opacity: 0.6;
}
.tr-stage::after { animation-duration: 74s; animation-direction: reverse; opacity: 0.35; }
@keyframes tr-dust {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-160px, -120px, 0); }
}

/* —— 卡背（鎏金纹） —— */
.tr-card-back {
  display: block;
  width: 100%; height: 100%;
  border-radius: 9px;
  background:
    radial-gradient(60% 42% at 50% 50%, rgba(212, 175, 106, 0.16), transparent 72%),
    repeating-linear-gradient(45deg, rgba(212, 175, 106, 0.07) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(-45deg, rgba(212, 175, 106, 0.07) 0 2px, transparent 2px 9px),
    linear-gradient(160deg, #182446, #0d1426 65%);
  border: 1px solid rgba(212, 175, 106, 0.5);
  box-shadow: inset 0 0 0 3px rgba(10, 16, 32, 0.9), inset 0 0 0 4px rgba(212, 175, 106, 0.35), 0 6px 18px rgba(0, 0, 0, 0.5);
  position: relative;
}
.tr-card-back::after {
  content: "✦";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: rgba(212, 175, 106, 0.8);
  text-shadow: 0 0 14px rgba(212, 175, 106, 0.6);
}

/* —— 洗牌旋舞 —— */
.tr-shuffle {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 30px;
}
.tr-shuffle-deck { position: relative; width: 104px; height: 180px; }
.tr-shuffle-deck .tr-card-back {
  position: absolute; inset: 0;
  animation: tr-swirl 1.35s cubic-bezier(0.45, 0, 0.25, 1) infinite;
}
.tr-shuffle-deck .tr-card-back:nth-child(1) { animation-delay: 0s; }
.tr-shuffle-deck .tr-card-back:nth-child(2) { animation-delay: 0.22s; }
.tr-shuffle-deck .tr-card-back:nth-child(3) { animation-delay: 0.44s; }
.tr-shuffle-deck .tr-card-back:nth-child(4) { animation-delay: 0.66s; }
.tr-shuffle-deck .tr-card-back:nth-child(5) { animation-delay: 0.88s; }
.tr-shuffle-deck .tr-card-back:nth-child(6) { animation-delay: 1.1s; }
@keyframes tr-swirl {
  0% { transform: translate(0, 0) rotate(0deg); }
  30% { transform: translate(-108px, -14px) rotate(-16deg); }
  55% { transform: translate(108px, 12px) rotate(14deg); }
  80% { transform: translate(-10px, -6px) rotate(-4deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}
.tr-shuffle-word {
  font-family: var(--font-serif);
  font-size: 16px; letter-spacing: 0.5em; text-indent: 0.5em;
  color: rgba(237, 232, 216, 0.7);
}
.tr-shuffle-word span { animation: tr-breath 1.4s ease-in-out infinite; display: inline-block; }
.tr-shuffle-word span:nth-child(2) { animation-delay: 0.3s; }
.tr-shuffle-word span:nth-child(3) { animation-delay: 0.6s; }

/* —— 扇形抽牌 —— */
.tr-fan-wrap {
  position: absolute; inset: 0;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 34px;
}
.tr-fan {
  position: relative;
  width: min(92%, 940px);
  height: 78%;
}
.tr-fan-card {
  position: absolute;
  bottom: 0;
  width: 62px; height: 107px;
  margin-left: -31px;
  transform-origin: 50% 130%;
  transition: transform 0.34s var(--ease-out), opacity 0.4s, filter 0.34s;
  cursor: pointer;
  padding: 0; border: none; background: none;
}
.tr-fan-card .tr-card-back { pointer-events: none; }
.tr-fan-card .tr-card-back::after { font-size: 13px; }
.tr-fan-card:hover, .tr-fan-card:focus-visible {
  transform: var(--fan-t) translateY(-30px) scale(1.1) !important;
  z-index: 99 !important;
  filter: drop-shadow(0 0 18px rgba(212, 175, 106, 0.55));
  outline: none;
}
.tr-fan-card.picked {
  transform: var(--fan-t) translateY(-120px) scale(0.72) !important;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.55s var(--ease-out), opacity 0.5s;
}

/* —— 牌阵桌布（绝对填充舞台：槽位 x/y 百分比以舞台为基准） —— */
.tr-table {
  position: absolute;
  inset: 26px 22px 30px;
  --cw: 13%;
}
.tr-slot {
  position: absolute;
  width: var(--cw);
  transform: translate(-50%, -50%);
  opacity: 0;
}
.tr-slot.in { animation: tr-slot-in 0.6s var(--ease-out) forwards; }
@keyframes tr-slot-in {
  from { opacity: 0; transform: translate(-50%, -62%) scale(0.86); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.tr-slot.cross { z-index: 3; }
.tr-slot.cross .tr-flip { transform: rotate(90deg) scale(0.92); }
.tr-flip {
  position: relative;
  width: 100%;
  aspect-ratio: 173 / 300;
  perspective: 900px;
  cursor: pointer;
}
.tr-flip-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.85s cubic-bezier(0.35, 0, 0.2, 1);
}
.tr-flip.flipped .tr-flip-inner { transform: rotateY(180deg); }
.tr-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: 9px;
  overflow: hidden;
}
.tr-face-front {
  transform: rotateY(180deg);
  border: 1px solid rgba(212, 175, 106, 0.55);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
  background: #0d1426;
}
.tr-face-front img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.tr-face-front.reversed img { transform: rotate(180deg); }
.tr-flip.flipped .tr-face-front { animation: tr-reveal-glow 1.1s ease-out; }
@keyframes tr-reveal-glow {
  0% { box-shadow: 0 0 0 rgba(212, 175, 106, 0); }
  35% { box-shadow: 0 0 42px rgba(212, 175, 106, 0.75); }
  100% { box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55); }
}
.tr-flip:hover:not(.flipped) .tr-card-back { box-shadow: inset 0 0 0 3px rgba(10, 16, 32, 0.9), inset 0 0 0 4px rgba(212, 175, 106, 0.6), 0 0 26px rgba(212, 175, 106, 0.4); }
.tr-slot-tag {
  margin-top: 7px;
  text-align: center;
  font-size: 11px; letter-spacing: 0.08em;
  color: rgba(237, 232, 216, 0.6);
  white-space: nowrap;
}
.tr-slot.cross .tr-slot-tag {
  position: absolute;
  top: -26px; left: 50%;
  transform: translateX(-50%);
  margin-top: 0;
  color: rgba(212, 175, 106, 0.75);
}

.tr-stage-foot { margin-top: 14px; text-align: center; }

/* ================= 幕三 · 牌意初解 ================= */
.tr-result { margin-top: 70px; }
.tr-reading-meta {
  margin: -8px 0 26px;
  font-size: 13px; letter-spacing: 0.08em;
  color: rgba(237, 232, 216, 0.55);
}
.tr-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tr-card-panel {
  display: flex; gap: 18px;
  padding: 18px;
  border: 1px solid rgba(212, 175, 106, 0.22);
  border-radius: var(--radius-md);
  background: rgba(16, 24, 46, 0.6);
  opacity: 0;
  transform: translateY(18px);
}
.tr-card-panel.in { animation: tr-panel-in 0.6s var(--ease-out) forwards; }
@keyframes tr-panel-in { to { opacity: 1; transform: translateY(0); } }
.tr-card-panel img {
  width: 74px; height: 128px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid rgba(212, 175, 106, 0.45);
  flex: 0 0 auto;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.tr-card-panel img.reversed { transform: rotate(180deg); }
.tr-card-info { min-width: 0; }
.tr-card-pos {
  font-size: 11.5px; letter-spacing: 0.1em;
  color: var(--gold-500);
}
.tr-card-name {
  margin-top: 4px;
  font-family: var(--font-serif);
  font-size: 17.5px; font-weight: 700;
  letter-spacing: 0.06em;
  color: #ede8d8;
}
.tr-card-name small { font-size: 11px; font-weight: 400; letter-spacing: 0.04em; color: rgba(237, 232, 216, 0.45); margin-left: 8px; }
.tr-orient {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 5px;
  font-size: 11px; font-weight: 400; letter-spacing: 0.1em;
  vertical-align: 2px;
}
.tr-orient.up { color: var(--gold-300); border: 1px solid rgba(212, 175, 106, 0.5); background: rgba(212, 175, 106, 0.1); }
.tr-orient.rev { color: #e8927c; border: 1px solid rgba(196, 84, 60, 0.55); background: rgba(196, 84, 60, 0.12); }
.tr-card-meaning {
  margin-top: 7px;
  font-size: 12.5px; line-height: 1.75; letter-spacing: 0.04em;
  color: rgba(237, 232, 216, 0.62);
}
.tr-card-kws { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 6px; }
.tr-card-kws span {
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 106, 0.3);
  background: rgba(212, 175, 106, 0.07);
  font-size: 11.5px; letter-spacing: 0.06em;
  color: rgba(237, 232, 216, 0.78);
}

.tr-cta {
  margin-top: 40px;
  display: flex; justify-content: center; gap: 16px; flex-wrap: wrap;
}
.tr-cta-ai { min-width: 300px; }
.tr-attribution {
  margin-top: 26px;
  text-align: center;
  font-size: 11px; letter-spacing: 0.06em;
  color: rgba(237, 232, 216, 0.35);
}

/* ================= 响应式 ================= */
@media (max-width: 900px) {
  .tr-spreads { grid-template-columns: repeat(2, 1fr); }
  .tr-cards { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tr-stage { min-height: 360px; }
  /* 防 iOS 聚焦自动放大：输入字号须 ≥16px */
  .tr-ask-input { font-size: 16px; }
  /* 灵光珠减负（小屏 GPU） */
  .tr-hero-orbs i { filter: blur(24px); opacity: 0.26; }
  .tr-hero-orbs i:nth-child(1) { width: 170px; height: 170px; }
  .tr-hero-orbs i:nth-child(2) { width: 200px; height: 200px; }
  .tr-hero-orbs i:nth-child(3) { width: 130px; height: 130px; }
  /* 洗牌：小舞台收幅 */
  .tr-shuffle-deck { width: 86px; height: 149px; }
  .tr-shuffle-deck .tr-card-back { animation-name: tr-swirl-m; }
  /* 扇面 → 横滑长卷（78 张在 1800px 上摊开，指尖可点） */
  .tr-fan-wrap {
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 26px;
  }
  .tr-fan-wrap::-webkit-scrollbar { display: none; }
  .tr-fan { width: 1800px; min-width: 1800px; height: 80%; }
  .tr-fan-card { width: 56px; height: 97px; margin-left: -28px; }
  .tr-fan-card .tr-card-back::after { font-size: 11px; }
  .tr-fan-card:active {
    transform: var(--fan-t) translateY(-22px) scale(1.08) !important;
    filter: drop-shadow(0 0 14px rgba(212, 175, 106, 0.55));
  }
  /* 桌布：收边距，牌略放大（tarot.js 窄屏同步放大 --cw 与纵横比） */
  .tr-table { inset: 20px 10px 26px; }
  .tr-slot-tag {
    font-size: 9.5px; letter-spacing: 0.02em;
    white-space: normal;
    max-width: 66px;
    margin-left: auto; margin-right: auto;
    line-height: 1.35;
  }
  .tr-slot.cross .tr-slot-tag { top: -30px; }
  .tr-begin, .tr-cta-ai { width: 100%; min-width: 0; }
  .tr-spread-diagram { height: 60px; }
  .tr-card-panel { padding: 14px; gap: 13px; }
  .tr-card-panel img { width: 62px; height: 107px; }
  .tr-act-title { font-size: 18px; }
  .tr-stage-hint { font-size: 13px; letter-spacing: 0.12em; }
  .tr-stage-head { flex-wrap: wrap; }
}
/* 小屏洗牌旋舞（收幅版，防溢出舞台） */
@keyframes tr-swirl-m {
  0% { transform: translate(0, 0) rotate(0deg); }
  30% { transform: translate(-58px, -10px) rotate(-13deg); }
  55% { transform: translate(58px, 9px) rotate(12deg); }
  80% { transform: translate(-6px, -4px) rotate(-3deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* 降低动效偏好：保留状态切换，去除持续动画 */
@media (prefers-reduced-motion: reduce) {
  .tr-hero-orbs i, .tr-stage::before, .tr-stage::after,
  .tr-shuffle-deck .tr-card-back, .tr-stage-hint i, .tr-shuffle-word span { animation: none !important; }
  .tr-flip-inner { transition-duration: 0.2s; }
  .tr-fan-card, .tr-spread, .tr-card-panel { transition-duration: 0.1s; }
}
