/*
 * Design tokens. The look comes from the subject: brush-written Kaiti in ink on rice
 * paper, with indigo for readings and a cinnabar seal red used only where something
 * is marked (progress, removal). Square corners, hairline rules, almost no motion.
 */
:root {
  --paper: #f5f6f1;
  --panel: #fcfcf9;
  --wash: #e9ebe4;
  --rule: #d5d8d0;
  --ink: #1b212a;
  --ink-2: #55606d;
  --ink-3: #87909b;
  --indigo: #27488a;
  --seal: #b5332b;
  --hl: rgba(39, 72, 138, 0.17);
  --scrim: rgba(27, 33, 42, 0.28);
  --edge: 0 0 0 1px var(--rule), 4px 4px 0 rgba(27, 33, 42, 0.1);

  /* Reader typography; overwritten from settings (app/apply-prefs.js). */
  --size: 20px;
  --lh: 1.75;
  --measure: 680px;

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-body: var(--font-ui);
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", "Noto Sans Mono", monospace;
  /* The Chinese face always comes first: its unicode-range covers CJK only, so Latin
     falls through to the body font. (WebKit's system-ui carries its own CJK fallback
     and would win if it came first.) */
  --font-zh: "CNReader Kai";
  --font-read: var(--font-zh), var(--font-body);
  --font-ui-zh: "CNReader Kai", var(--font-ui);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --gutter: 20px;
  --bar: 48px;
  color-scheme: light;
}

:root[data-theme="sepia"] {
  --paper: #efe5cd;
  --panel: #f7efdb;
  --wash: #e4d9be;
  --rule: #d3c5a6;
  --ink: #36291b;
  --ink-2: #6a583f;
  --ink-3: #937f62;
  --indigo: #2f4c7c;
  --seal: #a43727;
  --hl: rgba(47, 76, 124, 0.18);
  --edge: 0 0 0 1px var(--rule), 4px 4px 0 rgba(54, 41, 27, 0.12);
}

:root[data-theme="dark"] {
  --paper: #14161a;
  --panel: #1b1e23;
  --wash: #23272d;
  --rule: #30353c;
  --ink: #dcdad2;
  --ink-2: #a0a3a3;
  --ink-3: #70757a;
  --indigo: #93b3ea;
  --seal: #e56d60;
  --hl: rgba(147, 179, 234, 0.24);
  --scrim: rgba(0, 0, 0, 0.5);
  --edge: 0 0 0 1px var(--rule), 4px 4px 0 rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

:root[data-body="serif"] {
  --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif", serif;
}
:root[data-zh="sans"] { --font-zh: "CNReader ZH Sans"; }
:root[data-zh="serif"] { --font-zh: "CNReader ZH Serif"; }

/* System CJK faces behind a CJK-only unicode-range, for the non-Kaiti choices. When
   none of the local names exist the rule is ignored and the platform default wins. */
@font-face {
  font-family: "CNReader ZH Sans";
  src: local("PingFang SC"), local("Noto Sans CJK SC"), local("Noto Sans SC"), local("Source Han Sans SC"), local("Microsoft YaHei");
  unicode-range: U+2E80-2FDF, U+3000-303F, U+3100-312F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FF00-FFEF, U+20000-2FA1F;
}
@font-face {
  font-family: "CNReader ZH Serif";
  src: local("Songti SC"), local("STSong"), local("Noto Serif CJK SC"), local("Noto Serif SC"), local("Source Han Serif SC"), local("SimSun");
  unicode-range: U+2E80-2FDF, U+3000-303F, U+3100-312F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FF00-FFEF, U+20000-2FA1F;
}
