/* Qike · a woodblock-book reading room: rice paper, ink, one cinnabar seal. */
@font-face { font-family: "Cormorant Garamond"; src: url(/fonts/cormorant-garamond-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url(/fonts/cormorant-garamond-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url(/fonts/cormorant-garamond-latin-500-italic.woff2) format("woff2"); font-weight: 500; font-style: italic; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url(/fonts/eb-garamond-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url(/fonts/eb-garamond-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url(/fonts/eb-garamond-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root {
  color-scheme: light;
  --paper: #f5efe1;
  --paper-deep: #ebe2cc;
  --paper-light: #faf6ec;
  --ink: #1f2a26;
  --ink-soft: #3d4842;
  --muted: #776f60;
  --line: #d8ccb2;
  --line-soft: #e6dcc6;
  --cinnabar: #a3301c;
  --cinnabar-deep: #842414;
  --gilt: #a48650;
  --accent: var(--cinnabar);
  --display: "Cormorant Garamond", "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --text: "EB Garamond", "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  font: 18px/1.72 var(--text);
  /* Lining figures: numbers sit at capital height instead of rising and dipping like lowercase. */
  font-variant-numeric: lining-nums;
  color: var(--ink);
  background: var(--paper) url(/paper.svg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
:root:lang(zh-Hans) { font-size: 17px; line-height: 1.85; letter-spacing: 0.02em; }
* { box-sizing: border-box; }
::selection { background: rgba(163, 48, 28, 0.18); }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
a {
  color: inherit;
  text-decoration-color: rgba(31, 42, 38, 0.35);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color 0.2s, text-decoration-color 0.2s;
}
a:hover { color: var(--cinnabar); text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--cinnabar);
  outline-offset: 4px;
}
button { font: inherit; cursor: pointer; }
button:disabled { opacity: 0.55; cursor: wait; }
[hidden] { display: none !important; }

/* ——— Frame ——— */
header {
  width: 100%;
  flex: none;
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 44px 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  position: relative;
}
header::after {
  /* Double rule, as on the frame of a printed page. */
  content: "";
  position: absolute;
  left: 44px;
  right: 44px;
  bottom: 0;
  height: 4px;
  border-top: 1px solid var(--ink-soft);
  border-bottom: 1px solid var(--line);
  opacity: 0.55;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  justify-self: start;
}
.seal {
  display: inline-grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 2px;
  background: var(--cinnabar);
  color: #f8ecdf;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1;
  letter-spacing: 0;
  writing-mode: vertical-rl;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px var(--cinnabar), inset 0 0 0 3px rgba(248, 236, 223, 0.7);
  transform: rotate(-3deg);
}
.brand-name {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.brand:hover .seal { background: var(--cinnabar-deep); }
.brand:hover { color: var(--ink); }
header .site-nav {
  display: flex;
  align-items: center;
  gap: 34px;
}
header nav a {
  text-decoration: none;
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.site-nav a {
  position: relative;
  padding: 6px 0;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 0;
  height: 1px;
  background: var(--cinnabar);
  transition: width 0.3s ease, left 0.3s ease;
}
.site-nav a:hover::after, .site-nav a[aria-current="page"]::after { width: 100%; left: 0; }
.site-nav a[aria-current="page"] { color: var(--cinnabar); }
header .language {
  justify-self: end;
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 4px 14px;
  border-radius: 2px;
  white-space: nowrap;
  background: rgba(250, 246, 236, 0.6);
  transition: border-color 0.2s, color 0.2s;
}
header .language:hover { border-color: var(--cinnabar); }

main {
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  max-width: 1160px;
  margin: 0 auto;
  padding: 40px 44px 90px;
  scrollbar-color: var(--line) transparent;
}

footer {
  width: 100%;
  flex: none;
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 44px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px 40px;
  font-size: 0.86rem;
  position: relative;
}
footer::before {
  content: "";
  position: absolute;
  left: 44px;
  right: 44px;
  top: 0;
  border-top: 1px solid var(--line);
}
footer strong { font-family: var(--display); font-weight: 600; letter-spacing: 0.08em; }
footer p { margin: 0; color: var(--muted); font-style: italic; }
footer nav {
  display: flex;
  justify-content: flex-end;
  gap: 6px 24px;
  flex-wrap: wrap;
}
footer nav a { text-decoration: none; color: var(--ink-soft); }
.skip { position: absolute; top: -100px; }
.skip:focus { top: 0; background: var(--paper-light); z-index: 5; padding: 6px 12px; }

/* ——— Type ——— */
h1, h2, h3 {
  font-family: var(--display);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.005em;
  color: var(--ink);
}
h1 { font-size: clamp(2.6rem, 5.4vw, 4.6rem); margin: 18px 0 26px; }
h2 { font-size: 2.15rem; margin: 10px 0 22px; }
h3 { font-size: 1.45rem; font-weight: 600; }
:lang(zh-Hans) h1, :lang(zh-Hans) h2, :lang(zh-Hans) h3 { font-weight: 600; letter-spacing: 0.04em; line-height: 1.3; }
p { margin: 0 0 20px; }
.eyebrow, .h1-kicker {
  font-family: var(--display);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cinnabar);
  line-height: 1.6;
}
.eyebrow::before, .h1-kicker::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 12px 2px 0;
  background: var(--cinnabar);
  transform: rotate(45deg);
}
.h1-kicker { display: block; margin-bottom: 0.7rem; }
.lede { font-size: 1.2rem; max-width: 680px; color: var(--ink-soft); }
.muted { font-size: 0.86rem; color: var(--muted); margin-top: 20px; font-style: italic; }
:lang(zh-Hans) .muted, :lang(zh-Hans) footer p { font-style: normal; }
.number {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--cinnabar);
  font-variant-numeric: lining-nums tabular-nums;
}

/* ——— Buttons ——— */
.button {
  display: inline-block;
  background: var(--ink);
  color: #f6efe0;
  text-decoration: none;
  padding: 11px 28px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px rgba(31, 42, 38, 0.45);
  transition: background 0.25s, box-shadow 0.25s, color 0.25s;
}
.button:hover {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: #fbf3e6;
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--cinnabar);
}
.small { padding: 8px 16px; }
.actions { display: flex; gap: 30px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.actions a:not(.button) { font-style: italic; font-size: 1.08rem; }

/* ——— Home ——— */
/* A book's title page: centred title framed by a vertical couplet, the steps set below. */
.hero { padding: 28px 0 72px; }
.hero-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
}
.hero-main { text-align: center; }
.hero-main .lede { margin-inline: auto; max-width: 600px; }
.hero-main .actions { justify-content: center; margin-top: 30px; }
.hero h1 { font-size: clamp(2.6rem, 5vw, 4.4rem); margin: 22px 0 28px; }
.hero h1::after {
  /* Hairline rule with a central diamond, like a printer's ornament. */
  content: "";
  display: block;
  width: 180px;
  height: 9px;
  margin: 30px auto 0;
  background: url("/ornament.svg") center / 180px 9px no-repeat;
}
.hero-main h1, .hero-main .lede { text-wrap: balance; }
.couplet {
  writing-mode: vertical-rl;
  margin: 0;
  padding: 22px 10px;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 1.35rem;
  letter-spacing: 0.6em;
  color: var(--cinnabar);
  border-inline: 1px solid var(--line);
  opacity: 0.85;
  /* Flank the headline rather than the middle of the taller hero. */
  align-self: start;
  margin-top: 24px;
}
.couplet:lang(en) { font-family: var(--display); font-size: 0.92rem; font-weight: 600; letter-spacing: 0.32em; text-transform: uppercase; padding: 18px 8px; }
.cast-guide {
  position: relative;
  background: var(--paper-light);
  margin-top: 24px;
  padding: 32px 34px 24px;
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--paper-deep), 0 24px 40px -30px rgba(60, 44, 20, 0.45);
}
.cast-guide::before {
  /* Inner hairline border, like a printed cartouche. */
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid var(--line-soft);
  pointer-events: none;
}
.cast-guide > .eyebrow { margin: 0; }
.cast-guide ol { list-style: none; padding: 0; margin: 22px 0 20px; counter-reset: step; display: grid; gap: 18px; }
.cast-guide li { position: relative; padding: 0 0 0 48px; counter-increment: step; }
/* On the homepage the steps sit across the page, just above the cast button. */
:is(.hero, .reading-stage) .cast-guide { margin: 36px 0 34px; text-align: left; }
:is(.hero, .reading-stage) .cast-guide > .eyebrow, :is(.hero, .reading-stage) .artwork-note { text-align: center; }
:is(.hero, .reading-stage) .cast-guide ol { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
:is(.hero, .reading-stage) .cast-guide li { padding: 0 20px 0 64px; }
:is(.hero, .reading-stage) .cast-guide li + li { border-left: 1px solid var(--line-soft); }
:is(.hero, .reading-stage) .cast-guide li::before { left: 20px; }
:is(.hero, .reading-stage) .cast-guide li:first-child { padding-left: 44px; }
:is(.hero, .reading-stage) .cast-guide li:first-child::before { left: 0; }
.cast-guide li::before {
  content: counter(step, cjk-ideographic);
  position: absolute;
  left: 0;
  top: 2px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--cinnabar);
  color: var(--cinnabar);
  font-family: "Songti SC", "STSong", serif;
  font-size: 0.9rem;
  border-radius: 50%;
}
.cast-guide strong { display: block; font-family: var(--display); font-weight: 600; font-size: 1.28rem; line-height: 1.3; padding-top: 4px; }
.cast-guide li p { font-size: 0.95rem; line-height: 1.7; color: var(--ink-soft); margin: 8px 0 0; }
.artwork-note {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}
section { margin-bottom: 56px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin: 32px 0; }
.card {
  position: relative;
  display: block;
  text-decoration: none;
  padding: 30px 28px 26px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s;
}
.card:hover {
  color: var(--ink);
  transform: translateY(-3px);
  border-color: var(--gilt);
  box-shadow: 0 22px 36px -28px rgba(60, 44, 20, 0.55);
}
.card .mini { position: absolute; top: 28px; right: 26px; }
.card h3 { margin: 18px 0 14px; }
.card p {
  font-size: 0.95rem;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.card > span:last-child { font-style: italic; color: var(--cinnabar); }
.callout {
  position: relative;
  text-align: center;
  padding: 44px 24px 38px;
  margin: 56px auto 0;
  max-width: 760px;
  border-block: 1px solid var(--line);
}
.callout::before {
  content: "◇";
  position: absolute;
  top: -0.78em;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 14px;
  background: var(--paper);
  color: var(--cinnabar);
}
.callout h2 { font-size: 2rem; font-style: italic; }
:lang(zh-Hans) .callout h2 { font-style: normal; }

/* ——— Six-line figures ——— */
.line { display: flex; width: 100%; height: 11px; margin: 10px 0; gap: 18px; }
.line i { flex: 1; background: var(--ink); border-radius: 1.5px; }
.line.yang { gap: 0; }
/* Square the inner ends so the two halves of a solid line meet without a notch. */
.line.yang i:first-child { border-radius: 1.5px 0 0 1.5px; }
.line.yang i:last-child { border-radius: 0 1.5px 1.5px 0; }
.mini { display: inline-grid; gap: 3px; width: 26px; flex-shrink: 0; }
.mini i { display: flex; height: 3px; gap: 5px; }
.mini i::before, .mini i::after { content: ""; flex: 1; background: var(--ink-soft); border-radius: 1px; }
.mini i.yang { gap: 0; }

/* ——— Library ——— */
.breadcrumbs {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 30px;
  font-style: italic;
}
:lang(zh-Hans) .breadcrumbs { font-style: normal; }
.breadcrumbs a { margin-right: 5px; text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.library {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 44px 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.library a {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  padding: 20px 18px;
  min-width: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(250, 246, 236, 0.55);
  transition: background 0.25s, color 0.25s;
}
.library a > span:nth-child(2) { flex: 1; min-width: 0; line-height: 1.35; }
.library a:hover { background: var(--paper-light); color: var(--ink); }
.library a:hover .mini i::before, .library a:hover .mini i::after { background: var(--cinnabar); }
.library .number { min-width: 1.7em; }
.library strong { font-family: var(--display); font-weight: 600; font-size: 1.16rem; }
.library small { font-size: 0.82rem; color: var(--muted); letter-spacing: 0.02em; }
:lang(zh-Hans) .library strong { font-family: "Songti SC", "STSong", "Noto Serif SC", serif; font-size: 1.08rem; }

/* ——— Hexagram page ——— */
.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.35fr);
  align-items: center;
  gap: clamp(28px, 4.5vw, 64px);
  margin: 8px 0 64px;
}
/* Title slip beside the painting, like the label on a bound volume. */
.detail-hero { align-items: stretch; }
.detail-heading {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
  padding: 44px 32px 34px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--paper-deep), 0 24px 40px -30px rgba(60, 44, 20, 0.45);
}
.detail-heading::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid var(--line-soft);
  pointer-events: none;
}
/* Two rows, one per trigram: position on the left, its three lines centred, its name on the right. */
.hexagram-figure {
  --gua-width: 84px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--gua-width) minmax(0, 1fr);
  column-gap: 20px;
  /* Only slightly wider than the space between lines, so the six still read as one hexagram. */
  row-gap: 6px;
  align-items: center;
  width: 100%;
  margin-bottom: 28px;
}
.hexagram-figure::after {
  /* Dashed rule across the lines only, between the upper and lower trigram. */
  content: "";
  position: absolute;
  left: calc(50% - var(--gua-width) / 2);
  width: var(--gua-width);
  top: 50%;
  border-top: 1px dashed var(--muted);
  opacity: 0.6;
}
.trigram-row { display: contents; }
.hexagram-figure .line { height: 7px; margin: 6px 0; gap: 12px; }
.hexagram-figure .line.yang { gap: 0; }
.trigram-position {
  text-align: right;
  font-family: var(--display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.trigram-name { text-align: left; font-size: 0.98rem; color: var(--ink-soft); }
:lang(zh-Hans) .trigram-position { font-size: 0.86rem; letter-spacing: 0.2em; }
/* Break only words that cannot fit on a line of their own, and hyphenate them. */
.detail-heading h1 { font-size: clamp(2.2rem, 3.4vw, 3.2rem); overflow-wrap: break-word; hyphens: auto; margin: 0; max-width: 100%; }
.detail-heading .h1-kicker { font-size: 0.78rem; margin-bottom: 14px; }
.h1-alt {
  display: block;
  margin-top: 14px;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.4em;
  color: var(--cinnabar);
}
.h1-alt:lang(en) { font-family: var(--display); font-style: italic; letter-spacing: 0.02em; font-size: 1.35rem; color: var(--muted); }
.scene { margin: 1.5rem 0; max-width: 55rem; }
.detail-cover { margin: 0; max-width: none; align-self: center; }
.detail-cover a {
  display: block;
  padding: 14px;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.6) inset, 0 30px 50px -36px rgba(60, 44, 20, 0.6);
  position: relative;
}
.detail-cover a::after {
  /* Mounting silk edge around the painting. */
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(164, 134, 80, 0.45);
  pointer-events: none;
}
.scene img { display: block; width: 100%; height: auto; border: 1px solid rgba(60, 44, 20, 0.25); filter: sepia(0.08) contrast(1.02); }
.detail-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: clamp(34px, 5vw, 72px);
  align-items: start;
}
.detail-article { min-width: 0; }
.contents {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 18px 6px 0;
  border-right: 1px solid var(--line);
  font-size: 0.9rem;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.contents a {
  display: block;
  padding: 6px 8px 6px 18px;
  text-decoration: none;
  line-height: 1.35;
  color: var(--ink-soft);
  position: relative;
}
.contents a::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border: 1px solid var(--line);
  transform: rotate(45deg);
  transition: background 0.2s, border-color 0.2s;
}
.contents a[aria-current="location"] { color: var(--cinnabar); font-weight: 600; }
.contents a[aria-current="location"]::before { background: var(--cinnabar); border-color: var(--cinnabar); }
article { max-width: 760px; }
article section { scroll-margin-top: 20px; }
.detail-article section { scroll-margin-top: 32px; margin-bottom: 64px; }
.detail-article h2, .interpretation h2 {
  font-size: clamp(1.6rem, 3vw, 2.15rem);
  overflow-wrap: anywhere;
  padding-bottom: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.detail-article h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 54px;
  height: 3px;
  background: var(--cinnabar);
}
.source-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.9; margin-bottom: 1.5rem; }
.line-statements { list-style: none; padding: 0; margin: 0; counter-reset: yao; }
.line-statements li {
  position: relative;
  padding: 12px 0 12px 46px;
  border-bottom: 1px dotted var(--line);
  overflow-wrap: anywhere;
  counter-increment: yao;
}
.line-statements li::before {
  content: counter(yao);
  position: absolute;
  left: 0;
  top: 14px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--cinnabar);
  border: 1px solid rgba(163, 48, 28, 0.5);
  border-radius: 50%;
}
.notice {
  border-left: 2px solid var(--cinnabar);
  padding: 12px 20px;
  background: rgba(235, 226, 204, 0.6);
  font-size: 0.94rem;
  font-style: italic;
}
:lang(zh-Hans) .notice { font-style: normal; }
.picture-reading .lede { color: var(--ink); font-size: 1.24rem; line-height: 1.6; }
.picture-reading .lede::first-letter {
  float: left;
  font-family: var(--display);
  font-size: 3.6em;
  line-height: 0.82;
  padding: 0.06em 0.1em 0 0;
  color: var(--cinnabar);
}
:lang(zh-Hans) .picture-reading .lede::first-letter { font-size: 2.6em; line-height: 0.95; font-family: "Songti SC", "STSong", serif; }
.situations {
  margin: 1.8rem 0 2rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.situations div {
  padding: 18px 18px 16px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-top: 2px solid var(--cinnabar);
}
.situations dt {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cinnabar);
  margin: 0 0 6px;
}
.situations dd { margin: 0; color: var(--ink-soft); font-size: 0.96rem; line-height: 1.6; }
dt { font-weight: 600; margin-top: 24px; }
dd { margin: 6px 0 0; color: var(--ink-soft); }
.human-way, .human-way-en { line-height: 1.85; overflow-wrap: anywhere; }
.human-way-block { padding: 0 0 0 22px; margin: 0 0 22px; border-left: 1px solid var(--line); }
.human-way-block p { margin: 0 0 12px; white-space: pre-wrap; }
.human-way-en .human-way-block p:first-of-type { font-style: italic; color: var(--ink-soft); }
.human-way-block strong {
  display: block;
  margin: 0 0 8px -23px;
  padding-left: 20px;
  border-left: 3px solid var(--cinnabar);
  font-family: var(--display);
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.original-text {
  margin: 1.5rem 0 2rem;
  border: 1px solid var(--line);
  background: rgba(250, 246, 236, 0.6);
  padding: 0.7rem 1.1rem;
}
.original-text summary { cursor: pointer; color: var(--cinnabar); font-family: var(--display); font-weight: 600; font-size: 1.08rem; letter-spacing: 0.04em; }
.original-text[open] summary { margin-bottom: 1rem; }
.trigrams, .related { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.trigrams { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.trigrams li {
  padding: 16px 18px;
  border: 1px solid var(--line);
  background: var(--paper-light);
  overflow-wrap: anywhere;
}
.trigrams strong { display: block; font-family: var(--display); font-size: 0.98rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cinnabar); font-weight: 600; }
.trigram-symbol { font-size: 1.6rem; vertical-align: -0.15em; margin: 0 0.35rem 0 0; color: var(--ink); }
.related li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 1.5rem;
  padding: 0.7rem 0;
  border-bottom: 1px dotted var(--line);
  overflow-wrap: anywhere;
}
.related span { color: var(--muted); font-size: 0.92rem; font-style: italic; }
.related a { font-family: var(--display); font-weight: 600; font-size: 1.1rem; text-decoration: none; }
.reading-pagination {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  padding: 1.4rem 0;
  margin: 2.5rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 600;
}
.reading-pagination a { max-width: 100%; overflow-wrap: anywhere; text-decoration: none; }
.source-note { color: var(--muted); font-size: 0.88rem; }

/* ——— Casting ——— */
/* The steps come first, then the casting panel directly beneath them. */
.reading-stage { margin-bottom: 56px; }
.reading-stage .cast-guide { margin: 24px 0 28px; }
.reading-stage .casting { max-width: none; text-align: center; }
.reading-stage .cast-lines { width: min(100%, 420px); margin-inline: auto; }
.reading-stage .casting .button { margin: 12px 6px 0; }
.casting {
  position: relative;
  max-width: 640px;
  margin: 28px 0 0;
  padding: 40px 44px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  box-shadow: 0 24px 40px -32px rgba(60, 44, 20, 0.5);
}
.casting::before { content: ""; position: absolute; inset: 7px; border: 1px solid var(--line-soft); pointer-events: none; }
.cast-lines { min-height: 230px; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; }
.revealed-line, .waiting-line { display: flex; gap: 24px; align-items: center; }
.revealed-line > span, .waiting-line > span { font-size: 0.88rem; width: 76px; }
.revealed-line .line, .waiting-line .line { flex: 1; max-width: 260px; }
.revealed-line { animation: ink-in 0.6s ease both; }
.waiting-line { color: var(--muted); }
.waiting-line .line i { background: none; border-top: 1px dashed var(--line); margin-top: 5px; }
.casting .button { margin: 12px 12px 0 0; }
/* Once a result is ready, opening it is the main action; casting again steps back. */
.casting:has(#cast-result:not([hidden])) #cast-button {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  box-shadow: none;
}
.casting:has(#cast-result:not([hidden])) #cast-button:hover { border-color: var(--cinnabar); color: var(--cinnabar); }
#cast-status { margin-top: 20px; font-size: 1rem; font-style: italic; }
:lang(zh-Hans) #cast-status { font-style: normal; }
.placeholder { border: 1px dashed var(--line); padding: 45px 30px; text-align: center; margin: 25px 0; }

/* ——— Motion ——— */
@keyframes ink-in { from { opacity: 0; transform: translateY(6px); filter: blur(1.5px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  main > *, .hero > * { animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  main > :nth-child(2), .hero > :nth-child(2) { animation-delay: 0.08s; }
  main > :nth-child(3), .hero > :nth-child(3) { animation-delay: 0.16s; }
  main > :nth-child(n + 4) { animation-delay: 0.24s; }
  .seal { animation: stamp 0.7s 0.15s cubic-bezier(0.3, 1.4, 0.5, 1) both; }
}
@keyframes stamp { from { opacity: 0; transform: rotate(-3deg) scale(1.35); } to { opacity: 1; transform: rotate(-3deg) scale(1); } }
@media (prefers-reduced-motion: reduce) { .revealed-line { animation: none; } * { transition: none !important; } }

/* ——— Responsive ——— */
@media (max-width: 1080px) {
  .library { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero-head { grid-template-columns: minmax(0, 1fr); }
  .couplet { display: none; }
  :is(.hero, .reading-stage) .cast-guide ol { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  :is(.hero, .reading-stage) .cast-guide li, :is(.hero, .reading-stage) .cast-guide li:first-child { padding: 0 0 0 48px; }
  :is(.hero, .reading-stage) .cast-guide li + li { border-left: 0; }
  :is(.hero, .reading-stage) .cast-guide li::before { left: 0; }
}
@media (max-width: 960px) {
  header { grid-template-columns: 1fr auto; padding-bottom: 10px; }
  header .site-nav {
    order: 3;
    grid-column: 1 / -1;
    justify-content: space-between;
    gap: 6px 18px;
    flex-wrap: wrap;
    border-top: 1px solid var(--line-soft);
    padding-top: 4px;
  }
  header nav a { font-size: 0.98rem; }
  .situations { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 900px) {
  .detail-hero, .detail-layout { grid-template-columns: minmax(0, 1fr); }
  .detail-hero { gap: 20px; margin-bottom: 40px; }
  .detail-layout { gap: 26px; }
  .contents {
    top: 0;
    z-index: 4;
    max-height: 96px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    background: var(--paper-light);
    box-shadow: 0 12px 16px -16px rgba(60, 44, 20, 0.6);
  }
  .detail-article section { scroll-margin-top: 150px; }
}
@media (max-width: 760px) {
  :root { font-size: 17px; }
  header { padding: 12px 18px 8px; gap: 8px; }
  header::after { left: 18px; right: 18px; }
  .seal { width: 2.05rem; height: 2.05rem; font-size: 0.74rem; }
  .brand-name { display: none; }
  header nav a { font-size: 0.95rem; letter-spacing: 0.04em; }
  header .language { padding: 2px 12px; }
  main { padding: 26px 20px 56px; }
  .hero { padding-top: 12px; }
  .hero h1 { font-size: clamp(2.2rem, 10vw, 3rem); }
  .cards { grid-template-columns: 1fr; gap: 14px; }
  .card { padding: 24px; }
  .library { grid-template-columns: minmax(0, 1fr); }
  .library a { padding: 14px 16px; }
  .detail-heading { padding: 32px 20px 26px; }
  .hexagram-figure { --gua-width: 72px; column-gap: 14px; margin-bottom: 22px; }
  .detail-cover a { padding: 8px; }
  .detail-cover a::after { inset: 3px; }
  .trigrams { grid-template-columns: 1fr; }
  .cast-guide { padding: 28px 24px 22px; }
  .casting { padding: 22px; }
  .button { padding: 11px 20px; }
  .small { font-size: 0.85rem; padding: 7px 12px; }
  footer { padding: 7px 18px; grid-template-columns: 1fr; gap: 2px; }
  footer::before { left: 18px; right: 18px; }
  /* The header already carries the brand; dropping it keeps the footer links within the fixed frame. */
  footer > div { display: none; }
  footer nav { justify-content: flex-start; gap: 2px 14px; font-size: 0.8rem; }
}
