/* ============================================================
   易經 reading site — OKLCH design system (light theme)
   No hsl(var(--card-hue)); all colour in oklch().
   ============================================================ */
:root {
  --bg:        oklch(0.975 0.004 95);
  --surface:   oklch(1 0 0);
  --surface-2: oklch(0.965 0.006 95);
  --ink:       oklch(0.27 0.02 60);
  --ink-soft:  oklch(0.46 0.018 60);
  --ink-faint: oklch(0.62 0.014 60);
  --line:      oklch(0.88 0.01 95);
  --line-soft: oklch(0.92 0.008 95);

  --seal:      oklch(0.585 0.187 27);   /* 朱砂 vermilion accent */
  --seal-soft: oklch(0.95 0.03 27);
  --indigo:    oklch(0.52 0.11 255);    /* 靛 ink-blue */
  --indigo-soft: oklch(0.95 0.02 255);
  --gold:      oklch(0.74 0.10 85);     /* charlink gold */
  --jade:      oklch(0.68 0.09 165);    /* 青 secondary */

  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px oklch(0.2 0.02 60 / 0.05), 0 8px 28px oklch(0.2 0.02 60 / 0.07);
  --maxw: 1180px;
  --serif: "Songti SC", "Noto Serif CJK SC", "Noto Serif TC", "Source Han Serif",
           "STSong", "SimSun", "Georgia", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
          system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--seal-soft), transparent 60%),
    radial-gradient(1000px 500px at -10% 10%, var(--indigo-soft), transparent 55%),
    var(--bg);
  line-height: 1.75;
  font-size: 16.5px;
}
a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

/* ---------- top nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: oklch(1 0 0 / 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 18px; height: 58px; }
.brand { font-family: var(--serif); font-weight: 700; font-size: 1.18rem; color: var(--seal); letter-spacing: .12em; }
.brand small { color: var(--ink-faint); font-weight: 400; letter-spacing: .2em; font-size: .62rem; margin-left: 6px; }
.topnav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a {
  padding: 7px 13px; border-radius: 999px; color: var(--ink-soft);
  font-size: .9rem; transition: background .15s, color .15s;
}
.topnav a:hover { background: var(--surface-2); color: var(--seal); text-decoration: none; }

/* ---------- hero / index ---------- */
.hero { padding: 64px 0 30px; text-align: center; }
.hero .glyph-hero {
  font-family: var(--serif); font-size: clamp(64px, 12vw, 130px); line-height: 1;
  color: var(--seal); display: block; margin-bottom: 14px;
  text-shadow: 0 2px 0 oklch(1 0 0), 0 10px 30px var(--seal-soft);
}
.hero h1 { font-family: var(--serif); font-size: clamp(2rem, 5vw, 3.2rem); margin: .1em 0; letter-spacing: .14em; }
.hero .sub { color: var(--ink-soft); font-size: 1.05rem; letter-spacing: .18em; }
.hero .quote {
  margin: 26px auto 0; max-width: 760px; font-family: var(--serif);
  font-size: 1.22rem; color: var(--ink); line-height: 1.9;
}
.hero .quote cite { display: block; margin-top: 10px; font-style: normal; color: var(--ink-faint); font-size: .9rem; letter-spacing: .1em; }

.stats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 34px auto 8px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 22px; min-width: 96px; text-align: center; box-shadow: var(--shadow);
}
.stat b { font-family: var(--serif); font-size: 1.7rem; color: var(--seal); display: block; line-height: 1; }
.stat span { color: var(--ink-faint); font-size: .82rem; letter-spacing: .2em; }

/* ---------- generic section ---------- */
.section { padding: 40px 0; }
.section h2 {
  font-family: var(--serif); font-size: 1.5rem; letter-spacing: .14em; margin: 0 0 6px;
  display: flex; align-items: center; gap: 12px;
}
.section h2::before { content: ""; width: 5px; height: 1.4em; background: var(--seal); border-radius: 3px; }
.section .lead { color: var(--ink-soft); max-width: 820px; margin: 0 0 22px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- guide ---------- */
.guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 16px; }
.guide .card { padding: 20px 22px; }
.guide h3 { font-family: var(--serif); margin: 0 0 8px; color: var(--indigo); letter-spacing: .08em; }
.guide ul { margin: 0; padding-left: 1.1em; color: var(--ink-soft); }
.guide li { margin: 5px 0; }

/* ---------- 64 gua grid ---------- */
.gua-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px,1fr)); gap: 12px; }
.gua-cell {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 8px 12px; border-radius: var(--radius-s);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); transition: transform .15s, box-shadow .15s, border-color .15s;
}
.gua-cell:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--seal); text-decoration: none; }
.gua-cell .num { font-size: .68rem; color: var(--ink-faint); letter-spacing: .1em; }
.gua-cell .g { font-family: var(--serif); font-size: 2.1rem; line-height: 1; color: var(--seal); }
.gua-cell .nm { font-family: var(--serif); font-size: 1.05rem; letter-spacing: .12em; }

.wings { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 14px; }
.wing-cell { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; }
.wing-cell .t { font-family: var(--serif); font-size: 1.15rem; letter-spacing: .1em; }
.wing-cell .d { color: var(--ink-faint); font-size: .85rem; }

/* ---------- gua page ---------- */
.crumb { color: var(--ink-faint); font-size: .85rem; padding: 18px 0 0; }
.crumb a { color: var(--ink-soft); }

.gua-head { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; padding: 22px 0 10px; }
.gua-glyph { font-family: var(--serif); font-size: clamp(80px,16vw,150px); line-height: 1; color: var(--seal);
  text-align: center; padding: 10px 22px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); }
.gua-title h1 { font-family: var(--serif); font-size: 2.6rem; margin: 0; letter-spacing: .18em; }
.gua-title .meta { color: var(--ink-soft); margin-top: 6px; letter-spacing: .06em; }
.gua-title .meta b { color: var(--seal); }

.layout { display: grid; grid-template-columns: minmax(0,1fr) 312px; gap: 30px; align-items: start; padding: 10px 0 60px; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.block { margin: 0 0 22px; }
.block > .bk-h { font-family: var(--serif); font-size: 1.15rem; letter-spacing: .1em; color: var(--indigo);
  margin: 0 0 8px; padding-left: 12px; border-left: 4px solid var(--seal); }
.classical { font-family: var(--serif); font-size: 1.32rem; line-height: 2.0; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 22px; box-shadow: var(--shadow); }
.classical .gua-ci { font-size: 1.5rem; color: var(--seal); }

/* yao rows */
.yao { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; }
.yao-row { display: grid; grid-template-columns: 64px 1fr; gap: 0; border-top: 1px solid var(--line-soft); }
.yao-row:first-child { border-top: none; }
.yao-line { font-family: var(--serif); font-size: 1.05rem; color: var(--seal); text-align: center;
  padding: 16px 6px; background: var(--surface-2); align-self: stretch; display: flex; align-items: center; justify-content: center; }
.yao-line.yin { color: var(--indigo); }
.yao-body { padding: 14px 18px; }
.yao-ci { font-family: var(--serif); font-size: 1.22rem; line-height: 1.9; }
.yao-xiao { color: var(--ink-soft); font-size: .98rem; margin-top: 3px; }
.yao-xiao::before { content: "〈象〉 "; color: var(--ink-faint); font-size: .82rem; }

/* Module E baihua */
.zhang__baihua {
  margin-top: 10px; padding: 12px 14px; background: var(--indigo-soft);
  border-left: 3px solid var(--indigo); border-radius: var(--radius-s);
  font-size: .98rem; line-height: 1.85; color: var(--ink);
}
.zhang__baihua-label, .zhang__interp-label {
  display: inline-block; font-size: .72rem; letter-spacing: .14em; font-weight: 700;
  padding: 1px 8px; border-radius: 999px; margin-right: 8px; vertical-align: 1px;
}
.zhang__baihua-label { background: var(--seal); color: #fff; }
.zhang__interp-label { background: var(--jade); color: #fff; }
.zhang__interp { display: block; margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--line); }
.zhang__interp-text { color: var(--ink-soft); }

/* RHS panel (Module D) */
.rhs { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); }
.panel__title { font-family: var(--serif); color: var(--seal); letter-spacing: .12em; margin: 0 0 10px;
  font-size: 1.02rem; border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.rel-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; text-align: center; }
.rel { display: block; padding: 10px 4px; border-radius: var(--radius-s); background: var(--surface-2);
  border: 1px solid var(--line-soft); color: var(--ink); }
.rel:hover { border-color: var(--seal); text-decoration: none; transform: translateY(-2px); transition: .15s; }
.rel .rg { font-family: var(--serif); font-size: 1.6rem; color: var(--seal); display: block; line-height: 1.1; }
.rel .rl { font-size: .72rem; color: var(--ink-faint); letter-spacing: .1em; }
.rel .rn { font-family: var(--serif); font-size: .95rem; }
.panel ul { margin: 0; padding-left: 1.1em; color: var(--ink-soft); font-size: .92rem; }
.panel li { margin: 4px 0; }
.panel a { color: var(--indigo); }

/* ---------- annotations (Module A) ---------- */
.term, .q-famous { border-bottom: 1px dotted var(--seal); cursor: help; color: inherit; position: relative; }
.q-famous { border-bottom-style: solid; color: var(--seal); }
.charlink { color: var(--gold); font-weight: 600; text-decoration: none;
  border-bottom: 1px solid oklch(0.74 0.10 85 / 0.5); }
.charlink:hover { color: oklch(0.64 0.12 85); }

#anno-tip {
  position: fixed; z-index: 90; max-width: 320px; pointer-events: none;
  background: oklch(0.27 0.02 60); color: oklch(0.97 0.01 95);
  border-radius: 10px; padding: 11px 14px; font-size: .9rem; line-height: 1.7;
  box-shadow: 0 10px 30px oklch(0.2 0.02 60 / 0.3); opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s;
}
#anno-tip.show { opacity: 1; transform: translateY(0); }
#anno-tip b { color: var(--gold); }

/* ---------- people ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filters button { font-family: var(--sans); font-size: .85rem; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); cursor: pointer; }
.filters button.active { background: var(--seal); color: #fff; border-color: var(--seal); }

.plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px,1fr)); gap: 16px; }
.plcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); color: var(--ink); transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 6px; }
.plcard:hover { transform: translateY(-3px); text-decoration: none; border-color: var(--seal); }
.plcard__name { font-family: var(--serif); font-size: 1.4rem; color: var(--seal); letter-spacing: .1em; }
.plcard__meta { font-size: .82rem; color: var(--ink-faint); }
.plcard__title { font-size: .92rem; color: var(--indigo); }
.plcard__facts { margin: 4px 0 0; padding-left: 1.1em; color: var(--ink-soft); font-size: .88rem; }
.plcard__goto { margin-top: auto; font-size: .82rem; color: var(--seal); }

.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 28px; margin: 0 0 26px; scroll-margin-top: 80px;
  border-top: 4px solid var(--seal); }
.pcard--tier-S { border-top-color: var(--seal); }
.pcard--tier-A { border-top-color: var(--indigo); }
.pcard--tier-B { border-top-color: var(--jade); }
.pcard__head { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 14px; }
.pcard__name { font-family: var(--serif); font-size: 2rem; color: var(--seal); letter-spacing: .12em; }
.pcard__meta { margin: 6px 0; color: var(--ink-faint); font-size: .88rem; }
.pcard__role { color: var(--indigo); font-size: 1rem; }
.pcard__summary { color: var(--ink); font-size: 1.02rem; line-height: 1.9; }
.pcard__facts { margin: 12px 0; padding-left: 1.2em; color: var(--ink-soft); }
.pcard__highlight { background: var(--seal-soft); border-left: 3px solid var(--seal); border-radius: var(--radius-s);
  padding: 10px 14px; margin: 14px 0; font-size: .95rem; }
.pcard__highlight-tag { font-size: .7rem; letter-spacing: .14em; color: var(--seal); font-weight: 700; margin-right: 8px; }
.pbio__sec { margin: 16px 0; }
.pbio__h { font-family: var(--serif); color: var(--indigo); font-size: 1.1rem; letter-spacing: .08em; margin: 0 0 6px; }
.pbio__p { margin: 4px 0; color: var(--ink); }
.pbio__quotes { margin: 18px 0; padding: 16px 18px; background: var(--surface-2); border-radius: var(--radius-s); }
.pbio__quotes-h { font-family: var(--serif); color: var(--seal); letter-spacing: .1em; margin: 0 0 10px; }
.pbio__quote { margin: 0 0 12px; padding-left: 14px; border-left: 3px solid var(--gold); }
.pbio__quote-text { font-family: var(--serif); font-size: 1.08rem; color: var(--ink); }
.pbio__quote-anno { color: var(--ink-soft); font-size: .9rem; margin: 2px 0; }
.pbio__quote-src { color: var(--ink-faint); font-size: .82rem; font-style: normal; }
.pbio__ref { background: oklch(0.96 0.02 95); border: 1px dashed var(--line); border-radius: var(--radius-s); padding: 10px 14px; margin-top: 14px; font-size: .9rem; color: var(--ink-soft); }
.pbio__ref-tag { font-size: .7rem; letter-spacing: .14em; color: var(--indigo); font-weight: 700; margin-right: 8px; }

/* ---------- zhuan page ---------- */
.zhuan-chapter { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 26px; margin-bottom: 18px; }
.zhuan-chapter h3 { font-family: var(--serif); color: var(--seal); letter-spacing: .1em; margin: 0 0 10px; font-size: 1.25rem; }
.zhuan-text { font-family: var(--serif); font-size: 1.18rem; line-height: 2.0; color: var(--ink); }
.zhuan-text p { margin: 0 0 12px; }
.xref { color: var(--indigo); border-bottom: 1px solid oklch(0.52 0.11 255 / 0.4); cursor: pointer; }

/* ---------- themes ---------- */
.theme-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; }
.theme-card { padding: 20px 22px; color: var(--ink); display: flex; flex-direction: column; gap: 6px; }
.theme-card:hover { border-color: var(--seal); text-decoration: none; transform: translateY(-3px); transition: .15s; }
.theme-card .cat { font-size: .72rem; letter-spacing: .14em; color: var(--seal); }
.theme-card h3 { font-family: var(--serif); margin: 0; font-size: 1.25rem; letter-spacing: .06em; }
.theme-card p { color: var(--ink-soft); font-size: .92rem; margin: 0; }
.theme-body { max-width: 820px; }
.theme-body h3 { font-family: var(--serif); color: var(--indigo); letter-spacing: .08em; margin: 28px 0 8px; }
.theme-body p { color: var(--ink); margin: 0 0 14px; }
.theme-box { background: var(--seal-soft); border-left: 3px solid var(--seal); border-radius: var(--radius-s); padding: 12px 16px; margin: 16px 0; }

.footer { border-top: 1px solid var(--line); color: var(--ink-faint); font-size: .82rem; padding: 28px 0 50px; text-align: center; }
.footer a { color: var(--ink-soft); }

/* ---------- reading-aid toggles ---------- */
.anno-ctrl {
  position: sticky; top: 58px; z-index: 35;
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 7px 22px;
  background: oklch(1 0 0 / 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.anno-ctrl__btn {
  font: 600 13px/1 var(--sans);
  padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--gold); background: var(--surface);
  color: oklch(0.5 0.1 85); cursor: pointer; transition: .15s;
}
.anno-ctrl__btn.is-on { background: var(--gold); color: #fff; }
.anno-ctrl__btn:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

/* hide underline + tooltip when 字詞註 off */
body.no-anno .term, body.no-anno .q-famous { border-bottom: none; cursor: auto; }
body.no-anno #anno-tip { display: none !important; }
/* hide 白話 when off */
body.no-baihua .zhang__baihua,
body.no-baihua .zpar > .zhang__baihua { display: none; }

/* RHS collapse */
.rhs__toggle {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--gold); background: var(--gold); color: #fff;
  font-size: 18px; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 16px oklch(0.3 0.05 60 / 0.25);
}
.rhs__toggle:hover { background: oklch(0.64 0.12 85); }
body[data-rhs="collapsed"] .rhs { display: none; }

/* ---------- 十翼 per-paragraph 白話 ---------- */
.zpar { margin: 0 0 16px; }
.zpar > p { margin: 0; }
.zpar .zhang__baihua { margin-top: 8px; }
