/* yongshen.css — 「喜用神」叢集專用樣式（暖象牙精品風，沿用 shenqiang/wuxing-yong 色系）。
   在 :root 覆蓋 style.css 的暗金 token（本檔在 style.css / article.css 之後載入），整頁 chrome 自動翻亮；
   共用件沿用 article.css 結構，本檔只覆蓋配色/字體並補本叢集專屬元件：
   .ys-layers 取用神五層、.ys-stats 引擎實測數字、.ys-tool 頁內查詢、.ys-table 對照表、.ys-myths、.ys-note。
   配色克制：區塊標題與結論數字用深色，金色只留強調點（見 design-gold-restraint）。 */

:root {
  --bg: #f7f3ec; --bg-card: #ffffff; --bg-input: #fffdf9; --border: #e4ddce;
  --text: #201d18; --text-dim: #6f685c; --gold: #a6824c; --gold-soft: #c0a070;
  --radius: 14px;
  --xi: #4f8c5f;    /* 喜用 綠 */
  --ji: #b45c3f;    /* 忌 緋 */
  --grey: #5a7fb0;  /* 灰色地帶／提示 藍 */
  --lux-sans: 'Jost', 'Noto Sans TC', 'Helvetica Neue', Arial, sans-serif;
}

body { font-family: var(--lux-sans); }
.article h1, .article h2, .ys-note h2 { font-family: var(--lux-serif); font-weight: 600; }
.article h3 { font-family: var(--lux-serif); font-weight: 600; font-size: 1.22rem; margin: 22px 0 8px; color: var(--text); }
.ys-sub { color: var(--text-dim); font-size: 0.98rem; margin: 0 0 18px; }

/* 喜／忌／灰 小標籤 */
.ys-chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.86rem; font-weight: 500; line-height: 1.7; border: 1px solid currentColor; margin: 0 2px; }
.ys-chip.xi { color: var(--xi); } .ys-chip.ji { color: var(--ji); } .ys-chip.grey { color: var(--grey); }

/* 取用神的層次：一層一張卡，左側色條表示它對喜忌的作用 */
.ys-layers { display: grid; gap: 12px; margin: 6px 0 12px; counter-reset: ys-layer; }
.ys-layer {
  background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--gold-soft);
  border-radius: 12px; padding: 14px 18px; display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: start;
}
.ys-layer h3 { margin: 0; font-size: 1.18rem; }
.ys-layer h3::before { counter-increment: ys-layer; content: counter(ys-layer) "　"; color: var(--gold); font-size: 0.95rem; }
.ys-layer p { grid-column: 1 / -1; margin: 4px 0 0; font-size: 0.94rem; line-height: 1.85; color: var(--text); }
.ys-layer .ys-rate { font-size: 0.78rem; color: var(--text-dim); letter-spacing: 0.04em; text-align: right; white-space: nowrap; }
.ys-layer .ys-rate b { font-family: var(--lux-serif); font-size: 1.15rem; color: var(--text); font-weight: 600; }
.ys-layer.base { border-left-color: var(--xi); }
.ys-layer.hint { border-left-color: var(--grey); }
.ys-layer a { color: var(--gold); }

/* 引擎實測數字 */
.ys-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 8px 0 8px; }
.ys-stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 12px 12px; text-align: center; }
.ys-stat .n { display: block; font-family: var(--lux-serif); font-size: 1.9rem; font-weight: 600; color: var(--text); line-height: 1.1; }
.ys-stat .l { display: block; margin-top: 6px; font-size: 0.8rem; color: var(--text-dim); line-height: 1.55; }
.ys-source { font-size: 0.82rem; color: var(--text-dim); margin: 0 0 16px; }

/* 對照表 */
.ys-tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin: 4px 0 12px; }
/* 預設不設最小寬度（原本一律 560px，觀音籤四欄表在手機第四欄被藏到右邊）；五欄以上或 .wide 才撐寬橫捲 */
.ys-table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
.ys-table:has(> thead > tr > :nth-child(5)), .ys-table:has(> tbody:first-child > tr:first-child > :nth-child(5)) { min-width: 560px; }
.ys-table th, .ys-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; line-height: 1.75; }
.ys-table.wide { min-width: 760px; }
.ys-table thead th { white-space: nowrap; background: var(--bg-input); font-size: 0.8rem; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 600; }
.ys-table tbody th { font-family: var(--lux-serif); font-size: 1.02rem; color: var(--text); white-space: nowrap; }
.ys-table tr:last-child th, .ys-table tr:last-child td { border-bottom: 0; }
.ys-table .col-xi { color: var(--xi); } .ys-table .col-ji { color: var(--ji); }
.ys-table td.col-xi, .ys-table td.col-ji { color: var(--text); }
.ys-table thead .col-xi { color: var(--xi); } .ys-table thead .col-ji { color: var(--ji); }

/* 迷思 */
.ys-myths { display: grid; gap: 12px; margin: 6px 0 10px; }
.ys-myth { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; }
.ys-myth .m-wrong { margin: 0; color: var(--ji); font-size: 0.95rem; font-weight: 500; }
.ys-myth .m-wrong::before { content: "迷思"; font-size: 0.75rem; letter-spacing: 0.14em; background: var(--ji); color: #fffdf9; padding: 2px 7px; border-radius: 999px; margin-right: 8px; vertical-align: 1px; }
.ys-myth .m-right { margin: 8px 0 0; color: var(--text); font-size: 0.94rem; line-height: 1.85; }
.ys-myth .m-right::before { content: "其實"; font-size: 0.75rem; letter-spacing: 0.14em; background: var(--xi); color: #fffdf9; padding: 2px 7px; border-radius: 999px; margin-right: 8px; vertical-align: 1px; }
html[lang^="en"] .ys-myth .m-wrong::before { content: "MYTH"; }
html[lang^="en"] .ys-myth .m-right::before { content: "REALITY"; }
html[lang="zh-Hans"] .ys-myth .m-wrong::before { content: "误区"; }
html[lang="zh-Hans"] .ys-myth .m-right::before { content: "其实"; }

/* 範例盤：用一張真盤走一遍 */
.ys-case { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 8px 0 14px; }
.ys-case .pillars { display: flex; gap: 10px; margin: 2px 0 12px; flex-wrap: wrap; }
.ys-case .pillar { border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; text-align: center; background: var(--bg-input); min-width: 58px; }
.ys-case .pillar small { display: block; font-size: 0.75rem; color: var(--text-dim); letter-spacing: 0.08em; }
.ys-case .pillar b { font-family: var(--lux-serif); font-size: 1.25rem; color: var(--text); letter-spacing: 0.08em; }
.ys-case .pillar.dm { border-color: var(--gold-soft); }
.ys-case ol { margin: 0; padding-left: 1.3em; }
.ys-case li { margin: 4px 0; line-height: 1.85; font-size: 0.95rem; }

/* 誠實框 */
.ys-note { background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--gold-soft); border-radius: 0 var(--radius) var(--radius) 0; padding: 16px 20px; margin: 22px 0; }
.ys-note h2 { margin-top: 0; font-size: 1.3rem; }
.ys-note p { margin: 8px 0 0; line-height: 1.9; }

/* 頁內查詢工具 */
.ys-tool { background: var(--bg-card); border: 1px solid var(--border); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 18px 18px 16px; margin: 10px 0 18px; }
.ys-tool h2 { margin-top: 0; }
.ys-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; align-items: end; }
.ys-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--text-dim); letter-spacing: 0.04em; }
/* 字級 1rem：小於 16px 的欄位在 iOS Safari 聚焦時會自動放大頁面 */
.ys-form select, .ys-form input[type="number"], .ys-form input[type="date"], .ys-form input[type="time"], .ys-form input[type="text"] {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; width: 100%; box-sizing: border-box;
}
.ys-form .ys-opt { grid-column: 1 / 3; flex-direction: row; align-items: center; gap: 8px; font-size: 0.86rem; min-height: 44px; }
.ys-form .ys-opt input[type="checkbox"] { width: 20px; height: 20px; flex: none; margin: 0; accent-color: var(--gold); }
.ys-form button { grid-column: 3 / -1; }
.ys-form button {
  font: inherit; font-weight: 600; letter-spacing: 0.06em; border: 0; border-radius: 10px; padding: 11px 14px; cursor: pointer;
  background: var(--gold); color: #fffdf9;
}
.ys-form button:disabled { opacity: .6; cursor: wait; }
.ys-err { color: var(--ji); font-size: 0.9rem; margin: 10px 0 0; }
.ys-out { margin-top: 16px; }
.ys-out[hidden] { display: none; }
.ys-verdict { background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.ys-verdict .v-h { font-size: 0.78rem; letter-spacing: 0.1em; color: var(--text-dim); margin: 0 0 6px; }
.ys-verdict .v-row { margin: 4px 0; font-size: 1rem; line-height: 1.9; }
.ys-verdict .v-row .k { display: inline-block; min-width: 3.2em; color: var(--text-dim); font-size: 0.86rem; }
.ys-steps { display: grid; gap: 8px; }
.ys-step { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 0.92rem; line-height: 1.8; background: var(--bg-card); }
.ys-step .s-h { font-weight: 600; color: var(--text); margin-right: 6px; }
.ys-step.off { color: var(--text-dim); }
.ys-step.on { border-left: 3px solid var(--gold-soft); }
.ys-step.hint { border-left: 3px solid var(--grey); }
.ys-next { margin: 12px 0 0; font-size: 0.92rem; line-height: 1.85; }
.ys-next a { color: var(--gold); }
/* 今日農民曆：前一天／後一天 */
/* 兩欄的「項目｜內容」表（農民曆逐項）：不需要最小寬度，手機上直接折行，不必橫捲 */
.ys-table.ys-kv { min-width: 0; }
.ys-table.ys-kv td { overflow-wrap: anywhere; }
/* 今日農民曆總覽頁 H1 下方的今日摘要卡（js/huangli-tool.js 填入）；先留高度，內容進來時下方不跳 */
.hl-today { min-height: 250px; margin: 14px 0 6px; }
.hl-today .ys-verdict { margin-bottom: 6px; }
.hl-today-more { margin: 0 0 10px; font-size: 0.92rem; }
.hl-today-more a { display: inline-block; padding: 10px 0; color: var(--gold); }
.hl-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; }
.hl-nav button { min-height: 48px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-card); color: var(--text); font: inherit; font-size: 0.92rem; cursor: pointer; }
.hl-nav button:hover { border-color: var(--gold); }
.hl-nav a { margin-left: auto; font-size: 0.92rem; color: var(--gold); }

@media (max-width: 640px) {
  .ys-stats { grid-template-columns: repeat(2, 1fr); }
  .ys-form { grid-template-columns: repeat(2, 1fr); }
  .ys-form .ys-opt, .ys-form button { grid-column: 1 / -1; }
  .ys-layer { grid-template-columns: 1fr; }
  .ys-layer .ys-rate { text-align: left; }
}

/* 手機：能不橫捲就不橫捲。
   · 剛好三欄的對照表（有表頭）：拿掉最小寬度，內文自己換行。
   · 十二時辰表（.ys-hours，五到六欄但每格都很短）：縮字距與留白後塞得進一個手機寬。
   四欄以上的一般對照表內容長，維持原本的橫捲（外層可用鍵盤捲，見 js/a11y.js）。 */
@media (max-width: 640px) {
  .ys-table:has(thead th:nth-child(3):last-child), .ys-table.wide:has(thead th:nth-child(3):last-child) { min-width: 0; }
  .ys-table:has(thead th:nth-child(3):last-child) th, .ys-table:has(thead th:nth-child(3):last-child) td { padding: 9px 10px; overflow-wrap: anywhere; }
  .ys-table:has(thead th:nth-child(3):last-child) tbody th { white-space: normal; min-width: 4.5em; }
  .ys-table.ys-hours { min-width: 0; font-size: 0.82rem; }
  .ys-table.ys-hours th, .ys-table.ys-hours td { padding: 8px 5px; }
  .ys-table.ys-hours thead th { letter-spacing: 0; font-size: 0.75rem; white-space: normal; }
  .ys-table.ys-hours tbody th { font-size: 0.9rem; }
}

/* 可折疊的長清單（籤詩總覽的全籤一覽、逐籤連結）：總論先讀，清單按需展開 */
.ys-fold { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 0 16px; margin: 12px 0 20px; }
.ys-fold > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 500; color: var(--text); }
.ys-fold[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 12px; }
/* 手機窄螢幕（≤480px）：三、四欄的對照表改排成鍵值卡，一列一張，不必橫捲。
   .ys-cards 與每格的 data-label 由 js/a11y.js 依表頭補上（同時補 ARIA role，報讀器仍當表格唸）；沒跑 JS 時維持原本的表格。 */
@media (max-width: 480px) {
  .ys-table.ys-cards, .ys-table.ys-cards tbody, .ys-table.ys-cards tr, .ys-table.ys-cards th, .ys-table.ys-cards td { display: block; }
  .ys-table.ys-cards { min-width: 0; }
  .ys-table.ys-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .ys-table.ys-cards tr { padding: 10px 14px 12px; border-bottom: 1px solid var(--border); }
  .ys-table.ys-cards tr:last-child { border-bottom: 0; }
  .ys-table.ys-cards th, .ys-table.ys-cards td { padding: 2px 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .ys-table.ys-cards tbody th { font-size: var(--fs-md, 1.125rem); margin-bottom: 2px; }
  .ys-table.ys-cards td[data-label] { padding-top: 6px; }
  .ys-table.ys-cards td[data-label]::before { content: attr(data-label); display: block; color: var(--text-dim); font-size: var(--fs-xs, 0.8125rem); line-height: 1.5; letter-spacing: 0.04em; }
}
/* 神明生日總覽頁「下一個神明生日」（js/shendan-tool.js 填入；沒跑 JS 時容器帶 hidden 不顯示）。
   金色只留左邊線與連結，名稱與日期用深色。 */
.sd-next { background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--gold-soft); border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 18px; margin: 8px 0 18px; overflow-wrap: anywhere; }
.sd-next p { margin: 0; }
.sd-next .sd-next-h { font-size: 0.8rem; color: var(--text-dim); letter-spacing: 0.06em; }
.sd-next .sd-next-sub { margin-top: 12px; }
.sd-next .sd-next-main { font-family: var(--lux-serif); font-size: 1.2rem; font-weight: 600; color: var(--text); line-height: 1.6; margin-top: 2px; }
.sd-next .sd-next-date { font-size: 0.94rem; color: var(--text); line-height: 1.7; }
.sd-next .sd-nw { white-space: nowrap; }
.sd-next-more { list-style: none; margin: 4px 0 0; padding: 0; }
.sd-next-more li { font-size: 0.92rem; line-height: 1.8; color: var(--text); }
.sd-next-more .sd-next-when { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.sd-next-more .sd-next-left { color: var(--text-dim); font-size: 0.85rem; white-space: nowrap; }

/* 民俗區段（黃曆、神明生日、四套籤詩）表格內文至少 1rem（第六輪 elder#9）：html[data-folk] 由頁首內嵌腳本依網址標上 */
html[data-folk] .ys-table tbody td, html[data-folk] .ys-table tbody th { font-size: 1rem; }
html[data-folk] .ys-table thead th { font-size: 0.88rem; }
/* 黃曆逐日頁的「← 前一天／後一天 →」：原本是一行小字連結（159×22px），改成 48px 高的整顆按鈕（elder#4）。
   靠 rel＝prev／next 加網址辨認，不必重產 731 頁 */
.ys-next > a[rel="prev"][href*="/huangli/20"], .ys-next > a[rel="next"][href*="/huangli/20"] {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; margin: 4px 0; padding: 6px 16px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); color: var(--text); font-weight: 600; text-decoration: none;
}
.ys-next > a[rel="prev"][href*="/huangli/20"]:hover, .ys-next > a[rel="next"][href*="/huangli/20"]:hover { border-color: var(--gold); }
/* 黃曆總覽首屏卡的沖煞大字（js/huangli-tool.js；elder#4） */
.hl-chong-big { margin: 0 0 8px; font-size: 1.2rem; font-weight: 700; line-height: 1.5; color: var(--text); }
/* 「今天和你」的十二生肖按鈕（js/huangli-you.js；elder#4） */
.hl-you-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 6px 0 0; }
.hl-you-grid button {
  min-height: 48px; padding: 4px 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); color: var(--text);
  font: inherit; font-size: 1rem; cursor: pointer; line-height: 1.2;
}
.hl-you-grid button[aria-pressed="true"] { border-color: var(--gold); background: rgba(217, 178, 60, 0.16); font-weight: 700; }
.hl-you-grid button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (max-width: 480px) { .hl-you-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* ── 線上求籤（js/qiuqian.js、scripts/qiuqian-block.mjs；第六輪 compete#3＋elder#8）：每步一顆大按鈕、筊杯大圖示 ── */
.qq { background: var(--bg-card); border: 1px solid var(--border); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 18px 18px 16px; margin: 10px 0 22px; }
.qq h2 { margin-top: 0; color: var(--text); }
.qq-lead { font-size: 1.05rem; line-height: 1.8; }
.qq-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; margin: 4px 0 14px; font-size: 1rem; color: var(--text-dim); }
.qq-steps li { display: flex; align-items: center; gap: 6px; }
.qq-steps li span { display: inline-flex; align-items: center; justify-content: center; width: 1.7em; height: 1.7em; border-radius: 50%; border: 1px solid var(--border); font-size: .9rem; }
.qq-steps li.on { color: var(--text); font-weight: 600; }
.qq-steps li.on span { border-color: var(--gold); background: var(--gold); color: #fff; }
.qq-steps li.done span { border-color: var(--gold-soft); color: var(--gold); }
.qq-stage { text-align: center; }
.qq-q { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 1.05rem; color: var(--text); margin: 0 auto 6px; max-width: 520px; }
.qq-q input { font-size: 1.1rem; min-height: 52px; padding: 10px 12px; }
.qq-hint { font-size: .95rem; color: var(--text-dim); line-height: 1.7; max-width: 560px; margin: 6px auto 12px; }
.qq-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 56px; min-width: min(100%, 280px); padding: 12px 28px; margin: 6px 0 4px; border: 0; border-radius: 999px; background: linear-gradient(135deg, #8a6a3a 10%, var(--gold) 90%); color: #fff; font-size: 1.15rem; font-weight: 600; letter-spacing: .04em; cursor: pointer; text-decoration: none; }
.qq-btn:disabled { opacity: .6; cursor: progress; }
.qq-btn:focus-visible { outline: 3px solid var(--focus-ring, #8a6a3a); outline-offset: 3px; }
.qq-link { background: none; border: 0; color: var(--gold); font-size: 1rem; text-decoration: underline; min-height: 44px; cursor: pointer; }
.qq-cups { display: flex; justify-content: center; gap: 18px; color: var(--text); margin: 6px 0 2px; }
.qq-cup.flip { transform: scaleX(-1); }
.qq-cups.tossing .qq-cup { animation: qq-toss .65s ease-in-out; }
@keyframes qq-toss { 0% { transform: translateY(0) rotate(0); } 45% { transform: translateY(-34px) rotate(200deg); } 100% { transform: translateY(0) rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .qq-cups.tossing .qq-cup { animation: none; } }
.qq-count { font-size: 1.2rem; font-weight: 600; color: var(--text); margin: 4px 0; font-variant-numeric: tabular-nums; }
.qq-res { font-size: 1.05rem; line-height: 1.8; max-width: 560px; margin: 6px auto 8px; }
.qq-drawn { font-size: 1rem; color: var(--text-dim); margin: 6px 0 0; }
.qq-lot { font-family: var(--lux-serif, serif); font-size: 2rem; font-weight: 700; color: var(--text); margin: 4px 0 8px; }
.qq-note { font-size: .92rem; color: var(--text-dim); border-top: 1px dashed var(--border); padding-top: 10px; margin: 14px 0 0; }
/* 十二星座、十二生肖總覽頁的「今日運勢」入口（scripts/yunshi-links.mjs；第六輪 compete#1）。不用 .ys-tool，免得 apply-tool-first 把它當成總覽頁工具 */
.ys-jinri { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px 12px; margin: 10px 0 18px; }
.ys-jinri h2 { margin-top: 0; }
.ys-today-link { font-size: 1rem; background: var(--bg-card); border-left: 3px solid var(--gold-soft); padding: 8px 12px; }
