/* Engraving-ink on cool paper; the atlas's own ochre marks the Latin nomenclature. */
:root {
  --paper: #eef1f4;
  --sheet: #fbfcfd;
  --ink: #1e2733;
  --muted: #5d6a79;
  --rule: #d2d9e1;
  --ochre: #e0ad35;
  --mark-bg: #f6e5ad;
  --mark-ink: #3b2e06;
  --linked-bg: #e0ad35;
  --linked-ink: #1e2733;
  --focus: #2d6cdf;
  --serif: "PT Serif", Georgia, "Times New Roman", serif;
  --sans: "PT Sans", "Helvetica Neue", Arial, sans-serif;
  --gutter: 5.5rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151b22;
    --sheet: #1b222b;
    --ink: #e4e9ef;
    --muted: #93a0af;
    --rule: #2d3743;
    --mark-bg: rgba(224, 173, 53, .2);
    --mark-ink: #f3d98d;
    --linked-bg: #e0ad35;
    --linked-ink: #151b22;
    --focus: #7aa7ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--bar-h, 6rem) + 2.4rem); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.62 var(--serif);
  -webkit-font-smoothing: antialiased;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .7rem 1.25rem;
  background: var(--sheet);
  border-bottom: 3px solid var(--ochre);
  font-family: var(--sans);
  font-size: 14px;
}
.bar-title { display: flex; flex-direction: column; line-height: 1.2; margin-right: auto; }
.bar-title .authors { color: var(--muted); }
.bar-title .book { font-family: var(--serif); font-weight: 700; font-size: 18px; }
.bar-nav, .bar-actions { display: flex; align-items: center; gap: .9rem; }
.field { display: flex; align-items: center; gap: .4rem; color: var(--muted); }
select, input[type=number] {
  font: inherit; color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule); border-radius: 6px;
  padding: .35rem .5rem;
}
input[type=number] { width: 4.6rem; }
.of { white-space: nowrap; }
.switch { display: flex; align-items: center; gap: .45rem; cursor: pointer; }
.switch input { accent-color: var(--ochre); width: 1rem; height: 1rem; }
.download {
  display: inline-block;
  padding: .5rem .9rem;
  border-radius: 6px;
  background: var(--ink); color: var(--sheet);
  text-decoration: none; font-weight: 700;
}
.download:hover { background: var(--ochre); color: var(--linked-ink); }

/* column heads */
.cols {
  position: sticky; top: var(--bar-h, 3.6rem); z-index: 9;
  display: grid; grid-template-columns: var(--gutter) 1fr 1fr;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans); font-size: 14px; font-weight: 700;
}
.cols-head { padding: .45rem 1.75rem; }
.cols-head span { font-weight: 400; color: var(--muted); }
.cols-head.uk { border-left: 1px solid var(--rule); }

/* pages */
main { max-width: 1500px; margin: 0 auto; padding-bottom: 6rem; }
.loading { font-family: var(--sans); color: var(--muted); padding: 3rem var(--gutter); }
.page {
  display: grid; grid-template-columns: var(--gutter) 1fr;
  border-bottom: 1px solid var(--rule);
  content-visibility: auto;
  contain-intrinsic-size: auto 1400px;
}
.margin {
  padding: 1.6rem .75rem 0 1.25rem;
  font-family: var(--sans);
  display: flex; flex-direction: column; align-items: flex-start; gap: .35rem;
}
.margin .num {
  position: sticky; top: calc(var(--bar-h, 6rem) + 3.2rem);
  font-family: var(--serif); font-size: 2rem; line-height: 1; color: var(--muted);
}
.margin button {
  position: sticky; top: calc(var(--bar-h, 6rem) + 5.8rem);
  font: 13px var(--sans); color: var(--muted);
  background: none; border: 1px solid var(--rule); border-radius: 4px;
  padding: .15rem .45rem; cursor: pointer;
}
.margin button:hover { color: var(--ink); border-color: var(--muted); }
/* one row per paragraph or line: the original on the left, its translation on the right */
.body {
  display: grid; grid-template-columns: 1fr 1fr; align-content: start;
  min-width: 0; padding: 1.4rem 0 1.6rem;
  background: linear-gradient(90deg, transparent calc(50% - .5px), var(--rule) calc(50% - .5px),
              var(--rule) calc(50% + .5px), var(--sheet) calc(50% + .5px));
}
.c { padding: 0 1.75rem; min-width: 0; }
.c > p, .c > .row { margin: 0; max-width: 64ch; hyphens: auto; overflow-wrap: break-word; }
.c.p { padding-bottom: .85em; }
.c.p > p { text-align: left; }
.c.ln { line-height: 1.45; }
.c.ln.g { padding-top: .5em; }
.c.p.g { padding-top: .5em; }
.c.h { font-size: 1.15em; line-height: 1.35; }
.c.h.g { padding-top: .8em; }
.c.s { font-size: 15px; }
.c.rh { font-family: var(--sans); font-size: 14px; color: var(--muted); padding-bottom: .9em; }
.row.multi { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; border-bottom: 1px dotted var(--rule); }
.row.multi > span:last-child { white-space: nowrap; text-align: right; }
sub, sup { font-size: .7em; line-height: 0; }

/* figure labels: Latin as printed, the same in both languages, so one band across both columns */
.lab {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: .1rem 1.1rem;
  margin: .2rem 0 1rem; padding: .55rem 1.75rem;
  background: var(--paper);
  border-block: 1px dashed var(--rule);
  font-size: 13.5px; line-height: 1.45; color: var(--muted);
}

/* Latin nomenclature */
.la { font-style: italic; border-radius: 3px; transition: background-color .12s; hyphens: manual; }
.hl .la { background: var(--mark-bg); color: var(--mark-ink); padding: 0 .12em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.hl .la.linked { background: var(--linked-bg); color: var(--linked-ink); }
.lab .la { font-style: normal; }

/* page dialog: original scan and the Ukrainian page in the original layout */
dialog {
  border: none; border-radius: 8px; padding: 0;
  width: min(98vw, 1500px); max-width: none; max-height: 96vh;
  background: var(--sheet); color: var(--ink);
  overflow: hidden;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(10, 14, 20, .75); }
.dlg-bar {
  display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap;
  padding: .5rem .75rem; border-bottom: 1px solid var(--rule);
  font: 14px var(--sans);
}
.dlg-nav { display: flex; align-items: center; gap: .4rem; margin-right: auto; }
.dlg-nav button, .dlg-tabs button {
  font: 14px var(--sans); color: var(--ink); cursor: pointer;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: .3rem .65rem;
}
.dlg-nav button { font-size: 18px; line-height: 1; padding: .2rem .6rem; }
.dlg-nav button:disabled, .dlg-tabs button:disabled { opacity: .4; cursor: default; }
.scan-caption { min-width: 7.5rem; text-align: center; font-weight: 700; }
.dlg-tabs { display: flex; gap: .25rem; }
.dlg-tabs button[aria-selected=true] { background: var(--ochre); border-color: var(--ochre); color: var(--linked-ink); font-weight: 700; }
.close { font: 700 14px var(--sans); padding: .4rem .7rem; border-radius: 6px; border: none; background: var(--ink); color: var(--sheet); cursor: pointer; }
.imgs { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; padding: .75rem; overflow: auto; min-height: 0; }
.imgs figure { margin: 0; min-width: 0; }
.imgs img { display: block; width: 100%; height: auto; max-height: calc(96vh - 7rem); object-fit: contain; background: #fff; }
.imgs figcaption { font: 13px var(--sans); color: var(--muted); text-align: center; padding-top: .3rem; }
.imgs.mode-ru, .imgs.mode-uk { grid-template-columns: 1fr; }
.imgs.mode-ru .t, .imgs.mode-uk .o { display: none; }
.imgs.mode-ru img, .imgs.mode-uk img { max-height: none; width: auto; max-width: 100%; margin: 0 auto; }

/* view tabs: only on narrow screens */
.viewtabs { display: none; }
.short { display: none; }
@media (max-width: 860px) {
  :root { --gutter: 3.4rem; }
  body { font-size: 16px; }
  .bar { gap: .5rem .75rem; padding: .55rem 1rem; }
  .bar-title .authors { display: none; }
  .bar-title .book { font-size: 16px; }
  .bar-nav, .bar-actions { width: 100%; gap: .6rem; }
  .bar-nav .field:first-child { flex: 1; min-width: 0; }
  .bar-nav select { width: 100%; min-width: 0; }
  .page-field input[type=number] { width: 3.8rem; }
  .bar-actions { justify-content: space-between; }
  .long { display: none; }
  .short { display: inline; }
  .download { padding: .45rem .8rem; }
  .cols { display: none; }
  .viewtabs {
    position: sticky; top: var(--bar-h, 7rem); z-index: 9;
    display: flex; gap: .25rem; padding: .45rem 1rem;
    background: var(--paper); border-bottom: 1px solid var(--rule);
  }
  .viewtabs button {
    flex: 1; font: 14px var(--sans); color: var(--muted);
    padding: .4rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet);
  }
  .viewtabs button[aria-selected=true] { color: var(--linked-ink); background: var(--ochre); border-color: var(--ochre); font-weight: 700; }
  html { scroll-padding-top: calc(var(--bar-h, 7rem) + 3rem); }
  .page { grid-template-columns: var(--gutter) 1fr; }
  .margin { padding: 1.2rem .5rem 0 1rem; }
  .margin .num { font-size: 1.5rem; top: calc(var(--bar-h, 7rem) + 3.6rem); }
  .margin button { top: calc(var(--bar-h, 7rem) + 5.8rem); }
  .body { grid-template-columns: 1fr; background: none; padding: 1.1rem 0 1.4rem; }
  .c { padding: 0 1rem; }
  .lab { padding: .5rem 1rem; }
  .view-both .c.uk { background: var(--sheet); box-shadow: inset 3px 0 var(--ochre); padding-top: .3em; }
  .view-both .c.ru.p { padding-bottom: .3em; }
  .view-both .c.uk.p { margin-bottom: .6em; }
  .view-ru .c.uk, .view-uk .c.ru { display: none; }
  .both-tab { display: none; }
  .dlg-bar { gap: .5rem; }
  .imgs { padding: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
