/* Buchansicht (Entwurf 20.10.2026)
   Breit: Bild links, Text rechts wie ein aufgeschlagenes Bilderbuch.
   Schmal: Bild oben in voller Breite, Text darunter – nichts liegt mehr über dem Bild. */
:root {
  --ba-grund: #f4f1ea;
  --ba-papier: #fffdf8;
  --ba-tinte: #2d2a26;
  --ba-leise: #6f6a62;
  --ba-linie: #e6dfd2;
  --ba-akzent: #008c4a;      /* Marti-Grün */
  --ba-akzent-hell: #e3f3ea;
  --ba-knopf: #ffffff;
  --ba-schatten: 0 1px 2px rgba(45, 42, 38, .08), 0 6px 18px rgba(45, 42, 38, .08);
  --ba-titel: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --ba-lese: "Andika", "Verdana", system-ui, sans-serif;
  --ba-schrift-stufe: 0;
  --ba-schrift: calc(1.12rem + var(--ba-schrift-stufe) * .12rem);
  color-scheme: light;
}

* { box-sizing: border-box; }
body.ba {
  margin: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
  background: var(--ba-grund);
  color: var(--ba-tinte);
  font: 400 1rem/1.5 var(--ba-lese);
}
[hidden] { display: none !important; }
button { font: inherit; }

/* ---------- Kopf ---------- */
.ba-kopf {
  display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--ba-papier);
  border-bottom: 1px solid var(--ba-linie);
}
.ba-logo img { display: block; width: 52px; height: 52px; border-radius: 50%; }
.ba-titel {
  flex: 1; min-width: 0; margin: 0;
  font: 600 clamp(1.05rem, 2.6vw, 1.45rem)/1.2 var(--ba-titel);
  text-wrap: balance;
}
.ba-video { margin: 10px auto 0; text-align: center; }
.ba-video a { display: inline-flex; align-items: center; gap: 8px; color: var(--ba-tinte); font-weight: 700; text-decoration: none; }

/* ---------- Knöpfe ---------- */
.ba-knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 44px; height: 44px; padding: 0 12px;
  border: 1px solid var(--ba-linie); border-radius: 22px;
  background: var(--ba-knopf); color: var(--ba-tinte);
  font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer;
  transition: background .15s, transform .1s;
}
.ba-knopf:hover { background: var(--ba-akzent-hell); }
.ba-knopf:active { transform: scale(.96); }
.ba-knopf:focus-visible, .ba-mini:focus-visible { outline: 3px solid var(--ba-akzent); outline-offset: 2px; }
.ba-knopf:disabled { opacity: .35; cursor: default; background: var(--ba-knopf); }
.ba-knopf[aria-pressed="true"] { background: var(--ba-akzent); border-color: var(--ba-akzent); color: #fff; }
.ba-knopf-leise { background: transparent; }

/* ---------- Buch ---------- */
.ba-buch {
  flex: 1; width: 100%; max-width: 1280px; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 14px;
}
.ba-seite {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .85fr);
  align-items: center;
  gap: clamp(16px, 3vw, 36px);
  background: var(--ba-papier);
  border-radius: 18px;
  box-shadow: var(--ba-schatten);
  padding: clamp(12px, 2vw, 24px);
}
.ba-seite.ohne-text { grid-template-columns: minmax(0, 1fr); justify-items: center; }
.ba-bild { margin: 0; width: 100%; }
.ba-bild img {
  display: block; width: 100%; height: auto;
  max-height: calc(100vh - 230px); object-fit: contain;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  user-select: none; -webkit-user-drag: none;
}
.ba-seite.ohne-text .ba-bild img { width: auto; max-width: 100%; margin: 0 auto; }
.ba-bild img.ba-quer { aspect-ratio: auto; }   /* Querformat-Seiten (z. B. Adventgeschichte 4:3) */
.ba-text { min-width: 0; max-width: 34em; }
.ba-text h2 {
  margin: 0 0 .5em;
  font: 600 calc(var(--ba-schrift) * 1.45)/1.15 var(--ba-titel);
  color: var(--ba-akzent);
  text-wrap: balance;
}
.ba-text p { margin: 0 0 .8em; font-size: var(--ba-schrift); line-height: 1.65; }
.ba-text p:last-child { margin-bottom: 0; }
.ba-buch.liest-vor .ba-seite.ist-aktiv .ba-text { background: var(--ba-akzent-hell); border-radius: 12px; padding: 12px 16px; transition: background .3s; }

/* Seitenwechsel */
.ba-seite.von-rechts { animation: ba-rein-rechts .28s ease-out; }
.ba-seite.von-links  { animation: ba-rein-links .28s ease-out; }
/* nur ein kurzes Gleiten, ohne Ausblenden – sonst scheint beim Blättern der Hintergrund durch */
@keyframes ba-rein-rechts { from { transform: translateX(14px); } to { transform: none; } }
@keyframes ba-rein-links  { from { transform: translateX(-14px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .ba-seite.von-rechts, .ba-seite.von-links { animation: none; } }

/* ---------- Bedienleiste ---------- */
.ba-leiste {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
}
.ba-zurueck, .ba-weiter { font-size: 1.6rem; line-height: 1; padding: 0 16px; }
.ba-zaehler { min-width: 4.5em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ba-leise); }
.ba-trenner { width: 1px; height: 28px; background: var(--ba-linie); margin: 0 4px; }
.ba-schrift { display: inline-flex; gap: 4px; }

/* ---------- Miniaturen ---------- */
.ba-miniaturen {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px;
  scroll-snap-type: x proximity;
}
.ba-miniaturen { position: relative; }
.ba-mini {
  position: relative; flex: 0 0 auto; padding: 0; border: 3px solid transparent; border-radius: 10px;
  background: none; cursor: pointer; scroll-snap-align: center; opacity: .75;
}
.ba-mini img { display: block; width: 72px; height: 72px; object-fit: cover; border-radius: 7px; }
.ba-mini span {
  position: absolute; right: 4px; bottom: 4px; padding: 0 5px; border-radius: 6px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: .72rem; font-weight: 700;
}
.ba-mini.ist-aktiv { border-color: var(--ba-akzent); opacity: 1; }
.ba-mini:hover { opacity: 1; }

/* ---------- Fuß ---------- */
.ba-fuss {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  font-size: .9rem; color: var(--ba-leise);
}
.ba-fuss a { color: var(--ba-akzent); text-decoration: none; font-weight: 700; }
.ba-fuss small { flex-basis: 100%; text-align: center; font-size: .68rem; opacity: .6; }
.ba-fuss .ba-impressum { font-weight: 400; color: inherit; text-decoration: none; }
.ba-fuss .ba-impressum:hover { opacity: .8; }

/* ---------- Schmal (Handy, Tablet hochkant) ---------- */
@media (max-width: 820px) {
  .ba-seite { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 14px; align-items: start; }
  .ba-bild img { max-height: none; }
  .ba-text { padding: 0 6px 6px; max-width: none; }
  .ba-nur-breit { display: none; }
  .ba-logo img { width: 42px; height: 42px; }
  .ba-buch { padding-top: 12px; }
  .ba-trenner { display: none; }
  /* Bedienleiste bleibt beim Lesen langer Texte am unteren Rand erreichbar */
  .ba-leiste {
    position: sticky; bottom: 0; z-index: 2;
    margin: 0 -16px; padding: 8px 16px max(8px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--ba-grund) 92%, transparent);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--ba-linie);
  }
  .ba-knopf { min-width: 40px; height: 40px; padding: 0 8px; font-size: .95rem; }
  .ba-leiste { gap: 5px; flex-wrap: nowrap; }
  .ba-zaehler { min-width: 3.6em; font-size: .95rem; }
  .ba-zurueck, .ba-weiter { padding: 0 12px; }
  .ba-mini { position: relative; }
}

/* ---------- Vollbild ---------- */
.ba-buch:fullscreen {
  max-width: none; height: 100vh; overflow: auto;
  background: #1d1a24; padding: 16px 24px;
  justify-content: center;
}
.ba-buch:fullscreen .ba-seite { background: #2a2633; box-shadow: none; color: #f3eee6; }
.ba-buch:fullscreen .ba-text h2 { color: #ffb36b; }
.ba-buch:fullscreen .ba-bild img { max-height: calc(100vh - 110px); }
.ba-buch:fullscreen .ba-miniaturen { display: none; }
.ba-buch:fullscreen .ba-zaehler { color: #cfc8bd; }
.ba-buch:fullscreen.liest-vor .ba-seite.ist-aktiv .ba-text { background: #3a3446; }
@media (max-width: 820px) {
  .ba-buch:fullscreen .ba-leiste { background: #1d1a24; border-top-color: #3a3446; }
}

/* Hinweis bei Vorschau (Buch noch nicht erschienen oder ausgeschaltet) */
.ba-vorschau { margin: 0; padding: 8px 16px; background: #fff3cd; color: #5c4400; text-align: center; font-weight: 700; font-size: .92rem; }
