/* InfoPanda Flipbook – Viewer */

/* ---------- Blätter-Engine ---------- */
.fb-stage { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y; }
/* Zoom-Ebene (Mausrad / Zwei-Finger-Geste) */
.fb-zoomlayer {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  transform-origin: 0 0; transition: transform .16s ease-out;
}
.fb-zoomlayer.no-anim { transition: none; }
.fb-stage.is-zoomed, .fb-stage.is-zoomed .fb-book { touch-action: none; cursor: grab; }
.fb-stage.is-zoomed.is-panning, .fb-stage.is-zoomed.is-panning .fb-book { cursor: grabbing; }
.fb-stage.is-zoomed .fb-book { filter: none; }
.fb-book {
  position: relative; flex: none;
  transition: transform .55s cubic-bezier(.3,.1,.3,1);
  touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab;
  filter: drop-shadow(0 18px 22px rgba(20, 24, 30, .22)) drop-shadow(0 2px 4px rgba(20, 24, 30, .12));
}
.fb-book.is-dragging { cursor: grabbing; transition: none; }
.fb-page { position: absolute; top: 0; width: var(--pw); height: var(--ph); background: #fff; overflow: hidden; }
.fb-page img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.fb-page img:not([src]) { visibility: hidden; }
.fb-page.is-empty { background: transparent; }
.fb-left { left: 0; }
.fb-right { left: var(--pw); }
.fb-book.single .fb-left { display: none; }
.fb-book.single .fb-right { left: 0; }

/* Falz in der Buchmitte */
.fb-left::after, .fb-right::after { content: ''; position: absolute; top: 0; bottom: 0; width: 9%; pointer-events: none; }
.fb-left::after { right: 0; background: linear-gradient(to left, rgba(0,0,0,.16), rgba(0,0,0,.04) 35%, transparent); }
.fb-right::after { left: 0; background: linear-gradient(to right, rgba(0,0,0,.14), rgba(0,0,0,.03) 35%, transparent); }
.fb-book.single .fb-right::after { width: 3%; background: linear-gradient(to right, rgba(0,0,0,.08), transparent); }
.fb-page.is-empty::after { display: none; }

.fb-page.is-loading::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%; border: 2.5px solid rgba(31, 36, 48, .12); border-top-color: rgba(31, 36, 48, .45);
  animation: fb-spin .8s linear infinite;
}
@keyframes fb-spin { to { transform: rotate(360deg); } }

/* Faltung */
.fb-fold { position: absolute; top: 0; width: 0; height: var(--ph); pointer-events: none; display: none; z-index: 3; }
.fb-turn, .fb-castbox { position: absolute; top: 0; width: var(--pw); height: var(--ph); }
.fb-turn { background: #fff; }
.fb-castbox { overflow: hidden; }
.fb-flapwrap { position: absolute; left: 0; top: 0; width: 0; height: 0; filter: drop-shadow(0 0 5px rgba(0,0,0,.16)); }
.fb-flap { left: 0; top: 0; transform-origin: 0 0; background: #fbfbf9; }
.fb-flap.is-empty { background: linear-gradient(135deg, #fbfbf9, #eceeea); }
.fb-strip { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.fb-strip-front { background: linear-gradient(to bottom, rgba(0,0,0,.55), rgba(0,0,0,.12) 40%, transparent); }
.fb-strip-cast { background: linear-gradient(to bottom, rgba(0,0,0,.7), rgba(0,0,0,.18) 45%, transparent); }
.fb-strip-flap { background: linear-gradient(to bottom, rgba(0,0,0,.35), rgba(255,255,255,.55) 35%, rgba(255,255,255,0) 100%); }

/* ---------- Viewer-Oberfläche ---------- */
.ipv {
  --fb-accent: #2B7BB0; --fb-on-accent: #fff; --fb-bg: #E9F2F8; --fb-ink: #10263A;
  position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%; height: 100%; min-height: 320px; overflow: hidden;
  background: var(--fb-bg); color: var(--fb-ink);
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 14px;
  outline: none; -webkit-tap-highlight-color: transparent;
}
.ipv *, .ipv *::before, .ipv *::after { box-sizing: border-box; }
.ipv [hidden] { display: none !important; }

.ipv-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px 4px; min-height: 56px; }
.ipv-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ipv-logo { max-height: 36px; max-width: 160px; width: auto; object-fit: contain; display: block; }
.ipv-brandslot { display: flex; align-items: center; }
.ipv-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.ipv-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.ipv-extra { display: flex; align-items: center; gap: 8px; margin-left: 6px; }
.ipv-extra:empty { display: none; }

.ipv-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; text-decoration: none;
}
.ipv-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ipv-btn:hover { background: color-mix(in srgb, var(--fb-ink) 9%, transparent); }
.ipv-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.ipv-btn:focus-visible, .ipv-side:focus-visible, .ipv-range:focus-visible, .ipv-pageinput:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 2px; }

.ipv-stagewrap { position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; align-items: center; min-height: 0; padding: 10px 0; }
.ipv-stage { grid-column: 2; grid-row: 1; height: 100%; min-height: 0; }
.ipv-side-prev { grid-column: 1; grid-row: 1; }
.ipv-side-next { grid-column: 3; grid-row: 1; }
.ipv-side {
  justify-self: center; display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border-radius: 50%;
  border: 0; background: color-mix(in srgb, var(--fb-ink) 7%, transparent); color: inherit; cursor: pointer; z-index: 2;
  transition: background .15s, color .15s;
}
.ipv-side svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ipv-side:hover:not(:disabled) { background: var(--fb-accent); color: var(--fb-on-accent); }
.ipv-side:disabled { opacity: 0; pointer-events: none; }

/* Zoom-Anzeige */
.ipv-zoompill {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 99px;
  background: rgba(255,255,255,.92); color: #1F2430; box-shadow: 0 4px 16px rgba(0,0,0,.18);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.ipv-zoompill .ipv-btn { width: 34px; height: 34px; border-radius: 99px; }
.ipv-zoompill .ipv-btn svg { width: 19px; height: 19px; }
.ipv-zoompill .ipv-btn:hover { background: rgba(31,36,48,.08); }
.ipv-zoompill .ipv-zoomlabel { font-size: 13px; font-weight: 500; }

/* Lautstärke Blättergeräusch */
.ipv-soundwrap { position: relative; display: flex; }
.ipv-vol {
  --fb-ink: #1F2430;
  position: absolute; top: calc(100% + 6px); right: -6px; z-index: 9;
  display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 14px;
  background: #fff; color: #1F2430; box-shadow: 0 8px 26px rgba(0,0,0,.2);
}
.ipv-vol::before {
  content: ''; position: absolute; top: -6px; right: 20px; width: 12px; height: 12px;
  background: #fff; transform: rotate(45deg); border-radius: 2px;
}
.ipv-vol .ipv-btn { width: 36px; height: 36px; }
.ipv-vol .ipv-btn:hover { background: rgba(31,36,48,.08); }
.ipv-vol .ipv-volrange { width: 130px; flex: none; }
.ipv-volval { min-width: 4.2ch; text-align: right; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* Seitenbalken unten */
.ipv-foot { display: flex; align-items: center; gap: 8px; padding: 4px 14px 12px; }
.ipv-track { position: relative; flex: 1; display: flex; align-items: center; height: 40px; margin: 0 6px; }
.ipv-range {
  --fill: 0%; -webkit-appearance: none; appearance: none; width: 100%; height: 6px; margin: 0; border-radius: 99px; cursor: pointer;
  background: linear-gradient(to right, var(--fb-accent) var(--fill), color-mix(in srgb, var(--fb-ink) 16%, transparent) var(--fill));
}
.ipv-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--fb-accent); box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.ipv-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--fb-accent); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.ipv-range::-moz-range-track { background: transparent; }
.ipv-bubble {
  position: absolute; bottom: 34px; transform: translateX(-50%); padding: 4px 10px; border-radius: 8px; white-space: nowrap;
  background: var(--fb-accent); color: var(--fb-on-accent); font-size: 13px; font-weight: 500; pointer-events: none;
}
.ipv-pagebox { display: flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 4px; }
.ipv-pageinput {
  min-width: 3ch; padding: 4px 2px; border: 0; border-radius: 6px; background: transparent; color: inherit;
  font: 500 14px/1.2 inherit; font-family: inherit; text-align: right;
}
.ipv-pageinput:hover { background: color-mix(in srgb, var(--fb-ink) 8%, transparent); }
.ipv-pagetotal { opacity: .7; }

/* Ladeanzeige */
.ipv-status { position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; text-align: center; padding: 24px; background: var(--fb-bg); z-index: 5; }
.ipv-status-text { margin: 0; font-weight: 500; max-width: 36ch; }
.ipv-progress { width: 220px; height: 5px; border-radius: 99px; background: color-mix(in srgb, var(--fb-ink) 14%, transparent); overflow: hidden; justify-self: center; }
.ipv-progress span { display: block; height: 100%; width: 0; background: var(--fb-accent); transition: width .2s; }

/* Lupe und Übersicht */
.ipv-zoom, .ipv-grid { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; background: var(--fb-bg); }
.ipv-zoombar, .ipv-gridhead { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 10px 14px; }
.ipv-gridhead { justify-content: space-between; }
.ipv-gridhead h2 { margin: 0 0 0 4px; font-size: 16px; font-weight: 500; }
.ipv-zoomlabel { min-width: 5ch; text-align: center; font-variant-numeric: tabular-nums; }
.ipv-zoomscroll { flex: 1; overflow: auto; padding: 0 16px 16px; }
.ipv-zoomrow { display: flex; gap: 16px; width: max-content; min-width: 100%; justify-content: center; }
.ipv-zoompage { background: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.18); flex: none; }
.ipv-zoompage canvas { display: block; width: 100%; height: auto; }
.ipv-gridlist { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 18px; padding: 6px 18px 24px; align-content: start; }
.ipv-thumb { display: grid; gap: 6px; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; font: inherit; }
.ipv-thumbimg { display: block; background: #fff; box-shadow: 0 3px 10px rgba(0,0,0,.14); border: 2px solid transparent; overflow: hidden; }
.ipv-thumbimg canvas { display: block; width: 100%; height: 100%; }
.ipv-thumb.is-current .ipv-thumbimg, .ipv-thumb:hover .ipv-thumbimg { border-color: var(--fb-accent); }
.ipv-thumbnum { font-size: 13px; opacity: .75; }

/* Schmale Bildschirme */
@media (max-width: 640px) {
  .ipv-bar { padding: 8px 8px 2px; gap: 6px; }
  .ipv-title { display: none; }
  .ipv-logo { max-height: 30px; max-width: 110px; }
  .ipv-btn { width: 36px; height: 36px; }
  .ipv-stagewrap { grid-template-columns: 0 minmax(0, 1fr) 0; padding: 8px 10px; }
  .ipv-side { display: none; }
  .ipv-vol .ipv-volrange { width: 110px; }
  .ipv-zoompill { bottom: 12px; }
  .ipv-foot { padding: 2px 8px 10px; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  .fb-book, .fb-zoomlayer { transition: none; }
}
