/* ---------------------------------------------------------------------------
   The Hebrew Bible: Masoretic Text and the Dead Sea Scrolls.
   One stylesheet for all 969 pages.  No framework, no build step.

   The palette is drawn from the two witnesses rather than from a mood board:
   the Masoretic Text is a printed critical edition, so it is set crisp and
   cool; the manuscript lines are the older witness, so they carry the warmth
   and the wear.
   One accent colour, the mineral blue-green of the Dead Sea, and it is spent
   on one thing only: attestation.
   --------------------------------------------------------------------------- */

:root {
  --ink:       #17140f;   /* iron-gall black, warmed */
  --ink-2:     #5b5348;
  --ink-3:     #8b8377;
  --page:      #fcfbf8;
  --panel:     #ffffff;
  --rule:      #e4dfd3;
  --rule-2:    #f1ede3;
  --leather:   #f6f0e2;   /* the band behind a scroll line */
  --leather-2: #ece4d1;
  --scribe:    #3d3529;   /* scroll ink */
  --rec:       #b3a894;   /* editorially reconstructed letters */
  --traces:    #cdc4b0;   /* illegible: traces only */
  --sea:       #0e6b75;
  --sea-2:     #0a545c;
  --sea-soft:  #e2eff0;
  --sea-line:  #a4c9cb;

  --heb:    "Frank Ruhl Libre", "SBL Hebrew", "Taamey Frank CLM", "Ezra SIL",
            "Times New Roman", serif;
  --scroll: var(--heb);   /* the scroll lines are set in the same face as the MT */
  --lat:    Spectral, Georgia, "Times New Roman", serif;
  --mono:   ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --wrap: 62rem;
  --cell: 4px;            /* one chapter in an index stripe */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:       #ece7dd;
    --ink-2:     #a49c8e;
    --ink-3:     #7b7365;
    --page:      #14130f;
    --panel:     #1b1915;
    --rule:      #322e26;
    --rule-2:    #262219;
    --leather:   #221e17;
    --leather-2: #2c2619;
    --scribe:    #d9d0be;
    --rec:       #6d6454;
    --traces:    #565040;
    --sea:       #63c3cc;
    --sea-2:     #8ad9e0;
    --sea-soft:  #10322f;
    --sea-line:  #2f6265;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--lat);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "kern" 1;
}

a { color: var(--sea); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--sea-2); }

:focus-visible {
  outline: 2px solid var(--sea);
  outline-offset: 2px;
  border-radius: 2px;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.5rem; }

/* --- masthead ------------------------------------------------------------ */

.masthead { border-bottom: 1px solid var(--rule); background: var(--panel); }

.masthead .wrap { padding-block: 2.6rem 1.9rem; }

.title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.title h1 {
  margin: 0;
  font-size: 2.45rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.1;
}

/* The index alone carries a second line under the h1.  It is a flex column so
   that the container's baseline is the h1's, and the Hebrew stays level with
   it rather than with the subtitle. */
.title .titling { display: flex; flex-direction: column; gap: 0.5rem; }

.title .subtitle {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--ink-2);
}

.title .he {
  font-family: var(--heb);
  direction: rtl;
  font-size: 2.15rem;
  font-weight: 400;
  color: var(--ink-2);
  line-height: 1.1;
}

.byline {
  margin: 0.9rem 0 0;
  font-size: 0.97rem;
  color: var(--ink-3);
}

.standfirst {
  margin: 1.1rem 0 0;
  max-width: 46rem;
  font-size: 1.06rem;
  color: var(--ink-2);
}

.standfirst b { color: var(--ink); font-weight: 500; }

/* --- book index ---------------------------------------------------------- */

.canon { margin: 3rem 0 0; }

.canon > h2 {
  margin: 0 0 0.2rem;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--sea);
}

.canon > h2 .he {
  font-family: var(--heb);
  font-weight: 400;
  color: var(--ink-3);
  margin-inline-start: 0.6rem;
}

.canon > p { margin: 0 0 1.1rem; color: var(--ink-3); font-size: 0.92rem; }

.books { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }

.books li { border-bottom: 1px solid var(--rule-2); }

.book-row {
  display: grid;
  grid-template-columns: 15rem 1fr auto;
  align-items: center;
  gap: 1.4rem;
  padding: 0.72rem 0.6rem 0.72rem 0;
  text-decoration: none;
  color: inherit;
}

.book-row:hover { background: var(--rule-2); }
.book-row:hover .bk-name { color: var(--sea); }

.bk-name { font-size: 1.16rem; font-weight: 500; }

.bk-meta {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.bk-he {
  font-family: var(--heb);
  direction: rtl;
  font-size: 1.35rem;
  color: var(--ink-2);
  justify-self: end;
  min-width: 7.5rem;
  text-align: right;
}

/* the coverage stripe: one cell per chapter, cells the same size in every
   book, so the length of a stripe is the length of the book */
.stripe {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--cell);
  gap: 1px;
  justify-content: start;
  height: 15px;
  overflow: hidden;
}

.stripe i { background: var(--rule); border-radius: 1px; }
.stripe i.att { background: var(--sea); }

/* --- chapter grid (a book page) ------------------------------------------ */

.chapters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.4rem, 1fr));
  gap: 6px;
  margin: 1.6rem 0 0;
  padding: 0;
  list-style: none;
}

.ch {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--rule);
  border-radius: 3px;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 1.06rem;
  font-variant-numeric: tabular-nums;
  background: var(--panel);
}

.ch.att {
  background: var(--sea-soft);
  border-color: var(--sea-line);
  color: var(--ink);
}

.ch:hover { border-color: var(--sea); color: var(--sea); }

.scrolls {
  margin: 1.4rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-2);
  line-height: 2;
}

.sig {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.12rem 0.42rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink-2);
  background: var(--panel);
  margin-inline-end: 0.3rem;
  white-space: nowrap;
}

/* --- chapter page: header ------------------------------------------------ */

.chead {
  position: sticky;
  top: 0;
  z-index: 8;
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
}

.chead .wrap {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding-block: 0.7rem;
  flex-wrap: wrap;
}

.chead h1 { margin: 0; font-size: 1.3rem; font-weight: 600; white-space: nowrap; }
.chead h1 a { color: inherit; text-decoration: none; }
.chead h1 a:hover { color: var(--sea); }
.chead h1 .he { font-family: var(--heb); font-weight: 400; color: var(--ink-3); margin-inline-start: .5rem; }

.chead .att-line { font-size: 0.84rem; color: var(--ink-3); flex: 1 1 12rem; }
.chead .att-line b { color: var(--ink-2); font-weight: 500; }

.pager { display: flex; align-items: center; gap: 0.9rem; font-size: 0.88rem; white-space: nowrap; }
.pager a { text-decoration: none; }
.pager span { color: var(--ink-3); opacity: 0.45; }

/* the pointing switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--ink-2);
  user-select: none;
  white-space: nowrap;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 34px; height: 19px; flex: 0 0 auto;
  background: var(--rule); border-radius: 999px; position: relative;
  transition: background .14s ease;
}
.switch .thumb {
  position: absolute; top: 2px; inset-inline-start: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.28);
  transition: transform .14s ease;
}
.switch input:checked + .track { background: var(--sea); }
.switch input:checked + .track .thumb { transform: translateX(15px); }
.switch input:focus-visible + .track { outline: 2px solid var(--sea); outline-offset: 2px; }

/* --- chapter page: the text ---------------------------------------------- */

.text { padding-block: 1.6rem 4rem; }

.verse {
  display: grid;
  grid-template-columns: 3.1rem 1fr;
  gap: 0 0.7rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule-2);
}
.verse:last-child { border-bottom: none; }
.verse:target { background: var(--sea-soft); border-radius: 4px; }

.vn {
  grid-column: 1;
  text-align: right;
  font-size: 0.86rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  padding-top: 0.55rem;
  text-decoration: none;
}
.vn:hover { color: var(--sea); }

.mt {
  grid-column: 2;
  direction: rtl;
  text-align: right;
  font-family: var(--heb);
  font-size: 1.72rem;
  line-height: 2.0;
  font-weight: 400;
}

.witness {
  grid-column: 2;
  display: grid;
  grid-template-columns: 5.4rem 1fr;
  gap: 0.5rem 0.8rem;
  align-items: baseline;
  margin-top: 0.55rem;
  padding: 0.5rem 0.75rem 0.6rem;
  background: var(--leather);
  border-radius: 4px;
  border-inline-start: 2px solid var(--leather-2);
}

.witness .sg {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--scribe);
  opacity: 0.72;
  direction: ltr;
  white-space: nowrap;
  padding-top: 0.5rem;
}

.dss {
  direction: rtl;
  text-align: right;
  font-family: var(--scroll);
  font-size: 1.5rem;
  line-height: 1.95;
  color: var(--scribe);
}

.nowit {
  grid-column: 2;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--ink-3);
}

/* --- words --------------------------------------------------------------- */

.w { position: relative; cursor: help; border-radius: 2px; }
.w:hover, .w.on { background: var(--sea-soft); box-shadow: 0 0 0 2px var(--sea-soft); }

/* a word with a qere: the circellus of the printed editions, as a dotted rule */
.w.q { border-bottom: 1px dotted var(--sea); }

.rec { color: var(--rec); }
.rec.mid { visibility: hidden; }       /* deep inside a lacuna: keeps its width */
.blank { cursor: default; }
.blank:hover, .blank.on { background: none; box-shadow: none; }
.traces { color: var(--traces); }

/* --- the morphology card ------------------------------------------------- */

#card {
  position: fixed;
  z-index: 40;
  display: none;
  direction: ltr;
  text-align: left;
  min-width: 13rem;
  max-width: 22rem;
  padding: 0.75rem 0.9rem 0.8rem;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 5px;
  box-shadow: 0 12px 30px rgba(23,20,15,.16), 0 2px 6px rgba(23,20,15,.08);
  font-family: var(--lat);
  font-size: 0.9rem;
  line-height: 1.5;
}

#card .hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.9rem;
  padding-bottom: 0.45rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule-2);
}
#card .lx { font-family: var(--heb); font-size: 1.5rem; direction: rtl; line-height: 1.3; }
#card .gl { font-style: italic; color: var(--ink-2); text-align: right; }
#card .code { font-family: var(--mono); font-size: 0.76rem; color: var(--sea); }

#card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.9rem; margin: 0; }
#card dt { color: var(--ink-3); font-size: 0.82rem; }
#card dd { margin: 0; font-size: 0.86rem; }
#card .qr { margin-top: .45rem; padding-top: .45rem; border-top: 1px solid var(--rule-2); font-size:.82rem; color: var(--ink-2); }
#card .qr b { font-family: var(--heb); font-size: 1.15rem; font-weight: 400; color: var(--ink); direction: rtl; }

/* --- legend and footer --------------------------------------------------- */

.legend {
  margin: 2.4rem 0 0;
  padding: 1.1rem 1.3rem 1.2rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 5px;
  font-size: 0.9rem;
  color: var(--ink-2);
}
.legend h2 { margin: 0 0 0.5rem; font-size: 0.95rem; font-weight: 600; color: var(--ink); }
.legend dl { display: grid; grid-template-columns: 6.5rem 1fr; gap: 0.35rem 1rem; margin: 0; }
.legend dt { font-family: var(--scroll); font-size: 1.2rem; direction: rtl; text-align: right; color: var(--scribe); }
.legend dd { margin: 0; }
.legend p { margin: 0.9rem 0 0; }
.legend .k { color: var(--ink); font-weight: 500; }

footer {
  border-top: 1px solid var(--rule);
  margin-top: 3.5rem;
  padding-block: 1.6rem 3rem;
  font-size: 0.84rem;
  color: var(--ink-3);
}
footer p { margin: 0 0 0.4rem; max-width: 46rem; }

/* --- narrow screens ------------------------------------------------------ */

@media (max-width: 46rem) {
  :root { --cell: 3px; --wrap: 100%; }
  .wrap { padding: 0 1rem; }
  .title h1 { font-size: 1.9rem; }
  .title .he { font-size: 1.6rem; }
  .title .subtitle { font-size: 1.04rem; }
  .book-row { grid-template-columns: 1fr auto; gap: 0.4rem 1rem; padding-block: 0.85rem; }
  .book-row .stripe { grid-column: 1 / -1; }
  .verse { grid-template-columns: 2.2rem 1fr; }
  .mt { font-size: 1.5rem; line-height: 1.95; }
  .dss { font-size: 1.32rem; }
  .witness { grid-template-columns: 1fr; gap: 0.1rem; }
  .witness .sg { padding-top: 0.2rem; }
  #card { max-width: calc(100vw - 2rem); }
}

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

/* the pointing choice is remembered; hide the text for the one frame it takes
   to apply it, so a reader who chose consonants never sees the points flash */
.pending .text { visibility: hidden; }

.pager-b { margin: 0.9rem 0 0; }
