/* Dioscorides parallel reader — codex reading room.
   Tokens: paper ivory, warm ink, rubricated scholarly layer, botanical chrome. */

:root {
  --paper: #faf8f2;
  --paper-deep: #f2eee3;
  --ink: #262219;
  --dim: #7c7466;
  --rule: #e3ddce;
  --rubric: #8a2f2b;        /* footnote marks, apparatus, page markers */
  --rubric-soft: #f3e4e0;
  --leaf: #3d6b4f;          /* interactive chrome only */
  --leaf-soft: #e7efe7;
  --serif: Georgia, 'Times New Roman', serif;
  --greek: 'New Athena Unicode', 'GFS Porson', 'Palatino Linotype', 'Georgia Pro', Georgia, serif;
  --ui: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font: 16px/1.65 var(--serif);
  color: var(--ink);
  background: var(--paper);
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  flex-wrap: wrap;
}
.brand { font-variant: small-caps; letter-spacing: 0.14em; font-size: 17px; white-space: nowrap; }
.brand .sub { color: var(--dim); letter-spacing: 0.08em; font-size: 13px; margin-left: 6px; }
.pickers { display: flex; align-items: center; gap: 6px; }
.pickers .vs { color: var(--dim); font-family: var(--ui); font-size: 12px; }
select, .btn {
  font: 12px var(--ui);
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 4px 7px;
  cursor: pointer;
  max-width: 220px;
}
select:hover, .btn:hover { border-color: var(--leaf); }
.btn.active { background: var(--leaf); color: #fff; border-color: var(--leaf); }
.tool-link { display: inline-block; text-decoration: none; }
.btn:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--leaf); outline-offset: 1px;
}
.chnav { display: flex; align-items: center; gap: 6px; font-family: var(--ui); font-size: 13px; }
.chnav .where { min-width: 70px; text-align: center; color: var(--dim); }
.tools { margin-left: auto; display: flex; gap: 6px; }

/* ---------- frame ---------- */
.frame { flex: 1; display: flex; min-height: 0; }

/* TOC rail */
#toc {
  width: 250px; min-width: 250px;
  border-right: 1px solid var(--rule);
  background: var(--paper-deep);
  overflow-y: auto;
  font-family: var(--ui);
}
#toc.hidden { display: none; }
#toc .book > summary {
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--leaf); padding: 9px 14px 5px; cursor: pointer; user-select: none;
}
#toc a {
  display: flex; gap: 8px; align-items: baseline;
  padding: 2px 14px 2px 22px;
  font-size: 12.5px; color: var(--ink);
  text-decoration: none;
}
#toc a .n { color: var(--dim); min-width: 26px; font-variant-numeric: tabular-nums; }
#toc a .t { font-family: var(--greek); }
#toc a:hover { background: var(--leaf-soft); }
#toc a.current { background: var(--leaf-soft); box-shadow: inset 2px 0 0 var(--leaf); }

/* ---------- facing pages ---------- */
.panes { flex: 1; display: flex; min-width: 0; }
.pane {
  flex: 1; min-width: 0;
  overflow-y: auto;
  padding: 28px 36px 80px 44px;
}
/* the codex spine between the two pages */
.pane + .pane {
  border-left: 1px solid var(--rule);
  box-shadow: inset 14px 0 18px -16px rgba(60, 48, 20, 0.35);
}
.pane.hidden { display: none; }
.pane-head {
  font-family: var(--ui); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--dim);
  margin-bottom: 14px; padding-bottom: 6px; border-bottom: 1px solid var(--rule);
}
.pane-body { max-width: 39em; }
.edition-credits {
  max-width: 44em; margin: -6px 0 16px;
  font: 13px/1.5 var(--ui); overflow-wrap: anywhere;
}
.edition-credits > summary { cursor: pointer; color: var(--leaf); width: fit-content; }
.edition-credits > summary:focus-visible { outline: 2px solid var(--leaf); outline-offset: 3px; }
.credits-content { padding: 8px 0 12px; border-bottom: 1px solid var(--rule); }
.credits-content h3 { font-size: 13px; margin: 12px 0 5px; }
.credits-content dt { font-weight: 600; margin-top: 7px; }
.credits-content dd { margin: 0 0 5px; white-space: normal; }
.credits-content a { color: var(--leaf); }
.credits-links { list-style: none; margin-top: 4px; }
.pane-body p { margin: 0 0 0.85em; text-align: justify; hyphens: manual; }
.pane[data-lang="grc"] .pane-body, .pane-body .grc, .pane-body [lang="grc"] {
  font-family: var(--greek);
}
.pane-missing { color: var(--dim); font-style: italic; margin-top: 30px; }

/* chapter internals */
.chapter-head { font-size: 1.12em; font-weight: normal; margin: 0 0 0.7em; }
.chapter-head .foreign { font-style: normal; }
.seg-chapterTitle { font-weight: bold; }
.seg-synonyma { color: var(--dim); }
.section { display: block; position: relative; margin-bottom: 0.4em; }
.section::before {
  content: attr(data-n);
  position: absolute; left: -2.2em; top: 0.15em;
  font: 11px var(--ui); color: var(--dim);
}
.chapter > .commentary {
  font-size: 0.92em;
  color: #4c463a;
}
.chapter > .commentary p,
.chapter > p.commentary {
  text-align: left;
}
.chapter > .commentary-first,
.chapter .section > .commentary-first {
  border-top: 1px solid var(--rule);
  margin-top: 1.5em;
  padding-top: 0.9em;
}

/* an edition whose chapters hold the author's text and a commentary on it (Mattioli 1554):
   the commentary is set apart by its label, size and rule, in upright type (Sean, 2026-10-08) */
.dioscorides-text, .author-commentary { display: block; }
.chapter > .author-commentary {
  font-size: 0.95em;
  border-left: 3px solid var(--rubric-soft);
  padding-left: 0.8em;
}
.block-label {
  display: block; font: 11px var(--ui); font-style: normal;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim);
  margin: 0.2em 0 0.3em;
}
.note-lemma { margin-right: 0.5em; }
.note-marginal { font: 0.78em var(--ui); font-style: normal; color: var(--rubric); }
.note-marginal::before { content: "["; }
.note-marginal::after { content: "] "; }
.figure { display: block; font: 12px var(--ui); font-style: normal; color: var(--leaf); margin: 0.3em 0; }
.ex { color: var(--dim); }
.unclear { text-decoration: underline dotted var(--dim); }
.gap { color: var(--dim); font-style: normal; }

/* diplomatic apparatus of the page: hidden unless toggled */
.fw { display: none; }
body.show-fw .fw {
  display: block; font: 11px var(--ui); letter-spacing: 0.1em;
  color: var(--dim); text-align: center; margin: 4px 0;
}
.eol-hyphen { display: none; }
body.show-fw .eol-hyphen,
body.show-lineation .eol-hyphen { display: inline; }

/* line + page anchors */
.lb { position: relative; }
body.show-lineation .pane-body {
  --lineation-gutter: 3.8rem;
  max-width: calc(39em + var(--lineation-gutter));
  padding-inline-start: var(--lineation-gutter);
}
body.show-lineation .pane-body > .chapter .lb {
  display: block;
  block-size: 0;
  position: relative;
}
body.show-lineation .pane-body > .chapter p,
body.show-lineation .pane-body > .chapter .chapter-head {
  margin-block-end: 0;
  text-align: start;
}
body.show-lineation .pane-body > .chapter .lb[data-show]::after,
body.show-lineation .pane-body > .chapter .lb[data-n="1"]::after {
  content: attr(data-n);
  position: absolute;
  inset-inline-start: -1.35rem;
  inset-block-start: 0.38em;
  inline-size: 0.75rem;
  color: #a79d89;
  text-align: end;
  font: 10px/1 var(--ui);
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.pane-body { position: relative; }
a.pb {
  font: 10px var(--ui);
  color: var(--rubric);
  background: var(--rubric-soft);
  border-radius: 2px;
  padding: 0 4px;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: 0.15em;
}
a.pb:hover { background: var(--rubric); color: #fff; }
/* A page marker inside an explicitly unbroken word disappears with the
   diplomatic furniture in reading mode; either source-view toggle restores it. */
a.pb.nobreak-bridge { display: none; }
body.show-fw a.pb.nobreak-bridge,
body.show-lineation a.pb.nobreak-bridge { display: inline; }
/* page numbers are furniture, never part of a text selection */
a.pb { user-select: none; -webkit-user-select: none; }
/* reading view: a paragraph the page break splits (TEI @part I/M/F) flows on as one
   paragraph; the page marker stays inline, as in editions that break inside <p> */
body:not(.show-lineation) .pane-body > .chapter > p.part-I,
body:not(.show-lineation) .pane-body > .chapter > p.part-M,
body:not(.show-lineation) .pane-body > .chapter > p.part-F { display: inline; }
body:not(.show-lineation) .pane-body > .chapter > p.part-F::after { content: ""; display: block; margin-bottom: 0.75em; }
/* lineation view: every page marker in the left margin, wherever the TEI puts it */
body.show-lineation .pane-body a.pb {
  position: absolute;
  inset-inline-start: 0.25rem;
  inline-size: 2rem;
  padding-inline: 0;
  text-align: end;
  background: transparent;
  transform: translateY(0.35em);
}
body.show-lineation .pane-body > .chapter > a.pb {
  position: absolute;
  inset-inline-start: 0.25rem;
  inline-size: 2rem;
  padding-inline: 0;
  text-align: end;
  background: transparent;
  transform: translateY(0.35em);
}
body.show-lineation .pane-body > .chapter > a.pb:hover {
  color: var(--rubric);
  text-decoration: underline;
}

/* rubricated scholarly layer */
a.fnref { text-decoration: none; color: var(--rubric); font-weight: bold; }
a.fnref sup { font-size: 0.72em; }
a.fnref:hover sup { text-decoration: underline; }
.note-block {
  display: block; font-size: 0.88em; color: #55402e;
  border-left: 2px solid var(--rubric-soft);
  padding-left: 12px; margin: 0.5em 0 0.9em;
}
/* a note and its marks, highlighted together when either is clicked */
.endnotes li { cursor: pointer; border-radius: 2px; }
.note-hl { background: var(--rubric-soft); box-shadow: 0 0 0 2px var(--rubric-soft); }
a.fnref.note-hl { border-radius: 2px; }
.note-n { color: var(--rubric); font-weight: bold; font-size: 0.9em; }
/* sigla (codices, editions) open the Notes section, one printed entry a line */
.endnotes .siglorum .lb { display: block; }
.endnotes .siglorum .tei-label { display: block; font-variant: normal; font-weight: bold; margin: 0.3em 0 0.15em; }
.siglorum {
  font-size: 0.92em; background: var(--paper-deep);
  border: 1px solid var(--rule); border-radius: 3px;
  padding: 10px 14px; margin: 0.8em 0;
}
.tei-label { font-variant: small-caps; letter-spacing: 0.06em; }
/* Printed chapter numerals in the running text (Wellmann) can be hidden; numbers that
   are part of a chapter heading (Sprengel, Mattioli, Gunther) always stay. */
body.hide-chapter-numerals .tei-num-chapter { display: none; }
body.hide-chapter-numerals .chapter-head .tei-num-chapter { display: inline; }
/* A printed marginal label (Wellmann's section numbers within a chapter) sits in the
   section-number column beside its line; .section is the positioning box. */
.pane-body .margin-label {
  position: absolute; left: -2.2em; margin-top: 0.15em;
  font: 11px var(--ui); font-variant: normal; letter-spacing: normal; color: var(--rubric);
}
/* printer's error kept as printed; the correction shows on hover */
.sic { text-decoration: underline dotted var(--rubric); text-underline-offset: 3px; cursor: help; }
.sic-add { color: var(--rubric); cursor: help; }
.tr-note { color: var(--rubric); font-size: .75em; vertical-align: super; cursor: help; margin-left: .1em; }
/* Sperrdruck (TEI hi rend="spaced"): letter-spaced as printed */
.hi[data-rend="spaced"] { letter-spacing: 0.16em; }

.app { border-bottom: 1px dotted var(--rubric); cursor: pointer; }
.app-testimonia { border-bottom-style: dashed; }
.app:hover { background: var(--rubric-soft); }

/* endnotes */
.endnotes { margin-top: 2.2em; border-top: 1px solid var(--rule); padding-top: 0.8em; }
.endnotes h4 {
  font: 11px var(--ui); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--rubric); margin-bottom: 0.6em; font-weight: normal;
}
.endnotes ol { list-style: none; }
.endnotes li { font-size: 0.92em; margin-bottom: 0.45em; color: #4c463a; } /* = commentary */

/* ---------- facsimile drawer ---------- */
#facs {
  width: 40%; min-width: 320px;
  border-left: 1px solid var(--rule);
  background: #211e18;
  display: flex; flex-direction: column;
}
#facs[hidden] { display: none; }
#osd { flex: 1; }
.facs-caption {
  font: 11px var(--ui); letter-spacing: 0.08em;
  color: #cfc7b4; background: #191712;
  padding: 6px 12px;
  display: flex; justify-content: space-between; gap: 10px;
}
.facs-caption a { color: #9db8a3; }
.facs-msg {
  color: #cfc7b4; font: 13px var(--ui);
  padding: 18px; text-align: center;
}
.facs-msg a { color: #9db8a3; }

/* ---------- popover ---------- */
#popover {
  position: fixed; z-index: 50;
  max-width: 420px;
  background: #fffdf7;
  border: 1px solid var(--rule);
  border-top: 2px solid var(--rubric);
  box-shadow: 0 6px 24px rgba(50, 40, 15, 0.18);
  padding: 12px 14px;
  font-size: 0.88em;
  border-radius: 0 0 3px 3px;
}
#popover[hidden] { display: none; }
#popover .app-register-label {
  font: 10px var(--ui); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--rubric); margin-bottom: 4px;
}
#popover .app-reading { margin-bottom: 3px; }
#popover .app-lem-line .app-lem-text { font-weight: bold; }
#popover .app-wit { color: var(--rubric); font-size: 0.92em; }
#popover .app-wit abbr { text-decoration: none; cursor: help; border-bottom: 1px dotted var(--rubric); }
#popover .app-note { color: var(--dim); margin-top: 4px; }
#popover .grc, #popover [lang="grc"] { font-family: var(--greek); }
#popover .pop-close {
  float: right; border: 0; background: none; color: var(--dim);
  font: 14px var(--ui); cursor: pointer; margin-left: 8px;
}

/* ---------- small screens: layout is in mobile.css ---------- */
@media (max-width: 900px) {
  body.show-lineation .pane-body { --lineation-gutter: 3.25rem; }
}

@media (prefers-reduced-motion: no-preference) {
  #popover { animation: pop 0.12s ease-out; }
  @keyframes pop { from { opacity: 0; transform: translateY(-3px); } }
}

/* Printed registers retain their line structure independently of lineation. */
.sachregister .index-entry, .sachregister .index-line { display: block; }
.sachregister .index-entry[hidden] { display: none; }
.sachregister .lb, .errata .lb { display: none; }
.sachregister .index-entry .lb:not(:first-child) { display: block; }
.errata .matter-link { display: block; }
.index-filter { display: block; position: sticky; top: 0; background: var(--bg, #faf8f3); padding: .6rem 0; z-index: 1; }
.index-filter input { max-width: 100%; padding: .4rem; font: inherit; }
.index-english { font-size: .9em; color: var(--muted, #666); }
.pane[data-lang="eng"] .index-english { font-size: 1em; color: inherit; }
.matter-link { text-underline-offset: .15em; }

/* The other pane's chapters chosen through the Wellmann concordance (proposed until checked). */
.pairing-note { font-size: 0.85em; color: var(--dim); border-left: 3px solid var(--rubric);
  padding: 0.2em 0.6em; margin: 0 0 0.8em; }

/* part of a chapter shown alone (the section or span the other pane's chapter renders) */
.part-bar { font-size: 0.85em; color: var(--muted, #666); margin: 0 0 0.6em; }
.part-bar .part-toggle { font-size: inherit; }
#onlyMatchingPart { margin-bottom: 10px; }
.part-gap { text-align: center; color: var(--muted, #666); }

/* Wellmann's separately printed recension layer. */
.tei-recension { margin-top: 1.2em; padding-top: .6em; font-size: .85em; }
.tei-recension::before { content: ""; display: block; width: 5em; border-top: 1px solid currentColor; margin-bottom: .6em; }
.rv-label { font-weight: 600; margin-right: .4em; }
.tei-rv-bracketed { color: inherit; }
