/* 其一 · 起局仪式（ritual.css）
 *
 * 把「点按钮 → 等结果」变成一场问事的仪式：
 * 幕布落 → 罗盘转 → 时辰轮转 → 局成金印 → 九宫逐格点亮。
 *
 * 纪律（与 motion.css 对齐）：
 * - 只动 transform / opacity / clip；发光仅暖金、透明度 ≤0.35、只出现在仪式时刻
 * - prefers-reduced-motion / 低端设备 / .ritual-off：整层不出现，回退原 loading 文案
 * - 点击/按键任意时刻可跳过；JS 失败时 app.js 的原 loading 照常工作
 */

.ritual-veil {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 42%, rgba(16, 22, 28, 0.88) 0%, rgba(8, 11, 15, 0.96) 100%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s var(--ease-out), visibility 0s linear 0.5s;
  cursor: pointer; /* 点击任意处可跳过 */
}

.ritual-veil.is-on {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s var(--ease-out);
}

.ritual-veil.is-leaving {
  opacity: 0;
  visibility: visible;
  transition: opacity 0.55s var(--ease-out);
}

.ritual-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  transform: translateY(8px);
  opacity: 0;
  transition: transform 0.6s var(--ease-out), opacity 0.6s var(--ease-out);
  pointer-events: none; /* 舞台不拦点击，点击落在幕布上即跳过 */
}

.ritual-veil.is-on .ritual-stage {
  transform: none;
  opacity: 1;
  transition-delay: 0.15s;
}

/* ---- 罗盘 ---- */

.rt-compass {
  width: clamp(180px, 26vmin, 240px);
  height: clamp(180px, 26vmin, 240px);
}

.rt-compass .rc-ring {
  fill: none;
  stroke: rgba(211, 172, 87, 0.34);
  stroke-width: 0.8;
}

.rt-compass .rc-ring-strong {
  stroke: rgba(211, 172, 87, 0.62);
  stroke-width: 1.1;
}

.rt-compass .rc-tick {
  stroke: rgba(211, 172, 87, 0.4);
  stroke-width: 1;
  stroke-linecap: round;
}

.rt-compass .rc-gong {
  fill: none;
  stroke: rgba(211, 172, 87, 0.22);
  stroke-width: 0.7;
}

.rt-compass .rc-label {
  fill: rgba(240, 230, 208, 0.5);
  font-size: 7px;
  font-family: inherit;
  letter-spacing: 0.05em;
}

.rt-compass .rc-turn {
  transform-origin: 100px 100px;
  transform-box: view-box;
}

/* 落幕：外环带刻度整圈缓入旋转（一次性，1.8s） */
.ritual-veil.is-on .rc-turn-outer {
  animation: rt-turn 1.8s var(--ease-out) both;
}

/* 等待期：内环（九宫层）慢转，幅度克制 */
.ritual-veil.is-on .rc-turn-inner {
  animation: rt-turn 7.2s linear infinite;
  animation-delay: 1.8s;
}

@keyframes rt-turn {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 中宫时辰字 */
.rt-compass .rc-center {
  fill: #d3ac57;
  font-size: 20px;
  font-weight: 600;
  font-family: inherit;
}

/* ---- 问题回显 ---- */

.rt-question {
  max-width: min(560px, 78vw);
  text-align: center;
  color: rgba(240, 230, 208, 0.86);
  font-size: 14.5px;
  line-height: 1.7;
  letter-spacing: 0.06em;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- 四柱（响应抵达后落位） ---- */

.rt-pillars {
  display: flex;
  gap: 14px;
  min-height: 66px; /* 落位前占位，避免响应抵达时舞台跳动 */
  align-items: center;
}

.rt-pillar {
  min-width: 58px;
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.45s var(--ease-out), transform 0.45s var(--ease-out);
}

.rt-pillar.is-in {
  opacity: 1;
  transform: none;
}

.rt-pillar b {
  display: block;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: rgba(240, 230, 208, 0.95);
}

.rt-pillar span {
  display: block;
  margin-top: 4px;
  font-size: 10.5px;
  letter-spacing: 0.3em;
  color: rgba(211, 172, 87, 0.72);
}

/* ---- 状态流转 ---- */

.rt-status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(240, 230, 208, 0.55);
  font-size: 12px;
  letter-spacing: 0.42em;
  min-height: 18px;
}

.rt-status::before,
.rt-status::after {
  content: "";
  width: 34px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(211, 172, 87, 0.5));
}

.rt-status::after {
  background: linear-gradient(90deg, rgba(211, 172, 87, 0.5), transparent);
}

/* ---- 局成金印 ---- */

.rt-seal {
  position: absolute;
  right: clamp(20px, 14vw, 220px);
  top: clamp(84px, 22vh, 200px);
  width: 74px;
  height: 74px;
  border: 2px solid rgba(211, 172, 87, 0.85);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(211, 172, 87, 0.92);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.18em;
  writing-mode: vertical-rl;
  text-orientation: upright;
  transform: rotate(-6deg) scale(1.5);
  opacity: 0;
  pointer-events: none;
}

.rt-seal.is-stamped {
  animation: rt-stamp 0.5s var(--ease-spring) forwards;
}

@keyframes rt-stamp {
  0% { transform: rotate(-10deg) scale(1.5); opacity: 0; }
  55% { opacity: 0.95; }
  70% { transform: rotate(-6deg) scale(0.96); opacity: 0.92; }
  100% { transform: rotate(-6deg) scale(1); opacity: 0.9; }
}

.rt-skip {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(240, 230, 208, 0.3);
  font-size: 11px;
  letter-spacing: 0.24em;
  pointer-events: none;
}

/* ---- 盘面呼吸：宫格入场时序 + 值符/用神时刻 ---- */

/* 仪式落幕前，先藏盘面（JS 正常才会加 .ritual-board-wait，无 JS 永不隐藏内容） */
body.ritual-board-wait #chart-result .palace,
body.ritual-board-wait #chart-result .result-summary,
body.ritual-board-wait #chart-result .result-meta {
  opacity: 0;
}

.palace.rt-enter {
  animation: rt-palace-in 0.6s var(--ease-out) both;
  animation-delay: var(--rt-delay, 0ms);
}

@keyframes rt-palace-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* 值符宫：仪式时刻的一次性金晕（入场后脉动两息即止） */
.palace.rt-zhifu-glow {
  animation: rt-zhifu 2.4s var(--ease-out) 1;
}

@keyframes rt-zhifu {
  0% { box-shadow: 0 0 0 0 rgba(211, 172, 87, 0); }
  35% { box-shadow: 0 0 0 5px rgba(211, 172, 87, 0.35); }
  100% { box-shadow: 0 0 0 0 rgba(211, 172, 87, 0); }
}

/* 用神标记：三跳点睛 */
.marker.yong.rt-yong-pulse {
  animation: rt-yong 1.6s var(--ease-out) 1;
}

@keyframes rt-yong {
  0%, 100% { transform: none; }
  30% { transform: translateY(-2px) scale(1.12); }
  60% { transform: none; }
  80% { transform: translateY(-1px) scale(1.06); }
}

/* ---- 降级 ---- */

@media (prefers-reduced-motion: reduce) {
  .ritual-veil {
    display: none; /* 仪式整体让位：走原 loading */
  }

  .palace.rt-enter {
    animation: none;
    opacity: 1;
  }

  .palace.rt-zhifu-glow,
  .marker.yong.rt-yong-pulse {
    animation: none;
  }
}

@media (max-width: 640px) {
  .rt-seal {
    width: 58px;
    height: 58px;
    font-size: 17px;
    right: 26px;
    top: 96px;
  }

  .rt-skip {
    bottom: 92px; /* 让开底部 Tab 栏 */
    /* V5 收口第四批：基线 241 行的 11px 在手机上低于全站 12px 下限。
       这句「点 击 任 意 处 跳 过」是开屏仪式唯一一句操作提示，
       而且压在册纸底图上（同 240 行 rgba(240,230,208,.3) 的低透明度）。
       只抬字号不动透明度——要不要更亮是设计判断，先记在这里。
       宽度方向无风险：这条是 left:0/right:0 + text-align:center 的整行。 */
    font-size: 12px;
  }

  .rt-pillar b {
    font-size: 16px;
  }

  .rt-pillars {
    gap: 9px;
  }
}
