/* The web reader: full-screen verses over an ambient background, with the app's glass controls. */

:root {
  --bg: #1b0f2b;
  --text: #fff;
  --text-2: rgba(255, 255, 255, 0.72);
  --text-3: rgba(255, 255, 255, 0.5);
  --glass: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(255, 255, 255, 0.2);
  --glass-border: rgba(255, 255, 255, 0.16);
  --panel: rgba(28, 22, 40, 0.82);
  --accent: #ffd27a;
  --rounded: ui-rounded, "SF Pro Rounded", Nunito, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ink: 255, 255, 255;
  --verse-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  --label-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
  --backdrop: rgba(0, 0, 0, 0.35);
  --bar: rgba(22, 17, 32, 0.92);
  --seed-bg: linear-gradient(#3b1f4d, #1b0f2b);
  color-scheme: dark;
}

/* Light mode (docs/light-mode.md): deep plum-black text, white glass. */
:root[data-theme="light"] {
  --bg: #f6f1fa;
  --text: #211d26;
  --text-2: rgba(33, 29, 38, 0.68);
  --text-3: rgba(33, 29, 38, 0.5);
  --ink: 33, 29, 38;
  --glass: rgba(255, 255, 255, 0.55);
  --glass-strong: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(255, 255, 255, 0.7);
  --panel: rgba(252, 250, 255, 0.9);
  --accent: #a86a00;
  --verse-shadow: 0 2px 8px rgba(255, 255, 255, 0.6);
  --label-shadow: 0 1px 6px rgba(255, 255, 255, 0.7);
  --backdrop: rgba(40, 30, 50, 0.18);
  --bar: rgba(250, 247, 253, 0.94);
  --seed-bg: linear-gradient(#fcfaff, #ece4f3);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--rounded);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

#reader {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* Before the script takes over, and for crawlers: the verse itself. */
.seed {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--seed-bg);
  text-align: center;
}
.seed blockquote { margin: 0; max-width: 560px; }
.seed p { font: 400 clamp(26px, 5vw, 40px)/1.38 ui-serif, "New York", Georgia, serif; margin: 0 0 0.6em; text-shadow: var(--verse-shadow); }
.seed cite { font: 600 17px var(--rounded); font-style: normal; color: var(--text-2); }
.seed nav { position: absolute; bottom: calc(24px + var(--safe-bottom)); display: flex; gap: 20px; font-size: 14px; color: var(--text-3); }
.load-error, .noscript { position: fixed; left: 16px; right: 16px; bottom: 80px; text-align: center; color: var(--text-2); }

/* MARK: Background */

.ambient, .ambient-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.ambient { background: var(--bg); }

/* MARK: Pages */

.pager {
  position: absolute;
  inset: 0;
  touch-action: none;
}
.track { position: absolute; inset: 0; will-change: transform; }
.slide {
  position: absolute;
  left: 0;
  right: 0;
  height: 100%;
  display: grid;
  place-items: center;
}
.slide:nth-child(1) { top: -100%; }
.slide:nth-child(2) { top: 0; }
.slide:nth-child(3) { top: 100%; }

.verse {
  width: var(--text-width, 560px);
  height: var(--text-height, 70vh);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(var(--text-offset, 0));
  overflow: hidden;
  text-shadow: var(--verse-shadow);
  /* scrollTransition in VerseCardView: pages off screen are dim, small, and soft. */
  opacity: 0.2;
  scale: 0.92;
  filter: blur(4px);
  transition: opacity 0.45s ease, scale 0.45s ease, filter 0.45s ease;
}
.slide.current .verse { opacity: 1; scale: 1; filter: none; }
.content { display: flex; flex-direction: column; align-items: center; width: 100%; }
.verse.left .content { align-items: flex-start; }
.text {
  margin: 0;
  line-height: 1.376;
  overflow-wrap: break-word;
  user-select: text;
  -webkit-user-select: text;
}
.ref {
  margin: 0;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.5px;
}
.slide.loading .text::before {
  content: "";
  display: block;
  width: min(80%, 420px);
  height: 1.2em;
  margin: 0 auto;
  border-radius: 8px;
  background: rgba(var(--ink), 0.08);
  animation: pulse 1.2s ease-in-out infinite alternate;
}
@keyframes pulse { to { opacity: 0.4; } }

/* MARK: Glass controls */

.glass, .glass-disc {
  background: var(--glass);
  border: 0.5px solid var(--glass-border);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1), background 0.2s;
}
.glass:hover, .rail-button:hover .glass-disc { background: var(--glass-strong); }
.glass:active, .rail-button:active .glass-disc { transform: scale(0.86); }
.glass:focus-visible, .rail-button:focus-visible .glass-disc, .chip:focus-visible, .swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { width: 22px; height: 22px; flex: none; }
.icon.small { width: 13px; height: 13px; stroke-width: 3; }

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: calc(8px + var(--safe-top)) 14px 0;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar-side { display: flex; gap: 8px; pointer-events: none; }
.topbar-side > * { pointer-events: auto; }
.topbar-side.end { justify-content: flex-end; }
.topbar .citation { max-width: min(46vw, 320px); }
.pill {
  height: 48px;
  padding: 0 16px;
  border-radius: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.citation { font-weight: 600; min-width: 0; overflow: hidden; }
.citation .cite { overflow: hidden; text-overflow: ellipsis; }
.round {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
}

.rail {
  position: absolute;
  right: 10px;
  bottom: calc(max(var(--safe-bottom), 20px) + 40px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.wide .rail { right: 20px; bottom: 50%; transform: translateY(50%); }
.rail-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  color: rgba(var(--ink), 0.9);
  text-decoration: none;
  text-shadow: var(--label-shadow);
}
.glass-disc { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; }
.glass-disc .icon { width: 25px; height: 25px; }
.glass-disc.app img { border-radius: 7px; }
/* The rail buttons slide in one after another as each verse settles (railEntrance). */
.rail.enter .rail-button { animation: rail-in 0.5s cubic-bezier(0.3, 1.4, 0.5, 1) both; }
.rail.enter .rail-button:nth-child(2) { animation-delay: 0.06s; }
.rail.enter .rail-button:nth-child(3) { animation-delay: 0.12s; }
@keyframes rail-in { from { transform: translateX(60px); opacity: 0; } }

.stepper { display: none; }
@media (hover: hover) and (pointer: fine) {
  .stepper {
    position: absolute;
    right: 20px;
    bottom: calc(24px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .rail { bottom: auto; top: 50%; transform: translateY(-50%); right: 20px; }
  .wide .rail { bottom: auto; transform: translateY(-50%); }
}

.brand {
  position: absolute;
  left: 16px;
  bottom: calc(18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.brand-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  opacity: 0.8;
  text-shadow: var(--label-shadow);
}
.brand-name img { border-radius: 5px; }
.brand-name:hover { opacity: 1; }
.brand-get {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 17px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.toast {
  position: fixed;
  left: 50%;
  top: calc(72px + var(--safe-top));
  translate: -50% -10px;
  padding: 10px 18px;
  border-radius: 20px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, translate 0.25s;
  z-index: 30;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* MARK: Menus and sheets */

.glass-panel {
  background: var(--panel);
  border: 0.5px solid var(--glass-border);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  backdrop-filter: blur(30px) saturate(1.5);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-family: var(--rounded);
}

.menu {
  position: fixed;
  z-index: 20;
  min-width: 260px;
  padding: 6px;
  border-radius: 18px;
  opacity: 0;
  transform: scale(0.94) translateY(-6px);
  transform-origin: top left;
  transition: opacity 0.18s, transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.menu.open { opacity: 1; transform: none; }
.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
  font-size: 16px;
}
.menu button:hover, .menu button:focus-visible { background: rgba(var(--ink), 0.1); outline: none; }
.menu .lead { width: 22px; display: grid; place-items: center; flex: none; }
.menu .lead .icon { width: 20px; height: 20px; }
.menu .check { color: var(--accent); }
.menu .check .icon { width: 18px; height: 18px; }
.menu .trail { display: grid; color: var(--text-3); }
.menu .trail .icon { width: 16px; height: 16px; }
.menu .menu-back { gap: 6px; color: var(--text-2); font-weight: 700; font-size: 14px; padding: 9px 8px; }
.menu .menu-back .icon { width: 18px; height: 18px; }
.menu .name { flex: 1; }
.menu .abbr { color: var(--text-3); font-size: 13px; font-weight: 700; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--backdrop);
  opacity: 0;
  transition: opacity 0.3s;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed;
  z-index: 11;
  left: 50%;
  bottom: 0;
  width: min(100%, 560px);
  max-height: min(88dvh, 820px);
  display: flex;
  flex-direction: column;
  border-radius: 26px 26px 0 0;
  translate: -50% 100%;
  transition: translate 0.35s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.sheet.open { translate: -50% 0; }
@media (min-width: 700px) and (min-height: 600px) {
  .sheet { bottom: 50%; border-radius: 26px; translate: -50% calc(50% + 40px); opacity: 0; transition: translate 0.35s cubic-bezier(0.2, 0.9, 0.2, 1), opacity 0.25s; }
  .sheet.open { translate: -50% 50%; opacity: 1; }
}
.sheet-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 12px 12px 4px;
}
.sheet-head h2 { grid-column: 2; margin: 0; text-align: center; font-size: 17px; font-weight: 800; }
.sheet-back, .sheet-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: rgba(var(--ink), 0.1);
  display: grid;
  place-items: center;
  padding: 0;
}
.sheet-back { grid-column: 1; }
.sheet-close { grid-column: 3; justify-self: end; }
.sheet-back .icon, .sheet-close .icon { width: 18px; height: 18px; }
.sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 20px calc(24px + var(--safe-bottom));
}
.sheet h3 {
  margin: 18px 0 10px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

/* Index */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.number-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; padding-top: 10px; }
.book-grid button, .number-grid button {
  border: 0;
  border-radius: 12px;
  background: rgba(var(--ink), 0.07);
  padding: 12px 10px;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
}
.number-grid button { text-align: center; font-variant-numeric: tabular-nums; }
.book-grid button:hover, .number-grid button:hover { background: rgba(var(--ink), 0.14); }
.book-grid .here, .number-grid .here { background: rgba(255, 210, 122, 0.2); color: var(--accent); }

/* Search */
.search-field {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 46px;
  border-radius: 14px;
  background: rgba(var(--ink), 0.1);
}
.search-field .icon { width: 18px; height: 18px; color: var(--text-3); }
.search-field input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 17px; }
.results { padding-top: 8px; }
.hint, .count { color: var(--text-3); font-size: 14px; line-height: 1.5; }
.count { margin: 10px 0 4px; font-weight: 700; }
.result {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 12px 4px;
  border-bottom: 0.5px solid rgba(var(--ink), 0.1);
}
.result:hover { background: rgba(var(--ink), 0.05); }
.result-ref { display: block; font-weight: 800; font-size: 14px; margin-bottom: 4px; }
.result-text { font: 16px/1.45 ui-serif, Georgia, serif; color: var(--text-2); }
.result mark { background: rgba(255, 210, 122, 0.25); color: var(--text); border-radius: 3px; padding: 0 1px; }
.result.jump { display: flex; align-items: center; gap: 10px; font-size: 16px; padding: 14px 4px; }
.result.jump .icon { color: var(--accent); }

/* Settings and composer controls */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 0;
  border-radius: 18px;
  padding: 8px 14px;
  background: rgba(var(--ink), 0.08);
  font-size: 14px;
  font-weight: 600;
}
.chip.on { background: var(--text); color: var(--bg); }
.swatches { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; padding: 0; font-size: 11px; color: var(--text-2); }
.swatch span { width: 40px; height: 40px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(var(--ink), 0.15); }
.swatch.on { color: var(--text); font-weight: 800; }
.swatch.on span { box-shadow: inset 0 0 0 3px var(--text); }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  font-size: 16px;
  border-bottom: 0.5px solid rgba(var(--ink), 0.08);
}
.row .chips { justify-content: flex-end; }
.row input[type="range"] { width: min(60%, 260px); accent-color: var(--text); }
.row select {
  background: rgba(var(--ink), 0.1);
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
}
.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 51px;
  height: 31px;
  border-radius: 16px;
  background: rgba(var(--ink), 0.2);
  position: relative;
  transition: background 0.2s;
  margin: 0;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }
.note { color: var(--text-3); font-size: 14px; line-height: 1.5; margin-top: 18px; }

/* Share composer */
.share-sheet { width: min(100%, 520px); }
.share-sheet .sheet-body { padding-bottom: 0; }
.composer { display: flex; flex-direction: column; }
.preview-wrap { display: grid; place-items: center; padding: 6px 0 18px; }
.preview { border-radius: 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45); }
.segmented { display: flex; padding: 3px; border-radius: 12px; background: rgba(var(--ink), 0.08); }
.segmented button { flex: 1; border: 0; background: none; padding: 8px 4px; border-radius: 9px; font-size: 14px; font-weight: 700; }
.segmented button small { display: block; font-size: 11px; font-weight: 600; color: var(--text-3); }
.segmented button { font-size: 13px; line-height: 1.2; padding: 7px 2px; }
.wallpaper-size { margin-top: 6px; }
.format-caption { margin: 8px 0 0; text-align: center; font-size: 13px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.wallpaper-size select { max-width: 70%; }
.segmented button.on { background: rgba(var(--ink), 0.22); }
.controls .swatches { margin-top: 12px; }
.export-bar {
  position: sticky;
  bottom: 0;
  margin: 18px -20px 0;
  padding: 12px 20px calc(14px + var(--safe-bottom));
  background: var(--bar);
  border-top: 0.5px solid rgba(var(--ink), 0.08);
}
.export-buttons { display: flex; gap: 10px; }
.export {
  flex: 1;
  height: 50px;
  border: 0;
  border-radius: 25px;
  background: rgba(var(--ink), 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
}
.export:hover { background: rgba(var(--ink), 0.26); }
.export .icon { width: 20px; height: 20px; }
.export-progress { display: flex; align-items: center; gap: 12px; height: 50px; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.export-progress progress { flex: 1; accent-color: var(--text); }
.export-progress .stop { border: 0; background: none; font-weight: 800; color: var(--text); }
[hidden] { display: none !important; }

@media (max-width: 440px) {
  .pill { height: 40px; padding: 0 11px; font-size: 14px; }
  .citation .icon.small { display: none; }
  .round { width: 38px; height: 38px; }
  .round .icon { width: 20px; height: 20px; }
  .topbar, .topbar-side { gap: 4px; }
  .topbar { padding-left: 10px; padding-right: 10px; }
  /* Two 38 px buttons on each side keep the verse picker centered. */
  .topbar .citation { max-width: calc(100vw - 20px - 8px - 2 * 80px); }
  .brand { left: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .verse, .glass, .sheet, .menu { transition: none; }
  .rail.enter .rail-button { animation: none; }
}
