/* Blaetterer: ein Comic zum Durchblaettern, Seiten oder Bild fuer Bild. Ohne Bibliotheken.
   Baustein fuer Falzbeins Comicseiten, Agent fuer Falzbein, 20.11.2026. Gebrauch: siehe LIESMICH in blaetterer.js.
   Farben: nimmt die Tokens der Seite (--flaeche, --grund, --text, --leise, --linie, --akzent, --akzent-text),
   sonst eigene Rueckfallwerte, hell als Standard, dunkel ueber prefers-color-scheme oder html[data-modus]. */

:root {
  --bl-fb-flaeche: #FFFDF8;
  --bl-fb-tisch: #EFE8DA;
  --bl-fb-text: #1B1D22;
  --bl-fb-leise: #555B66;
  --bl-fb-linie: #D6D1C6;
  --bl-fb-akzent: #1F4E8C;
  --bl-fb-akzent-text: #FFFFFF;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-modus="hell"]) {
    --bl-fb-flaeche: #1C1F25;
    --bl-fb-tisch: #121418;
    --bl-fb-text: #ECE8E1;
    --bl-fb-leise: #BEB9B1;
    --bl-fb-linie: #3A3E47;
    --bl-fb-akzent: #9CC3F5;
    --bl-fb-akzent-text: #101318;
  }
}
:root[data-modus="dunkel"] {
  --bl-fb-flaeche: #1C1F25;
  --bl-fb-tisch: #121418;
  --bl-fb-text: #ECE8E1;
  --bl-fb-leise: #BEB9B1;
  --bl-fb-linie: #3A3E47;
  --bl-fb-akzent: #9CC3F5;
  --bl-fb-akzent-text: #101318;
}

.bl {
  --bl-flaeche: var(--flaeche, var(--bl-fb-flaeche));
  --bl-tisch: var(--grund, var(--bl-fb-tisch));
  --bl-text: var(--text, var(--bl-fb-text));
  --bl-leise: var(--leise, var(--bl-fb-leise));
  --bl-linie: var(--linie, var(--bl-fb-linie));
  --bl-akzent: var(--akzent, var(--bl-fb-akzent));
  --bl-akzent-text: var(--akzent-text, var(--bl-fb-akzent-text));
  --bl-dauer: 460ms;
  position: relative;
  max-width: 100%;
  color: var(--bl-text);
  margin: 1.2em 0 1.6em;
}
.bl *, .bl *::before, .bl *::after { box-sizing: border-box; }
.bl-vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* Ohne Skript: die Ersatzfassung (vom Seitenbau mitgegeben) bleibt stehen */
.bl.bl-bereit > .bl-ersatz { display: none; }
.bl-ersatz img { display: block; max-width: 100%; height: auto; margin: 0 0 1em; }

/* Leiste oben */
.bl-leiste { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; }
.bl-ansicht { display: inline-flex; border: 2px solid var(--bl-linie); border-radius: 999px; padding: 3px; background: var(--bl-flaeche); }
.bl-ansicht[hidden] { display: none; }
.bl button, .bl a.bl-knopf { font: inherit; }
.bl-ansicht button {
  min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent;
  color: var(--bl-text); cursor: pointer; font-weight: 700; font-size: .95rem;
}
.bl-ansicht button[aria-pressed="true"] { background: var(--bl-akzent); color: var(--bl-akzent-text); }
.bl-voll {
  min-height: 44px; min-width: 44px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px;
  border: 2px solid var(--bl-linie); border-radius: 999px; background: var(--bl-flaeche); color: var(--bl-text);
  cursor: pointer; font-weight: 700; font-size: .95rem;
}
.bl-voll[hidden] { display: none; }
.bl-voll svg { width: 18px; height: 18px; }
.bl button:focus-visible, .bl a:focus-visible { outline: 3px solid var(--bl-text); outline-offset: 3px; }

/* Buehne */
.bl-buehne {
  position: relative; overflow: hidden; border-radius: 12px; background: var(--bl-tisch);
  border: 1px solid var(--bl-linie); perspective: 1600px; touch-action: pan-y pinch-zoom;
  height: 60vh; user-select: none; -webkit-user-select: none;
}
.bl-blatt { position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; padding: 10px; }
.bl-blatt img {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  border-radius: 4px; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); background: var(--bl-flaeche);
  -webkit-user-drag: none;
}

/* Die beiden Haelften: echte Knoepfe, rechts weiter, links zurueck */
.bl-haelfte {
  position: absolute; top: 0; bottom: 0; width: 50%; z-index: 3; border: 0; margin: 0; padding: 0 12px;
  background: transparent; cursor: pointer; display: flex; align-items: center; color: var(--bl-text);
  -webkit-tap-highlight-color: transparent;
}
.bl-haelfte[disabled] { cursor: default; }
.bl-haelfte[disabled] .bl-pfeil { visibility: hidden; }
.bl-zurueck { left: 0; justify-content: flex-start; }
.bl-weiter { right: 0; justify-content: flex-end; }
.bl-pfeil {
  width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bl-flaeche); border: 2px solid var(--bl-linie); opacity: .72;
}
.bl-pfeil svg { width: 20px; height: 20px; }
.bl-haelfte:hover .bl-pfeil, .bl-haelfte:focus-visible .bl-pfeil { opacity: 1; border-color: var(--bl-akzent); }
.bl-haelfte:focus-visible { outline: none; }
.bl-haelfte:focus-visible .bl-pfeil { outline: 3px solid var(--bl-text); outline-offset: 2px; }

/* Ende: Nachwort, PDF, nochmal */
.bl-endkarte { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px 64px; }
.bl-endkarte > div {
  background: var(--bl-flaeche); border: 1px solid var(--bl-linie); border-radius: 12px; padding: 20px 24px;
  max-width: 40rem; max-height: 100%; overflow: auto; box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}
.bl-endkarte h3 { margin: 0 0 .5em; font-size: 1.3rem; line-height: 1.2; }
.bl-endkarte p { margin: 0 0 1em; line-height: 1.55; }
.bl-endknoepfe { display: flex; flex-wrap: wrap; gap: 10px; position: relative; z-index: 4; }
.bl a.bl-knopf, .bl button.bl-knopf {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 20px; border-radius: 12px;
  font-weight: 700; text-decoration: none; cursor: pointer; border: 2px solid var(--bl-akzent);
}
.bl a.bl-knopf { background: var(--bl-akzent); color: var(--bl-akzent-text); }
.bl button.bl-knopf { background: var(--bl-flaeche); color: var(--bl-akzent); }
.bl-ende-aktiv .bl-haelfte { width: 56px; }

/* Fortschritt */
.bl-fuss { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; min-height: 28px; }
.bl-punkte { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.bl-punkte li { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--bl-leise); margin: 0; }
.bl-punkte li.bl-gesehen { background: var(--bl-leise); }
.bl-punkte li.bl-jetzt { background: var(--bl-akzent); border-color: var(--bl-akzent); transform: scale(1.25); }
.bl-zahl { margin: 0; color: var(--bl-leise); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Vollbild */
.bl:fullscreen { background: var(--bl-tisch); padding: 12px 16px; margin: 0; display: flex; flex-direction: column; }
.bl:fullscreen .bl-buehne { flex: 1 1 auto; border: 0; }
.bl:-webkit-full-screen { background: var(--bl-tisch); padding: 12px 16px; margin: 0; }

/* Umblaettern: die Seite kippt leicht nach links weg, die naechste gleitet nach */
@keyframes bl-weg-vor { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(-7%) rotateY(16deg); } }
@keyframes bl-her-vor { from { opacity: 0; transform: translateX(4%); } to { opacity: 1; transform: none; } }
@keyframes bl-weg-zurueck { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(7%) rotateY(-10deg); } }
@keyframes bl-her-zurueck { from { opacity: 0; transform: translateX(-4%); } to { opacity: 1; transform: none; } }
@keyframes bl-blende-aus { from { opacity: 1; } to { opacity: 0; } }
@keyframes bl-blende-ein { from { opacity: 0; } to { opacity: 1; } }
.bl-weg { z-index: 2; pointer-events: none; transform-origin: left center; }
.bl-weg.bl-vor { animation: bl-weg-vor var(--bl-dauer) cubic-bezier(.4, 0, .2, 1) both; }
.bl-weg.bl-rueck { animation: bl-weg-zurueck var(--bl-dauer) cubic-bezier(.4, 0, .2, 1) both; transform-origin: right center; }
.bl-her.bl-vor { animation: bl-her-vor var(--bl-dauer) cubic-bezier(.2, 0, .2, 1) both; }
.bl-her.bl-rueck { animation: bl-her-zurueck var(--bl-dauer) cubic-bezier(.2, 0, .2, 1) both; }
@media (prefers-reduced-motion: reduce) {
  .bl { --bl-dauer: 220ms; }
  .bl-weg.bl-vor, .bl-weg.bl-rueck { animation: bl-blende-aus var(--bl-dauer) linear both; transform: none; }
  .bl-her.bl-vor, .bl-her.bl-rueck { animation: bl-blende-ein var(--bl-dauer) linear both; transform: none; }
  .bl-punkte li.bl-jetzt { transform: none; }
}

@media (max-width: 480px) {
  .bl-ansicht button { padding: 0 12px; font-size: .9rem; }
  .bl-voll .bl-voll-text { display: none; }
  .bl-endkarte { padding: 12px 52px; }
  .bl-endkarte > div { padding: 16px; }
  .bl-pfeil { width: 38px; height: 38px; }
  .bl-haelfte { padding: 0 6px; }
}
