/* Layout */

.layout { align-items: start; }

.reader { padding: 48px 40px 96px; min-width: 0; }
.reader > * { max-width: var(--measure); margin-inline: auto; }

/* Chapter */

.chapter-head { text-align: center; margin-bottom: 40px; }

.chapter-head h1 {
  margin: 0;
  font: 600 calc(2.4rem * var(--scale)) / 1.2 var(--reading);
  color: var(--text);
}

.chapter-head p {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.prose > p, .verse .hebrew {
  margin: 0 0 1.1em;
  font: calc(1.75rem * var(--scale)) / var(--leading) var(--reading);
  text-align: justify;
}

.w {
  border-radius: 6px;
  padding: 0.04em 0.06em;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

@media (hover: hover) {
  .w:hover { background: var(--hover); }
  .vn:hover { background: var(--accent-soft); }
}

.w.in-verse { background: var(--verse-soft); }
.w.sel { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-line); }

.vn {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.1em 0.35em;
  border-radius: 99px;
  font: 600 0.42em/1.4 var(--sans);
  text-align: center;
  vertical-align: 0.9em;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  font-variant-numeric: tabular-nums;
}

.lead { white-space: nowrap; }

.ribbon {
  display: inline-block;
  width: 0.8em;
  height: 1.4em;
  margin-inline-start: 0.3em;
  vertical-align: -0.35em;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%);
}

.ribbon-0 { background: var(--ink-0); }
.ribbon-1 { background: var(--ink-1); }
.ribbon-2 { background: var(--ink-2); }
.focus-ref .ribbon { font-size: 14px; }
.vn.sel { background: var(--accent); color: var(--bg); }
.hebrew-numerals .vn { font: 600 0.55em/1.4 var(--reading); vertical-align: 0.7em; }

.setuma { display: inline-block; width: 1.8em; }
.pmark { font-size: 0.7em; color: var(--faint); }

.verses { display: grid; }

.verse {
  padding: 14px 16px;
  margin-inline: -16px;
  transition: background 0.15s;
}

.verse + .verse { border-top: 1px solid var(--line); }
.verse.sel { background: var(--verse-soft); border-color: transparent; border-radius: 14px; }
.verse.sel + .verse { border-color: transparent; }

.verse .hebrew { margin: 0 0 6px; }

.verse .english {
  margin: 0;
  font: calc(1.08rem * var(--scale)) / calc(var(--leading) * 0.75) var(--serif);
  color: var(--muted);
  cursor: pointer;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.chapter-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 0.15s, transform 0.15s;
}

.chapter-link:hover { border-color: var(--accent-line); }
.chapter-link.i-right { flex-direction: row-reverse; text-align: right; }
.chapter-link .i { color: var(--accent); }
.chapter-link .label { display: block; font-size: 12px; color: var(--muted); }
.chapter-link .ref { font-weight: 600; }

.chapter + .chapter { margin-top: 64px; padding-top: 56px; border-top: 1px solid var(--line); }
.scroll-chapter + .scroll-chapter { break-before: column; }
html:has(.continuous), html:has(.continuous) body, .continuous .scroller { overflow-anchor: none; }

/* Interlinear */

.interlinear { display: grid; }

.il-verse { padding: 14px 12px; margin-inline: -12px; }
.il-verse + .il-verse { border-top: 1px solid var(--line); }
.il-verse.sel { background: var(--verse-soft); border-radius: 14px; border-color: transparent; }
.il-verse.sel + .il-verse { border-color: transparent; }

.il-words { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 2px; }

.il-words .vn { font-size: 12px; vertical-align: 0; margin: 0.7em 0 0 6px; }
.hebrew-numerals .il-words .vn { font-size: 15px; }

.cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  max-width: 8.5rem;
  padding: 2px 7px 7px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}

.cell-he { font: calc(1.6rem * var(--scale)) / calc(var(--leading) * 0.8) var(--reading); white-space: nowrap; }

.cell-gloss {
  font: 500 calc(0.74rem * var(--scale)) / 1.25 var(--sans);
  color: var(--muted);
  text-align: center;
}

@media (hover: hover) { .cell:hover { background: var(--hover); } }
.cell.in-verse { background: var(--verse-soft); }
.cell.sel { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.cell.sel .cell-he, .cell.sel .cell-gloss { color: var(--accent-text); }

.il-verse .english {
  margin: 8px 0 0;
  font: calc(1.02rem * var(--scale)) / 1.6 var(--serif);
  color: var(--muted);
  cursor: pointer;
}

/* Scroll */

.app.layout-scroll .reader { padding: 0; }
.layout-scroll .reader > * { max-width: none; }

.scroller {
  height: calc(var(--app-h) - var(--bar-h) - var(--dock-h));
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: none;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.scroll-sheet {
  height: 100%;
  --sheet-pad: 64px;
  padding: 36px var(--sheet-pad) 28px;
  column-width: min(calc(19rem * var(--scale)), calc(100vw - 72px));
  column-gap: 64px;
  column-rule: 1px solid var(--line);
  column-fill: auto;
}

.scroll-chapter > p {
  margin: 0 0 0.9em;
  font: calc(1.55rem * var(--scale)) / var(--leading) var(--reading);
  text-align: justify;
}

.scroll-sheet::after { content: ""; display: block; position: relative; inset-inline-start: var(--end-pad, var(--sheet-pad)); height: 1px; margin-top: -1px; }

.scroll-sheet .chapter-head { margin-bottom: 24px; break-inside: avoid; break-after: avoid; }

.scroll-verse { margin: 0 -10px 0.9em; padding: 2px 10px; border-radius: 10px; transition: background 0.15s; }
.scroll-verse.sel { background: var(--verse-soft); }
.scroll-verse .hebrew { margin: 0; font: calc(1.55rem * var(--scale)) / var(--leading) var(--reading); text-align: justify; }

.scroll-verse .english {
  margin: 2px 0 0;
  font: calc(0.98rem * var(--scale)) / 1.55 var(--serif);
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.scroll-edge { display: flex; justify-content: center; break-inside: avoid; }
.scroll-edge.start { margin-bottom: 20px; }
.scroll-edge.end { margin-top: 32px; }
.scroll-edge:not(:has(a)) { display: none; }

@supports (anchor-name: --a) {
  .scroll-sheet { position: relative; --edge-w: 160px; }
  .scroll-sheet:has(.scroll-edge.start a) { padding-inline-start: var(--edge-w); }
  .scroll-sheet:has(.scroll-edge.end a) { --end-pad: var(--edge-w); }
  .scroll-sheet .scroll-chapter { anchor-name: --scroll-chapter; }
  .scroll-edge { position: absolute; top: 50%; margin: 0; translate: -50% -50%; }
  .scroll-edge.start { left: calc(anchor(--scroll-chapter right) + var(--edge-w) / 2); }
  .scroll-edge.end { left: calc(anchor(--scroll-chapter left) - var(--edge-w) / 2); }
  .scroll-edge .chapter-link, .scroll-edge .chapter-link.i-right { flex-direction: column; gap: 6px; max-width: calc(var(--edge-w) - 24px); text-align: center; }
  .scroll-edge .ref { white-space: nowrap; }
}

html:has(.layout-scroll), html:has(.layout-scroll) body { height: 100%; overflow: hidden; overscroll-behavior: none; }

.layout-scroll .reader::before,
.layout-scroll .reader::after {
  content: "";
  position: fixed;
  top: var(--bar-h);
  bottom: 0;
  z-index: 5;
  width: 36px;
  pointer-events: none;
}

.layout-scroll .reader::before { right: 0; background: linear-gradient(to left, color-mix(in srgb, var(--text) 10%, transparent), transparent); }
.layout-scroll .reader::after { left: 0; background: linear-gradient(to right, color-mix(in srgb, var(--text) 10%, transparent), transparent); }

/* Focus */

.app.layout-focus .reader { padding: 0; }
.layout-focus .reader > * { max-width: none; }

.focus {
  min-height: calc(var(--app-h) - var(--bar-h) - var(--dock-h));
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 28px 24px 28px;
  transition: padding 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.focus-ref { display: grid; justify-items: center; gap: 2px; font-size: 12px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.focus-ref-he { font: 600 1.15rem var(--reading); letter-spacing: 0; text-transform: none; color: var(--text); }

.focus-stage { display: grid; place-items: center; padding: 24px 0; }

.focus-verse {
  max-width: 50rem;
  text-align: center;
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.focus-hebrew { margin: 0; font: calc(2.8rem * var(--scale)) / var(--leading) var(--reading); }

.focus-verse .english {
  max-width: 38rem;
  margin: 28px auto 0;
  font: calc(1.2rem * var(--scale)) / 1.6 var(--serif);
  color: var(--muted);
}

.focus-controls { display: flex; align-items: center; gap: 18px; width: 100%; max-width: 32rem; margin: 0 auto; }

.focus-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.focus-btn:hover { border-color: var(--accent-line); }
.focus-btn:active { transform: scale(0.94); }

.focus-meter { flex: 1; display: grid; gap: 8px; justify-items: center; }
.focus-track { position: relative; width: 100%; height: 4px; border-radius: 99px; background: var(--line); overflow: hidden; }
.focus-track span { position: absolute; top: 0; right: 0; bottom: 0; border-radius: inherit; background: var(--accent); transition: width 0.3s ease; }
.focus-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
