/* styles.css v1.1.0 */
/* Layout idea: one narrow reading column, booklet colors, fixed bottom tabs on phones. */
:root {
  color-scheme: light;
  --navy: #0B2059;
  --navy-soft: #23376e;
  --gold: #C8921A;
  --gold-soft: #F1D48A;
  --cream: #FFF6DE;
  --paper: #FBFAF6;
  --card: #FFFFFF;
  --ink: #161B24;
  --muted: #5F677A;
  --line: #E4DFD0;
  --good: #2E7D32;
  --font-en: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-he: "Frank Ruhl Libre", "Times New Roman", serif;
  --fs: 1;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-en);
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: 76px;
}
a { color: var(--navy); }
img { max-width: 100%; height: auto; display: block; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { text-wrap: balance; line-height: 1.2; margin: 0; }
[lang="he"] { font-family: var(--font-he); }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--navy); color: #fff;
  padding: 10px 16px;
}
.brand { display: flex; align-items: baseline; gap: 10px; color: #fff; text-decoration: none; }
.brand-he { font-size: 24px; font-weight: 700; color: var(--gold-soft); }
.brand-en { font-weight: 700; letter-spacing: .01em; }
.top-link { color: var(--gold-soft); font-size: 14px; font-weight: 600; text-decoration: none; }

main { max-width: 760px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
main:focus { outline: none; }
.loading, .empty { color: var(--muted); padding: 24px 0; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; padding: 4px 0;
  border-radius: 10px;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--navy); }
.tabs a.on svg { stroke-width: 2.2; }

/* Day header */
.day {
  background: var(--navy); color: #fff; border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.day .eyebrow { color: var(--gold-soft); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.day h1 { font-size: 24px; font-weight: 800; }
.day .dates { color: #D5DBEE; font-size: 14px; }
.day .note { background: rgba(255,255,255,.12); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.day-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--navy); background: var(--navy); color: #fff;
  border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 14px; text-decoration: none;
}
.btn.gold { background: var(--gold-soft); border-color: var(--gold-soft); color: var(--navy); }
.btn.ghost { background: transparent; color: var(--navy); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: default; }

/* Chapter block */
.chapter { display: flex; flex-direction: column; gap: 10px; }
.chapter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--navy); padding-bottom: 6px; }
.chapter-head h2 { font-size: 19px; color: var(--navy); font-weight: 800; }
.chapter-head .count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.row {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; text-decoration: none; color: inherit;
}
.row:hover { border-color: var(--gold); }
.badge {
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  background: var(--cream); color: var(--navy); font-weight: 800; font-size: 15px;
  border: 1px solid var(--gold-soft); font-variant-numeric: tabular-nums;
}
.row.aux .badge { background: var(--navy); color: var(--gold-soft); border-color: var(--navy); font-size: 11px; }
.row-title { font-weight: 700; color: var(--navy); line-height: 1.3; }
.row-sub { color: var(--muted); font-size: 13.5px; line-height: 1.35; }
.row-part { color: var(--gold); font-size: 12px; font-weight: 700; }
.tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; font-size: 13px; font-weight: 800; }
.tick.done { background: var(--good); border-color: var(--good); color: #fff; }

/* Reader */
.crumb { color: var(--muted); font-size: 13px; font-weight: 600; }
.crumb a { color: var(--muted); }
.reader-head { display: flex; flex-direction: column; gap: 4px; }
.pill {
  align-self: flex-start; background: linear-gradient(#F3D77D, #D9A520); color: var(--navy);
  font-weight: 800; border-radius: 999px; padding: 4px 14px; font-size: 14px;
}
.reader-head h1 { font-size: 24px; color: var(--navy); font-weight: 800; }
.reader-head .sub { color: var(--muted); }
.scene { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #EDEAE0; padding: 0; width: 100%; display: block; }
.scene img { width: 100%; }
.hint { color: var(--muted); font-size: 12.5px; text-align: center; margin: -8px 0 0; }
.saying { background: var(--cream); border-left: 5px solid var(--gold); border-radius: 10px; padding: 12px 14px; }
.saying .label { color: var(--navy); font-size: 11.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.saying p { margin: 4px 0 0; font-weight: 700; font-size: calc(16.5px * var(--fs)); line-height: 1.45; }
.block { display: flex; flex-direction: column; gap: 8px; }
.block h2 { font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.english p { margin: 0 0 10px; font-size: calc(16.5px * var(--fs)); max-width: 65ch; }
.english b { font-weight: 700; color: var(--ink); }
.english span { color: #5A6172; }
.english .key { font-size: 12.5px; color: var(--muted); }
.hebrew p { margin: 0; font-family: var(--font-he); font-size: calc(21px * var(--fs)); line-height: 1.75; }
.hebrew .key { font-family: var(--font-en); font-size: 12.5px; color: var(--muted); direction: ltr; text-align: left; }
.sizer { display: inline-flex; gap: 6px; }
.sizer button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 2px 9px; font-weight: 700; color: var(--navy); }
.reader-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pager .btn { padding: 12px; }
.textpage p { margin: 0 0 8px; max-width: 65ch; }

/* Study view and reading controls */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--navy); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--navy); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--card); color: var(--muted); padding: 6px 12px; font-weight: 600; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--navy); color: #fff; }
.study { display: flex; flex-direction: column; gap: 14px; }
.chapter-head a.count { color: var(--navy); font-weight: 600; }
.st { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.st h3 { font-size: 17px; }
.st h3 a { color: var(--navy); text-decoration: none; display: block; }
.st h3 small { color: var(--gold); font-size: 12px; font-weight: 700; white-space: nowrap; }
.st-num { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; margin-right: 6px; border-radius: 8px; background: var(--cream); border: 1px solid var(--gold-soft); font-size: 14px; font-variant-numeric: tabular-nums; }
.st-cols { display: flex; flex-direction: column-reverse; gap: 12px; }
.st-sum { margin: 0; background: var(--cream); border-left: 4px solid var(--gold); border-radius: 8px; padding: 8px 12px; font-size: calc(15px * var(--fs)); }
.heb-img { width: 100%; border-radius: 8px; cursor: zoom-in; }
.heb-img + .heb-img { margin-top: 8px; }
.no-pics .st-pic { display: none; }
.lang-he .st-en { display: none; }
.lang-en .st-he { display: none; }
@media (min-width: 820px) {
  .st-cols { flex-direction: row; align-items: flex-start; }
  .st-cols > div { flex: 1; min-width: 0; }
}

/* Browse */
.section-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.section-card h2 { font-size: 18px; color: var(--navy); font-weight: 800; }
.section-card .en { color: var(--muted); font-size: 13.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--gold-soft); background: var(--cream); color: var(--navy); border-radius: 10px; padding: 7px 12px; font-weight: 700; font-size: 14px; text-decoration: none; }
.chip small { font-weight: 500; color: var(--muted); }

/* Search and ask */
.field { display: flex; gap: 8px; }
.field input, .ask-box textarea {
  flex: 1; width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}
.field input:focus, .ask-box textarea:focus { border-color: var(--navy); outline: none; }
.help { color: var(--muted); font-size: 13.5px; margin: 0; }
.result { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: inherit; display: block; }
.result .where { color: var(--gold); font-weight: 800; font-size: 12.5px; letter-spacing: .04em; }
.result .title { color: var(--navy); font-weight: 700; }
.result .snip { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.result .snip[dir="rtl"] { font-family: var(--font-he); font-size: 17px; }
mark { background: #FBE7A6; color: inherit; border-radius: 3px; padding: 0 1px; }
.ask-box { display: flex; flex-direction: column; gap: 10px; }
.ask-box textarea { min-height: 96px; resize: vertical; }
.examples { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.examples button { border: 1px dashed var(--gold); background: transparent; color: var(--navy); border-radius: 10px; padding: 6px 10px; font-size: 14px; text-align: left; }
.answer { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; white-space: pre-wrap; }
.answer.error { border-color: #C9792B; background: #FFF4E8; }
.fine { color: var(--muted); font-size: 12.5px; margin: 0; }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-head h1 { font-size: 20px; color: var(--navy); font-weight: 800; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1 / 1; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none; font-variant-numeric: tabular-nums;
}
.cal-cell.blank { border: 0; background: transparent; }
.cal-cell.has { color: var(--navy); border-color: var(--gold-soft); background: var(--cream); }
.cal-cell.has::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.cal-cell.prev::after { background: transparent; border: 1.5px solid var(--gold); }
.cal-cell.today { outline: 2px solid var(--navy); outline-offset: -2px; }
.cal-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.cal-list a { display: flex; justify-content: space-between; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; text-decoration: none; color: inherit; }
.cal-list .d { font-weight: 700; color: var(--navy); white-space: nowrap; }
.cal-list .l { color: var(--muted); text-align: right; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-right: 5px; }
.legend i.o { background: transparent; border: 1.5px solid var(--gold); }

/* About */
.prose h1 { font-size: 24px; color: var(--navy); font-weight: 800; margin-bottom: 8px; }
.prose h2 { font-size: 17px; color: var(--navy); margin: 14px 0 4px; }
.prose p { margin: 0 0 10px; max-width: 65ch; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: #0A1022; display: flex; flex-direction: column; }
.lightbox[hidden] { display: none; }
.lightbox-bar { display: flex; justify-content: space-between; padding: 10px 12px; gap: 8px; }
.lightbox-bar button { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; }
.lightbox-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; display: flex; align-items: flex-start; }
.lightbox-scroll img { width: 100%; max-width: none; margin: auto; }
.lightbox-scroll.zoom img { width: 240%; margin: 0; }

@media (min-width: 820px) {
  .tabs { justify-content: center; gap: 8px; }
  .tabs a { flex: 0 0 auto; flex-direction: row; gap: 6px; font-size: 14px; padding: 8px 16px; }
  .tabs svg { width: 18px; height: 18px; }
  main { padding-top: 24px; }
  .lightbox-scroll.zoom img { width: 170%; }
}
@media (prefers-reduced-motion: no-preference) {
  .row, .chip, .btn { transition: border-color .15s, background-color .15s; }
}
