/* Confucius.page working pages. Palette fixed (盈科生, 2026-11-08): red #BF211E, black #000000,
   orange #E59500, slate #4F646F, off-white #FCFCFC. How each colour is used is still open;
   red and orange stay sparing. Orange is never used for text on the off-white page (contrast). */

:root, :root[data-theme="day"] {
  --bg: #FCFCFC;
  --text: #000000;
  --muted: #4F646F;
  --rule: rgba(79, 100, 111, .28);
  --wash: rgba(79, 100, 111, .08);
  --card: #FFFFFF;
  --accent: #BF211E;
  --mark: #E59500;
  --shadow: 0 10px 30px rgba(0, 0, 0, .14);
  --foot-bg: #4F646F;          /* footer: off-white on slate, about 6:1 */
  --foot-text: #FCFCFC;
  --foot-muted: #DDE4E7;
  /* Jigmo has the characters but no punctuation (「」《》，：…): those come from the
     computer's own Chinese fonts, named after it. */
  --font-cjk: "Jigmo", "Noto Serif TC", "Source Han Serif TC", "PMingLiU", "MingLiU", "Songti TC", serif;
  /* English: LaTeX's default typeface, Latin Modern Roman, for text and labels alike (盈科生,
     2026-11-29: "Use LaTeX default formatting"); Georgia until its files are in fonts/. */
  --font-latex: "Latin Modern Roman", "LM Roman 10", "CMU Serif", "Computer Modern Serif", Georgia, "Times New Roman";
  --font-text: var(--font-latex), "Jigmo", "PMingLiU", "Songti TC", serif;
  --font-ui: var(--font-latex), "Jigmo", "Microsoft JhengHei", "PingFang TC", serif;
  color-scheme: light;
}

/* Night: a dark slate, lighter than the old demo; red lightened for contrast. */
:root[data-theme="night"] {
  --bg: #1F2A30;
  --text: #FCFCFC;
  --muted: #B7C4CA;
  --rule: rgba(252, 252, 252, .16);
  --wash: rgba(252, 252, 252, .07);
  --card: #27353C;
  --accent: #E8706D;
  --mark: #E59500;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --foot-bg: #141C20;
  --foot-text: #FCFCFC;
  --foot-muted: #B7C4CA;
  color-scheme: dark;
}

/* One column for every page, as wide as the 經 with its label (盈科生, 2026-11-12): the 經 sets
   the measure, no row runs wider, and there is space on both sides of any wider screen. */
:root {
  --label-size: 2.75rem;       /* the row labels: all one size, larger than the passage (盈科生) */
  --jing-size: 2.2rem;         /* the passage's characters */
  --cell: 3.45rem;             /* one cell per character or punctuation mark */
  --label-w: 6.5rem;           /* the label column: two label characters wide */
  --label-gap: 2rem;
  --measure: calc(11 * var(--cell));   /* the 經's line, eleven cells; 65–70 letters of English */
  --page-w: calc(var(--label-w) + var(--label-gap) + var(--measure));
}
@media (max-width: 720px) {
  :root { --label-size: 2rem; --jing-size: 1.7rem; --cell: 2.85rem; }   /* seven cells a line */
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.6 var(--font-text);
}
:lang(zh-Hant) { font-family: var(--font-cjk); }
a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { width: min(var(--page-w), calc(100% - 2 * max(16px, 4vw))); margin-inline: auto; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--card); padding: .4rem .8rem; z-index: 60; }

/* working-page strip, header, footer */
.working { background: var(--wash); color: var(--muted); font: .8rem var(--font-ui); padding: .35rem 0; }
header.site { border-bottom: 1px solid var(--rule); }
header.site .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; padding-block: 1rem; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; font: 600 1.15rem var(--font-ui); }
.brand img { width: 44px; height: 44px; object-fit: contain; }
:root[data-theme="night"] .brand img { filter: invert(1); }
.menu { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: .25rem .9rem; font: .92rem var(--font-ui); }
.menu a { text-decoration: none; }
.menu .off { color: var(--muted); opacity: .65; cursor: default; }
.tools { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
#theme-toggle {
  font: .85rem var(--font-ui); color: var(--text); background: transparent; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 5px; padding: .3rem .8rem;
}
main { padding-block: 1.5rem 1rem; }

/* buttons: the arrows and "Read" (orange with black text, about 9:1); rectangular (盈科生, 2026-11-12) */
.arrow {
  display: inline-grid; place-items: center; width: 3.2rem; height: 2.2rem; border-radius: 5px;
  background: var(--mark); color: #000; text-decoration: none; font: 1.2rem var(--font-ui);
}
.arrow:hover { color: #000; filter: brightness(1.08); }
.arrow.off { opacity: .3; }
.button {
  display: inline-flex; align-items: center; gap: .45rem; border-radius: 5px; padding: .45rem 1.15rem;
  background: var(--mark); color: #000; font: 600 .95rem var(--font-ui); text-decoration: none; white-space: nowrap;
}
.button:hover { color: #000; filter: brightness(1.08); }
.button.quiet {
  background: transparent; color: var(--text); border: 1px solid var(--rule);
  font-weight: 400; font-size: .82rem; padding: .1rem .7rem; margin-left: .4rem; border-radius: 4px;
}
.button.quiet:hover { border-color: var(--mark); filter: none; }

/* the footer */
@media (max-width: 720px) {       /* phones: the switch beside the logo, the menu below */
  .tools { order: 2; }
  .menu { order: 3; flex-basis: 100%; }
}

footer.site { margin-top: 3rem; background: var(--foot-bg); color: var(--foot-text); font: .88rem/1.6 var(--font-ui); }
footer.site .wrap { padding-block: 1.6rem 2.2rem; }
footer.site a { color: var(--foot-text); }
footer.site a:hover { color: var(--foot-text); text-decoration: underline; }
footer.site .brand { font-size: 1.05rem; }
footer.site .brand img { width: 36px; height: 36px; filter: invert(1); }
.foot-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; }
.to-top { text-decoration: none; font-size: .85rem; }
.foot-line { margin: .5rem 0 1rem; }
.foot-menu {
  display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; padding: .7rem 0;
  border-block: 1px solid rgba(252, 252, 252, .22);
}
.foot-menu a { text-decoration: none; }
.foot-menu .off { color: var(--foot-muted); opacity: .7; cursor: default; }
.foot-credits { color: var(--foot-muted); font-size: .78rem; margin: .9rem 0 0; }

/* rows with the label column */
.row { display: grid; grid-template-columns: var(--label-w) minmax(0, 1fr); gap: 0 var(--label-gap); padding: 1.3rem 0; border-top: 1px solid var(--rule); }
.row:first-child { border-top: 0; }
.label { padding-top: .2rem; }
.label .zh { display: block; width: 2em; font-size: var(--label-size); line-height: 1.15; }  /* 劉氏 over 正義 */
.label .en { display: block; font: .7rem var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
#jing .label .zh { color: var(--accent); }
.row h3 { font: 600 .95rem var(--font-ui); margin: 1.2rem 0 .4rem; }
.row h4 { font: 600 .9rem var(--font-ui); margin: .8rem 0 .2rem; }
details > summary { cursor: pointer; font: .9rem var(--font-ui); color: var(--muted); padding: .2rem 0; }
details > summary:hover { color: var(--text); }
details[open] > summary { margin-bottom: .4rem; }
.todo { font: .85rem var(--font-ui); color: var(--muted); margin: .2rem 0 .6rem; }
.todo b { background: var(--mark); color: #000; font-size: .68rem; letter-spacing: .06em; border-radius: 3px; padding: .05rem .35rem; margin-right: .5rem; }
@media (max-width: 720px) {
  .row { grid-template-columns: minmax(0, 1fr); gap: .5rem; }
  .label { display: flex; align-items: baseline; gap: .6rem; }
  .label .zh { display: inline; width: auto; }
}

/* the passage: its reference line with the arrows, then the 經 */
.passage-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin: 0 0 .9rem; }
.ref { font: .85rem var(--font-ui); color: var(--muted); margin: 0 0 .9rem; font-weight: 400; }
.passage-head .ref { margin: 0; }
.ref a { text-decoration: none; }
.ref .pid { margin-left: .5rem; color: var(--text); font-weight: 600; }
.pager { display: flex; gap: .5rem; flex: none; }
/* The 經 (盈科生, 2026-11-12: even spacing). Every character and punctuation mark sits in a cell of
   the same width (--cell), inside a unit as much as between units, so the spacing is even; a
   unit is wider than its cells only where one word of its gloss cannot fit. A full line is
   eleven cells, exactly the width of the rows below. Lines are not stretched to the edge, which
   would spread the characters unevenly. The spaces between cells (where a line may break) take
   no room (font-size 0). */
.passage { font-size: 0; }
.grp { white-space: nowrap; }                /* a unit and its punctuation: never split */
.u, .phrase {
  display: inline-flex; flex-direction: column; vertical-align: top; margin-bottom: 1rem;
  text-align: center; text-align-last: auto; white-space: normal;   /* glosses still wrap */
}
.u {
  align-items: center; padding: .15rem 0 .35rem;
  border-radius: 4px; border-bottom: 2px solid transparent; cursor: pointer;
}
.u .hz { display: flex; font-size: var(--jing-size); line-height: 1.15; }
.u .hz > * { width: var(--cell); text-align: center; text-decoration: none; color: inherit; }
.u .gl {
  font: .68rem/1.25 var(--font-ui); color: var(--muted); margin-top: .25rem;
  max-width: calc(var(--n, 1) * var(--cell) - .25rem); min-width: min-content;
  min-height: 2.5em;           /* room for two lines of gloss, so the lines of the 經 sit evenly */
}
.u-grammar .gl { font-style: italic; }
.nw { white-space: nowrap; }                 /* "(-men)", "(-ies)": never split at the hyphen */
.u:hover, .u.open, .u:focus-within { background: var(--wash); border-bottom-color: var(--mark); }
.pu {
  display: inline-block; vertical-align: top; width: var(--cell); margin-bottom: 1rem;
  font-size: var(--jing-size); line-height: 1.15; padding-top: .15rem; text-align: center; color: var(--muted);
}
.phrase .ph-units { display: flex; }
.phrase .u { margin-bottom: 0; }
.phrase .ph-gloss {
  font: .68rem/1.25 var(--font-ui); color: var(--muted); contain: inline-size;  /* never widens the phrase */
  border-top: 2px solid var(--mark); margin: .2rem .3rem 0; padding-top: .15rem;
}
/* "Cite this passage", at the very bottom of the page (盈科生, 2026-11-12) */
.cite { margin-top: 2.5rem; padding-top: .9rem; border-top: 1px solid var(--rule); font: .82rem/1.6 var(--font-ui); color: var(--muted); overflow-wrap: anywhere; }
.cite h2 { font: 600 .7rem var(--font-ui); letter-spacing: .08em; text-transform: uppercase; margin: 0 0 .3rem; }
.cite p { margin: .1rem 0; }

/* rows below the passage */
.variant { margin: .4rem 0 1rem; }
.variant h4 { margin: 0 0 .2rem; }
.v-text { font-size: 1.25rem; margin: 0 0 .2rem; }
.v-text ins { text-decoration: none; background: var(--wash); border-bottom: 2px solid var(--mark); }
.v-text del { color: var(--muted); }
.v-note { color: var(--muted); font-size: .95rem; margin: 0; }
.basis { margin: .2rem 0 .6rem; padding-left: 1.4rem; font-size: .98rem; line-height: 1.75; }
.basis .src { color: var(--muted); }
.person, .note, .reading { margin-bottom: .8rem; }
.person p, .note p { margin: .15rem 0; }
.seg { margin: .5rem 0 1rem; }
.seg-head { font-size: 1.1rem; margin: 0 0 .2rem; }

/* the card */
.card {
  position: absolute; z-index: 50; width: min(27rem, calc(100vw - 2rem)); max-height: min(72vh, 42rem); overflow: auto;
  background: var(--card); color: var(--text); border: 1px solid var(--rule); border-radius: 10px;
  box-shadow: var(--shadow); padding: .9rem 1.1rem 1rem;
}
.card .c-close { float: right; border: 0; background: none; color: var(--muted); font: 1.4rem var(--font-ui); cursor: pointer; line-height: 1; padding: 0 .2rem; }
.c-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: .3rem .9rem; }
.c-hz { font-size: 2.6rem; line-height: 1.1; }
.c-py { font: 1rem var(--font-ui); }
.c-py s, .c-gloss s, .note s { color: var(--muted); margin-left: .45rem; }
.c-gloss { font-size: 1.2rem; margin: .4rem 0 .2rem; }
.card h4 { font: 600 .7rem var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: .9rem 0 .25rem; }
.card .basis { font-size: .95rem; }
.c-senses, .c-person, .c-about, .c-links { font: .85rem/1.5 var(--font-ui); margin: .3rem 0; }
.c-links a { font-size: 1.1rem; margin-right: .2rem; }
@media (max-width: 720px), (hover: none) {
  .card {
    position: fixed; left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto;
    max-height: 75vh; border-radius: 14px 14px 0 0;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }
}

/* Book, contents and Glossary pages */
.prose { max-width: var(--measure); }      /* running text never wider than the 經 */
.prose.wide { max-width: none; }           /* the Glossary index's grid */
.prose.wide .lede { max-width: var(--measure); }
.prose h1 { font: 600 1.7rem/1.3 var(--font-ui); margin: .5rem 0 1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; margin: .5rem 0 1rem; }
.page-head h1 { margin: 0; }
.prose h2 { font: 600 1.2rem var(--font-ui); margin: 2rem 0 .6rem; }
.prose h3 { font: 600 1rem var(--font-ui); margin: 1.5rem 0 .4rem; }
.prose blockquote { margin: 1rem 0; padding: .1rem 0 .1rem 1rem; border-left: 3px solid var(--rule); }
.prose blockquote p { margin: .5rem 0; }
.prose blockquote :lang(zh-Hant) { font-size: 1.08rem; }
.passages li, .books li { margin: .3rem 0; }
.glossary-entry h1 { display: flex; align-items: baseline; flex-wrap: wrap; gap: .4rem 1rem; }
.g-hz { font-size: 3.6rem; font-weight: 400; line-height: 1; }
.g-readings { font: 1rem var(--font-ui); color: var(--muted); }
.g-uses { list-style: none; padding: 0; }
.g-uses li { display: flex; flex-wrap: wrap; gap: .2rem 1rem; padding: .5rem 0; border-top: 1px solid var(--rule); }
.g-gloss { min-width: 16rem; }
.g-py { font-family: var(--font-ui); margin-right: .4rem; }
.g-index { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .5rem; }
.g-index a { display: grid; grid-template-columns: auto 1fr; gap: 0 .5rem; align-items: center; text-decoration: none; border: 1px solid var(--rule); border-radius: 6px; padding: .4rem .6rem; }
.g-index .g-hz { font-size: 1.8rem; grid-row: span 3; }
.g-index .g-py, .g-index .g-gl, .g-index .g-n { font: .75rem/1.3 var(--font-ui); }
.g-index .g-gl, .g-index .g-n { color: var(--muted); }

/* Imported texts in the 注, 英譯 and 劉氏正義 rows (2026-11-29) */
.cmt { margin: .2rem 0 .9rem; }
.cmt .cl { color: var(--muted); font-size: 1rem; margin: 0 0 .15rem; }
.cmt .nt { font-size: 1.05rem; line-height: 1.85; margin: 0; }
.src-line { color: var(--muted); font: .8rem/1.5 var(--font-ui); margin: .3rem 0 .9rem; }
.zy, .zy-jing { line-height: 1.9; margin: 0 0 .7rem; }
.zy-jing { font-size: 1.12rem; }
.zhu-mark { color: var(--muted); }
.reading.en p { margin: 0 0 .5rem; }
/* LaTeX sets running text justified and hyphenated (盈科生, 2026-11-29) */
.prose p, .prose li, .reading.en p { text-align: justify; hyphens: auto; -webkit-hyphens: auto; }

/* People and Sources (盈科生, 2026-11-29) */
.people li, .sources li { margin: .45rem 0; }
.names { list-style: none; padding: 0; }
.table-wrap { overflow-x: auto; }
.errata { border-collapse: collapse; font: .82rem/1.45 var(--font-ui); width: 100%; }
.errata th, .errata td { border-bottom: 1px solid var(--rule); padding: .35rem .5rem; text-align: left; vertical-align: top; }
.errata th { font-weight: 600; white-space: nowrap; }
.errata td:nth-child(3), .errata td:nth-child(4) { min-width: 8rem; }
