/* ============================================================
   通玄 TONGXUAN · 奇门遁甲页 qimen.css
   遁甲局表单 → 九宫布盘（洛书序点亮） → AI 深度解读入口
   颜色一律取自 base.css token / 金色·朱砂 rgba，换肤零负担
   ============================================================ */

/* ================= 页首 ================= */
.qm-hero-divider { animation: pageUp 1s var(--ease-out) 0.28s both; }

/* ================= 第一幕 · 遁甲局 ================= */
.qm-entry { padding-top: 72px; }

/* —— 类别 chips（宣纸上的小金印） —— */
.qm-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.qm-chip {
  padding: 9px 24px;
  font-family: var(--font-serif);
  font-size: 14.5px; font-weight: 600;
  letter-spacing: 0.16em; text-indent: 0.16em;
  color: var(--paper-ink-soft);
  border: 1px solid rgba(150, 114, 58, 0.4);
  border-radius: 999px;
  background: rgba(250, 247, 239, 0.75);
  transition: color 0.3s, border-color 0.3s, background 0.3s,
              box-shadow 0.3s, transform 0.3s var(--ease-out);
}
.qm-chip:hover {
  transform: translateY(-2px);
  color: var(--gold-700);
  border-color: rgba(184, 145, 75, 0.7);
}
.qm-chip.active {
  background: linear-gradient(135deg, var(--gold-300), var(--gold-500) 60%, var(--gold-600));
  color: #241a08;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(212, 175, 106, 0.3);
}
.qm-chip:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

/* —— 用事时间 —— */
.qm-now-time {
  margin-left: 10px;
  font-family: var(--font-sans);
  font-size: 12.5px; letter-spacing: 0.04em;
  color: var(--paper-ink-soft);
}
.qm-date-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
}
.qm-date-grid[hidden] { display: none; }

/* ================= 第二幕 · 九宫布盘 ================= */
.qm-pan-section {
  padding-top: 40px;
  border-top: 1px solid rgba(44, 42, 36, 0.08);
  scroll-margin-top: calc(var(--nav-h) + 12px);
}
.qm-pan-section .section-head { margin-bottom: 52px; }
.chart-badge-row { margin-top: 16px; }

/* —— 局象信息条（四枚金框 chip） —— */
.qm-info-strip {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 14px;
  max-width: 860px;
  margin: 0 auto 42px;
}
.qm-info {
  display: inline-flex; align-items: baseline; gap: 12px;
  padding: 11px 26px;
  border: 1px solid rgba(184, 145, 75, 0.55);
  border-radius: 999px;
  background: rgba(212, 175, 106, 0.1);
  box-shadow: inset 0 1px 0 rgba(250, 247, 239, 0.6), 0 3px 10px rgba(44, 42, 36, 0.06);
}
.qm-info-label {
  font-family: var(--font-serif);
  font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--gold-700);
  white-space: nowrap;
}
.qm-info-value {
  font-family: var(--font-serif);
  font-size: 17px; font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--paper-ink);
  white-space: nowrap;
}

/* —— 盘底座：深色圆角大卡 —— */
.qm-board-wrap {
  max-width: 860px;
  margin-inline: auto;
  padding: clamp(16px, 3.4vw, 34px);
  border: 1px solid rgba(184, 145, 75, 0.6);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(ellipse 120% 90% at 50% -20%, rgba(212, 175, 106, 0.13), transparent 55%),
    linear-gradient(165deg, var(--ink-800), var(--ink-950) 92%);
  box-shadow: 0 30px 70px rgba(44, 42, 36, 0.22), inset 0 1px 0 rgba(212, 175, 106, 0.2);
  overflow-x: auto;
}

/* —— 九宫：1px 金线网格 —— */
.qm-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  min-width: 300px;
  border: 1px solid rgba(212, 175, 106, 0.38);
  background: rgba(212, 175, 106, 0.32);
}

/* —— 宫格：洛书数序 1→9 逐宫点亮 —— */
.qm-palace {
  position: relative;
  min-height: 176px;
  padding: 32px 10px 18px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 7px;
  text-align: center;
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, rgba(212, 175, 106, 0.05), transparent 60%),
    linear-gradient(180deg, var(--ink-900), var(--ink-850));
  animation: qmPalaceIn 0.55s var(--ease-out) both;
  animation-delay: calc((var(--ls, 1) - 1) * 110ms);
}
@keyframes qmPalaceIn {
  from { opacity: 0; transform: scale(0.9) translateY(8px); }
  to   { opacity: 1; transform: none; }
}
/* 金光一闪 */
.qm-palace::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 72% 62% at 50% 45%, var(--gold-glow), transparent 72%);
  opacity: 0;
  animation: qmFlash 0.85s ease-out both;
  animation-delay: calc((var(--ls, 1) - 1) * 110ms + 0.16s);
}
@keyframes qmFlash {
  0%   { opacity: 0; }
  32%  { opacity: 1; }
  100% { opacity: 0; }
}

/* 宫名 + 洛书数角标 */
.qm-corner {
  position: absolute; top: 9px; left: 11px;
  font-family: var(--font-serif);
  font-size: 11px; letter-spacing: 0.16em;
  color: var(--text-low);
  white-space: nowrap;
}

/* 值符 / 用神 角标印 */
.qm-mark {
  position: absolute; top: 8px; right: 8px;
  font-family: var(--font-serif);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.14em; text-indent: 0.14em;
  line-height: 1.5;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
}
.qm-mark-zhifu {
  color: var(--paper-50);
  background: linear-gradient(155deg, var(--cinnabar), var(--cinnabar-deep));
  box-shadow: 0 3px 9px rgba(150, 53, 44, 0.45), inset 0 0 0 1px rgba(250, 247, 239, 0.35);
  transform: rotate(4deg);
}
.qm-mark-useful {
  color: var(--gold-300);
  border: 1px solid rgba(212, 175, 106, 0.6);
  background: rgba(212, 175, 106, 0.14);
}

/* 特殊宫描边 */
.qm-palace.is-zhifu {
  z-index: 1;
  box-shadow: inset 0 0 0 1.5px var(--cinnabar), inset 0 0 28px rgba(184, 73, 62, 0.16);
}
.qm-palace.is-useful {
  z-index: 1;
  box-shadow: inset 0 0 0 1.5px var(--gold-500), inset 0 0 28px rgba(212, 175, 106, 0.14);
}
/* 中五宫：降饱和，无门无神 */
.qm-palace.is-center {
  background: var(--ink-850);
}
.qm-palace.is-center .qm-star { color: var(--text-mid); }
.qm-palace.is-center .qm-gan-tian {
  color: var(--text-mid);
  border-color: rgba(237, 232, 216, 0.25);
  background: rgba(237, 232, 216, 0.05);
}

/* —— 宫内四层：八神 → 九星 → 八门 → 天地盘干 —— */
.qm-god {
  font-size: 12px;
  letter-spacing: 0.3em; text-indent: 0.3em;
  color: var(--text-low);
}
.qm-star {
  font-family: var(--font-serif);
  font-size: 15.5px; font-weight: 600;
  letter-spacing: 0.24em; text-indent: 0.24em;
  color: var(--gold-400);
}
.qm-door {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 31px); font-weight: 900;
  letter-spacing: 0.14em; text-indent: 0.14em;
  line-height: 1.25;
  background: linear-gradient(170deg, var(--gold-300) 12%, var(--gold-500) 58%, var(--gold-700) 96%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 3px 12px rgba(212, 175, 106, 0.22));
}
.qm-center-note {
  font-family: var(--font-serif);
  font-size: 12.5px; letter-spacing: 0.22em;
  color: var(--text-low);
}
.qm-gans { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.qm-gan {
  display: inline-flex; align-items: center; justify-content: center;
  width: 27px; height: 27px;
  font-family: var(--font-serif);
  font-size: 14px; font-weight: 700;
  border-radius: 6px;
}
.qm-gan-tian {
  color: var(--gold-300);
  border: 1px solid rgba(212, 175, 106, 0.55);
  background: rgba(212, 175, 106, 0.12);
}
.qm-gan-di {
  color: var(--text-mid);
  border: 1px solid rgba(237, 232, 216, 0.22);
  background: rgba(237, 232, 216, 0.05);
}
.qm-gan-sep {
  width: 3px; height: 3px;
  transform: rotate(45deg);
  background: rgba(212, 175, 106, 0.5);
}

.qm-board-note {
  max-width: 860px;
  margin: 18px auto 0;
  text-align: center;
  font-size: 12.5px; letter-spacing: 0.1em;
  line-height: 2;
  color: var(--paper-ink-soft);
}

/* ================= 动效克制 ================= */
@media (prefers-reduced-motion: reduce) {
  .qm-hero-divider { animation: none; }
  .qm-palace { animation: none; opacity: 1; transform: none; }
  .qm-palace::after { animation: none; opacity: 0; }
}

/* ================= 响应式 ================= */
@media (max-width: 720px) {
  .qm-entry { padding-top: 52px; }
  .qm-date-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qm-date-grid[hidden] { display: none; }
  .check-line { white-space: normal; }

  .qm-info-strip { gap: 10px; margin-bottom: 34px; }
  .qm-info { padding: 8px 16px; gap: 8px; }
  .qm-info-label { font-size: 11.5px; letter-spacing: 0.2em; }
  .qm-info-value { font-size: 15px; }

  .qm-palace { min-height: 132px; padding: 27px 6px 13px; gap: 5px; }
  .qm-door { font-size: 21px; }
  .qm-star { font-size: 13.5px; letter-spacing: 0.18em; text-indent: 0.18em; }
  .qm-god { font-size: 10.5px; letter-spacing: 0.22em; text-indent: 0.22em; }
  .qm-center-note { font-size: 11px; }
  .qm-gan { width: 22px; height: 22px; font-size: 12px; border-radius: 5px; }
  .qm-corner { top: 6px; left: 7px; font-size: 9.5px; letter-spacing: 0.1em; }
  .qm-mark { top: 5px; right: 5px; font-size: 9px; padding: 1px 5px; }
}
