/* PDF-Viewer im Ascherl-Design.
 *
 * Bewusst NICHT der mitgelieferte Viewer von PDF.js: dessen graues Chrome
 * sieht nach Adobe aus und nicht nach Ascherl. Verwendet wird nur die
 * Rendering-Bibliothek, die Oberflaeche hier ist eigener Code.
 */

.viewer {
  background: var(--ac-flaeche);
  border-block: 1px solid var(--ac-blau-28);
  margin-top: var(--ac-s4);
}

/* ---------- Werkzeugleiste ---------- */

.v-leiste {
  position: sticky; top: var(--ac-kopf); z-index: 20;
  display: flex; align-items: center; gap: var(--ac-s2);
  flex-wrap: wrap;
  padding: 10px var(--ac-gutter);
  background: var(--ac-grund);
  border-bottom: 1px solid var(--ac-blau-28);
}
.v-gruppe { display: flex; align-items: center; gap: var(--ac-s1); }
.v-gruppe--rechts { margin-left: auto; }

.v-knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  /* 44px: Touch-Mindestgroesse, gilt auch auf dem Desktop. */
  min-width: 44px; min-height: 44px; padding: 0 12px;
  background: var(--ac-flaeche); color: var(--ac-blau);
  border: 1px solid var(--ac-blau-28); border-radius: var(--ac-radius);
  font: inherit; font-size: var(--ac-t-s); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.v-knopf:hover:not([disabled]) { background: var(--ac-blau); color: var(--ac-weiss);
                                 border-color: var(--ac-blau); }
.v-knopf[disabled] { opacity: .35; cursor: default; }
.v-knopf[aria-pressed="true"] { background: var(--ac-blau); color: var(--ac-weiss);
                                border-color: var(--ac-blau); }
.v-knopf svg { width: 17px; height: 17px; fill: none; stroke: currentColor;
               stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.v-seitenfeld {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--ac-t-s); color: var(--ac-blau-55);
}
.v-seitenfeld input {
  width: 66px; min-height: 44px; text-align: center;
  font-family: var(--ac-mono); font-size: var(--ac-t-s);
  color: var(--ac-blau); background: var(--ac-flaeche);
  border: 1px solid var(--ac-blau-28); border-radius: var(--ac-radius);
}

.v-suche { display: flex; align-items: center; gap: 6px; }
.v-suche input {
  min-height: 44px; min-width: 190px; padding: 0 14px;
  font: inherit; font-size: var(--ac-t-s); color: var(--ac-blau);
  background: var(--ac-flaeche);
  border: 1px solid var(--ac-blau-28); border-radius: var(--ac-radius);
}
.v-suche input::placeholder { color: var(--ac-blau-55); }

.v-zoomwert { font-family: var(--ac-mono); font-size: var(--ac-t-xs);
              color: var(--ac-blau-55); min-width: 46px; text-align: center; }

/* ---------- Buehne ---------- */

.v-buehne {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr);
  background: var(--ac-tief);
}
.v-buehne.hat-trefferliste { grid-template-columns: 300px minmax(0, 1fr); }
@media (max-width: 1023px) { .v-buehne.hat-trefferliste { grid-template-columns: minmax(0, 1fr); } }

.v-trefferliste {
  border-right: 1px solid var(--ac-blau-28);
  background: var(--ac-flaeche);
  max-height: 78vh; overflow-y: auto;
  padding: var(--ac-s2);
}
@media (max-width: 1023px) {
  .v-trefferliste { border-right: 0; border-bottom: 1px solid var(--ac-blau-28);
                    max-height: 240px; }
}
.v-trefferkopf { font-size: var(--ac-t-xs); text-transform: uppercase;
                 letter-spacing: .1em; color: var(--ac-blau-55);
                 padding: 8px 10px; }
.v-treffer {
  display: block; width: 100%; text-align: left;
  /* 44 px Mindesthoehe: die Trefferliste wird auf dem Handy mit dem Finger
     bedient, und ein Fehlgriff springt an die falsche Katalogseite. */
  min-height: 44px;
  padding: 11px 10px; border: 0; border-bottom: 1px solid var(--ac-blau-12);
  background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.v-treffer:hover, .v-treffer[aria-current="true"] { background: var(--ac-blau-06); }
.v-treffer b { display: block; font-family: var(--ac-mono); font-size: var(--ac-t-xs);
               font-weight: 400; color: var(--ac-blau-55); margin-bottom: 3px; }
.v-treffer span { font-size: 13px; line-height: 1.45; }
.v-treffer mark { background: rgba(255,30,35,.16); color: inherit; }

.v-scroll {
  /* Feste Hoehe statt max-height: beim Blaettern soll die Ansicht in eine
     gleichbleibende Flaeche passen, sonst springt die Seitengroesse von
     Ansicht zu Ansicht. Gescrollt wird nur, wenn hineingezoomt wurde. */
  overflow: auto;
  height: clamp(420px, 82vh, 1100px);
  padding: var(--ac-s3) var(--ac-s2);
  display: flex; align-items: flex-start; justify-content: center;
  /* Ohne das rutscht auf iOS das Pinch-Zoom in den Seitenscroll hinein. */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* Ist hineingezoomt, laesst sich die Seite mit der Maus verschieben. */
.v-scroll.kann-schieben { cursor: grab; }
.v-scroll.schiebt {
  cursor: grabbing;
  /* Waehrend des Ziehens nichts markieren - sonst blaut sich der Seitentext ein. */
  user-select: none; -webkit-user-select: none;
}
.v-scroll.schiebt .v-feld { pointer-events: none; }
.v-seiten { display: flex; flex-direction: column; align-items: center;
            /* Genug Luft fuer die Seitenbeschriftung ueber der Ansicht. */
            margin: auto; padding-top: 26px; }
/* Ausgeblendete Ansichten bleiben im DOM - dort wird im Hintergrund schon
   die naechste Doppelseite gezeichnet. */
.v-reihe[hidden] { display: none; }

/* Eine Reihe traegt eine Seite (einzeln) oder zwei (Doppelseite). Die beiden
   Haelften stossen ohne Abstand aneinander - so, wie ein aufgeschlagener
   Katalog aussieht, bei dem Tabellen ueber den Bund laufen. */
/* Bewusst NICHT position:relative - sonst wird die Reihe zum Bezugspunkt fuer
   offsetTop, und der Viewer haelt jede Seite fuer ganz oben. */
.v-reihe { display: flex; gap: 0; align-items: flex-start; }
/* Angedeuteter Bund zwischen den beiden Haelften einer Doppelseite. */
.v-reihe > .v-seite:first-child:not(:only-child)::before {
  content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 18px;
  background: linear-gradient(to right, transparent, rgba(7, 19, 46, .16));
  pointer-events: none; z-index: 2;
}
.v-reihe > .v-seite:last-child:not(:only-child)::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 18px;
  background: linear-gradient(to left, transparent, rgba(7, 19, 46, .16));
  pointer-events: none; z-index: 2;
}

/* Jede Seite ist zuerst nur ein Platzhalter in korrekter Hoehe. Erst wenn sie
   in die Naehe des Sichtfelds kommt, wird tatsaechlich gerendert - sonst
   wuerden 428 Seiten den Browser lahmlegen. */
.v-seite {
  position: relative; background: #fff;
  /* Kein Rahmen mehr, sondern ein Schatten: auf dunklem Grund wirkt die
     Seite dadurch wie ein aufliegendes Blatt statt wie ein Kasten. */
  border: 0;
  box-shadow: 0 2px 18px rgba(0, 0, 0, .45);
  width: 100%; max-width: 100%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, .3); font-size: var(--ac-t-s);
}
.v-seite canvas { display: block; width: 100%; height: auto; }
/* Die Beschriftung steht UEBER ihrer Seite, nicht darunter: zwischen zwei
   Seiten waere sonst nicht erkennbar, zu welcher der beiden sie gehoert. */
.v-seite::after {
  content: attr(data-nr);
  position: absolute; top: -21px; right: 2px;
  font-family: var(--ac-mono); font-size: 11px;
  color: rgba(255, 255, 255, .45);
  letter-spacing: .04em;
}
.v-seite[data-treffer="1"]::after { color: var(--ac-rot); }
.v-seite[data-treffer="1"] { outline: 2px solid var(--ac-rot); outline-offset: 0; }

.v-laden {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: var(--ac-s6) var(--ac-s3); color: var(--ac-blau-55);
  font-size: var(--ac-t-s);
}
.v-spinner {
  width: 18px; height: 18px; border: 2px solid var(--ac-blau-28);
  border-top-color: var(--ac-blau); border-radius: 50%;
  animation: v-dreh .7s linear infinite;
}
@keyframes v-dreh { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .v-spinner { animation-duration: 2.4s; } }

.v-fehler {
  margin: var(--ac-s4) auto; max-width: 52ch; text-align: center;
  border-left: 3px solid var(--ac-rot); background: rgba(255,30,35,.06);
  padding: var(--ac-s3); font-size: var(--ac-t-s);
}

/* ---------- Vollbild ---------- */

.viewer:fullscreen { background: var(--ac-grund); }
.viewer:fullscreen .v-leiste { top: 0; }
.viewer:fullscreen .v-scroll { height: calc(100vh - 66px); }
.viewer:fullscreen .v-trefferliste { max-height: calc(100vh - 66px); }

/* ---------- Mobil ---------- */

@media (max-width: 767px) {
  .v-leiste { top: 0; gap: 6px; padding: 8px 10px; }
  .v-gruppe--rechts { margin-left: 0; width: 100%; }
  .v-suche input { min-width: 0; width: 100%; }
  .v-scroll { padding: var(--ac-s2) 6px; height: clamp(360px, 74vh, 900px); }
  .v-beschriftung { display: none; }
}


/* ---------- Seiten-Übersicht ---------- */

.v-uebersicht {
  position: absolute; inset: 0; z-index: 15;
  background: var(--ac-tief);
  overflow-y: auto;
  padding: var(--ac-s3);
  overscroll-behavior: contain;
}
.v-uebersicht[hidden] { display: none; }
.v-uebersicht-kopf {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--ac-s3); flex-wrap: wrap;
  border-bottom: 1px solid rgba(255, 255, 255, .18);
  padding-bottom: 10px; margin-bottom: var(--ac-s3);
}
.v-uebersicht-kopf h3 { margin: 0; font-size: var(--ac-t-h3); font-weight: 400;
                        color: #fff; }
.v-uebersicht .v-knopf { background: var(--ac-tief-hell); color: #fff;
                         border-color: rgba(255,255,255,.25); }
.v-uebersicht .v-knopf:hover { background: #fff; color: var(--ac-tief); }

.v-raster {
  display: grid; gap: 20px 14px;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}
.v-blatt {
  display: flex; flex-direction: column; gap: 5px;
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: inherit; text-align: center;
}
.v-blatt img, .v-blatt .v-platzhalter {
  width: 100%; aspect-ratio: 1 / 1.414; object-fit: contain;
  background: var(--ac-flaeche);
  border: 1px solid rgba(255, 255, 255, .14);
  display: block;
}
.v-blatt:hover img { border-color: #fff; }
.v-blatt[aria-current="true"] img { outline: 2px solid var(--ac-rot);
                                    outline-offset: -1px; }
.v-blatt span { font-family: var(--ac-mono); font-size: 11px;
                color: rgba(255, 255, 255, .55); }
.v-blatt[data-treffer="1"] span { color: #ff8a8d; }

/* ---------- Anklickbare Artikelnummern ---------- */

.v-felder { position: absolute; inset: 0; pointer-events: none; }
.v-feld {
  position: absolute; display: block;
  pointer-events: auto;
  /* content-box, damit das Polster die Wortbox VERGROESSERT statt sie von
     innen aufzufressen. Senkrecht nur 1 px: in den Artikeltabellen liegen die
     Zeilen rund 1,2 % der Seitenhoehe auseinander, bei mehr wuerde ein Feld
     den Nachbarartikel ueberlappen - und ein Fehlgriff fuehrte zum falschen
     Produkt. Wer genauer zielen will, zoomt; die Felder wachsen mit. */
  box-sizing: content-box;
  margin: -1px -4px; padding: 1px 4px;
  border-radius: 2px;
  background: transparent;
  transition: background .12s, box-shadow .12s;
}
.v-feld:hover, .v-feld:focus-visible {
  background: rgba(255, 30, 35, .14);
  box-shadow: 0 0 0 1px var(--ac-rot);
}
/* Alle Felder dauerhaft zeigen - ueber den Knopf in der Leiste. */
.v-buehne.felder-zeigen .v-feld { background: rgba(0, 60, 209, .10); }
.v-buehne.felder-zeigen .v-feld:hover { background: rgba(255, 30, 35, .18); }

@media (max-width: 767px) {
  .v-raster { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); }
  .v-uebersicht { padding: var(--ac-s2); }
}


/* ---------- Blätterpfeile neben dem Katalog ---------- */

.v-pfeil {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 12;
  width: 52px; height: 92px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .10);
  border: 0; border-radius: 4px;
  color: #fff; cursor: pointer;
  /* Nicht ganz sichtbar, bis der Zeiger in die Nähe kommt - die Seite soll
     im Vordergrund stehen, nicht die Bedienung. */
  opacity: .42;
  transition: opacity .15s, background .15s;
}
.v-buehne:hover .v-pfeil { opacity: .85; }
.v-pfeil:hover, .v-pfeil:focus-visible { opacity: 1; background: rgba(255,255,255,.22); }
.v-pfeil[disabled] { opacity: 0; pointer-events: none; }
.v-pfeil svg { width: 26px; height: 26px; fill: none; stroke: currentColor;
               stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.v-pfeil--links  { left: 10px; }
.v-pfeil--rechts { right: 10px; }

/* Auf schmalen Flächen nehmen die Pfeile der Seite den Platz weg -
   dort wird gewischt. */
@media (max-width: 767px) {
  .v-pfeil { display: none; }
}


/* ---------- Großansicht als Overlay ---------- */
/*
 * Der Katalog belegt den ganzen Bildschirm, und die Wirtsseite scrollt nicht
 * mehr darunter weg. Genau das macht den Unterschied zwischen "PDF auf einer
 * Webseite" und "Katalog durchblättern".
 */

.v-overlay {
  position: fixed; inset: 0; z-index: 2147483000;
  background: var(--ac-tief);
  display: flex; flex-direction: column;
  /* Sicherheitsabstand fuer Geraete mit Aussparungen. */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: v-auf .16s ease-out;
}
@keyframes v-auf { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .v-overlay { animation: none; } }

.v-overlay .viewer { flex: 1; display: flex; flex-direction: column;
                     border: 0; margin: 0; min-height: 0; }
.v-overlay .v-buehne { flex: 1; min-height: 0; }
.v-overlay .v-scroll { height: auto; flex: 1; min-height: 0; }
.v-overlay .v-leiste { position: static; }

/* Der Schliessen-Knopf sitzt in der Leiste ganz rechts. */
.v-schliessen { margin-left: 8px; }

/* Solange das Overlay offen ist, darf die Seite darunter nicht scrollen -
   sonst liest man im Katalog und die Wirtsseite wandert im Hintergrund. */
.v-body-fest { overflow: hidden !important; }
