/* Hersteller-Slider (pichler_brand_slider_pro)
   Aufbau: 1. Basis  2. Kopf  3. Raster und Slider  4. Eintrag  5. Stile  6. Drüberfahren  7. Pfeile, Punkte, Pause
           8. Handy (unter 540 px Portlet-Breite)  9. Editor-Hinweise  10. Ohne Hersteller  11. Fallback ohne Container-Queries
   Schrift kommt vom Theme. Spalten, Format und Farben setzt das Portlet als Variablen (--pbs-accent immer).
   Seit 1.2.0 lesen die Farben die Variablen des Templates PICHLER 2027 (--p27-*), der zweite Wert ist der bisherige
   Rückfall: ohne das Template bleibt alles wie in 1.1.0. */

/* ------------------------------------------------------------- 1. Basis */
.opc-pbs {
  --pbs-ink: var(--p27-ink, #1f2933);
  --pbs-muted: var(--p27-ink-2, #5b6672);
  --pbs-line: var(--p27-line, #e3e8ee);
  container: pbs / inline-size;
  width: 100%;
}
.opc-pbs,
.opc-pbs *,
.opc-pbs *::before,
.opc-pbs *::after { box-sizing: border-box; }

/* -------------------------------------------------------------- 2. Kopf */
.opc-pbs .pbs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 20px;
  margin-bottom: 16px;
}
.opc-pbs .pbs-title { margin: 0; }
.opc-pbs p.pbs-title { font-weight: 600; }
.opc-pbs .pbs-all {
  color: var(--pbs-accent-text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.opc-pbs .pbs-all::after { content: " \2192"; }
.opc-pbs .pbs-all:hover { text-decoration: underline; text-underline-offset: 3px; }
.opc-pbs .pbs-all:focus-visible { outline: 2px solid var(--pbs-accent); outline-offset: 2px; border-radius: 2px; }

/* ------------------------------------------------- 3. Raster und Slider */
/* n = Logos pro Reihe, c = belegte Spalten. Bei wenigen Logos steht die Reihe mittig. */
.opc-pbs .pbs-stage {
  --pbs-n: var(--pbs-n-sm, 3);
  --pbs-c: var(--pbs-c-sm, 3);
  --pbs-gap: 12px;
  --pbs-slot: calc((100% - (var(--pbs-n) - 1) * var(--pbs-gap)) / var(--pbs-n));
  position: relative;
}
@container pbs (min-width: 540px) {
  .opc-pbs .pbs-stage { --pbs-n: var(--pbs-n-md, 4); --pbs-c: var(--pbs-c-md, 4); --pbs-gap: 16px; }
}
@container pbs (min-width: 860px) {
  .opc-pbs .pbs-stage { --pbs-n: var(--pbs-n-lg, 6); --pbs-c: var(--pbs-c-lg, 6); }
}

.opc-pbs .pbs-track {
  display: grid;
  grid-template-columns: repeat(var(--pbs-c), var(--pbs-slot));
  justify-content: center;
  gap: var(--pbs-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}
.opc-pbs .pbs-item { min-width: 0; }

/* Slider ohne Skript: natives Scrollen mit Einrasten. Innenabstand oben und unten, damit Schatten und Anheben nicht
   abgeschnitten werden. Platz für die Pfeile neben der Reihe nur, wenn es etwas zu blättern gibt. */
.opc-pbs--slider .pbs-viewport {
  padding: 6px 0 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.opc-pbs--slider .pbs-viewport::-webkit-scrollbar { display: none; }
.opc-pbs--slider .pbs-track {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: var(--pbs-slot);
  justify-content: start;
}
.opc-pbs--slider .pbs-item { scroll-snap-align: start; }
.opc-pbs--slider.is-scrollable .pbs-stage:has(> .pbs-arrow) { padding: 0 48px; }

/* Mit Skript: endloses Band, das per transform läuft. Ziehen mit der Maus, senkrecht scrollt die Seite weiter.
   Der Fokusring steht innen, weil das Band an den Rändern abschneidet. */
.opc-pbs.is-loop .pbs-viewport {
  overflow: hidden;
  overflow: clip;
  scroll-snap-type: none;
  cursor: grab;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}
.opc-pbs.is-loop .pbs-track { will-change: transform; }
.opc-pbs.is-loop .pbs-item { scroll-snap-align: none; }
.opc-pbs.is-loop a.pbs,
.opc-pbs.is-loop .pbs-logo { -webkit-user-drag: none; }
.opc-pbs.is-loop a.pbs:focus-visible { outline-offset: -2px; }
.opc-pbs.is-dragging .pbs-viewport { cursor: grabbing; }
.opc-pbs.is-dragging a.pbs { pointer-events: none; }

/* ------------------------------------------------------------ 4. Eintrag */
.opc-pbs .pbs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  color: inherit;
  text-align: center;
  text-decoration: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease, background-color .2s ease;
}
.opc-pbs .pbs-media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: var(--pbs-ratio, 4 / 3);
  padding: var(--pbs-pad, 10%);
  overflow: hidden;
}
.opc-pbs--size-s { --pbs-pad: 16%; }
.opc-pbs--size-m { --pbs-pad: 10%; }
.opc-pbs--size-l { --pbs-pad: 4%; }
.opc-pbs .pbs-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: filter .25s ease, opacity .25s ease, transform .25s ease;
}
/* Hersteller ohne Logo: der Name als Schriftzug in der Logo-Fläche */
.opc-pbs .pbs-wordmark {
  color: var(--pbs-name, var(--pbs-ink));
  font-weight: 700;
  font-size: 1.05em;
  line-height: 1.2;
  letter-spacing: .02em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.opc-pbs .pbs-name {
  display: block;
  max-width: 100%;
  color: var(--pbs-name, var(--pbs-muted));
  line-height: 1.3;
  overflow-wrap: break-word;
  transition: color .2s ease;
}
.opc-pbs--name-s .pbs-name { font-size: .875em; }
/* Ausgeblendet: der Name steht dann als Bildtext im Logo */
.opc-pbs--no-name .pbs { gap: 0; }

.opc-pbs--logo-gray .pbs-logo,
.opc-pbs--logo-gray-hover .pbs-logo { filter: grayscale(1); opacity: .7; }

/* -------------------------------------------------------------- 5. Stile */
/* Kachel: weiße Karte mit feinem Rand, Name in der Karte */
.opc-pbs--card .pbs {
  padding: 8px 8px 12px;
  border: 1px solid var(--pbs-line);
  border-radius: 10px;
  background: var(--pbs-tile, #fff);
  box-shadow: 0 1px 2px rgba(31, 41, 51, .04);
}
.opc-pbs--card.opc-pbs--no-name .pbs { padding: 8px; }

/* Fläche: hellgraue Logo-Fläche ohne Rand. multiply lässt den weißen Grund von JPG-Logos in der Fläche aufgehen. */
.opc-pbs--tile .pbs-media {
  border-radius: 10px;
  background: var(--pbs-tile, var(--p27-hangar, #f2f5f8));
}

/* Markenleiste (PICHLER 2027, seit 1.2.0): Logos frei, eine Linie über und unter der Reihe. Hersteller ohne Logo
   stehen als ruhiger grauer Schriftzug in der Überschriften-Schrift, beim Drüberfahren in Schriftfarbe. */
.opc-pbs--band .pbs-stage {
  border-top: 1px solid var(--pbs-line);
  border-bottom: 1px solid var(--pbs-line);
}
.opc-pbs--band.opc-pbs--slider .pbs-viewport { padding: 12px 0; }
.opc-pbs--band.opc-pbs--grid .pbs-track { padding: 12px 0; }
.opc-pbs--band .pbs-media { border-radius: var(--p27-r-ctl, 8px); }
.opc-pbs--band .pbs-wordmark {
  color: var(--pbs-name, #8a96a2);
  font-family: var(--p27-font-head, inherit);
  font-weight: var(--p27-head-weight, 700);
  font-size: 18px;
  letter-spacing: .01em;
  text-transform: none;
  overflow-wrap: normal;
  transition: color .2s ease;
}
@media (hover: hover) {
  .opc-pbs--band a.pbs:hover .pbs-wordmark { color: var(--pbs-ink); }
}
/* Schmale Leiste (Handy): kleiner, damit Namen ganz bleiben statt mitten im Wort umzubrechen */
@container pbs (max-width: 539px) {
  .opc-pbs--band .pbs-wordmark { font-size: 14px; letter-spacing: 0; }
}
.opc-pbs--tile .pbs-logo { mix-blend-mode: multiply; }

/* Frei: nur Logo und Name */
.opc-pbs--plain .pbs-media { border-radius: 8px; }

/* Trennstrich: ohne Rahmen, eine feine Linie zwischen den Logos mit etwas Luft oben und unten.
   Am Anfang jeder Reihe steht kein Strich. In einer Reihe (Slider, am Handy wischbar) fehlt er nur beim ersten. */
.opc-pbs--divider .pbs-item { position: relative; }
.opc-pbs--divider .pbs-item::before {
  content: "";
  position: absolute;
  top: 14%;
  bottom: 14%;
  left: calc(var(--pbs-gap) / -2);
  width: 1px;
  background: var(--pbs-line);
}
.opc-pbs--divider .pbs-item:first-child::before { display: none; }
/* Im endlosen Band hat jedes Logo seinen Strich, am linken Rand liegt er außerhalb und wird abgeschnitten */
.opc-pbs--divider.is-loop .pbs-item::before { display: block; }
@container pbs (max-width: 539px) {
  .opc-pbs--divider.opc-pbs--m-grid.opc-pbs--sm-2 .pbs-item:nth-child(2n+1)::before,
  .opc-pbs--divider.opc-pbs--m-grid.opc-pbs--sm-3 .pbs-item:nth-child(3n+1)::before,
  .opc-pbs--divider.opc-pbs--m-grid.opc-pbs--sm-4 .pbs-item:nth-child(4n+1)::before { display: none; }
}
@container pbs (min-width: 540px) and (max-width: 859px) {
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--md-3 .pbs-item:nth-child(3n+1)::before,
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--md-4 .pbs-item:nth-child(4n+1)::before,
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--md-5 .pbs-item:nth-child(5n+1)::before,
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--md-6 .pbs-item:nth-child(6n+1)::before,
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--md-7 .pbs-item:nth-child(7n+1)::before { display: none; }
}
@container pbs (min-width: 860px) {
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--lg-3 .pbs-item:nth-child(3n+1)::before,
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--lg-4 .pbs-item:nth-child(4n+1)::before,
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--lg-5 .pbs-item:nth-child(5n+1)::before,
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--lg-6 .pbs-item:nth-child(6n+1)::before,
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--lg-7 .pbs-item:nth-child(7n+1)::before,
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--lg-8 .pbs-item:nth-child(8n+1)::before,
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--lg-9 .pbs-item:nth-child(9n+1)::before,
  .opc-pbs--divider.opc-pbs--grid.opc-pbs--lg-10 .pbs-item:nth-child(10n+1)::before { display: none; }
}

/* ------------------------------------------------------- 6. Drüberfahren */
/* Nur Einträge mit Link reagieren, und nur mit echter Maus (am Handy bleibt sonst der Zustand nach dem Antippen) */
@media (hover: hover) {
  .opc-pbs--logo-gray-hover a.pbs:hover .pbs-logo { filter: none; opacity: 1; }
  .opc-pbs--hover-lift a.pbs:hover .pbs-name { color: var(--pbs-accent-text); }
  .opc-pbs--hover-lift.opc-pbs--card a.pbs:hover {
    border-color: color-mix(in srgb, var(--pbs-accent) 40%, var(--pbs-line));
    box-shadow: 0 6px 18px rgba(31, 41, 51, .08);
    transform: translateY(-2px);
  }
  .opc-pbs--hover-lift:not(.opc-pbs--card) a.pbs:hover .pbs-logo { transform: scale(1.05); }
  .opc-pbs--hover-lift.opc-pbs--tile a.pbs:hover .pbs-media {
    background: color-mix(in srgb, var(--pbs-accent) 6%, var(--pbs-tile, var(--p27-hangar, #f2f5f8)));
  }
}
.opc-pbs--logo-gray-hover a.pbs:focus-visible .pbs-logo { filter: none; opacity: 1; }
.opc-pbs a.pbs:focus-visible {
  outline: 2px solid var(--pbs-accent);
  outline-offset: 2px;
  border-radius: 10px;
}

/* ------------------------------------------- 7. Pfeile, Seiten-Punkte und Pause */
/* Pfeile neben der Reihe sitzen im Innenabstand der Bühne, nie auf den Logos */
.opc-pbs .pbs-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--pbs-line);
  border-radius: 50%;
  background: #fff;
  color: var(--pbs-ink);
  box-shadow: 0 1px 3px rgba(31, 41, 51, .1);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.opc-pbs .pbs-stage > .pbs-arrow {
  position: absolute;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
}
.opc-pbs .pbs-arrow[hidden] { display: none; }
.opc-pbs .pbs-stage > .pbs-arrow--prev { left: 0; }
.opc-pbs .pbs-stage > .pbs-arrow--next { right: 0; }
@media (hover: hover) {
  .opc-pbs .pbs-arrow:hover { border-color: var(--pbs-accent); background: var(--pbs-accent); color: #fff; }
}
.opc-pbs .pbs-arrow:focus-visible { outline: 2px solid var(--pbs-accent); outline-offset: 2px; }
.opc-pbs .pbs-chevron {
  width: 9px;
  height: 9px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
}
.opc-pbs .pbs-arrow--prev .pbs-chevron { margin-left: 4px; transform: rotate(-135deg); }
.opc-pbs .pbs-arrow--next .pbs-chevron { margin-right: 4px; transform: rotate(45deg); }

/* Leiste unter der Reihe: Pfeile (Einstellung "Unter der Reihe"), Punkte und Pause, mittig */
.opc-pbs .pbs-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}
.opc-pbs .pbs-nav[hidden],
.opc-pbs .pbs-nav:not(:has(:not([hidden]))) { display: none; }
.opc-pbs .pbs-nav .pbs-arrow { width: 32px; height: 32px; box-shadow: none; }

.opc-pbs .pbs-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.opc-pbs .pbs-dots[hidden] { display: none; }
/* Klickfläche 24 px, sichtbar ist der Punkt in der Mitte */
.opc-pbs .pbs-dot {
  position: relative;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.opc-pbs .pbs-dot::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--p27-line, #cfd6de);
  transform: translate(-50%, -50%);
  transition: width .25s ease, background-color .25s ease;
}
.opc-pbs .pbs-dot:hover::after { background: var(--p27-ink-2, #9aa5b1); }
.opc-pbs .pbs-dot[aria-current="true"]::after { width: 20px; background: var(--pbs-accent); }
.opc-pbs .pbs-dot:focus-visible { outline: 2px solid var(--pbs-accent); outline-offset: -2px; border-radius: 6px; }

/* Pause: zwei Balken, angehalten ein Dreieck */
.opc-pbs .pbs-pause {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--pbs-line);
  border-radius: 50%;
  background: #fff;
  color: var(--pbs-muted);
  cursor: pointer;
}
.opc-pbs .pbs-pause[hidden] { display: none; }
.opc-pbs .pbs-pause:hover { border-color: var(--pbs-accent); color: var(--pbs-accent-text); }
.opc-pbs .pbs-pause:focus-visible { outline: 2px solid var(--pbs-accent); outline-offset: 2px; }
.opc-pbs .pbs-pause-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 10px;
  border-right: 2.5px solid currentColor;
  border-left: 2.5px solid currentColor;
  transform: translate(-50%, -50%);
}
.opc-pbs.is-paused .pbs-pause-icon {
  width: 0;
  height: 0;
  margin-left: 1px;
  border-top: 5px solid transparent;
  border-right: 0;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
}

/* --------------------------------- 8. Handy (Portlet schmaler als 540 px) */
@container pbs (max-width: 539px) {
  .opc-pbs .pbs-stage > .pbs-arrow { display: none; }
  .opc-pbs.is-scrollable .pbs-stage:has(> .pbs-arrow) { padding: 0; }
  .opc-pbs .pbs-head { margin-bottom: 12px; }
  /* Raster: untereinander statt Slider */
  .opc-pbs--m-grid .pbs-viewport {
    padding: 0;
    overflow: visible;
    scroll-snap-type: none;
  }
  .opc-pbs--m-grid .pbs-track {
    grid-template-columns: repeat(var(--pbs-c), var(--pbs-slot));
    grid-auto-flow: row;
    justify-content: center;
  }
  /* Wischbar: eine Reihe, das nächste Logo schaut an */
  .opc-pbs--m-slider .pbs-viewport {
    padding: 6px 0 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .opc-pbs--m-slider .pbs-viewport::-webkit-scrollbar { display: none; }
  .opc-pbs--m-slider .pbs-track {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - var(--pbs-n) * var(--pbs-gap)) / (var(--pbs-n) + .4));
    justify-content: start;
  }
  .opc-pbs--m-slider .pbs-item { scroll-snap-align: start; }
}

/* Passen bei dieser Breite alle Logos in eine Reihe, stehen sie mittig wie im Raster (kein Slider, nichts schaut an) */
@container pbs (max-width: 539px) {
  .opc-pbs--fit-sm .pbs-viewport { overflow: visible; scroll-snap-type: none; }
  .opc-pbs--fit-sm .pbs-track {
    grid-template-columns: repeat(var(--pbs-c), var(--pbs-slot));
    grid-auto-flow: row;
    justify-content: center;
  }
}
@container pbs (min-width: 540px) and (max-width: 859px) {
  .opc-pbs--fit-md .pbs-viewport { overflow: visible; scroll-snap-type: none; }
  .opc-pbs--fit-md .pbs-track {
    grid-template-columns: repeat(var(--pbs-c), var(--pbs-slot));
    grid-auto-flow: row;
    justify-content: center;
  }
}
@container pbs (min-width: 860px) {
  .opc-pbs--fit-lg .pbs-viewport { overflow: visible; scroll-snap-type: none; }
  .opc-pbs--fit-lg .pbs-track {
    grid-template-columns: repeat(var(--pbs-c), var(--pbs-slot));
    grid-auto-flow: row;
    justify-content: center;
  }
}

/* Letzte Reihe mittig (Einstellung "Letzte Reihe im Raster"): Flex mit Umbruch statt Grid, gleiche Breite je Logo.
   Volle Reihen sehen aus wie im Grid, eine unvolle letzte Reihe steht in der Mitte. Der Abzug von 0,1 px verhindert,
   dass Rundung die letzte Spalte einer vollen Reihe in die nächste schiebt. */
@container pbs (min-width: 540px) {
  .opc-pbs--grid.opc-pbs--last-center .pbs-track {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
  .opc-pbs--grid.opc-pbs--last-center .pbs-item { flex: 0 0 calc(var(--pbs-slot) - .1px); }
}
@container pbs (max-width: 539px) {
  .opc-pbs--m-grid.opc-pbs--last-center .pbs-track {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
  .opc-pbs--m-grid.opc-pbs--last-center .pbs-item { flex: 0 0 calc(var(--pbs-slot) - .1px); }
}

@media (prefers-reduced-motion: reduce) {
  .opc-pbs *,
  .opc-pbs *::before,
  .opc-pbs *::after { transition: none !important; }
}

/* ------------------------------------------------------ 9. Editor-Hinweise */
.opc-pbs .pbs-empty,
.opc-pbs .pbs-issues {
  margin: 10px 0 0;
  padding: 10px 14px;
  border: 1px dashed #cfd6de;
  background: #f5f7fa;
  color: #6b7680;
  font-size: 12px;
  list-style: none;
}
.opc-pbs .pbs-issues { border-color: #e7c873; background: #fdf8ea; color: #7a5b0c; }

/* ---------------------------------------------------- 10. Ohne Hersteller */
/* Im Shop gibt das Portlet dann nur den Marker aus. Ausgeblendet wird der innerste OPC-Container, der ihn enthält,
   äußere Container bleiben. Ohne Container zeigt der Marker selbst nichts. */
.opc-Container:has(.opc-pbs-empty):not(:has(.opc-Container .opc-pbs-empty)) { display: none; }

/* ------------------------- 11. Fallback für Browser ohne Container-Queries */
@supports not (container-type: inline-size) {
  @media (min-width: 576px) {
    .opc-pbs .pbs-stage { --pbs-n: var(--pbs-n-md, 4); --pbs-c: var(--pbs-c-md, 4); --pbs-gap: 16px; }
  }
  @media (min-width: 992px) {
    .opc-pbs .pbs-stage { --pbs-n: var(--pbs-n-lg, 6); --pbs-c: var(--pbs-c-lg, 6); }
  }
}
