/* ============================================================
   ACF Kran Galerie
   Mobile-first: Die Basisregeln beschreiben das Telefon
   (1 Bild je Seite). Breakpoints 481 / 769 / 1025 px –
   identisch mit gallery.js und den SLOTS im PHP.
   Farben und Radius aus dem Klaas-Theme (--kk-*), mit Fallback.
   ============================================================ */

.acf-gallery-wrapper {
  margin: 2rem auto;
}

/* --- Raster ------------------------------------------------- */

.acf-gallery-wrapper .acf-gallery-items {
  display: flex;
  flex-wrap: wrap;
  margin-left: -1rem;
  margin-right: -1rem;
}

.acf-gallery-wrapper .acf-gallery-item {
  width: 100%;
  padding: 0 1rem;
  box-sizing: border-box;
  display: none;
}

/* Bevor das Script läuft, so viele Bilder zeigen, wie auf die erste Seite
   passen – dann springt beim Start nichts. Danach steuert .is-visible. */
.acf-gallery-wrapper:not(.is-ready) .acf-gallery-item:first-child,
.acf-gallery-wrapper.is-ready .acf-gallery-item.is-visible {
  display: block;
}

@media (min-width: 481px) {
  .acf-gallery-wrapper .acf-gallery-item { width: 50%; }
  .acf-gallery-wrapper:not(.is-ready) .acf-gallery-item:nth-child(-n+2) { display: block; }
}

@media (min-width: 769px) {
  .acf-gallery-wrapper .acf-gallery-item { width: 33.333%; }
  .acf-gallery-wrapper:not(.is-ready) .acf-gallery-item:nth-child(-n+3) { display: block; }
}

@media (min-width: 1025px) {
  .acf-gallery-wrapper .acf-gallery-item { width: 25%; }
  .acf-gallery-wrapper:not(.is-ready) .acf-gallery-item:nth-child(-n+4) { display: block; }
}

/* --- Quadratischer Rahmen ----------------------------------- */

.acf-gallery-wrapper .acf-gallery-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 0;
  /* Platzhalter, solange ein nachgeladenes Bild noch unterwegs ist */
  background: var(--kk-flaeche-kuehl, #F0F2F5);
}

/* Bild füllt den Rahmen, längste Kante wird beschnitten */
.acf-gallery-wrapper .acf-gallery-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 0;
}

/* Link über dem Bild (vollflächig) */
.acf-gallery-wrapper .acf-gallery-image a {
  position: absolute;
  inset: 0;
  display: block;
  cursor: zoom-in;
}

/* overflow:hidden schneidet einen äußeren Rahmen ab – daher nach innen */
.acf-gallery-wrapper .acf-gallery-image a:focus-visible {
  outline: 3px solid var(--kk-blau, #164194);
  outline-offset: -3px;
}

/* --- Hinweis „vergrößern" ------------------------------------ */

/* Touch: dauerhaft sichtbares Plus unten rechts – ohne Mauszeiger
   gibt es kein Hover, das den Hinweis einblenden könnte. */
.acf-gallery-wrapper .acf-gallery-image .acf-overlay {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(22, 65, 148, 0.85); /* --kk-blau */
  pointer-events: none;
}

.acf-gallery-wrapper .acf-gallery-image .acf-overlay::after {
  content: "+";
  font-size: 1.5rem;
  line-height: 1;
  color: #fff;
}

/* Maus: großflächiges Overlay, nur beim Überfahren */
@media (hover: hover) and (pointer: fine) {
  .acf-gallery-wrapper .acf-gallery-item {
    transition: transform 0.3s ease;
  }
  .acf-gallery-wrapper .acf-gallery-item:hover {
    transform: scale(1.03);
  }

  .acf-gallery-wrapper .acf-gallery-image .acf-overlay {
    inset: 0;
    width: auto;
    height: auto;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  .acf-gallery-wrapper .acf-gallery-image:hover .acf-overlay,
  .acf-gallery-wrapper .acf-gallery-image a:focus-visible .acf-overlay {
    opacity: 1;
  }
  .acf-gallery-wrapper .acf-gallery-image .acf-overlay::after {
    font-size: 2rem;
  }
}

/* --- Blättern ----------------------------------------------- */

.acf-gallery-wrapper .acf-gallery-pagination {
  margin-top: 1.5rem;
}

.acf-gallery-wrapper .acf-gallery-pagination[hidden] {
  display: none;
}

.acf-gallery-wrapper .acf-gallery-pagination ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px; /* = GAP in gallery.js */
}

.acf-gallery-wrapper .acf-gallery-pagination li {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Telefon: Pfeile außen, „2 / 8" in der Mitte – mit dem Daumen gut erreichbar */
.acf-gallery-wrapper .acf-gallery-pagination.is-compact ul {
  flex-wrap: nowrap;
  justify-content: space-between;
}

.acf-gallery-wrapper .acf-gallery-counter {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: var(--kk-text-stark, #3A404B);
  font-variant-numeric: tabular-nums;
}

/* Knöpfe: mindestens 44 × 44 px (Mobile-First-To-do 9) */
.acf-gallery-wrapper .acf-gallery-pagination .acf-gallery-btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 44px; /* = TARGET in gallery.js */
  min-height: 44px;
  margin: 0;
  padding: 0 12px;
  border: 0;
  border-radius: var(--kk-radius, 5px);
  background: var(--kk-flaeche-kuehl, #F0F2F5);
  color: var(--kk-text-stark, #3A404B);
  font: inherit; /* Futura aus dem Theme, nicht die Systemschrift des Browsers */
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.acf-gallery-wrapper .acf-gallery-pagination .acf-gallery-btn--prev,
.acf-gallery-wrapper .acf-gallery-pagination .acf-gallery-btn--next {
  padding: 0;
  width: 44px;
}

.acf-gallery-wrapper .acf-gallery-pagination .acf-gallery-btn svg {
  display: block;
}

.acf-gallery-wrapper .acf-gallery-pagination .acf-gallery-btn.active {
  background: var(--kk-blau, #164194);
  color: var(--kk-weiss, #fff);
}

.acf-gallery-wrapper .acf-gallery-pagination .acf-gallery-btn:focus-visible {
  outline: 3px solid var(--kk-blau, #164194);
  outline-offset: 2px;
}

.acf-gallery-wrapper .acf-gallery-pagination .acf-gallery-btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: default;
}

@media (hover: hover) and (pointer: fine) {
  .acf-gallery-wrapper .acf-gallery-pagination .acf-gallery-btn:not(.active):not([aria-disabled="true"]):hover {
    background: var(--kk-blau-hell, #B4CDF0);
    color: var(--kk-blau-dunkel, #0E2E63);
  }
}

/* --- Sonstiges ---------------------------------------------- */

/* Nur für Screenreader (Ansage „Bild 2 von 8") */
.acf-gallery-wrapper .acf-gallery-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .acf-gallery-wrapper .acf-gallery-item,
  .acf-gallery-wrapper .acf-gallery-image .acf-overlay,
  .acf-gallery-wrapper .acf-gallery-pagination .acf-gallery-btn {
    transition: none;
  }
  .acf-gallery-wrapper .acf-gallery-item:hover {
    transform: none;
  }
}
