:root {
  color-scheme: dark;
  --gold: #d8c68f;
  --sand: #e8e0cc;
  --bg: #101018;
  --panel: #17171f;
  --border: #2a2a35;
  --accent: #8a6d2c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--sand);
  font-family: Georgia, "Times New Roman", serif;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

header {
  /* safe-area padding keeps content clear of the iPhone notch / home
     indicator when installed to the home screen (black-translucent). */
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 6px calc(12px + env(safe-area-inset-left));
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 8px;
}

.brand-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  align-self: center;
}

.brand-name {
  font-size: 17px;
  letter-spacing: 4px;
  color: var(--sand);
}

.brand-theta { color: #d3a13c; }

.brand-tag {
  font-size: 9px;
  letter-spacing: 2.5px;
  color: #8a8aa0;
}

.pickers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pickers label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: #9a9aa8;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 90px;
}

select {
  font-family: inherit;
  font-size: 15px;
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #1c1c26;
  color: var(--sand);
  min-height: 40px;
}

.attribution {
  margin-top: 6px;
  font-size: 11px;
  font-style: italic;
  color: #8a8aa0;
  line-height: 1.4;
}

#stage-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 42vh;
  background: #000;
  overflow: hidden;
}

#stage {
  position: absolute;
  inset: 0;
  cursor: pointer;
  /* No double-tap-to-zoom: double tap is verse prev/next. */
  touch-action: manipulation;
}

#stage-bg {
  position: absolute;
  inset: 0;
  transition: background 0.3s ease;
}

#stage-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

#stage-img.diagram { object-fit: contain; }
#stage-img.visible { display: block; }

/* Inline icons (play/pause/fullscreen). Monochrome SVG rather than Unicode
   glyphs so iOS Safari doesn't substitute a color emoji (▶/⏸ render as
   emoji-in-a-circle on iPhone). Inherits the button's text color. */
.ic {
  width: 1.05em;
  height: 1.05em;
  fill: currentColor;
  vertical-align: -0.18em;
  flex: none;
}

#btn-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
#btn-play .ic { width: 18px; height: 18px; vertical-align: 0; }
#btn-stage-play .ic { width: 40px; height: 40px; }
#btn-fullscreen .ic { width: 22px; height: 22px; vertical-align: 0; }

/* Text visuals (.txt/.rtf files in visuals/) — rendered like the notes
   box, but centered on the stage over the book gradient. */
#stage-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 60px);
  max-height: calc(100% - 80px);
  overflow: hidden;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 14px 22px;
  border-radius: 8px;
  font-style: italic;
  color: var(--sand);
  font-size: clamp(13px, 3vw, 20px);
  white-space: pre-wrap;
  pointer-events: none;
  display: none;
}

#stage-text.visible { display: block; }

#idle-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 40px;
  font-style: italic;
  color: #8a8aa0;
  white-space: pre-line;
  font-size: clamp(14px, 4vw, 22px);
}

#notes-box {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 60px);
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 8px 14px;
  border-radius: 6px;
  font-style: italic;
  pointer-events: none;
  bottom: 20%;
  color: var(--sand);
  font-size: clamp(11px, 2.4vw, 16px);
}

#notes-box:empty { display: none; }

/* Fullscreen: the Fullscreen API is used where available; this fixed
   overlay is both the iOS Safari fallback (no requestFullscreen on
   arbitrary elements) and the shared styling for either mode. */
#stage-wrap.fullscreen {
  position: fixed;
  inset: 0;
  height: 100dvh;
  z-index: 1000;
}

/* Center Play/Pause, video-player style: summoned by a single tap on
   the stage, fades back out after a few seconds (see app.js). */
#btn-stage-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 34px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(216, 198, 143, 0.45);
  border-radius: 50%;
  color: var(--sand);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  touch-action: manipulation;
}

#btn-stage-play.show {
  opacity: 1;
  pointer-events: auto;
}

/* Fullscreen toggle, video-player style: while not in fullscreen it stays
   visible to encourage a fullscreen view; in fullscreen it fades out after
   a tap like the center control (see app.js). */
#btn-fullscreen {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 10;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 10px;
  font-size: 22px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(216, 198, 143, 0.4);
  border-radius: 8px;
  color: var(--sand);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  touch-action: manipulation;
}

#btn-fullscreen.show {
  opacity: 1;
  pointer-events: auto;
}

#controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

button {
  font-family: inherit;
  font-size: 15px;
  background: #1c1c26;
  color: var(--sand);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 44px;
}

button:active { background: var(--accent); }

button.primary {
  background: var(--accent);
  border-color: #a9843a;
  color: #16130a;
  font-weight: bold;
  min-width: 100px;
}

#verse-progress {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: #9a9aa8;
}

.toggles {
  display: flex;
  gap: 14px;
  padding: 8px 12px;
  font-size: 12px;
  color: #9a9aa8;
  background: var(--panel);
}

.toggles label { display: flex; align-items: center; gap: 5px; }

#verse-panel {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 14px calc(40px + env(safe-area-inset-bottom));
  max-height: 30vh;
}

#verse-panel p {
  margin: 0 0 10px;
  line-height: 1.5;
  font-size: 16px;
}

#verse-panel .vnum {
  font-weight: bold;
  color: var(--gold);
  margin-right: 6px;
  font-size: 13px;
  vertical-align: super;
}

#verse-panel p.current {
  background: rgba(216, 198, 143, 0.12);
  border-radius: 6px;
  padding: 4px 8px;
  margin-left: -8px;
  margin-right: -8px;
}

@media (min-width: 700px) {
  #stage-wrap { min-height: 55vh; }
  header, #controls, .toggles, #verse-panel { padding-left: 24px; padding-right: 24px; }
}
