/*
 * Seitenbereiche mit Hintergrund (Partials/Bereich.html, Tabelle tx_pslayouts_bereich)
 *
 * .ps-bereich                      Wrapper um eine Spalte des Seitenlayouts
 *   --spalte-<colPos>              für eigene Regeln je Spalte (kunde.scss)
 *   .ps-bg-N / .kundeneffekt       Hintergrundfarbe (Website-Farbe bzw. Kundendesign)
 *   --bild, --negativ, --innen-<klein|normal|gross>, --seite-<klein|normal|gross> (links/rechts), --ueber-n1…n4 (überlappt den Bereich davor),
 *   --hoehe (Feld „Mindesthöhe“, Wert als style="min-height: …")
 * .ps-bereich__hg > .ps-bereich__bild   Hintergrundbild als background-image (Größe, Ausrichtung, feststehend)
 *   .ps-bereich__abdunkeln--30/50/70/h30/h50/h70   Schicht darüber
 *   .ps-bereich__hg--einfaerben --m30…m100         Bild schwarz-weiß auf die Farbe multipliziert
 * Anpassbar in kunde.scss: --ps-bereich-innen (Innenabstand oben/unten „normal“, Standard 2.5 × Grundabstand),
 * --ps-bereich-innen-seite (Innenabstand links/rechts „normal“, Standard 1.5 × Grundabstand),
 * --ps-bereich-text-negativ (sonst --ps-container-text-negativ bzw. #fff).
 */
.ps-bereich {
  --pb-innen: var(--ps-bereich-innen, calc(var(--ps-grundabstand, 20px) * 2.5));
  --pb-seite: var(--ps-bereich-innen-seite, calc(var(--ps-grundabstand, 20px) * 1.5));
  position: relative;
  isolation: isolate;
}
/* Überlappen: der Bereich schiebt sich über den davor (Vielfaches von --ps-container-abstand bzw. --ps-bereich-abstand)
   und liegt dabei oben */
.ps-bereich[class*="ps-bereich--ueber-"] {
  --pb-abstand: var(--ps-bereich-abstand, var(--ps-container-abstand, calc(var(--ps-grundabstand, 20px) * 2.5)));
  z-index: 1;
}
.ps-bereich--ueber-n1 { margin-top: calc(var(--pb-abstand) * -1); }
.ps-bereich--ueber-n2 { margin-top: calc(var(--pb-abstand) * -2); }
.ps-bereich--ueber-n3 { margin-top: calc(var(--pb-abstand) * -3); }
.ps-bereich--ueber-n4 { margin-top: calc(var(--pb-abstand) * -4); }
.ps-bereich--innen-klein  { padding-block: calc(var(--pb-innen) / 2); }
.ps-bereich--innen-normal { padding-block: var(--pb-innen); }
.ps-bereich--innen-gross  { padding-block: calc(var(--pb-innen) * 2); }
/* links und rechts (Feld „Innenabstand links und rechts“, Standard „Normal“; „Keiner“ = keine Klasse) */
.ps-bereich--seite-klein  { padding-inline: calc(var(--pb-seite) / 2); }
.ps-bereich--seite-normal { padding-inline: var(--pb-seite); }
.ps-bereich--seite-gross  { padding-inline: calc(var(--pb-seite) * 2); }

.ps-bereich__hg {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.ps-bereich__bild {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-size: cover;
  background-image: var(--pb-bild-2400);
}
/*
 * Responsive Varianten (Bereich.html liefert --pb-bild-800/-1200/-1800/-2400, JPG/PNG als WebP):
 * die kleinste Variante, die breiter ist als Fensterbreite × Pixeldichte. Hochformat zählt × 1,5 – dort werden die
 * Bereiche hoch und „Füllen“ vergrößert das Bild entsprechend. Gilt auch für „feststehend“ (bezieht sich aufs Fenster).
 */
@media (orientation: landscape) and (max-width: 1800px) and (max-resolution: 1dppx),
       (orientation: landscape) and (max-width: 900px) and (max-resolution: 2dppx),
       (orientation: landscape) and (max-width: 600px),
       (orientation: portrait) and (max-width: 1200px) and (max-resolution: 1dppx),
       (orientation: portrait) and (max-width: 600px) and (max-resolution: 2dppx),
       (orientation: portrait) and (max-width: 400px) {
  .ps-bereich__bild { background-image: var(--pb-bild-1800); }
}
@media (orientation: landscape) and (max-width: 1200px) and (max-resolution: 1dppx),
       (orientation: landscape) and (max-width: 600px) and (max-resolution: 2dppx),
       (orientation: landscape) and (max-width: 400px),
       (orientation: portrait) and (max-width: 800px) and (max-resolution: 1dppx),
       (orientation: portrait) and (max-width: 400px) and (max-resolution: 2dppx),
       (orientation: portrait) and (max-width: 266px) {
  .ps-bereich__bild { background-image: var(--pb-bild-1200); }
}
@media (orientation: landscape) and (max-width: 800px) and (max-resolution: 1dppx),
       (orientation: landscape) and (max-width: 400px) and (max-resolution: 2dppx),
       (orientation: landscape) and (max-width: 266px),
       (orientation: portrait) and (max-width: 533px) and (max-resolution: 1dppx),
       (orientation: portrait) and (max-width: 266px) and (max-resolution: 2dppx),
       (orientation: portrait) and (max-width: 177px) {
  .ps-bereich__bild { background-image: var(--pb-bild-800); }
}
/* Originalgröße und Kacheln: Größe des Bildes zählt, daher immer dieselbe (große) Variante */
.ps-bereich__bild:is(.ps-bereich__bild--auto, .ps-bereich__bild--kacheln) {
  background-image: var(--pb-bild-2400);
}
.ps-bereich__bild--contain { background-size: contain; }
.ps-bereich__bild--auto    { background-size: auto; }
.ps-bereich__bild--kacheln { background-size: auto; background-repeat: repeat; }
.ps-bereich__bild--fixed   { background-attachment: fixed; }
/* iOS/iPadOS kennt background-attachment: fixed nicht (zeigt sonst ein riesiges, unscharfes Bild) */
@supports (-webkit-touch-callout: none) {
  .ps-bereich__bild--fixed { background-attachment: scroll; }
}

/* abdunkeln / aufhellen */
.ps-bereich__abdunkeln {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: .3;
}
.ps-bereich__abdunkeln--50 { opacity: .5; }
.ps-bereich__abdunkeln--70 { opacity: .7; }
.ps-bereich__abdunkeln--h30,
.ps-bereich__abdunkeln--h50,
.ps-bereich__abdunkeln--h70 { background: #fff; }
.ps-bereich__abdunkeln--h50 { opacity: .5; }
.ps-bereich__abdunkeln--h70 { opacity: .7; }

/* einfärben: Bild schwarz-weiß auf die Farbe multipliziert, Stufe = Deckkraft des Bildes */
.ps-bereich__hg--einfaerben {
  background-color: var(--pc-einfaerben, var(--ps-color-primary, #000));
}
.ps-bereich__hg--einfaerben > .ps-bereich__bild {
  filter: grayscale(1);
  mix-blend-mode: multiply;
}
.ps-bereich__hg--m30 > .ps-bereich__bild { opacity: .35; }
.ps-bereich__hg--m50 > .ps-bereich__bild { opacity: .55; }
.ps-bereich__hg--m70 > .ps-bereich__bild { opacity: .75; }

/* Schrift hell */
.ps-bereich--negativ {
  color: var(--ps-bereich-text-negativ, var(--ps-container-text-negativ, #fff));
}
/* wie weit die helle Schrift reicht (bis zur nächsten hellen Fläche): css/schrift-hell.css */

/* Hoher Kontrast: keine Hintergrundbilder, Text auf der normalen Fläche */
html.ps-kontrast .ps-bereich__hg {
  display: none;
}
html.ps-kontrast .ps-bereich--negativ {
  color: inherit;
}
