/* noahs-bible (design rules: web crate docs). System fonts, no images.
   --wj (words of Christ) is the only decorative colour; pairs >= 4.5:1. */
:root {
  color-scheme: light dark;
  --fg: #1d1b18; --bg: #fdfcf8; --muted: #5d5850;
  --accent: #1d4f9c; --mark: #fbe7a1; --wj: #a3191b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6e2da; --bg: #16171a; --muted: #aaa49a;
    --accent: #8db6f7; --mark: #433708; --wj: #f28b82;
  }
}
html { --head: 3.5rem; background: var(--bg); color: var(--fg); scroll-padding-top: var(--head); }
html:has(#q:focus) { scroll-padding-top: 0 }
body {
  max-width: 84rem; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem);
  font: clamp(1.0625rem, .95rem + .35vw, 1.3rem)/1.6 Charter, "Bitstream Charter", "Sitka Text", Cambria, "Noto Serif", serif;
  overflow-wrap: break-word;
}
/* The measure stays ~70ch (WCAG 1.4.8); tables and outlines take the width. */
main > * { max-width: 38em; }
main > table, main > ul.outline { max-width: none; }
header, footer, nav, form, table, dialog, .bar, .popover, [popovertarget], .scope, .muted, .xrefs, .v {
  font-family: system-ui, sans-serif; font-size: .9rem;
}
input, select, button, textarea { font: inherit; max-width: 100%; }
code, kbd, pre { font-family: ui-monospace, monospace; font-size: .9em; }
kbd { border: 1px solid var(--muted); border-radius: 3px; padding: 0 .3em; white-space: nowrap; }
pre { white-space: pre-wrap; }

a { color: var(--accent); text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
mark { background: var(--mark); color: inherit; }
.muted, .date, .v, .note-start::before { color: var(--muted); }
.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* Chrome. */
.skip { position: absolute; left: -100vw; }
.skip:focus { left: 1rem; top: .5rem; z-index: 3; padding: .3em .6em; background: var(--bg); }
/* Sticky; --head (max height) keeps toc, heads, targets clear. */
header {
  position: sticky; top: 0; z-index: 2; box-sizing: border-box; min-height: var(--head);
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .75rem 0; border-bottom: 1px solid var(--muted); background: var(--bg);
}
header > a:first-child { color: var(--fg); font-weight: 700; text-decoration: none; }
header form { display: flex; flex: 1 1 14rem; gap: .4rem; max-width: 34rem; }
header input { flex: 1; min-width: 0; }
header nav { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-left: auto; }
header > button, header nav > button { border: 0; padding: 0; background: none; color: var(--accent); text-decoration: underline; }
header > button { color: var(--muted); text-decoration-style: dotted; }
/* Below 60rem two lines, so --head is known: name and links, then the box. */
@media (max-width: 60rem) { html { --head: 5.5rem; } header form { order: 1; flex-basis: 100%; } }
/* Phones, short screens: it may wrap past --head and costs room, so it scrolls away. */
@media (max-width: 40rem) { header form { max-width: none; } }
@media (max-width: 40rem), (max-height: 32rem) { html { --head: 0px; } header { position: static; } }
/* Key hints need a keyboard: hidden on touch screens, never by width (zoom keeps the off switch). */
@media (hover: none) and (pointer: coarse) { header > button { display: none; } }
/* Contents: a wrapped row after the text; left of it from 60rem (one column without :has). */
nav.toc { box-sizing: border-box; margin-top: 2rem; padding-top: .5rem; border-top: 1px solid var(--muted); }
nav.toc :is(ul, ol) { display: flex; flex-wrap: wrap; gap: .1em 1em; list-style: none; padding: 0; margin: 0; }
nav.toc ol { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.75em, 1fr)); gap: .2em; }
nav.toc ol a { display: block; line-height: 2.75em; text-align: center; }
nav.toc [aria-current="page"] { background: var(--mark); color: var(--fg); }
nav.toc h2, .toc-title { font-size: 1em; margin: .8em 0 .4em; }
@media screen and (min-width: 60rem) {
  body:has(> nav.toc) { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); column-gap: 2.5rem; }
  body:has(> nav.toc) > * { grid-column: 1 / -1; }
  /* Sticky contents stick to the grid's end, past their row, over a full-width footer. */
  body:has(> nav.toc) > :is(main, footer) { grid-column: 2; }
  body:has(> nav.toc) > main { grid-row: 2; }
  body:has(> nav.toc) > nav.toc {
    grid-column: 1; grid-row: 2; align-self: start; position: sticky; top: var(--head);
    max-height: calc(100vh - var(--head)); overflow-y: auto; margin: 0; padding: 1rem 0; border: 0;
  }
  body:has(> nav.toc) > nav.toc ul { display: block; }
}
footer { margin: 3rem 0 1.5rem; padding-top: .75rem; border-top: 1px solid var(--muted); }
.bar, .pages, .steps { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: .5rem 0; }
[aria-current] { font-weight: 700; }
.steps { margin-top: 1.5rem; } .steps [rel=next] { margin-left: auto; }
.steps a, .pages a { display: inline-block; padding: .3em 0; }

h1, h2, h3 { line-height: 1.25; margin: 1.4em 0 .5em; }
h1 { font-size: 1.5em; margin-top: 1em; }
h2 { font-size: 1.2em; }
h3 { font-size: 1em; }

/* Reading (render's markup). */
.segment, .segment > p { display: inline; }
.v { font-size: .75em; font-variant-numeric: tabular-nums; text-decoration: none; padding: 0 .15em; }
/* Inline padding grows the tap area without moving the line; kept inside the line gap (2.5.8 inline exception). */
a.v { padding: .25em .3em; }
a.v:hover { text-decoration: underline; }
/* A jumped-to verse lands mid-screen. */
.segment [id] { scroll-margin-top: calc(40vh - var(--head)); }
.v:target, .hl { background: var(--mark); color: var(--fg); }
@media (forced-colors: active) { .hl { forced-color-adjust: none; background: Mark; color: MarkText; } }
.paragraph-start { display: block; margin-top: .8em; }
.poetry-line::before { content: "\A"; white-space: pre; }
.paragraph-start + .poetry-line::before { content: none; }
.poetry-line::after { content: ""; display: inline-block; width: 1em; }
.poetry-line[data-level="2"]::after { width: 2em; }
.poetry-line[data-level="3"]::after { width: 3em; }
.canonical-heading, .added, .selah { font-style: italic; }
.divine-name { font-variant: small-caps; }
.wj, .wj a.strongs { color: var(--wj); }
sup { line-height: 0; }
.notes { display: block; font-size: .85em; margin: .3em 0 .6em 1em; }
.notes p { margin: 0; }
.note-start::before { content: "\2E22"; }
.strongs::after, .lemma::after, .gloss::after, .translit::after, .source-word::after, .morph::after {
  font: .7em/0 system-ui, sans-serif; color: var(--muted); vertical-align: super; margin-left: .1em;
  white-space: nowrap;
}
/* Interlinear: a word stacks over its original and transliteration and wraps as one unit. */
:is(.gloss, .translit, .source-word) { display: inline-block; vertical-align: top; text-align: center; margin-bottom: .4em; }
:is(.gloss, .translit, .source-word) :is(.gloss, .translit, .source-word) { margin: 0; }
:is(.gloss, .translit, .source-word)::after { display: block; font: .8em/1.3 system-ui, sans-serif; vertical-align: baseline; margin: 0; }
.source-word::after { font-family: inherit; font-size: .9em; color: var(--fg); }
.strongs::after { content: attr(data-strongs); }
.lemma::after { content: attr(data-lemma); }
.gloss::after { content: attr(data-gloss); }
.translit::after { content: attr(data-translit); }
.source-word::after { content: attr(data-source-word); }
.morph::after { content: attr(data-morph); font-family: ui-monospace, monospace; }
.xrefs { margin: .2em 0 .8em 1em; }
/* shortcut: no font is shipped (no external assets); cantillation shows only where the system has a pointed Hebrew font. */
[lang="he"], [lang="hbo"] { font-family: "SBL Hebrew", "Ezra SIL", "Noto Serif Hebrew", "Taamey Frank CLM", "Times New Roman", serif; }
/* Hebrew text reads larger; titles in column heads, labels and the documents line stay UI size. */
:is([lang="he"], [lang="hbo"]):not(th, label, .documents > *) { font-size: 1.2em; }
.error { border-left: 3px solid var(--accent); padding-left: .6em; }
.work { margin: .6em 0 .2em; font: .9rem system-ui, sans-serif; }
h2 .date { font-size: .75em; font-weight: 400; }
.excerpt { margin: 0 0 1em 1em; }

/* Lists, tables, forms. */
ol.hits { list-style: none; padding: 0; }
ol.hits li { margin: .7em 0; }
ul.outline { columns: 10em; padding: 0; list-style: none; }
ul.outline li { break-inside: avoid; }
ul.numbers { columns: auto; display: flex; flex-wrap: wrap; gap: .2em .6em; }
ul.numbers a { display: inline-block; min-width: 2em; padding: .15em 0; text-align: center; }
table { border-collapse: collapse; margin: 1em 0; }
th, td {
  padding: .3em .8em .3em 0; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--muted);
}
td code { white-space: nowrap; }
td.count { text-align: right; font-variant-numeric: tabular-nums; }
/* Library: language and license break between words, never inside one. */
table.docs th, table.docs td + td { overflow-wrap: normal; hyphens: manual; }
fieldset { border: 1px solid var(--muted); margin: 1em 0; padding: .4em .8em; }
form p { margin: .6em 0; }
input[type="number"] { width: 6em; }
/* Boxes: 24px with their margin (WCAG 2.5.8). */
[type="checkbox"], [type="radio"] { inline-size: 1.25rem; block-size: 1.25rem; margin: .125rem .3rem .125rem 0; vertical-align: -.3rem; flex: none; accent-color: var(--accent); }
/* Choice lists: one choice per line, a box never parted from its label; long lists in columns. */
:where(fieldset, p, div, span):has(> [type="checkbox"] + label) { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: .2rem; }
label:has(> [type="checkbox"]) { display: block; break-inside: avoid; padding-left: 1.55rem; text-indent: -1.55rem; }
:where(fieldset, p):has(> label > [type="checkbox"]) { columns: 15em; column-gap: 1.5rem; }
summary { cursor: pointer; }
button { cursor: pointer; }

/* page::popup; no popover support: shown inline. */
.popover:popover-open {
  max-width: min(36em, 92vw); max-height: 85vh; overflow: auto; box-sizing: border-box;
  border: 1px solid var(--muted); padding: 0 1rem; background: var(--bg); color: var(--fg);
}
.popover::backdrop { background: rgb(0 0 0 / .3); }
.popover:popover-open > h2 { margin: .8em 0 .5em; }
.popover:popover-open ul { columns: 14em; padding: 0; list-style: none; line-height: 2.2; }
/* Apply and Close stay in view. */
.popover:popover-open .apply { position: sticky; bottom: 0; display: flex; gap: 1rem; margin: 0; padding: .5rem 0 1rem; border-top: 1px solid var(--muted); background: var(--bg); }
.popover:popover-open .choose ul { columns: auto; line-height: 1.4; }
.choose li { display: flex; gap: .5em; align-items: center; margin: .5em 0; }
.choose li a { margin-left: auto; white-space: nowrap; }
@media (max-width: 40rem) {
  .popover:popover-open { inset: auto 0 0; width: 100%; max-width: none; max-height: 80vh; margin: 0; }
}
/* Inline panels (languages) would bloat the sticky header. */
@supports not selector(:popover-open) { [popovertarget] { display: none; } html { --head: 0px; } header { position: static; } }

/* keys.js overlay. */
dialog {
  max-width: min(32em, 90vw); border: 1px solid var(--muted);
  background: var(--bg); color: var(--fg);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h2 { margin-top: 0; }
dialog dl { display: grid; grid-template-columns: auto 1fr; gap: .3em 1em; }
dialog dd { margin: 0; }
dialog button { margin-right: .5em; }

/* Side by side: up to 38rem per column in main's width; below 48rem the cells stack, each named. */
table.parallel { width: min(100%, 38rem * var(--cols, 1)); table-layout: fixed; }
.cols-2 { --cols: 2; } .cols-3 { --cols: 3; } .cols-4 { --cols: 4; }
.cols-5 { --cols: 5; } .cols-6 { --cols: 6; } .cols-7 { --cols: 7; } .cols-8 { --cols: 8; }
.parallel td { padding-right: 1.2em; }
/* Column names stay in view. */
.parallel thead th { position: sticky; top: var(--head); z-index: 1; background: var(--bg); box-shadow: 0 1px var(--muted); }
.parallel caption, .parallel .doc {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.documents { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: .5rem 0; }
@media (max-width: 48rem) {
  /* Wide tables scroll in place, never the page. */
  main table:not(.parallel) { display: block; overflow-x: auto; }
  .parallel tbody, .parallel tr, .parallel td { display: block; }
  .parallel thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .parallel td { padding: .3em 0; }
  .parallel td.empty { display: none; }
  .parallel .doc {
    position: static; width: auto; height: auto; clip-path: none;
    display: block; color: var(--muted); font: .8rem system-ui, sans-serif; white-space: normal;
  }
}

@media print {
  :root { --fg: #000000; --bg: #ffffff; --muted: #444444; --accent: #000000; --wj: #000000; --mark: #dddddd; }
  header, footer, nav, form, dialog, .bar, .steps, .skip, .scope, .jump, .popover, [popovertarget] { display: none; }
  .v:target, .hl { background: none; }
  .parallel thead th { position: static; }
  /* The read documents' titles: the checked entries of the Documents panel. */
  .bar:has(#documents) { display: block; }
  .bar > :not(#documents), #documents > :not(form), .choose li:not(:has(> :checked)), .choose li > :not(label), .choose :is(summary, .apply, h3) { display: none; }
  #documents, #documents form { display: block; position: static; inset: auto; width: auto; max-height: none; overflow: visible; margin: 0 0 1em; padding: 0; border: 0; }
  #documents ul { columns: auto; margin: 0; padding: 0; line-height: inherit; }
  /* Side by side the column heads name them. */
  main:has(.parallel) #documents, .documents { display: none; }
  .choose li { display: block; margin: 0; }
  .choose details::details-content { content-visibility: visible; }
  body { max-width: none; padding: 0; font-size: 11pt; }
  main:has(.hl) .segment:not(.hl) { display: none; }
  /* Only the asked passage prints: its label, not the chapter's. */
  h1 .asked[hidden] { display: inline; }
  h1:has(.asked) .chapter { display: none; }
  a { text-decoration: none; }
}
