/* 易经六十四卦 — 静态展示样式 */
:root {
    --bg: #161616;
    --surface: #1c1a17;
    --surface-2: #242019;
    --text: #efe6d6;
    --text-dim: #b5a894;
    --text-faint: #8a7a68;
    --border: #302b25;
    --accent: #d4a24c;
    --serif: "Songti SC", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
    --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    color-scheme: dark;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--serif);
    background: var(--bg);
    color: var(--text);
    line-height: 1.85;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 22px; }

/* 通用页头 */
.site-head { padding: 56px 0 36px; text-align: center; }
.site-head h1 {
    font-size: 1.7em; font-weight: 600; letter-spacing: 0.14em;
    color: var(--text);
}
.site-head .sub {
    margin-top: 12px; font-size: 0.85em; letter-spacing: 0.16em;
    color: var(--text-faint); font-family: var(--sans);
}

/* 卜卦 */
.divination { margin-top: 26px; }
.bu {
    font-family: var(--serif);
    font-size: 1.02em;
    letter-spacing: 0.1em;
    padding: 10px 26px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    cursor: pointer;
    transition: background .2s ease;
}
.bu:hover, .bu:focus-visible { background: rgba(212, 162, 76, 0.13); }
.cast { margin-top: 24px; }
.nums { display: flex; justify-content: center; gap: 12px; }
.slot {
    width: 42px; height: 46px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 7px;
    font-family: var(--sans); font-size: 1.4em; color: var(--text);
    transition: border-color .2s ease, background .2s ease;
}
.slot.filled {
    border-color: var(--accent);
    background: rgba(212, 162, 76, 0.10);
}
.pos-row {
    display: flex; justify-content: center; gap: 12px;
    margin-top: 8px; font-family: var(--sans);
    font-size: 0.72em; color: var(--text-faint);
}
.pos-row span { width: 42px; text-align: center; }
/* 结果区：左右卦象夹着文字 */
.result-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    max-width: 660px;
    margin: 26px auto 0;
}
.hex-side { flex: 0 0 84px; width: 84px; }
.hex-side svg { display: block; width: 84px; height: auto; overflow: visible; }
.hex-side line {
    stroke: var(--accent);
    stroke-width: 5;
    stroke-linecap: round;
}
.yao-in { opacity: 0; animation: yaoIn .25s ease forwards; }
@keyframes yaoIn { to { opacity: 1; } }
.result { flex: 0 1 auto; max-width: 300px; text-align: center; font-size: 0.95em; line-height: 2.1; color: var(--text-dim); }
.result .hexname { color: var(--accent); font-size: 1.22em; letter-spacing: 0.12em; }

/* 断卦依据 */
.advice {
    max-width: 560px;
    margin: 26px auto 0;
    padding-top: 22px;
    border-top: 1px solid var(--border);
    text-align: left;
}
.advice-head {
    font-family: var(--sans); font-size: 0.74em; letter-spacing: 0.22em;
    color: var(--text-faint); margin-bottom: 16px;
}
.advice-item { margin-bottom: 18px; }
.advice-item:last-child { margin-bottom: 0; }
.advice-top { display: flex; align-items: baseline; gap: 12px; }
.advice-role {
    font-family: var(--sans); font-size: 0.72em; letter-spacing: 0.14em;
    color: var(--accent);
}
.advice-link {
    font-size: 0.94em; color: var(--accent); text-decoration: none;
    letter-spacing: 0.06em;
}
.advice-link:hover { text-decoration: underline; }
.advice-text { margin-top: 7px; font-size: 0.96em; line-height: 1.9; color: var(--text-dim); }
.advice-item.minor .advice-role { color: var(--text-faint); }
.advice-item.minor .advice-link { color: var(--text-dim); }
.advice-item.minor .advice-text { color: var(--text-faint); }

/* 索引网格 */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 12px;
    padding-bottom: 72px;
}

/* 宽屏下索引页加宽，每行固定 8 卦；详情页仍保持阅读宽度 */
@media (min-width: 1000px) {
    .wrap.wide { max-width: 1200px; }
    .grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
.card {
    display: flex; flex-direction: column; align-items: center;
    padding: 20px 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color .18s ease, background .18s ease;
}
.card:hover, .card:focus-visible {
    border-color: var(--accent);
    background: var(--surface-2);
}
/* 卜卦命中的卦 */
.card.active {
    border-color: var(--accent);
    background: rgba(212, 162, 76, 0.13);
    box-shadow: 0 0 0 1px var(--accent) inset;
}
.card.active .name { color: var(--accent); }
/* 卦象：用 sign 直接画六爻，从下往上 */
.hex { display: inline-flex; flex-direction: column-reverse; gap: 4px; }
.hex i { display: block; width: 42px; height: 4px; border-radius: 1px; background: var(--accent); }
.hex i.n { display: flex; justify-content: space-between; background: none; }
.hex i.n b { display: block; width: 18px; height: 4px; border-radius: 1px; background: var(--accent); }
.hex.lg { gap: 7px; }
.hex.lg i { width: 78px; height: 7px; }
.hex.lg i.n b { width: 34px; height: 7px; }
.card .hex { margin-bottom: 2px; }
.card .name {
    margin-top: 12px; font-size: 1.06em; letter-spacing: 0.1em;
}
.card .no {
    margin-top: 4px; font-size: 0.72em; letter-spacing: 0.14em;
    color: var(--text-faint); font-family: var(--sans);
}

/* 详情页头 */
.hex-head {
    padding: 52px 0 34px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.hex-head .hex.lg { margin-bottom: 4px; }
.hex-head h1 {
    margin-top: 16px; font-size: 2.1em; font-weight: 600; letter-spacing: 0.16em;
}
.hex-head .no {
    margin-top: 8px; font-size: 0.78em; letter-spacing: 0.2em;
    color: var(--text-faint); font-family: var(--sans);
}

/* 章节 */
section { padding: 34px 0; border-bottom: 1px solid var(--border); }
section:last-of-type { border-bottom: none; }
h2 {
    font-size: 0.78em; font-weight: 500; letter-spacing: 0.26em;
    color: var(--text-faint); font-family: var(--sans);
    margin-bottom: 18px;
}
.classic { font-size: 1.04em; line-height: 2; color: var(--text); }
.classic + .classic { margin-top: 12px; }

/* 六爻 */
.yao-list { display: flex; flex-direction: column; gap: 14px; }
.yao-item {
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.yao-item .pos {
    font-size: 0.74em; letter-spacing: 0.2em; color: var(--accent);
    font-family: var(--sans); margin-bottom: 8px;
}
.yao-item .text { font-size: 1.02em; line-height: 1.9; }
.yao-item .xiang {
    margin-top: 10px; padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: 0.9em; line-height: 1.9; color: var(--text-dim);
}

/* 从断卦依据跳转进来时，高亮对应的章节 */
section:target,
details:target {
    background: rgba(212, 162, 76, 0.08);
    box-shadow: inset 3px 0 0 var(--accent);
}
.yao-item:target {
    border-color: var(--accent);
    background: rgba(212, 162, 76, 0.13);
    box-shadow: inset 3px 0 0 var(--accent);
}

/* 折叠块 */
details {
    padding: 26px 0;
    border-bottom: 1px solid var(--border);
}
details summary {
    cursor: pointer; list-style: none;
    font-size: 0.82em; letter-spacing: 0.2em; color: var(--text-dim);
    font-family: var(--sans);
}
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "＋ "; color: var(--accent); }
details[open] summary::before { content: "－ "; }
details[open] summary { margin-bottom: 16px; }
details .body { font-size: 1em; line-height: 2; white-space: pre-wrap; }

/* 翻页 */
.pager {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; padding: 36px 0 64px;
    font-size: 0.84em; letter-spacing: 0.08em; color: var(--text-dim);
    font-family: var(--sans);
}
.pager a {
    padding: 9px 16px; border: 1px solid var(--border); border-radius: 6px;
    transition: border-color .18s ease, color .18s ease;
}
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager .mid { color: var(--text-faint); }

/* 页脚 */
footer {
    padding: 0 0 56px; text-align: center;
    font-size: 0.74em; letter-spacing: 0.1em; color: var(--text-faint);
    font-family: var(--sans);
}

/* 窄屏 */
@media (max-width: 480px) {
    body { line-height: 1.8; }
    .wrap { padding: 0 16px; }
    .site-head { padding: 40px 0 28px; }
    .site-head h1 { font-size: 1.4em; }
    .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .result-row { gap: 16px; }
    .hex-side { flex: 0 0 60px; width: 60px; }
    .hex-side svg { width: 60px; }
    .card { padding: 16px 8px 13px; }
    .card .hex i { width: 36px; height: 3.5px; }
    .card .hex i.n b { width: 15px; height: 3.5px; }
    .hex-head { padding: 40px 0 28px; }
    .hex-head .hex.lg i { width: 64px; height: 6px; }
    .hex-head .hex.lg i.n b { width: 28px; height: 6px; }
    .hex-head h1 { font-size: 1.75em; }
    .yao-item { padding: 15px 16px; }
}
