/* hexinfo.css — 易經卦象說明視窗（搭配 hexinfo.js）
   /chart1/ 與 /chart2/ 共用；各站以下列變數套用自己的色調。 */
.hx-dlg {
  --hx-ink: #1f2f52;         /* 卦頭底色（藏青） */
  --hx-gold: #fde68a;        /* 卦名 */
  --hx-paper: #f6f7f9;       /* 內文淡底 */
  --hx-line: #e2e4ea;
  --hx-text: #2a2d38;
  --hx-muted: #6b6f7c;
  --hx-yi: #2c6b2f;
  --hx-yi-tint: #e8f4e6;
  --hx-shen: #a52222;
  --hx-shen-tint: #fbeceb;
  --hx-serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --hx-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;

  box-sizing: border-box;
  width: min(560px, calc(100vw - 32px));
  max-width: none;
  max-height: min(760px, calc(100vh - 40px));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: #fff;
  color: var(--hx-text);
  font-family: var(--hx-sans);
  line-height: 1.6;
  letter-spacing: 0;
  box-shadow: 0 24px 64px rgba(10, 12, 24, .32), 0 2px 8px rgba(10, 12, 24, .12);
}

.hx-dlg *,
.hx-dlg *::before,
.hx-dlg *::after { box-sizing: border-box; }

.hx-dlg::backdrop {
  background: rgba(12, 14, 26, .52);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.hx-dlg[open] { animation: hx-in .18s ease-out; }
@keyframes hx-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

/* 不支援 <dialog> 的舊瀏覽器 */
.hx-dlg-fallback {
  position: fixed; inset: 0; z-index: 1000; width: auto; max-height: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0; background: rgba(12, 14, 26, .52); box-shadow: none;
}
.hx-dlg-fallback[hidden] { display: none; }
.hx-dlg-fallback .hx-card {
  width: min(560px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 40px));
  border-radius: 16px; background: #fff; box-shadow: 0 24px 64px rgba(10, 12, 24, .32);
}

html.hx-lock { overflow: hidden; }

.hx-card {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  overflow: auto;
  overscroll-behavior: contain;
}

/* 卦頭：深色底、六爻、卦名 */
.hx-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 24px 56px 22px 28px;
  background: var(--hx-ink);
  color: #fff;
}

.hx-fig {
  flex: 0 0 auto;
  width: 64px;
  height: auto;
  fill: #fff;
}

.hx-headtext { min-width: 0; }

.hx-no {
  margin: 0 0 4px;
  color: rgba(255, 255, 255, .62);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .16em;
}

.hx-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  color: var(--hx-gold);
  font-family: var(--hx-serif);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .08em;
}

.hx-title b { font-size: 40px; font-weight: 900; }
.hx-title small { font-size: 18px; font-weight: 600; opacity: .9; }

.hx-tris {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
}

.hx-tris span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 4px;
  border: 1px solid rgba(255, 255, 255, .26);
  border-radius: 999px;
  color: rgba(255, 255, 255, .88);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
}

.hx-tris i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0;
}

.hx-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  cursor: pointer;
}

.hx-close svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; }
.hx-close:hover { background: rgba(255, 255, 255, .2); }
.hx-close:focus-visible { outline: 2px solid var(--hx-gold); outline-offset: 2px; }

/* 內文 */
.hx-body { padding: 20px 28px 6px; }

.hx-kw {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.hx-kw li {
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--hx-paper);
  color: var(--hx-text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
}

.hx-plain {
  margin: 0;
  color: var(--hx-text);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.75;
}

.hx-adv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 0;
}

.hx-adv > div {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--hx-yi-tint);
}

.hx-adv .hx-shen { background: var(--hx-shen-tint); }

.hx-adv dt {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--hx-yi);
  color: #fff;
  font-family: var(--hx-serif);
  font-size: 14px;
  font-weight: 700;
}

.hx-adv .hx-shen dt { background: var(--hx-shen); }

.hx-adv dd {
  margin: 1px 0 0;
  color: var(--hx-text);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.55;
}

.hx-classic {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--hx-line);
}

.hx-classic p {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  margin: 0 0 8px;
  color: var(--hx-text);
  font-family: var(--hx-serif);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.75;
  letter-spacing: .04em;
}

.hx-classic span {
  align-self: start;
  margin-top: 3px;
  padding: 1px 0;
  border: 1px solid var(--hx-line);
  border-radius: 6px;
  color: var(--hx-muted);
  font-family: var(--hx-sans);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
  letter-spacing: .1em;
}

/* 上一卦／下一卦 */
.hx-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 20px 18px;
}

.hx-nav {
  min-height: 34px;
  margin: 0;
  padding: 4px 12px;
  border: 1px solid var(--hx-line);
  border-radius: 999px;
  background: #fff;
  color: var(--hx-muted);
  font-family: var(--hx-sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
}

.hx-nav span { font-size: 16px; line-height: 1; }
.hx-nav:hover { border-color: var(--hx-muted); color: var(--hx-text); }
.hx-nav:focus-visible { outline: 2px solid var(--hx-ink); outline-offset: 2px; }

/* 手機：自下方滑出的面板 */
@media (max-width: 560px) {
  .hx-dlg {
    width: 100vw;
    max-height: 88vh;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
  }
  .hx-dlg[open] { animation: hx-up .22s ease-out; }
  .hx-head { gap: 16px; padding: 20px 52px 18px 18px; }
  .hx-fig { width: 52px; }
  .hx-title b { font-size: 34px; }
  .hx-body { padding: 16px 18px 4px; }
  .hx-plain { font-size: 16px; }
  .hx-adv { grid-template-columns: minmax(0, 1fr); }
  .hx-foot { padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); }
}
@keyframes hx-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .hx-dlg[open] { animation: none; }
}

@media print {
  .hx-dlg { display: none !important; }
}
