@import url("data:text/css,");

:root {
  --ink: #ede8dd;
  --muted: #a9a393;
  --paper: #111820;
  --paper-soft: #17212a;
  --night: #080c11;
  --gold: #c89b5b;
  --gold-bright: #e6c488;
  --blue: #5f8ca4;
  --line: rgba(232, 215, 182, 0.16);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --reading-size: 100%;
  --content-width: 760px;
  color-scheme: dark;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--night);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 5%, rgba(54, 85, 103, 0.18), transparent 34rem),
    var(--night);
  font-family: "Noto Sans Hebrew", "Noto Sans", Arial, sans-serif;
  font-size: var(--reading-size);
  line-height: 1.75;
  overflow-x: hidden;
}

body[data-lang="en"] {
  font-family: "Noto Sans", Arial, sans-serif;
}

button, select, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--gold-bright); }

.skip-link {
  position: fixed;
  inset-block-start: -4rem;
  inset-inline-start: 1rem;
  z-index: 100;
  padding: .65rem 1rem;
  color: #080c11;
  background: var(--gold-bright);
  border-radius: 0 0 .6rem .6rem;
  transition: inset-block-start .2s;
}
.skip-link:focus { inset-block-start: 0; }

.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  z-index: 80;
  background: rgba(255,255,255,.05);
}
.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  box-shadow: 0 0 14px rgba(230,196,136,.55);
  transition: width .2s ease-out;
}

.topbar {
  position: fixed;
  inset: 3px 0 auto;
  z-index: 60;
  height: 64px;
  padding: 0 clamp(.8rem, 3vw, 2.5rem);
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto minmax(110px, 1fr);
  align-items: center;
  gap: 1rem;
  background: linear-gradient(180deg, rgba(8,12,17,.94), rgba(8,12,17,.76));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand { text-align: center; line-height: 1.1; }
.brand strong { display: block; font-family: "Noto Serif Hebrew", "Noto Serif", Georgia, serif; }
.brand span { display: block; margin-top: .25rem; color: var(--muted); font-size: .7rem; }

.icon-button, .language-switch, .ghost-button, .primary-button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  color: var(--ink);
  border-radius: 999px;
  padding: .55rem .9rem;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.icon-button:hover, .language-switch:hover, .ghost-button:hover {
  border-color: rgba(230,196,136,.5);
  background: rgba(230,196,136,.09);
}
.language-switch { justify-self: end; }
.topbar .icon-button { justify-self: start; }

.toc-drawer {
  position: fixed;
  z-index: 100;
  inset-block: 0;
  inset-inline-start: 0;
  width: min(430px, 90vw);
  padding: 1.4rem;
  background: rgba(12,17,24,.985);
  box-shadow: var(--shadow);
  transform: translateX(-105%);
  transition: transform .34s cubic-bezier(.2,.75,.2,1);
  overflow-y: auto;
}
[dir="rtl"] .toc-drawer { transform: translateX(105%); }
.toc-drawer.open { transform: translateX(0); }
.toc-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.toc-head h2 { font-family: "Noto Serif Hebrew", "Noto Serif", Georgia, serif; }
.toc-drawer nav { display: grid; gap: .25rem; margin-top: 1rem; }
.toc-drawer nav a {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  align-items: baseline;
  gap: .5rem;
  padding: .7rem .75rem;
  color: var(--ink);
  border-radius: .7rem;
  text-decoration: none;
}
[dir="rtl"] .toc-drawer nav a { grid-template-columns: 2.2rem 1fr; }
.toc-drawer nav a span { color: var(--gold); font-variant-numeric: tabular-nums; }
.toc-drawer nav a:hover, .toc-drawer nav a.active { background: rgba(200,155,91,.12); }
.keyboard-hint { margin: 2rem .5rem; color: var(--muted); font-size: .8rem; }

.drawer-backdrop {
  position: fixed;
  z-index: 90;
  inset: 0;
  background: rgba(0,0,0,.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s;
}
.drawer-backdrop.open { opacity: 1; visibility: visible; }

.cover {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  background: #0b1118;
}
.cover::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  background-image: url("cover.webp"), linear-gradient(145deg, #13222d, #070a0e);
  background-size: cover;
  background-position: center;
  filter: saturate(.72) contrast(1.06);
  transform: scale(1.035);
  animation: cover-breathe 18s ease-in-out infinite alternate;
}
.cover::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5,8,12,.55), rgba(5,8,12,.22) 42%, rgba(5,8,12,.92)),
    radial-gradient(circle at 50% 44%, transparent, rgba(5,8,12,.48) 70%);
}
.cover-light {
  position: absolute;
  z-index: 2;
  width: min(70vw, 900px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(208,169,105,.18), transparent 64%);
  filter: blur(18px);
}
.cover-content {
  position: relative;
  z-index: 3;
  width: min(900px, calc(100% - 2rem));
  padding: 7rem 1rem 8rem;
  text-align: center;
  text-shadow: 0 3px 20px rgba(0,0,0,.65);
}
.eyebrow { color: var(--gold-bright); letter-spacing: .12em; font-size: .78rem; }
.cover h1 {
  margin: .35rem 0 1.1rem;
  font-family: "Noto Serif Hebrew", "Noto Serif", Georgia, serif;
  font-size: clamp(3.2rem, 10vw, 8.5rem);
  line-height: .95;
  font-weight: 600;
}
.cover blockquote {
  max-width: 650px;
  margin: 1.5rem auto;
  color: #f2eadb;
  font-family: "Noto Serif Hebrew", "Noto Serif", Georgia, serif;
  font-size: clamp(1.05rem, 2.5vw, 1.55rem);
}
.cover-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }
.primary-button {
  color: #14110b;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 10px 35px rgba(200,155,91,.25);
}
.primary-button:hover { transform: translateY(-2px); }
.scroll-cue { position: absolute; z-index: 3; inset-block-end: 1.5rem; inset-inline-start: 50%; width: 24px; height: 38px; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; }
.scroll-cue span { position: absolute; inset-block-start: 7px; inset-inline-start: 9px; width: 4px; height: 8px; border-radius: 2px; background: var(--gold-bright); animation: scroll-cue 1.8s infinite; }

.gate-divider {
  min-height: 42vh;
  display: grid;
  place-items: center;
  padding: 8rem 1.5rem 5rem;
  color: var(--gold-bright);
  background:
    linear-gradient(90deg, transparent, rgba(200,155,91,.08), transparent),
    var(--night);
  border-block: 1px solid var(--line);
  text-align: center;
}
.gate-divider span {
  max-width: 900px;
  font-family: "Noto Serif Hebrew", "Noto Serif", Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 4.5rem);
  line-height: 1.2;
}

.chapter {
  --scene: none;
  position: relative;
  display: grid;
  grid-template-columns: minmax(300px, 42%) minmax(0, 1fr);
  min-height: 100svh;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.chapter.scene-technology { --scene: url("scene-technology.webp"); }
.chapter.scene-biblical { --scene: url("scene-biblical.webp"); }
.chapter.scene-rise { --scene: url("scene-rise.webp"); }
.chapter.scene-nature { --scene: url("scene-nature.webp"); }
.chapter.scene-kingship { --scene: url("scene-kingship.webp"); }
.chapter.scene-modern { --scene: url("scene-modern.webp"); }
.chapter.scene-dawn { --scene: url("scene-dawn.webp"); }
[dir="rtl"] .chapter { grid-template-columns: minmax(0, 1fr) minmax(300px, 42%); }
[dir="rtl"] .chapter .chapter-visual { grid-column: 2; }
[dir="rtl"] .chapter .chapter-text { grid-column: 1; grid-row: 1; }
.chapter-visual {
  position: relative;
  min-height: 100%;
  background-image:
    linear-gradient(180deg, rgba(8,12,17,.08), rgba(8,12,17,.72)),
    var(--scene),
    linear-gradient(145deg, #1c2a34, #0d1218);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.chapter-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 65%, var(--paper));
}
[dir="rtl"] .chapter-visual::after { background: linear-gradient(-90deg, transparent 65%, var(--paper)); }
.chapter-visual-inner { position: sticky; top: 64px; height: calc(100svh - 64px); padding: 2rem; display: flex; align-items: end; }
.chapter-number { position: relative; z-index: 1; color: rgba(255,255,255,.24); font: 300 clamp(4rem, 11vw, 9rem)/1 "Noto Serif", Georgia, serif; }

.chapter-text {
  width: min(100%, calc(var(--content-width) + 7rem));
  margin-inline: auto;
  padding: clamp(6.5rem, 10vw, 10rem) clamp(1.4rem, 6vw, 5.5rem) 9rem;
  background: linear-gradient(180deg, rgba(24,33,42,.96), var(--paper) 10rem);
}
.chapter-text h2 {
  margin: 0 0 2.8rem;
  color: var(--gold-bright);
  font-family: "Noto Serif Hebrew", "Noto Serif", Georgia, serif;
  font-size: clamp(2rem, 4.5vw, 3.8rem);
  line-height: 1.18;
  font-weight: 600;
  text-wrap: balance;
}
.chapter-text h3 { margin-top: 3rem; color: var(--gold-bright); font-family: "Noto Serif Hebrew", "Noto Serif", Georgia, serif; }
.chapter-text p, .chapter-text li {
  position: relative;
  max-width: var(--content-width);
  margin-block: 0 1.2rem;
  color: #e7e2d8;
  font-family: "Noto Serif Hebrew", "Noto Serif", Georgia, serif;
  font-size: clamp(1.08rem, 1.7vw, 1.28rem);
  line-height: 1.9;
  transition: color .24s, background .24s, opacity .24s, transform .24s;
}
.chapter-text li { margin-block: .45rem; }
.chapter-text ul, .chapter-text ol { max-width: var(--content-width); padding-inline-start: 1.5rem; }
.chapter-text blockquote {
  max-width: var(--content-width);
  margin: 2rem 0;
  padding: 1.1rem 1.35rem;
  border-inline-start: 3px solid var(--gold);
  background: rgba(200,155,91,.08);
  border-radius: .35rem;
}
.chapter-text blockquote p { margin: 0; color: #f4e8d2; font-size: clamp(1.15rem, 2vw, 1.42rem); }
.chapter-text hr { margin: 3rem 0; border: 0; border-top: 1px solid var(--line); }
.chapter-text a { text-underline-offset: .2em; overflow-wrap: anywhere; }
.narration-unit { border-radius: .35rem; cursor: pointer; }
.narration-unit:hover { color: #fff; }
.narration-unit.active-reading {
  color: #fff;
  background: linear-gradient(90deg, rgba(200,155,91,.14), transparent);
  box-shadow: -1rem 0 0 rgba(200,155,91,.14);
}
[dir="rtl"] .narration-unit.active-reading {
  background: linear-gradient(-90deg, rgba(200,155,91,.14), transparent);
  box-shadow: 1rem 0 0 rgba(200,155,91,.14);
}

.control-dock {
  position: fixed;
  z-index: 70;
  left: 50%;
  inset-block-end: max(.8rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(920px, calc(100% - 1.4rem));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .62rem .75rem;
  background: rgba(11,16,22,.91);
  border: 1px solid rgba(230,196,136,.22);
  border-radius: 1.15rem;
  box-shadow: 0 18px 55px rgba(0,0,0,.48);
  backdrop-filter: blur(18px);
}
.transport { display: flex; align-items: center; gap: .4rem; }
.round-button, .play-button {
  border: 0;
  color: var(--ink);
  background: rgba(255,255,255,.07);
  cursor: pointer;
}
.round-button { width: 2.45rem; height: 2.45rem; border-radius: 50%; }
.play-button { min-width: 7.8rem; height: 2.75rem; padding: 0 1rem; border-radius: 999px; color: #17130c; background: linear-gradient(135deg, var(--gold-bright), var(--gold)); font-weight: 700; }
.dock-options { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .75rem; }
.dock-options label { display: flex; align-items: center; gap: .35rem; white-space: nowrap; }
select { max-width: 160px; color: var(--ink); background: #1b252e; border: 1px solid var(--line); border-radius: .45rem; padding: .25rem .4rem; }
.switch-label input { position: absolute; opacity: 0; pointer-events: none; }
.switch-label span { width: 2rem; height: 1.1rem; padding: 2px; border-radius: 999px; background: #3b4248; transition: background .2s; }
.switch-label span::after { content: ""; display: block; width: .85rem; height: .85rem; border-radius: 50%; background: #ddd; transition: transform .2s; }
.switch-label input:checked + span { background: var(--gold); }
.switch-label input:checked + span::after { transform: translateX(.9rem); }
[dir="rtl"] .switch-label input:checked + span::after { transform: translateX(-.9rem); }

.experience-panel {
  position: fixed;
  z-index: 55;
  inset-block-start: 78px;
  inset-inline-end: 1rem;
  display: grid;
  gap: .65rem;
  width: 170px;
  padding: .7rem;
  color: var(--muted);
  background: rgba(11,16,22,.76);
  border: 1px solid var(--line);
  border-radius: .9rem;
  backdrop-filter: blur(12px);
  font-size: .72rem;
  opacity: .32;
  transition: opacity .2s;
}
.experience-panel:hover, .experience-panel:focus-within { opacity: 1; }
.experience-panel label { display: grid; gap: .25rem; }
.mode-switcher { display: grid; gap: .25rem; }
.mode-switcher button { padding: .4rem .55rem; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: .45rem; text-align: start; cursor: pointer; }
.mode-switcher button.active { color: var(--gold-bright); background: rgba(200,155,91,.1); border-color: var(--line); }

.caption-panel {
  position: fixed;
  z-index: 65;
  inset-inline: max(1rem, env(safe-area-inset-left));
  inset-block-end: 6.8rem;
  display: none;
  justify-content: center;
  pointer-events: none;
}
.caption-panel span {
  max-width: min(900px, 92vw);
  padding: .8rem 1.1rem;
  color: #fff;
  background: rgba(5,8,12,.9);
  border: 1px solid var(--line);
  border-radius: .7rem;
  box-shadow: var(--shadow);
  font-family: "Noto Serif Hebrew", "Noto Serif", Georgia, serif;
  font-size: clamp(1.15rem, 3vw, 1.8rem);
  line-height: 1.55;
  text-align: center;
}
.toast { position: fixed; z-index: 110; left: 50%; inset-block-start: 82px; transform: translateX(-50%) translateY(-20px); max-width: min(520px, 90vw); padding: .75rem 1rem; color: var(--ink); background: #202b34; border: 1px solid var(--line); border-radius: .7rem; opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

body.mode-read .chapter { display: block; min-height: 0; }
body.mode-read .chapter-visual { display: none; }
body.mode-read .chapter-text { padding-inline: clamp(1.4rem, 7vw, 7rem); background: var(--paper); }
body.mode-read .chapter-text h2 { max-width: var(--content-width); }

body.mode-focus .caption-panel { display: flex; }
body.mode-focus .chapter { display: block; min-height: 0; }
body.mode-focus .chapter-visual { display: none; }
body.mode-focus .chapter-text { width: min(100%, 980px); padding-inline: clamp(1rem, 4vw, 3rem); }
body.mode-focus .narration-unit { opacity: .2; }
body.mode-focus .narration-unit.active-reading { opacity: 1; transform: scale(1.015); }

body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
  scroll-behavior: auto !important;
  animation: none !important;
  transition-duration: .01ms !important;
}

@keyframes cover-breathe { from { transform: scale(1.035); } to { transform: scale(1.09); } }
@keyframes scroll-cue { 0% { opacity: 0; transform: translateY(0); } 25% { opacity: 1; } 80% { opacity: 0; transform: translateY(14px); } 100% { opacity: 0; } }

@media (max-width: 900px) {
  .chapter, [dir="rtl"] .chapter { display: block; }
  .chapter-visual, [dir="rtl"] .chapter .chapter-visual { grid-column: auto; min-height: 52svh; }
  .chapter-visual-inner { height: 52svh; top: 64px; }
  .chapter-visual::after, [dir="rtl"] .chapter-visual::after { background: linear-gradient(180deg, transparent 55%, var(--paper)); }
  [dir="rtl"] .chapter .chapter-text { grid-column: auto; grid-row: auto; }
  .chapter-text { padding-top: 4rem; }
  .dock-options { display: none; }
  .control-dock { justify-content: center; width: auto; }
  .experience-panel { width: 145px; }
}

@media (max-width: 620px) {
  .topbar { grid-template-columns: auto 1fr auto; height: 58px; padding-inline: .55rem; }
  .brand span { display: none; }
  .brand strong { font-size: .82rem; }
  .topbar .icon-button span { display: none; }
  .language-switch { padding: .45rem .65rem; font-size: .75rem; }
  .cover-content { padding-top: 6rem; }
  .chapter-text { padding: 3.4rem 1.15rem 8rem; }
  .chapter-text p, .chapter-text li { font-size: 1.08rem; line-height: 1.85; }
  .experience-panel { inset-block-start: auto; inset-block-end: 5.4rem; inset-inline-end: .55rem; width: auto; opacity: .2; }
  .experience-panel label, .mode-switcher button:not(.active) { display: none; }
  .experience-panel:hover { width: 155px; opacity: 1; }
  .experience-panel:hover label, .experience-panel:hover .mode-switcher button { display: grid; }
  .play-button { min-width: 6.7rem; height: 2.55rem; }
  .round-button { width: 2.25rem; height: 2.25rem; }
  .control-dock { inset-block-end: max(.35rem, env(safe-area-inset-bottom)); padding-block: .42rem; }
  .caption-panel { inset-block-end: 5.6rem; }
}

@media print {
  .topbar, .control-dock, .experience-panel, .caption-panel, .reading-progress, .scroll-cue, .toc-drawer, .drawer-backdrop { display: none !important; }
  .cover { min-height: 100vh; break-after: page; }
  .gate-divider { break-before: page; }
  .chapter { display: block; min-height: 0; break-before: page; }
  .chapter-visual { height: 34vh; min-height: 0; }
  .chapter-text { padding: 2rem; color: #111; background: white; }
  .chapter-text p, .chapter-text li { color: #111; }
}
