/* wsMagazin – Blätteransicht. Wird unverändert in jeden Ausgabeordner kopiert. */

:root {
  --bg: #e9e7e2;
  --accent: #f0a202;
  --bar: #2e3841;
  --bar-ink: #e9edf0;
  --bar-dim: #8d99a3;
  --shadow: rgba(20, 26, 31, .28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1f2429;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; }

/* ---------- Bühne ---------- */

#stage {
  position: absolute;
  inset: 0 0 56px 0;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
}

#book {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  perspective: 2600px;
  transition: transform .45s cubic-bezier(.3, .7, .3, 1);
}

.half {
  position: absolute;
  top: 0;
  height: 100%;
}

.page {
  position: absolute;
  inset: 0;
  background: #fff;
  overflow: hidden;
}

.page img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.page.blank { background: transparent; }

/* Leichter Falz in der Buchmitte */
.half.left .page::after,
.half.right .page::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 7%;
  pointer-events: none;
}
.half.left .page::after  { right: 0; background: linear-gradient(to left,  rgba(0,0,0,.16), rgba(0,0,0,0)); }
.half.right .page::after { left: 0;  background: linear-gradient(to right, rgba(0,0,0,.13), rgba(0,0,0,0)); }
.single .half .page::after, .page.blank::after { display: none; }

.half > .page:not(.blank) { box-shadow: 0 6px 24px var(--shadow); }

/* Das umschlagende Blatt */
.leaf {
  position: absolute;
  top: 0;
  height: 100%;
  transform-style: preserve-3d;
  z-index: 5;
  will-change: transform;
}
.leaf .page { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.leaf .back { transform: rotateY(180deg); }
.leaf .shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Einzelseiten-Modus (schmale Fenster): Seite gleitet seitlich */
.slide { position: absolute; top: 0; height: 100%; z-index: 5; }

/* Links aus dem PDF */
.page a.link {
  position: absolute;
  display: block;
  border-radius: 2px;
  transition: background .15s;
}
.page a.link:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* Logo des Projekts: im Hintergrund in einer Ecke, hinter dem Heft */
.logo {
  position: absolute;
  z-index: 0;
  width: min(var(--logo-size, 180px), 26vw);
  height: min(var(--logo-size, 180px), 26vw);
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.logo.br { right: 18px; bottom: 14px; object-position: right bottom; }
.logo.bl { left: 18px;  bottom: 14px; object-position: left bottom; }
.logo.tr { right: 18px; top: 14px;    object-position: right top; }
.logo.tl { left: 18px;  top: 14px;    object-position: left top; }

/* Klickflächen an den Rändern */
.edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 14%;
  max-width: 120px;
  z-index: 8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s;
}
.edge.prev { left: 0; }
.edge.next { right: 0; }
.edge svg { width: 44px; height: 44px; fill: none; stroke: var(--bar); stroke-width: 2; filter: drop-shadow(0 1px 2px rgba(255,255,255,.7)); }
@media (hover: hover) { .edge:hover { opacity: .75; } }
.edge.off { display: none; }

/* ---------- Leiste ---------- */

#bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  background: var(--bar);
  color: var(--bar-ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  gap: 8px;
  z-index: 20;
}
#bar .group { display: flex; align-items: center; gap: 2px; }
#bar .title {
  color: var(--bar-dim);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 28vw;
  margin-left: 8px;
}

.btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--bar-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .12s, transform .07s;
  text-decoration: none;
}
.btn:hover { background: rgba(255,255,255,.09); }
.btn:active { transform: scale(.93); background: rgba(255,255,255,.16); }
.btn:disabled { opacity: .3; cursor: default; background: transparent; }
.btn.on { color: var(--accent); }
.btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#pager {
  display: flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--bar-dim);
}
#total { white-space: nowrap; }
#pageInput {
  width: 64px;
  height: 32px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 7px;
  background: rgba(255,255,255,.06);
  color: var(--bar-ink);
  text-align: center;
  font: inherit;
  font-size: 13px;
}
#pageInput:focus { outline: none; border-color: var(--accent); }

/* ---------- Überlagerungen ---------- */

.overlay {
  position: absolute;
  inset: 0 0 56px 0;
  z-index: 15;
  background: color-mix(in srgb, var(--bar) 94%, transparent);
  color: var(--bar-ink);
  display: none;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.overlay.open { display: block; }

/* Seitenübersicht */
#thumbs .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 22px 16px;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}
#thumbs button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--bar-dim);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
#thumbs img {
  width: 100%;
  display: block;
  background: #fff;
  border-radius: 2px;
  margin-bottom: 6px;
  outline: 3px solid transparent;
  outline-offset: 2px;
  transition: outline-color .12s, transform .12s;
}
#thumbs button:hover img { transform: translateY(-2px); }
#thumbs button.current img { outline-color: var(--accent); }
#thumbs button.current { color: var(--accent); }

/* Suche */
#search .inner { max-width: 720px; margin: 0 auto; padding: 24px; }
#searchInput {
  width: 100%;
  height: 46px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.07);
  color: var(--bar-ink);
  font: inherit;
  font-size: 17px;
  padding: 0 14px;
}
#searchInput:focus { outline: none; border-color: var(--accent); }
#searchInfo { color: var(--bar-dim); font-size: 13px; margin: 12px 2px; }
.hit {
  display: flex;
  gap: 14px;
  width: 100%;
  text-align: left;
  border: 0;
  background: rgba(255,255,255,.04);
  color: var(--bar-ink);
  border-radius: 9px;
  padding: 11px 13px;
  margin-bottom: 6px;
  cursor: pointer;
}
.hit:hover { background: rgba(255,255,255,.1); }
.hit .no {
  flex: none;
  width: 52px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--bar-dim);
  padding-top: 2px;
}
.hit mark { background: var(--accent); color: #1f2429; border-radius: 2px; padding: 0 1px; }

/* Lupe */
/* Deckend, auch bei durchsichtigem Seitenhintergrund – sonst schiene das Heft durch. */
#zoom { background: color-mix(in srgb, var(--bg-solid, var(--bg)) 97%, #000); cursor: grab; }
#zoom.drag { cursor: grabbing; }
#zoom .sheet { display: flex; margin: 24px auto; width: max-content; box-shadow: 0 8px 30px var(--shadow); }
#zoom .sheet img { display: block; background: #fff; }

/* ---------- Schmale Fenster ---------- */

@media (max-width: 640px) {
  #bar .title, .wide-only { display: none; }
  #bar { padding: 0 4px; }
  .btn { width: 38px; }
  #pageInput { width: 54px; }
}

/* Laden */
#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8d99a3;
  font-size: 13px;
}
