/* -------------------------------------------------------------------
   broschuere.css - die Firmenbroschuere zum Blaettern.

   Das Buch ist ein Rechteck aus zwei Seiten. Seine Breite kommt aus
   dem Platz, seine Hoehe aus dem Seitenverhaeltnis des Drucks
   (--br-verhaeltnis, gesetzt im Markup) - so steht die Hoehe fest,
   bevor das erste Bild da ist, und beim Laden springt nichts.

   Unter 900 Punkten steht eine Seite allein. Das Blaettern bleibt,
   die Drehung nicht: auf dem Telefon waere eine halbe Sekunde
   Animation je Seite nur im Weg.
   ------------------------------------------------------------------- */

/* --- Die Unterlage ---------------------------------------------------
 *
 * Die Broschuere liegt auf einer dunklen Flaeche, nicht auf dem
 * weissen Grund der Seite. Das ist kein Schmuck: weisse Seiten auf
 * weissem Grund haben keinen Rand, und ohne Rand blaettert man
 * nichts - man sieht nur wechselnde Bilder.
 */

.br {
  margin: 0 auto;
  max-width: 1180px;
  padding: clamp(24px, 3.2vw, 48px) clamp(14px, 2.4vw, 32px)
           clamp(18px, 2.4vw, 30px);
  border-radius: 20px;
  background:
    radial-gradient(120% 120% at 50% -10%,
                    rgba(52, 204, 255, .14) 0%, transparent 58%),
    linear-gradient(170deg, #1a3a55 0%, #0a1722 72%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07);
}

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

.br-buehne {
  position: relative;
  padding: 0 clamp(52px, 5vw, 68px);
}

/* Die Breite richtet sich nach dem, was knapper ist: der Platz
   neben den Pfeilen oder die Hoehe des Fensters. Eine Doppelseite,
   die unten aus dem Bild laeuft, ist keine Doppelseite. */
.br-buch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, calc(78vh * var(--br-verhaeltnis) * 2));
  aspect-ratio: calc(var(--br-verhaeltnis) * 2) / 1;
  margin: 0 auto;

  /* Die Tiefe, in der sich das Blatt dreht. Ohne sie waere die
     Drehung ein flaches Zusammenschieben. */
  perspective: 2600px;
}

.br-blatt {
  position: relative;
  overflow: hidden;
  background: #fff;
  /* Die Broschuere wirft einen Schatten auf die Unterlage - erst
     dadurch liegt sie darauf und klebt nicht daran. */
  box-shadow: 0 26px 52px -22px rgba(0, 0, 0, .75);
}

/* Die aeusseren Ecken sind rund, die am Falz nicht. */
.br-blatt.ist-links  { border-radius: 3px 0 0 3px; }
.br-blatt.ist-rechts { border-radius: 0 3px 3px 0; }

.br-blatt img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Jede Seite laesst sich vergroessern - die linke wie die
     rechte, durch Anklicken. */
  cursor: zoom-in;
}

.br-blatt.ist-leer img { cursor: default; }

/* Der Falz: ein schmaler Schatten zu beiden Seiten der Mitte. Er
   macht aus zwei Bildern ein Buch. */
.br-blatt.ist-links {
  box-shadow: 0 26px 52px -22px rgba(0, 0, 0, .75),
              inset -14px 0 22px -14px rgba(10, 23, 34, .4);
}
.br-blatt.ist-rechts {
  box-shadow: 0 26px 52px -22px rgba(0, 0, 0, .75),
              inset 14px 0 22px -14px rgba(10, 23, 34, .4);
}

/* --- Der Schnitt -----------------------------------------------------
 *
 * Aussen an jeder Haelfte liegen die Kanten der uebrigen Blaetter.
 * Es sind keine echten Seiten, sondern ein Streifen aus feinen
 * Linien - aber genau daran erkennt man, dass noch etwas kommt.
 * Er sitzt neben dem Buch, nicht darin: die Haelften schneiden ab,
 * was ueber sie hinausragt.
 */

.br-buch::before,
.br-buch::after {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 11px;
  width: 9px;
  z-index: 0;
  background: repeating-linear-gradient(to right,
      #fdfdfd 0 1px, #c9d3dc 1px 2px, #f3f6f8 2px 3px);
  box-shadow: 0 22px 40px -20px rgba(0, 0, 0, .7);
}

.br-buch::before { left: -9px;  border-radius: 3px 0 0 3px; }
.br-buch::after  { right: -9px; border-radius: 0 3px 3px 0; }

/* Vor der Titelseite liegt links nichts, hinter der Rueckseite
   rechts nichts - dort gibt es auch keinen Schnitt. */
.br-buch.ohne-links::before  { display: none; }
.br-buch.ohne-rechts::after  { display: none; }

/* Eine leere Haelfte - vor der Titelseite und hinter der
   Rueckseite. Sie bleibt da, damit das Buch nicht die Breite
   wechselt, zeigt aber nichts. */
.br-blatt.ist-leer {
  background: none;
  box-shadow: none;
}
.br-blatt.ist-leer img { visibility: hidden; }

/* --- Das drehende Blatt ---------------------------------------------- */

.br-dreh {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
  z-index: 3;
}

/* Vorwaerts: das Blatt liegt rechts und klappt nach links.
   Rueckwaerts: es liegt links und klappt nach rechts. */
.br-dreh.ist-vorwaerts  { left: 50%; transform-origin: left center; }
.br-dreh.ist-rueckwaerts { left: 0;  transform-origin: right center; }

.br-dreh.laeuft { transition: transform .62s cubic-bezier(.4, .05, .3, 1); }

.br-dreh-seite {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.br-dreh-seite img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.br-dreh-seite.ist-hinten { transform: rotateY(180deg); }

/* Waehrend der Drehung faellt ein Schatten auf die Seite darunter -
   sonst sieht es aus, als schwebe ein Zettel ueber dem Buch. */
.br-dreh::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to left, rgba(10, 23, 34, .22), transparent 42%);
  opacity: 0;
  transition: opacity .3s ease;
}
.br-dreh.laeuft::after { opacity: 1; }

/* --- Die Pfeile ------------------------------------------------------ */

.br-pfeil {
  position: absolute;
  top: 50%;
  width: 46px;
  height: 46px;
  margin-top: -23px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(10, 23, 34, .12);
  border-radius: 50%;
  background: #fff;
  color: #183650;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(10, 23, 34, .12);
  transition: background .18s ease, color .18s ease, transform .18s ease;
  z-index: 4;
}

.br-pfeil svg { width: 22px; height: 22px; }
.br-pfeil.ist-zurueck { left: 0; }
.br-pfeil.ist-vor     { right: 0; }

.br-pfeil:hover { background: #34ccff; border-color: #34ccff; color: #fff; }
.br-pfeil:active { transform: scale(.94); }

.br-pfeil[disabled] {
  opacity: .32;
  cursor: default;
  box-shadow: none;
}
.br-pfeil[disabled]:hover { background: #fff; color: #183650; }

/* --- Die Leiste darunter --------------------------------------------- */

.br-leiste {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 24px);
  margin-top: clamp(20px, 2.4vw, 30px);
  padding: 0 clamp(4px, 1.6vw, 20px);
}

.br-stand {
  margin: 0;
  min-width: 11ch;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, .88);
}

.br-regler { flex: 1 1 auto; display: block; }

.br-regler input[type="range"] {
  display: block;
  width: 100%;
  accent-color: #34ccff;
  cursor: pointer;
}

.br-versteckt {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.br-knopf {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid rgba(255, 255, 255, .26);
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.br-knopf svg { width: 18px; height: 18px; }
.br-knopf:hover { background: #34ccff; border-color: #34ccff; color: #0a1722; }

/* --- Die Lupe -------------------------------------------------------- */

.br-gross {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 40px);
  background: rgba(10, 23, 34, .92);
  overflow: auto;
  overscroll-behavior: contain;
}

.br-gross[hidden] { display: none; }

/* Zuerst steht die ganze Seite im Bild - so hoch, wie das Fenster
   hergibt. Ein Klick macht sie so breit wie das Fenster; dann
   steht der Text gross da und man rollt durch die Seite. */
.br-gross-innen img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - clamp(24px, 6vw, 80px));
  height: auto;
  margin: 0 auto;
  background: #fff;
  cursor: zoom-in;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}

.br-gross.ist-breit { place-items: start center; }

.br-gross.ist-breit .br-gross-innen img {
  width: 100%;
  max-width: 1600px;
  max-height: none;
  cursor: zoom-out;
}

.br-gross-zu {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
}

.br-gross-zu svg { width: 22px; height: 22px; }
.br-gross-zu:hover { background: rgba(255, 255, 255, .26); }

.br-gross-pfeil {
  position: fixed;
  top: 50%;
  width: 46px;
  height: 46px;
  margin-top: -23px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
}

.br-gross-pfeil svg { width: 24px; height: 24px; }
.br-gross-pfeil.ist-zurueck { left: 14px; }
.br-gross-pfeil.ist-vor     { right: 14px; }
.br-gross-pfeil:hover { background: rgba(255, 255, 255, .28); }
.br-gross-pfeil[disabled] { opacity: .3; cursor: default; }

.br-gross-stand {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  color: rgba(255, 255, 255, .9);
  font-size: 13px;
  font-weight: 600;
}

/* --- Ohne Skript ----------------------------------------------------- */

.br-liste img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 18px;
  box-shadow: 0 10px 30px rgba(10, 23, 34, .14);
}

/* --- Eine Seite allein ------------------------------------------------
 *
 * Unter 900 Punkten. Das Buch wird einspaltig, die zweite Haelfte
 * verschwindet, und der Falz mit ihr.
 */

@media (max-width: 900px) {
  .br-buch {
    grid-template-columns: 1fr;
    aspect-ratio: var(--br-verhaeltnis) / 1;
    width: min(100%, 480px, calc(74vh * var(--br-verhaeltnis)));
    perspective: none;
  }

  .br-blatt.ist-rechts { display: none; }
  .br-blatt.ist-links  {
    border-radius: 3px;
    box-shadow: 0 20px 40px -18px rgba(0, 0, 0, .8);
  }
  .br-dreh { display: none; }

  /* Die Schnittkante nur rechts - eine einzelne Seite hat keinen
     Falz, aber sie liegt auf dem Rest der Broschuere. Welche Seite
     gezeigt wird, setzt das Skript (ohne-links). */
  .br-buehne { padding: 0 40px; }
  .br-pfeil { width: 38px; height: 38px; margin-top: -19px; }

  .br-leiste { padding: 0; flex-wrap: wrap; }
  .br-stand { order: 1; }
  .br-knopf { order: 2; margin-left: auto; }
  .br-regler { order: 3; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .br-dreh.laeuft { transition: none; }
}
