/*
 * Gong's look: ink on rice paper, few words, no boxes, one red accent. Yang (paper) is the default,
 * Yin (ink) is picked with the taijitu in the header and remembered. Fonts are Gong's trimmed web
 * fonts (SIL OFL); Chinese characters outside the trimmed set fall back to the system's fonts.
 */
@font-face { font-family: "Yuji"; src: url("fonts/YujiSyuku_400Regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "MaShan"; src: url("fonts/MaShanZheng_400Regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Noto"; src: url("fonts/NotoSans_400Regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "NotoMedium"; src: url("fonts/NotoSans_500Medium.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #f5f1ea; --ink: #161412; --sub: #6a635b; --line: #dad3c8;
  --red: #b8162c; --red-text: #a3142a; --red-soft: rgba(184, 22, 44, 0.08);
  --title: "Yuji", serif; --sign: "MaShan", "Yuji", serif;
  --body: "Noto", system-ui, sans-serif; --medium: "NotoMedium", "Noto", system-ui, sans-serif;
  --relief-hi: rgba(255, 255, 255, 0.95); --relief-shade: rgba(60, 45, 25, 0.55);
  --paper: url("art/paper-light.png");
  color-scheme: light;
}
:root[data-theme="yin"] {
  --bg: #121110; --ink: #eee9e1; --sub: #a59e95; --line: #34302c;
  --red: #e8574b; --red-text: #ee7b70; --red-soft: rgba(232, 87, 75, 0.14);
  --relief-hi: rgba(255, 236, 210, 0.22); --relief-shade: rgba(0, 0, 0, 0.95);
  --paper: url("art/paper-dark.png");
  color-scheme: dark;
}

* { box-sizing: border-box; }
html {
  background-color: var(--bg);
  background-image: var(--paper);
  background-size: 512px 512px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
}
body { margin: 0; position: relative; min-height: 100vh; }
.relief-defs { position: absolute; }

/* The day's art lies on the top of the paper and scrolls away with it. */
.day-art { position: absolute; inset: 0 0 auto 0; height: 100vh; overflow: hidden; pointer-events: none; z-index: -1; }
.day-art img { position: absolute; top: -2vh; right: -6vw; width: min(640px, 90vw); opacity: 0.14; }
:root[data-theme="yin"] .day-art img { width: min(320px, 70vw); top: -48px; right: -56px; opacity: 0.3; }

a { color: var(--ink); text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { color: var(--red-text); text-decoration-color: currentColor; }

.top {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  max-width: 1080px; margin: 0 auto; padding: 20px 24px 12px;
}
.wordmark { font-family: var(--title); font-size: 28px; text-decoration: none; filter: url(#press); }
.nav { display: flex; gap: 18px; flex-wrap: wrap; font-family: var(--medium); }
.nav a { text-decoration: none; color: var(--sub); filter: url(#press); }
.nav a:hover { color: var(--ink); }
.search { position: relative; margin-left: auto; }
.search input {
  width: 220px; border: 0; background: transparent; color: var(--ink);
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 var(--relief-hi);
  padding: 6px 2px; font: inherit; outline: none;
}
.search input:focus { border-bottom-color: var(--red); }
.results {
  position: absolute; right: 0; top: 40px; z-index: 5; width: 320px; max-height: 60vh; overflow: auto;
  list-style: none; margin: 0; padding: 6px 0; background-color: var(--bg); background-image: var(--paper);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.results li a { display: block; padding: 6px 14px; text-decoration: none; }
.results li a:hover, .results li a:focus { background: var(--red-soft); }
.results .k { color: var(--sub); font-size: 12px; margin-left: 6px; }
.theme-toggle { border: 0; background: transparent; padding: 4px; cursor: pointer; display: inline-grid; place-items: center; }
.theme-toggle svg { transition: transform 0.6s ease; }
.theme-toggle .taiji-yin { fill: #161412; }
.theme-toggle .taiji-yang { fill: #f5f1ea; }
.theme-toggle .taiji-rim { fill: none; stroke: var(--ink); stroke-width: 3; }
:root[data-theme="yin"] .theme-toggle svg { transform: rotate(180deg); }

main { max-width: 1080px; margin: 0 auto; padding: 8px 24px 48px; }
h1.title { font-family: var(--title); font-weight: 400; font-size: 40px; line-height: 1.2; margin: 24px 0 8px; filter: url(#press); }
h1.home { font-size: 56px; }
h2 { font-family: var(--title); font-weight: 400; font-size: 24px; margin: 36px 0 10px; filter: url(#press); }
h3 { font-family: var(--medium); font-weight: 500; font-size: 15px; margin: 18px 0 6px; color: var(--sub); }
.lead { font-size: 18px; max-width: 720px; }
.stats { font-family: var(--medium); color: var(--red-text); }
.sub, .years, .aka { color: var(--sub); }
.aka { font-size: 15px; margin-top: 0; }
.hanzi { font-family: var(--sign), "PingFang SC", "Noto Sans CJK SC", serif; color: var(--sub); font-weight: 400; }
h1 .hanzi { font-size: 0.7em; }
.note { border-left: 3px solid var(--red); padding: 4px 12px; max-width: 760px; }
.kind { font-size: 12px; color: var(--sub); border-bottom: 1px dotted var(--sub); white-space: nowrap; }
.kind-legendary, .kind-uncertain { color: var(--red-text); border-color: var(--red-text); }
.cite { font-size: 12px; color: var(--sub); text-decoration: none; }
.cols { columns: 3 260px; column-gap: 32px; padding-left: 18px; }
.cols li { break-inside: avoid; margin: 2px 0; }

/* The tree: nested lists with ink lines; a dashed line for a student, solid for a disciple. */
.tree, .tree ul { list-style: none; padding-left: 0; margin: 0; }
.tree ul { margin-left: 10px; padding-left: 18px; border-left: 1px solid var(--line); }
.tree li { position: relative; padding: 2px 0; }
.tree ul > li::before { content: ""; position: absolute; left: -18px; top: 14px; width: 14px; border-top: 1px solid var(--ink); }
.tree ul > li.link-student::before { border-top-style: dashed; }
.tree ul > li.link-legendary::before, .tree ul > li.link-uncertain::before { border-top: 1px dotted var(--red); }
.tree > li { margin-bottom: 10px; }

.items { padding-left: 18px; columns: 2 320px; column-gap: 32px; }
.items li { break-inside: avoid; }
.items .group { margin: 6px 0; }
.sources { font-size: 14px; padding-left: 22px; }
.sources li { margin: 6px 0; }
.sid { font-family: var(--medium); color: var(--sub); margin-right: 4px; }
.kinds dt { font-family: var(--medium); }
.kinds dd { margin: 0 0 8px 0; color: var(--sub); }
.in-lineage { margin-top: 12px; }
.facts li { margin: 4px 0; }
.prose { max-width: 760px; }
.prose table { border-collapse: collapse; }
.prose td, .prose th { padding: 4px 12px 4px 0; text-align: left; box-shadow: 0 1px 0 var(--relief-hi); border-bottom: 1px solid var(--line); }
.prose code { font-size: 0.9em; color: var(--sub); }

footer { max-width: 1080px; margin: 0 auto; padding: 16px 24px 40px; font-size: 14px; border-top: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--relief-hi); }

@media (max-width: 700px) {
  .top { gap: 12px; padding: 14px 16px 8px; }
  .top { position: relative; }
  .theme-toggle { position: absolute; top: 16px; right: 12px; }
  .search { margin-left: 0; width: 100%; }
  .search input { width: 100%; }
  .results { width: 100%; }
  main { padding: 4px 16px 40px; }
  h1.title { font-size: 32px; }
  h1.home { font-size: 42px; }
}
