/* ==========================================================================
   mod_fw_bildwechsel – wechselnde Bilder
   Übernimmt Farben und Schrift aus dem Feuerwehr-Template, funktioniert aber
   auch mit jedem anderen Template.
   ========================================================================== */

.fwb {
  --fwb-accent: var(--fw-red, #b3121b);
  --fwb-dark: var(--fw-dark, #1f242b);
  --fwb-focus: var(--fw-signal, #f2b705);
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  overflow: hidden;
  margin-bottom: 1.5rem;
  border-radius: 4px;
  background: var(--fwb-dark);
  color: #fff;
}

.fwb__viewport {
  position: relative;
  aspect-ratio: var(--fwb-ratio, 16 / 9);
  overflow: hidden;
}

.fwb__track {
  position: absolute;
  inset: 0;
}

.fwb__slide {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity .9s ease, visibility 0s linear .9s;
}

.fwb__slide.is-active {
  z-index: 1;
  opacity: 1;
  visibility: visible;
  transition: opacity .9s ease, visibility 0s;
}

.fwb__link {
  display: block;
  width: 100%;
  height: 100%;
  color: inherit;
}

.fwb__img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: var(--fwb-fit, cover);
}

/* Schieben */
.fwb--slide .fwb__track {
  display: flex;
  transition: transform .7s cubic-bezier(.6, 0, .2, 1);
}

.fwb--slide .fwb__slide {
  position: relative;
  flex: 0 0 100%;
  opacity: 1;
  visibility: visible;
  transition: none;
}

/* Überblenden mit langsamem Zoom */
.fwb--zoom .fwb__slide.is-active .fwb__img {
  animation: fwb-zoom calc(var(--fwb-interval, 6s) + 1.5s) linear both;
}

@keyframes fwb-zoom {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

/* Bildunterschrift */
.fwb__caption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 4rem clamp(1rem, 4cqi, 1.75rem) 4.25rem;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .74));
  color: #fff;
  font-family: var(--fw-font-cond, inherit);
  font-size: clamp(1.05rem, .85rem + 2cqi, 1.85rem);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

.fwb__caption span {
  display: block;
  max-width: 34ch;
}

.fwb:not(:has(.fwb__controls)) .fwb__caption {
  padding-bottom: 1.25rem;
}

/* Steuerung */
.fwb__controls {
  position: absolute;
  right: clamp(.75rem, 2vw, 1.25rem);
  bottom: calc(clamp(.75rem, 2vw, 1.1rem) + 4px);
  left: clamp(1rem, 3vw, 1.75rem);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: .4rem;
  pointer-events: none;
}

.fwb__controls > * {
  pointer-events: auto;
}

.fwb__dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
  order: -1;
  max-width: 60%;
  margin-right: auto;
}

.fwb__dot {
  position: relative;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.fwb__dot::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 5px;
  margin-top: -2.5px;
  background: rgba(255, 255, 255, .5);
  transition: background-color .2s;
}

.fwb__dot:hover::after {
  background: rgba(255, 255, 255, .85);
}

.fwb__dot.is-active::after {
  background: #fff;
}

.fwb__btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  background: rgba(20, 24, 29, .66);
  color: #fff;
  cursor: pointer;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%);
  transition: background-color .15s;
}

.fwb__btn:hover {
  background: var(--fwb-accent);
}

.fwb__btn svg {
  width: 20px;
  height: 20px;
}

.fwb__btn:focus-visible,
.fwb__dot:focus-visible,
.fwb__link:focus-visible {
  outline: 3px solid var(--fwb-focus);
  outline-offset: -3px;
  clip-path: none;
}

.fwb__icon-play,
.fwb.is-paused .fwb__icon-pause {
  display: none;
}

.fwb.is-paused .fwb__icon-play {
  display: block;
}

/* Laufbalken: zeigt die Zeit bis zum nächsten Bild und steuert den Wechsel */
.fwb__progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4;
  height: 4px;
  background: rgba(255, 255, 255, .14);
}

.fwb__progress span {
  display: block;
  height: 100%;
  background: var(--fwb-accent);
  transform: scaleX(0);
  transform-origin: left;
}

.fwb.is-running .fwb__progress span {
  animation: fwb-progress var(--fwb-interval, 6s) linear forwards;
}

@keyframes fwb-progress {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.fwb.is-paused .fwb__progress span,
.fwb__viewport:focus-within ~ .fwb__progress span {
  animation-play-state: paused;
}

@media (hover: hover) {
  .fwb:hover .fwb__progress span {
    animation-play-state: paused;
  }
}

/* Rahmen "Wache": Torrahmen wie auf der Startseite des Feuerwehr-Templates */
.fwb--wache {
  padding: 16px 16px 0;
  border-radius: 0;
}

.fwb--wache::before {
  content: "";
  position: absolute;
  top: 6px;
  right: 16px;
  left: 16px;
  height: 3px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .55) 0 34px, transparent 34px 40px);
}

/* Im Banner des Feuerwehr-Templates über die volle Breite */
.fw-banner .fwb {
  margin-bottom: 0;
  border-radius: 0;
}

.fw-banner .fwb__viewport {
  max-height: 72vh;
  width: 100%;
}

.fw-banner .fwb__caption,
.fw-banner .fwb__controls {
  padding-inline: max(var(--fw-gutter, 1.5rem), calc((100% - var(--fw-container, 1240px)) / 2));
}

.fw-banner .fwb__controls {
  right: 0;
  left: 0;
}

@container (max-width: 480px) {
  .fwb__btn {
    width: 38px;
    height: 38px;
  }

  .fwb__prev,
  .fwb__next {
    display: none;
  }

  .fwb__caption {
    padding-bottom: 3.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fwb__slide,
  .fwb__slide.is-active,
  .fwb--slide .fwb__track {
    transition: none;
  }

  .fwb--zoom .fwb__slide.is-active .fwb__img {
    animation: none;
  }
}
