/* Optional text fonts (only downloaded when selected). Licenses in /fonts/licenses/ */
@font-face { font-family: "Taamey D"; src: url(/fonts/TaameyD.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Shofar"; src: url(/fonts/ShofarD.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Taamey Ashkenaz"; src: url(/fonts/TaameyAshkenaz.ttf) format("truetype"); font-display: swap; }
@font-face { font-family: "Keter Aram Tsova"; src: url(/fonts/KeterAramTsova.ttf) format("truetype"); font-display: swap; }
@font-face { font-family: "Keter YG"; src: url(/fonts/KeterYG.ttf) format("truetype"); font-display: swap; }
@font-face { font-family: "Ezra SIL"; src: url(/fonts/EzraSIL.ttf) format("truetype"); font-display: swap; }

:root {
  --text-font: "Ezra SIL";
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #efe9df;
  --fg: #1d1b18;
  --muted: #6b655c;
  --faint: #a59d91;
  --line: #e2dbcf;
  --accent: #7a4b1e;
  --accent-fg: #ffffff;
  --accent-soft: #f1e4d4;
  --done: #3c7a4a;
  --shadow: 0 1px 2px #0000000f, 0 4px 16px #0000000d;
  --heb: "Noto Serif Hebrew", "SBL Hebrew", "Times New Roman", serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text-scale: 1;
  --player-h: 168px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171512; --surface: #221f1b; --surface-2: #2b2722; --fg: #ece6dc; --muted: #a39b8f; --faint: #6f685e;
    --line: #36312a; --accent: #e0a868; --accent-fg: #1d1408; --accent-soft: #3a2c1c; --done: #7cc28c;
    --shadow: 0 1px 2px #0006, 0 4px 16px #0004;
  }
}
:root[data-theme="dark"] {
  --bg: #171512; --surface: #221f1b; --surface-2: #2b2722; --fg: #ece6dc; --muted: #a39b8f; --faint: #6f685e;
  --line: #36312a; --accent: #e0a868; --accent-fg: #1d1408; --accent-soft: #3a2c1c; --done: #7cc28c;
  --shadow: 0 1px 2px #0006, 0 4px 16px #0004;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 var(--ui);
  padding-bottom: calc(var(--player-h) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.he { font-family: var(--heb); direction: rtl; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { flex: 1; text-align: center; font-size: 17px; font-weight: 600; color: var(--accent); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); }
.icon-btn:active { background: var(--surface-2); }
#backBtn:not([hidden]) + .brand { margin-right: 0; }

main { max-width: 720px; margin: 0 auto; padding: 16px; }

/* ---------- home ---------- */
.card {
  background: var(--surface); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px;
  display: block; width: 100%; text-align: start;
}
.card .label { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.card .big { font-family: var(--heb); font-size: 34px; line-height: 1.2; margin: 6px 0 2px; direction: rtl; text-align: right; }
.card .sub { color: var(--muted); font-size: 15px; display: flex; justify-content: space-between; gap: 8px; }
.card.hero { background: var(--accent); color: var(--accent-fg); }
.card.hero .label, .card.hero .sub { color: color-mix(in srgb, var(--accent-fg) 78%, transparent); }
.card .cta { margin-top: 14px; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.card.hero .cta { background: color-mix(in srgb, var(--accent-fg) 18%, transparent); padding: 8px 14px; border-radius: 999px; }
.resume .bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 12px; overflow: hidden; }
.resume .bar > i { display: block; height: 100%; background: var(--accent); }

h2.section { font-size: 15px; color: var(--muted); font-weight: 600; margin: 26px 4px 10px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; direction: rtl; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow);
  font-family: var(--heb); font-size: 16px; white-space: nowrap;
}
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-fg); }
.plist { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.plist li + li { border-top: 1px solid var(--line); }
.plist button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-align: start; min-height: 60px; }
.plist button:active { background: var(--surface-2); }
.plist .names { flex: 1; min-width: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.plist .en { color: var(--muted); font-size: 14px; }
.plist .hename { font-family: var(--heb); font-size: 20px; direction: rtl; }
.plist .tag { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 999px; margin-inline-start: 6px; }
.ring { flex: none; width: 26px; height: 26px; }
.ring circle { fill: none; stroke-width: 3; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--accent); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; }
.ring.complete .fg { stroke: var(--done); }
.this-week { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: inherit; }

/* ---------- parsha view ---------- */
.ptitle { text-align: center; margin: 4px 0 14px; }
.ptitle .he { font-family: "Taamey D", var(--heb); font-size: 40px; display: block; line-height: 1.2; }
.card .big { font-family: "Taamey D", var(--heb); }
.thead-actions { display: flex; align-items: center; gap: 10px; }
.tg-toggle {
  font-family: var(--heb); font-size: 14px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); min-height: 32px;
}
.tg-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.ptitle .en { color: var(--muted); font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; direction: rtl; margin-bottom: 18px; }
.chip {
  font-family: var(--heb); font-size: 15px; padding: 7px 12px; border-radius: 12px; background: var(--surface);
  box-shadow: var(--shadow); display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
}
.chip small { font-family: var(--ui); font-size: 12px; color: var(--muted); }
.chip.done { color: var(--done); }
.chip.done::after { content: "✓"; font-family: var(--ui); font-size: 13px; }
.chip.current { background: var(--accent); color: var(--accent-fg); }
.chip.current small { color: inherit; opacity: .8; }
.chip.viewing { outline: 2px solid var(--accent); outline-offset: -2px; }
.chip.missing { opacity: .45; box-shadow: none; border: 1px dashed var(--faint); cursor: default; }

.textbox { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 18px 18px 8px; }
.textbox .thead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 8px; }
.textbox .thead .he { font-size: 22px; font-weight: 600; }
.textbox .thead .ref { color: var(--muted); font-size: 13px; }
.verses { direction: rtl; text-align: right; }
.verse { padding: 10px 0; border-bottom: 1px solid var(--line); }
.verse:last-child { border-bottom: 0; }
.verse .mikra, .font-preview { font-family: var(--text-font), var(--heb); }
.verse .targum { font-family: var(--heb); }
.verse .mikra { font-size: calc(23px * var(--text-scale)); line-height: 1.85; }
.verse .num { font-family: var(--heb); font-size: calc(14px * var(--text-scale)); color: var(--accent); font-weight: 600; margin-left: 6px; }
.verse .targum { font-size: calc(18px * var(--text-scale)); line-height: 1.75; color: var(--muted); margin-top: 4px; }
body.no-targum .targum { display: none; }
.hpart { font-size: 13px; color: var(--muted); padding: 10px 0 0; direction: ltr; text-align: left; }
.note { color: var(--muted); font-size: 14px; text-align: center; padding: 18px 8px; }

/* ---------- player ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface);
  border-top: 1px solid var(--line); box-shadow: 0 -4px 20px #0000001a;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.player > * { max-width: 688px; margin-left: auto; margin-right: auto; }
.p-info { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; cursor: pointer; }
.p-title { font-family: var(--heb); font-size: 18px; direction: rtl; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; order: 2; }
.p-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-seek { display: flex; align-items: center; gap: 10px; margin: 6px auto 2px; }
.time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 38px; }
.time:last-child { text-align: right; }
#seek { flex: 1; accent-color: var(--accent); height: 28px; }
.p-controls { display: flex; align-items: center; justify-content: space-between; }
.ctl { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; }
.ctl:active { background: var(--surface-2); }
.ctl.small { width: 52px; font-size: 15px; font-weight: 700; color: var(--accent); }
.ctl.play { width: 64px; height: 64px; background: var(--accent); color: var(--accent-fg); }
.ctl.play:active { filter: brightness(.92); background: var(--accent); }
.ctl.play .i-pause { display: none; }
.player.playing .ctl.play .i-play { display: none; }
.player.playing .ctl.play .i-pause { display: block; }
.ctl:disabled { opacity: .3; }
.spacer { visibility: hidden; }
.player.loading .ctl.play { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .6; } }

/* ---------- settings ---------- */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(420px, calc(100vw - 32px));
  background: var(--surface); color: var(--fg); box-shadow: 0 10px 40px #0004;
}
dialog::backdrop { background: #0006; }
dialog form { padding: 20px; }
dialog h2 { margin: 0 0 10px; font-size: 20px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: inherit; }
.row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.stepper { display: flex; gap: 6px; }
.stepper button { font-family: var(--heb); padding: 6px 12px; border-radius: 8px; background: var(--surface-2); font-size: 16px; }
.font-preview {
  direction: rtl; text-align: right; font-size: calc(22px * var(--text-scale)); line-height: 1.8;
  background: var(--surface-2); border-radius: 10px; padding: 8px 12px; margin: 10px 0 2px;
}
.credits { font-size: 12px; color: var(--muted); margin: 14px 0; }
.done { width: 100%; padding: 12px; border-radius: 12px; background: var(--accent); color: var(--accent-fg); font-weight: 600; }

@media (min-width: 600px) {
  .card .big { font-size: 40px; }
}
