/* Ner Chaim — a printed sefer by candlelight */
:root {
  --paper: #f6efe2;
  --paper-2: #efe5d2;
  --ink: #2a2018;
  --ink-soft: #6b5a48;
  --rule: #d9c9ad;
  --flame: #c8741f;
  --flame-2: #e9a23b;
  --glow: rgba(233, 162, 59, .18);
  --card: #fbf6ec;
  --serif: "EB Garamond", "Iowan Old Style", Georgia, serif;
  --display: "Cormorant", "EB Garamond", Georgia, serif;
  --heb: "Frank Ruhl Libre", "Times New Roman", serif;
  --measure: 38rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17120d; --paper-2: #1f1811; --ink: #efe3cf; --ink-soft: #b09c82; --rule: #3a2f24;
    --flame: #e9a23b; --flame-2: #ffcf7a; --glow: rgba(255, 190, 90, .10); --card: #1d1610;
  }
}
:root[data-theme="dark"] {
  --paper: #17120d; --paper-2: #1f1811; --ink: #efe3cf; --ink-soft: #b09c82; --rule: #3a2f24;
  --flame: #e9a23b; --flame-2: #ffcf7a; --glow: rgba(255, 190, 90, .10); --card: #1d1610;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 400 1.18rem/1.7 var(--serif);
  background:
    radial-gradient(60rem 40rem at 50% -10rem, var(--glow), transparent 70%),
    var(--paper);
  min-height: 100vh;
}
body::before {               /* faint paper grain */
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .35; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: inherit; }
[lang="he"] { font-family: var(--heb); font-size: 1.06em; line-height: 1.5; unicode-bidi: isolate; }

/* flame mark */
.flame { display: inline-block; width: .62em; height: .95em; position: relative; vertical-align: -.1em; }
.flame::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 70%, var(--flame-2) 0 30%, var(--flame) 55%, transparent 72%);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  filter: blur(.3px); animation: flicker 3.2s ease-in-out infinite; transform-origin: 50% 100%;
}
.flame.big { width: 2.2rem; height: 3.3rem; }
.flame.small { width: .55em; height: .85em; margin-right: .5em; }
@keyframes flicker {
  0%, 100% { transform: scale(1, 1) rotate(-1deg); opacity: .95; }
  30% { transform: scale(.96, 1.04) rotate(1.5deg); opacity: 1; }
  60% { transform: scale(1.03, .97) rotate(-.5deg); opacity: .9; }
}
@media (prefers-reduced-motion: reduce) { .flame::before { animation: none; } }

/* header / footer */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: .7rem clamp(1rem, 4vw, 2.5rem); background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule);
}
.mark { display: flex; gap: .55rem; align-items: center; text-decoration: none; font: 600 1.35rem var(--display); letter-spacing: .02em; }
.top nav { display: flex; gap: 1.2rem; align-items: center; font-size: 1rem; }
.top nav a { text-decoration: none; color: var(--ink-soft); }
.top nav a:hover { color: var(--flame); }
.theme { background: none; border: 1px solid var(--rule); color: var(--ink-soft); border-radius: 50%; width: 2rem; height: 2rem; cursor: pointer; }
.foot { text-align: center; color: var(--ink-soft); font-size: .95rem; padding: 3rem 1rem 4rem; border-top: 1px solid var(--rule); margin-top: 4rem; }

/* home */
.hero { text-align: center; padding: clamp(3rem, 10vh, 7rem) 1rem 2.5rem; }
.title-heb { font-size: clamp(2rem, 6vw, 3rem); margin: 1rem 0 0; color: var(--ink-soft); }
.hero h1 { font: 500 clamp(3.2rem, 10vw, 6.2rem)/1 var(--display); margin: .2rem 0 .8rem; letter-spacing: .01em; }
.by { font-style: italic; color: var(--ink-soft); margin: 0 0 2.2rem; }
.hero-search, .search-form { display: flex; max-width: 34rem; margin: 0 auto; border: 1px solid var(--rule); background: var(--card); border-radius: 999px; padding: .3rem; box-shadow: 0 8px 30px -18px rgba(60, 35, 10, .5); }
.hero-search input, .search-form input[type=search], #q { flex: 1; border: 0; background: none; font: inherit; color: var(--ink); padding: .55rem 1rem; outline: none; min-width: 0; }
.hero-search button { border: 0; border-radius: 999px; background: var(--ink); color: var(--paper); font: inherit; padding: .4rem 1.2rem; cursor: pointer; }
.week { max-width: 60rem; margin: 1rem auto 0; padding: 0 1rem; }
.week-inner { border: 1px solid var(--rule); background: var(--card); border-radius: 14px; padding: 1.4rem 1.6rem; position: relative; overflow: hidden; }
.week-inner::after { content: ""; position: absolute; right: -4rem; top: -4rem; width: 14rem; height: 14rem; background: radial-gradient(var(--glow), transparent 70%); }
.week .eyebrow { margin: 0; }
.week h2 { font: 500 2rem var(--display); margin: .1rem 0 .6rem; }
.week ul { list-style: none; padding: 0; margin: 0; columns: 2 16rem; column-gap: 2rem; }
.week li { break-inside: avoid; padding: .25rem 0; }
.week li a { text-decoration: none; border-bottom: 1px solid transparent; }
.week li a:hover { border-color: var(--flame); }
.week small { color: var(--ink-soft); }
.books { max-width: 72rem; margin: 3rem auto 0; padding: 0 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr)); gap: 1rem; }
.card {
  position: relative; text-decoration: none; background: var(--card); border: 1px solid var(--rule); border-radius: 14px;
  padding: 1.6rem 1.3rem 1.3rem; display: flex; flex-direction: column; min-height: 15rem;
  transition: transform .35s cubic-bezier(.2, .7, .2, 1), box-shadow .35s; animation: rise .8s both; animation-delay: calc(var(--i) * 90ms);
}
.card:hover { transform: translateY(-4px); box-shadow: 0 18px 40px -24px rgba(80, 45, 10, .6); }
.card .n { font: italic 500 1rem var(--display); color: var(--flame); }
.card .heb { font-size: 2.1rem; margin-top: auto; }
.card .name { font: 500 1.9rem/1.1 var(--display); }
.card .eng { color: var(--ink-soft); font-style: italic; }
.card .meta { margin-top: .8rem; font-size: .9rem; color: var(--ink-soft); border-top: 1px solid var(--rule); padding-top: .6rem; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* book page */
.eyebrow { text-transform: uppercase; letter-spacing: .22em; font-size: .78rem; color: var(--flame); margin: 0; }
.book, .essay, .search { max-width: 64rem; margin: 0 auto; padding: 2.5rem clamp(1rem, 4vw, 2rem); }
.book-head { text-align: center; margin-bottom: 2.5rem; }
.book-head h1 { font: 500 clamp(3rem, 8vw, 4.8rem)/1 var(--display); margin: .3rem 0 0; }
.book-head .heb { font-size: 2rem; margin: .2rem 0; color: var(--ink-soft); }
.sub { color: var(--ink-soft); font-style: italic; margin: .2rem 0 1rem; }
.toc { columns: 2 22rem; column-gap: 3rem; }
.parasha { break-inside: avoid; margin: 0 0 2rem; animation: rise .7s both; animation-delay: calc(var(--i) * 40ms); }
.parasha h2 { font: 600 1.35rem var(--display); margin: 0 0 .3rem; padding-bottom: .3rem; border-bottom: 1px solid var(--rule); }
.parasha ol { list-style: none; margin: 0; padding: 0; counter-reset: e; }
.parasha li a { display: flex; justify-content: space-between; gap: 1rem; padding: .32rem 0; text-decoration: none; }
.parasha li a:hover .t { color: var(--flame); }
.parasha .m { color: var(--ink-soft); font-size: .9rem; white-space: nowrap; }
.parasha .m i { color: var(--flame); font-style: normal; }

/* essay page */
.essay { max-width: calc(var(--measure) + 4rem); }
.crumbs { font-size: .95rem; color: var(--ink-soft); }
.crumbs a { text-decoration: none; color: var(--flame); }
.essay h1 { font: 500 clamp(2.4rem, 6vw, 3.4rem)/1.08 var(--display); margin: .5rem 0 .2rem; }
.text { max-width: var(--measure); }
.text p { margin: 0 0 1.05em; hyphens: auto; }
.text p:first-child:not(.verse)::first-letter { font: 500 3.4em/0.8 var(--display); float: left; padding: .08em .08em 0 0; color: var(--flame); }
.text p.verse {
  text-align: center; font-size: 1.25rem; line-height: 1.9; margin: 1.6rem 0 .6rem; padding: 1rem 1.2rem;
  border-block: 1px solid var(--rule); background: linear-gradient(90deg, transparent, var(--paper-2), transparent);
}
.text p.verse + p.verse { margin-top: -.6rem; border-top: 0; }
.text p.verse + p:not(.verse) { font-style: italic; text-align: center; color: var(--ink-soft); margin-bottom: 1.6rem; }
.text p.verse::first-letter { all: unset; }
.text p.playing { background: var(--glow); box-shadow: -.6rem 0 0 var(--glow), .6rem 0 0 var(--glow); border-radius: 4px; }
.fn {
  font: 600 .62em var(--serif); vertical-align: super; line-height: 0; border: 0; background: none; color: var(--flame);
  cursor: pointer; padding: 0 .1em;
}
.note-pop {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); width: min(34rem, calc(100% - 2rem)); z-index: 10;
  background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 1rem 2.4rem 1rem 1.2rem;
  font-size: 1rem; box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .5);
}
.note-pop .x { position: absolute; top: .4rem; right: .6rem; border: 0; background: none; font-size: 1.3rem; cursor: pointer; color: var(--ink-soft); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: var(--measure); margin-top: 3rem; border-top: 1px solid var(--rule); padding-top: 1.2rem; }
.pager a { text-decoration: none; font: 500 1.2rem var(--display); }
.pager small { display: block; font: .75rem var(--serif); text-transform: uppercase; letter-spacing: .18em; color: var(--ink-soft); }
.pager .next { text-align: right; }

/* audio player */
.player {
  display: flex; align-items: center; gap: .8rem; max-width: var(--measure); margin: 1.2rem 0 2.2rem;
  padding: .55rem .8rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--card);
  position: sticky; top: 4rem; z-index: 4;
}
.player.soon { color: var(--ink-soft); font-style: italic; position: static; padding-left: 1.2rem; }
.player .play { width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 0; background: var(--ink); color: var(--paper); cursor: pointer; font-size: .95rem; flex: none; }
.player .bar { flex: 1; height: 6px; background: var(--rule); border-radius: 3px; cursor: pointer; position: relative; }
.player .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--flame), var(--flame-2)); border-radius: 3px; }
.player .time { font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--ink-soft); min-width: 5.5rem; text-align: right; }
.player .speed { border: 1px solid var(--rule); background: none; color: var(--ink); border-radius: 999px; padding: .1rem .6rem; cursor: pointer; font: inherit; font-size: .85rem; }

/* search page */
.search h1 { font: 500 3rem var(--display); text-align: center; margin: .5rem 0 1.2rem; }
.search-form { flex-direction: column; border-radius: 18px; padding: .6rem; }
.search-form #q { font-size: 1.2rem; }
.modes { display: flex; gap: 1.4rem; justify-content: center; font-size: .95rem; color: var(--ink-soft); padding: .3rem 0 .2rem; }
.status { text-align: center; color: var(--ink-soft); font-style: italic; min-height: 1.6em; }
.results { list-style: none; padding: 0; max-width: 46rem; margin: 1rem auto; }
.results li { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.results .where { font-size: .9rem; color: var(--ink-soft); }
.results .where b { color: var(--flame); font-weight: 500; }
.results a.title { font: 500 1.35rem var(--display); text-decoration: none; display: block; }
.results p { margin: .3rem 0 0; }
.results mark { background: var(--glow); color: inherit; box-shadow: 0 0 0 2px var(--glow); border-radius: 2px; }
/* the passage a reference or search result points to stays marked while you read around it */
:root { --ref-bg: rgba(232, 176, 60, .28); --ref-bar: #c8841f; }
:root[data-theme="dark"] { --ref-bg: rgba(255, 196, 90, .16); --ref-bar: #e9a23b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ref-bg: rgba(255, 196, 90, .16); --ref-bar: #e9a23b; } }
.text p:target {
  background: var(--ref-bg); box-shadow: -.9rem 0 0 var(--ref-bg), .9rem 0 0 var(--ref-bg);
  border-radius: 3px; scroll-margin-top: 30vh; animation: refin .9s ease-out;
}
.text p:target::after { content: ""; position: absolute; left: -.9rem; top: 0; bottom: 0; width: 4px; background: var(--ref-bar); border-radius: 2px; }
@keyframes refin { from { background: rgba(232, 176, 60, .6); } }

@media (max-width: 640px) {
  body { font-size: 1.1rem; }
  .top nav { gap: .8rem; }
  .player { top: 3.6rem; }
  .player .time { min-width: auto; }
}

/* progress, bookmarks, continue listening */
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: -1.2rem 0 2rem; }
.actions button { font: inherit; font-size: .92rem; border: 1px solid var(--rule); background: none; color: var(--ink-soft); border-radius: 999px; padding: .25rem .9rem; cursor: pointer; }
.actions button[aria-pressed="true"] { color: var(--flame); border-color: var(--flame); }
.text p { position: relative; }
.bm-para { position: absolute; left: -2.1rem; top: .15rem; border: 0; background: none; color: var(--ink-soft); font-size: 1rem; cursor: pointer; opacity: 0; transition: opacity .2s; padding: .1rem .3rem; }
.text p.touch > .bm-para, .bm-para.on, .bm-para:focus-visible { opacity: 1; }
@media (hover: hover) and (pointer: fine) { .text p:hover > .bm-para { opacity: 1; } }
.bm-para.on { color: var(--flame); }
.text p.verse > .bm-para { left: auto; right: -2.1rem; }
@media (max-width: 760px) { .bm-para { left: auto; right: -.4rem; top: -1.1rem; } .text p.verse > .bm-para { right: -.4rem; } }
.parasha li.done .t::after { content: " ✓"; color: var(--flame); }
.parasha li.started .t::after { content: " ◐"; color: var(--ink-soft); font-size: .85em; }
.progress-line { color: var(--flame); margin: 0; }
.continue { max-width: 60rem; margin: 0 auto 1rem; padding: 0 1rem; }
.continue-card { display: grid; gap: .1rem; text-decoration: none; border: 1px solid var(--flame); border-radius: 14px; padding: 1rem 1.4rem; background: var(--card); }
.continue-card .ct { font: 500 1.6rem var(--display); }
.continue-card .cm { color: var(--ink-soft); font-size: .95rem; }
.cbar { height: 4px; background: var(--rule); border-radius: 2px; margin-top: .5rem; overflow: hidden; }
.cbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--flame), var(--flame-2)); }
.saved { max-width: 46rem; margin: 0 auto; padding: 2.5rem 1rem; }
.saved h1 { font: 500 3rem var(--display); text-align: center; margin: .5rem 0 0; }
.saved h2 { font: 600 1.4rem var(--display); border-bottom: 1px solid var(--rule); margin-top: 2rem; }
.center { text-align: center; }
.results .remove { border: 0; background: none; color: var(--ink-soft); font: inherit; font-size: .85rem; padding: 0; cursor: pointer; text-decoration: underline; }
.results .empty { color: var(--ink-soft); font-style: italic; border: 0; }

/* text size */
:root { --scale: 1; }
body { font-size: calc(1.18rem * var(--scale)); }
@media (max-width: 640px) { body { font-size: calc(1.1rem * var(--scale)); } }
.size { background: none; border: 1px solid var(--rule); color: var(--ink-soft); border-radius: 999px; height: 2rem; padding: 0 .55rem; cursor: pointer; font: 500 .8rem var(--serif); }
.size span { font-size: 1.25em; }
.player .dl { text-decoration: none; color: var(--ink-soft); border: 1px solid var(--rule); border-radius: 50%; width: 1.9rem; height: 1.9rem; display: grid; place-items: center; flex: none; }

/* topics */
.topics, .topic { max-width: 64rem; margin: 0 auto; padding: 2.5rem clamp(1rem, 4vw, 2rem); }
.tgrid { columns: 2 20rem; column-gap: 3rem; }
.tgroup { break-inside: avoid; margin-bottom: 2rem; }
.tgroup h2 { font: 600 1.35rem var(--display); border-bottom: 1px solid var(--rule); margin: 0 0 .4rem; padding-bottom: .3rem; }
.tgroup ul { list-style: none; padding: 0; margin: 0; }
.tgroup li { padding: .3rem 0; }
.tgroup li a { text-decoration: none; }
.tgroup li a:hover { color: var(--flame); }
.tgroup li.soon { color: var(--ink-soft); }
.topic { max-width: calc(var(--measure) + 4rem); }
.topic h1 { font: 500 clamp(2.6rem, 7vw, 3.8rem)/1.05 var(--display); margin: .4rem 0 1rem; }
.topic h2 { font: 600 1.45rem var(--display); margin: 2rem 0 .4rem; }
.topic p { max-width: var(--measure); }
.ai-note { font-size: .92em; color: var(--ink-soft); border-left: 3px solid var(--flame); background: var(--card); padding: .8rem 1rem; border-radius: 0 10px 10px 0; max-width: var(--measure); }
.lead { font-size: 1.12em; font-style: italic; }
.cite { font: 600 .62em var(--serif); vertical-align: super; line-height: 0; text-decoration: none; color: var(--flame); margin-left: .12em; }
.cites { font: 600 .62em var(--serif); vertical-align: super; line-height: 0; color: var(--ink-soft); margin-left: .12em; }
.cites .cite { font: inherit; vertical-align: baseline; margin: 0; }
.quote { margin: 1.4rem 0; max-width: var(--measure); }
.quote blockquote { margin: 0; padding: .2rem 0 .2rem 1.2rem; border-left: 2px solid var(--rule); font-size: 1.02em; }
.quote figcaption { font-size: .88em; color: var(--ink-soft); padding-left: 1.2rem; margin-top: .3rem; }
.quote figcaption a { color: var(--flame); text-decoration: none; }
.sources { margin-top: 2rem; max-width: var(--measure); font-size: .95em; }
.sources summary { cursor: pointer; color: var(--ink-soft); }
.sources li span, .related li span { color: var(--ink-soft); font-size: .9em; }
.related h3 { font: 600 1.1rem var(--display); margin: 1.2rem 0 .2rem; color: var(--flame); }
.related ul { margin: 0; padding-left: 1.1rem; }
.related a, .sources a { text-decoration: none; }

/* ---------- book view ---------- */
.view-toggle { font: inherit; font-size: .92rem; border: 1px solid var(--rule); background: none; color: var(--ink); border-radius: 999px; padding: .25rem .9rem; cursor: pointer; }
body.in-book { overflow: hidden; }
body.in-book > main, body.in-book > .foot { visibility: hidden; }
.book-view { position: fixed; inset: 0; z-index: 3; background:
  radial-gradient(70rem 50rem at 50% 30%, var(--glow), transparent 70%), color-mix(in srgb, var(--paper) 70%, #8a6a45 30%); }
:root[data-theme="dark"] .book-view { background: #0e0b08; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .book-view { background: #0e0b08; } }
.book-view .player { position: fixed; top: calc(3.4rem + 6px); left: 50%; transform: translateX(-50%); width: min(38rem, calc(100% - 1.5rem)); margin: 0; z-index: 6; }
.bv-stage { position: absolute; left: 0; right: 0; perspective: 2400px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.bv-page {
  position: absolute; top: 0; bottom: 0; width: var(--pw); overflow: hidden; background: var(--paper);
  box-shadow: 0 10px 40px -18px rgba(40, 20, 0, .55);
}
.bv-page::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.bv-page.single { left: calc(50% - var(--pw) / 2); border-radius: 3px 8px 8px 3px; }
.bv-page.left { left: calc(50% - var(--pw)); border-radius: 8px 0 0 8px; background: linear-gradient(90deg, var(--paper) 88%, color-mix(in srgb, var(--paper) 86%, #000) 100%); }
.bv-page.right { left: 50%; border-radius: 0 8px 8px 0; background: linear-gradient(90deg, color-mix(in srgb, var(--paper) 86%, #000) 0%, var(--paper) 12%); }
.bv-spine { display: none; }
.spread .bv-spine { display: block; position: absolute; top: 0; bottom: 0; left: calc(50% - 1px); width: 2px; z-index: 2; background: rgba(0, 0, 0, .12); }
.bv-page .bv-flow { position: absolute; top: var(--py, 48px); left: var(--px, 44px); column-fill: auto; font-size: 1.04em; line-height: 1.62; }
.bv-page .bv-flow p { margin: 0 0 .85em; break-inside: auto; orphans: 2; widows: 2; }
.bv-page .bv-flow p.verse { break-inside: avoid; margin: .8em 0 .5em; }
.bv-page .bv-flow p:first-child::first-letter, .bv-page .bv-flow .bv-title + p::first-letter { all: unset; }
.bv-page .bv-flow .bv-title + p:not(.verse)::first-letter { font: 500 3.2em/0.8 var(--display); float: left; padding: .08em .08em 0 0; color: var(--flame); }
.bv-title { break-after: avoid; text-align: center; padding: 1.2em 0 1.4em; }
.bv-title h1 { font: 500 2.3em/1.05 var(--display); margin: .3em 0 .2em; }
.bv-title .sub { font-size: .9em; }
.bv-title::after { content: "❧"; display: block; color: var(--flame); margin-top: .6em; font-size: 1.3em; }
.bv-end { text-align: center; margin-top: 2em !important; font-family: var(--display); font-size: 1.2em; }
.bv-end a { color: var(--flame); text-decoration: none; }
.bv-run, .bv-foot { position: absolute; left: 0; right: 0; text-align: center; font: italic .78rem var(--serif); color: var(--ink-soft); letter-spacing: .04em; }
.bv-run { top: 16px; }
.bv-foot { bottom: 14px; font-style: normal; }
.bv-page.blank .bv-flow { display: none; }
.bv-flow .ref { background: var(--ref-bg); box-shadow: -.5rem 0 0 var(--ref-bg), .5rem 0 0 var(--ref-bg); border-radius: 3px; }
.bv-flow .bm-para { left: auto; right: -1.9rem; top: 0; }

/* the turning page */
.bv-flip { position: absolute; top: 0; bottom: 0; width: var(--pw); transform-style: preserve-3d; z-index: 4;
  transition: transform .62s cubic-bezier(.45, .05, .25, 1); }
.bv-flip .face { position: absolute; inset: 0; left: 0 !important; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.bv-flip .back { transform: rotateY(180deg); }
.bv-shade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(0,0,0,0), rgba(0,0,0,.18)); opacity: 0; transition: opacity .62s; }
.bv-flip.go .bv-shade { opacity: 1; }
.bv-flip.right.fwd { left: 50%; transform-origin: left center; }
.bv-flip.right.fwd.go { transform: rotateY(-180deg); }
.bv-flip.left.back { left: calc(50% - var(--pw)); transform-origin: right center; }
.bv-flip.left.back.go { transform: rotateY(180deg); }
.bv-flip.single { left: calc(50% - var(--pw) / 2); transform-origin: left center; }
.bv-flip.single.fwd.go { transform: rotateY(-100deg); opacity: .0; transition: transform .6s cubic-bezier(.45,.05,.25,1), opacity .25s .35s; }
.bv-flip.single.back { transform: rotateY(-100deg); opacity: 0; }
.bv-flip.single.back.go { transform: rotateY(0); opacity: 1; transition: transform .6s cubic-bezier(.45,.05,.25,1), opacity .2s; }

/* page bar */
.bv-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 52px; display: flex; align-items: center; justify-content: center; gap: .8rem;
  padding: 0 1rem; color: var(--ink-soft); font-size: .9rem; }
.bv-bar button { border: 1px solid var(--rule); background: var(--card); color: var(--ink); border-radius: 50%; width: 2.1rem; height: 2.1rem; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.bv-num { min-width: 6.5rem; text-align: center; font-variant-numeric: tabular-nums; }
.bv-seek { width: min(16rem, 34vw); accent-color: var(--flame); }
@media (max-width: 420px) { .bv-seek { display: none; } }

/* small screens: keep the header on one line */
.mark span:last-child { white-space: nowrap; }
@media (max-width: 560px) {
  .top { padding: .55rem .8rem; }
  .mark { font-size: 1.12rem; gap: .35rem; }
  .top nav { gap: .55rem; font-size: .86rem; }
  .top nav a[href$="index.html#books"] { display: none; }
  .theme, .size { width: auto; min-width: 1.8rem; height: 1.8rem; padding: 0 .35rem; }
}
.book-view { padding-bottom: env(safe-area-inset-bottom); }
.bv-bar { bottom: env(safe-area-inset-bottom); }

.bv-bar button:disabled { opacity: .35; cursor: default; }
.bv-bar .bv-first, .bv-bar .bv-last { font-size: 1rem; }
@media (max-width: 420px) { .bv-bar { gap: .5rem; } .bv-num { min-width: 4.8rem; } }

/* ---------- full-screen book view ---------- */
body.in-book > header.top { display: none; }
.book-view { z-index: 20; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--paper); }
.book-view .bv-page { box-shadow: none; border-radius: 0 !important; }
.book-view .bv-page.left { box-shadow: inset -18px 0 24px -22px rgba(60, 35, 10, .45); }
.book-view .bv-page.right { box-shadow: inset 18px 0 24px -22px rgba(60, 35, 10, .45); }
.bv-top, .bv-bar, .book-view .player { transition: opacity .3s, transform .3s; }
.bv-top { position: absolute; left: 0; right: 0; top: 0; z-index: 8; display: flex; align-items: center; gap: .8rem;
  padding: calc(env(safe-area-inset-top) + .55rem) 1rem .55rem; background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule); }
.bv-ttl { flex: 1; text-align: center; font: 500 1.05rem var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bv-done { border: 0; background: none; color: var(--flame); font: 600 1rem var(--serif); cursor: pointer; padding: .2rem .3rem; }
.bv-aa { border: 1px solid var(--rule); background: none; color: var(--ink-soft); border-radius: 999px; height: 1.9rem; padding: 0 .55rem; cursor: pointer; font: 500 .8rem var(--serif); }
.bv-aa span { font-size: 1.25em; }
.book-view .player { top: calc(env(safe-area-inset-top) + 3.6rem); z-index: 8; }
.book-view .bv-bar { z-index: 8; bottom: 0; height: auto; padding: .6rem 1rem calc(env(safe-area-inset-bottom) + .6rem);
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--rule); }
.book-view:not(.chrome) .bv-bar { opacity: 0; transform: translateY(100%); pointer-events: none; }
.book-view:not(.chrome) .player { opacity: 0; pointer-events: none; }
.book-view .bv-run { top: calc(10px); }
@media (hover: hover) and (pointer: fine) { .book-view:hover .bv-bar { opacity: 1; transform: none; pointer-events: auto; } }

/* playback speed menu */
/* (.player is sticky, which already anchors the speed menu) */
.book-view .player { position: fixed; }
.speed-menu { position: absolute; right: .4rem; top: calc(100% + .4rem); z-index: 12; background: var(--card); border: 1px solid var(--rule);
  border-radius: 12px; padding: .3rem; display: grid; min-width: 8.5rem; box-shadow: 0 14px 34px -16px rgba(40, 20, 0, .5); }
.speed-menu[hidden] { display: none; }
.speed-menu button { border: 0; background: none; color: var(--ink); font: inherit; font-size: .95rem; text-align: left; padding: .4rem .7rem; border-radius: 8px; cursor: pointer; }
.speed-menu button small { color: var(--ink-soft); }
.speed-menu button:hover { background: var(--paper-2); }
.speed-menu button[aria-checked="true"] { color: var(--flame); font-weight: 600; }
.speed-menu button[aria-checked="true"]::after { content: " ✓"; }

/* the top bar (Done · chapter · AA) always stays visible in book view */
.bv-top { padding: .55rem 1rem; }
.book-view .player { top: calc(env(safe-area-inset-top) + 3.4rem); }

/* ---------- Kindle-style reader ---------- */
.book-view { --bv-size: 1.04; --bv-line: 1.62; --bv-font: var(--serif); }
.book-view .bv-page .bv-flow { font-size: calc(var(--bv-size) * 1em); line-height: var(--bv-line); font-family: var(--bv-font); }
.book-view .bv-page .bv-flow [lang="he"] { font-family: var(--heb); }
.bv-top { gap: .35rem; }
.bv-icon { border: 0; background: none; color: var(--ink-soft); font: 500 1.15rem var(--serif); width: 2.2rem; height: 2.2rem; border-radius: 8px;
  display: grid; place-items: center; cursor: pointer; text-decoration: none; flex: none; }
.bv-icon:hover { background: var(--paper-2); }
.bv-icon.bv-aa { font-size: .85rem; } .bv-icon.bv-aa span { font-size: 1.3em; }
.bv-mark { filter: grayscale(1) opacity(.55); }
.bv-mark.on { filter: none; }
.bv-ribbon { position: absolute; top: 0; right: 22px; width: 18px; height: 34px; z-index: 3;
  background: linear-gradient(var(--flame), var(--flame-2)); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); }
/* status line */
.bv-status { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 8px); z-index: 5; display: flex; justify-content: space-between;
  padding: 0 1.4rem; font: .78rem var(--serif); color: var(--ink-soft); cursor: pointer; user-select: none; }
.spread .bv-status { left: calc(50% - var(--book-w, 100%) / 2); right: calc(50% - var(--book-w, 100%) / 2); }
.book-view.chrome .bv-status { opacity: 0; }
.bv-page .bv-foot { display: none; }
/* panels */
.bv-panel { position: absolute; z-index: 15; top: calc(env(safe-area-inset-top) + 3.5rem); right: .6rem; width: min(22rem, calc(100% - 1.2rem));
  background: var(--card); color: var(--ink); border: 1px solid var(--rule); border-radius: 14px; box-shadow: 0 22px 50px -20px rgba(0, 0, 0, .45); padding: .6rem; }
.bv-panel[hidden] { display: none; }
.bv-aa-panel .row { display: grid; grid-template-columns: 4.6rem 1fr; align-items: center; gap: .5rem; padding: .45rem .3rem; border-bottom: 1px solid var(--rule); }
.bv-aa-panel .row:last-child { border-bottom: 0; }
.bv-aa-panel .row > span:first-child { font-size: .85rem; color: var(--ink-soft); }
.bv-aa-panel .row:first-child { grid-template-columns: 4.6rem auto 1fr auto; }
.bv-aa-panel [data-act] { border: 1px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: 8px; width: 2.4rem; height: 2.2rem; font: 500 .9rem var(--serif); cursor: pointer; }
.bv-aa-panel [data-act].big { font-size: 1.35rem; }
.dots { display: flex; justify-content: center; gap: .35rem; }
.dots i { width: .45rem; height: .45rem; border-radius: 50%; background: var(--rule); }
.dots i.on { background: var(--flame); }
.seg { display: flex; border: 1px solid var(--rule); border-radius: 9px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--paper); color: var(--ink); font: .85rem var(--serif); padding: .45rem .2rem; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg [data-v="literata"] { font-family: "Literata", Georgia, serif; }
.seg [data-v="sans"] { font-family: "Atkinson Hyperlegible", "Helvetica Neue", Arial, sans-serif; }
.swatches { border: 0; gap: .6rem; justify-content: flex-start; }
.swatches button { flex: none; width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 1px solid #bbb !important; padding: 0; }
.swatches [data-v="white"] { background: #fff; } .swatches [data-v="paper"] { background: #f6efe2; }
.swatches [data-v="sepia"] { background: #f1e4c8; } .swatches [data-v="black"] { background: #111; }
.swatches button[aria-pressed="true"] { outline: 2px solid var(--flame); outline-offset: 2px; background-image: none; }
.swatches [data-v="white"][aria-pressed="true"] { background: #fff; } .swatches [data-v="paper"][aria-pressed="true"] { background: #f6efe2; }
.swatches [data-v="sepia"][aria-pressed="true"] { background: #f1e4c8; } .swatches [data-v="black"][aria-pressed="true"] { background: #111; }
.bv-toc-panel { max-height: min(70vh, 36rem); overflow: auto; padding: .4rem .2rem; }
.toc-head { font: 600 1.15rem var(--display); padding: .3rem .8rem .5rem; border-bottom: 1px solid var(--rule); }
.toc-list { list-style: none; margin: 0; padding: .2rem 0; }
.toc-list .par { font: 600 .78rem var(--serif); text-transform: uppercase; letter-spacing: .12em; color: var(--flame); padding: .8rem .8rem .2rem; }
.toc-list a { display: block; padding: .35rem .8rem; text-decoration: none; border-radius: 8px; }
.toc-list a:hover { background: var(--paper-2); }
.toc-list a.here { background: var(--glow); font-weight: 600; }
/* page colors (themes) — apply to the reader only */
.book-view.theme-white { --paper: #ffffff; --paper-2: #f2f2f2; --card: #ffffff; --ink: #161616; --ink-soft: #666; --rule: #e3e3e3; }
.book-view.theme-sepia { --paper: #f1e4c8; --paper-2: #e8d8b6; --card: #f6ecd6; --ink: #4a3624; --ink-soft: #7c6449; --rule: #d9c49c; }
.book-view.theme-black { --paper: #000; --paper-2: #151515; --card: #121212; --ink: #d9d4cb; --ink-soft: #8d877e; --rule: #2a2a2a; --glow: rgba(255,190,90,.10); }
.book-view.theme-white .bv-page::before, .book-view.theme-black .bv-page::before { display: none; }
.book-view.theme-white .bv-page, .book-view.theme-white .bv-page.left, .book-view.theme-white .bv-page.right,
.book-view.theme-black .bv-page, .book-view.theme-black .bv-page.left, .book-view.theme-black .bv-page.right { background: var(--paper); }
.book-view.theme-paper { --paper: #f6efe2; --paper-2: #efe5d2; --card: #fbf6ec; --ink: #2a2018; --ink-soft: #6b5a48; --rule: #d9c9ad; }
/* slide page turn */
.bv-stage.sliding .bv-page { transition: transform .32s cubic-bezier(.3,.1,.2,1); }
.bv-page.slide-out.to-left { transform: translateX(-100%); } .bv-page.slide-out.to-right { transform: translateX(100%); }
.bv-page.slide-in.from-right { transform: translateX(100%); } .bv-page.slide-in.from-left { transform: translateX(-100%); }
.bv-stage.sliding .bv-page.slide-in { transform: none; }
.bv-stage.sliding .bv-page.slide-out.to-left { transform: translateX(-100%); }
@media (max-width: 420px) { .bv-ttl { font-size: .95rem; } .bv-icon { width: 2rem; } }
.bv-icon.bv-aa { white-space: nowrap; width: 2.4rem; } .bv-find { font-size: 1.35rem; }

/* footnote / source pop-up: always on top, including the full-screen book view */
.note-pop { z-index: 40; }
.note-pop .src-where { font-size: .82rem; color: var(--flame); text-transform: uppercase; letter-spacing: .08em; }
.note-pop .src-title { font: 600 1.15rem var(--display); margin: .1rem 0 .3rem; }
.note-pop .src-snip { margin: 0 0 .5rem; font-style: italic; color: var(--ink-soft); }
.note-pop .src-go { color: var(--flame); text-decoration: none; font-weight: 600; }
.cite { cursor: pointer; }

/* footnote and source numbers: small to look at, big to tap (one tap is enough on a phone) */
.fn, .cite { position: relative; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.fn::after, .cite::after { content: ""; position: absolute; left: -14px; right: -14px; top: -16px; bottom: -12px; }
.cites { position: relative; }

/* the paragraph being read aloud */
.text p.playing, .bv-flow p.playing { background: var(--glow); box-shadow: -.6rem 0 0 var(--glow), .6rem 0 0 var(--glow); border-radius: 4px; transition: background .4s; }

/* the player sits under the essay heading, then sticks below the site header while you scroll */
main.essay > .player[data-src] { position: sticky; top: 3.9rem; z-index: 4; }
@media (max-width: 640px) { main.essay > .player[data-src] { top: 3.3rem; } }

/* draggable audio bar: a slim line with a generous touch area and a knob */
.player .bar { touch-action: none; height: 6px; margin: 14px 0; cursor: pointer; }
.player .bar::before { content: ""; position: absolute; left: -6px; right: -6px; top: -18px; bottom: -18px; }
.player .knob { position: absolute; top: 50%; left: 0; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: var(--flame); box-shadow: 0 1px 4px rgba(0, 0, 0, .3); transition: transform .12s; pointer-events: none; }
.player .bar.dragging .knob { transform: scale(1.35); }
.player .bar.dragging .fill { transition: none; }

/* full essays that live under a topic */
.full-essays { max-width: var(--measure); margin: 2.2rem 0 1rem; padding: 1.1rem 1.3rem; border: 1px solid var(--flame); border-radius: 14px; background: var(--card); }
.full-essays h2 { margin: 0 0 .1rem; }
.full-essays .sub { margin: 0 0 .6rem; font-size: .95em; }
.full-essays ul { list-style: none; margin: 0; padding: 0; }
.full-essays li a { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; text-decoration: none; border-top: 1px solid var(--rule); }
.full-essays .t { font: 500 1.3rem var(--display); }
.full-essays .m { color: var(--ink-soft); font-size: .9rem; white-space: nowrap; align-self: center; }
.full-essays li a:hover .t { color: var(--flame); }

/* listening review */
.review { max-width: 46rem; margin: 0 auto; padding: 2.5rem 1rem; }
.review h1 { font: 500 2.8rem var(--display); text-align: center; margin: .4rem 0 0; }
.review .how { font-size: .98em; color: var(--ink-soft); border-left: 3px solid var(--flame); background: var(--card); padding: .8rem 1rem; border-radius: 0 10px 10px 0; }
.rv-bar { position: sticky; top: 3.4rem; z-index: 3; display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; padding: .6rem 0; background: var(--paper); border-bottom: 1px solid var(--rule); font-size: .92rem; }
.rv-bar button { font: inherit; border: 0; border-radius: 999px; background: var(--ink); color: var(--paper); padding: .35rem 1rem; cursor: pointer; }
#rv-count { margin-left: auto; color: var(--ink-soft); }
.rv-essay h2 { font: 600 1.3rem var(--display); margin: 1.8rem 0 .4rem; }
.rv-essay h2 a { text-decoration: none; color: var(--flame); }
.rv-item { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: start; padding: .8rem 0; border-top: 1px solid var(--rule); }
.rv-play { width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0; background: var(--ink); color: var(--paper); font-size: .95rem; cursor: pointer; }
.rv-meta { font-size: .8rem; color: var(--ink-soft); margin-bottom: .15rem; }
.rv-meta a { color: var(--flame); text-decoration: none; }
.rv-marks { display: flex; gap: .35rem; }
.rv-marks button { font: inherit; font-size: .9rem; border: 1px solid var(--rule); background: none; color: var(--ink); border-radius: 999px; padding: .3rem .8rem; cursor: pointer; }
.rv-item.is-ok .rv-marks [data-m="ok"] { background: #3d7a4f; border-color: #3d7a4f; color: #fff; }
.rv-item.is-redo .rv-marks [data-m="redo"] { background: var(--flame); border-color: var(--flame); color: #fff; }
.rv-item.is-ok .rv-text { opacity: .55; }
.rv-hide-ok .rv-item.is-ok { display: none; }
@media (max-width: 560px) { .rv-item { grid-template-columns: auto 1fr; } .rv-marks { grid-column: 2; } }

/* the three essay buttons: one tidy row, icon above label, easy to tap */
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; max-width: var(--measure); margin: .2rem 0 2rem; }
.actions button, .actions .view-toggle {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
  min-height: 4rem; padding: .55rem .3rem; border: 1px solid var(--rule); border-radius: 14px; background: var(--card);
  color: var(--ink-soft); font: 500 .86rem/1.15 var(--serif); text-align: center; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: border-color .15s, color .15s, background .15s;
}
.actions svg { width: 1.55rem; height: 1.55rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.actions button[aria-pressed="true"] { color: var(--flame); border-color: var(--flame); background: color-mix(in srgb, var(--flame) 9%, var(--card)); }
.actions button[aria-pressed="true"] svg { fill: color-mix(in srgb, var(--flame) 22%, transparent); }
.actions button:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { .actions button:hover { border-color: var(--flame); color: var(--ink); } }
@media (min-width: 700px) { .actions { grid-template-columns: repeat(3, minmax(0, 11rem)); } .actions button { flex-direction: row; min-height: 2.9rem; gap: .5rem; } .actions svg { width: 1.25rem; height: 1.25rem; } }
