/* ==========================================================
   gallery-Modul — globale Variablen für Theme-Konformität
   ========================================================== */

.gallery-page {
  padding: 3rem 0 4rem;
}
.gallery-page__head {
  text-align: center;
  margin-bottom: 2rem;
}
.gallery-page__head h1 {
  margin: 0 0 .5rem;
  color: var(--color-primary);
}
.gallery-page__lead {
  color: var(--color-text);
  opacity: .8;
  max-width: 640px;
  margin: 0 auto;
}
.gallery-page__empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text);
  opacity: .6;
}

/* Block-Variante (für Hooks/Shortcode) */
.gallery-block {
  padding: 1.5rem 0;
}
.gallery-block.is-compact {
  background: var(--color-secondary);
  padding: 1rem 0;
}
.gallery-block__title {
  margin: 0 0 .5rem;
  color: var(--color-primary);
  text-align: center;
}
.gallery-block__lead {
  text-align: center;
  color: var(--color-text);
  opacity: .8;
  margin-bottom: 1.5rem;
}

/* Grid */
.gallery-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .5rem;
  grid-template-columns: repeat(var(--gallery-cols, 3), 1fr);
}
@media (max-width: 900px) {
  .gallery-grid { grid-template-columns: repeat(min(var(--gallery-cols, 3), 3), 1fr); }
}
@media (max-width: 600px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: .35rem; }
}
@media (max-width: 380px) {
  .gallery-grid { grid-template-columns: 1fr; }
}

.gallery-grid__item {
  position: relative;
  overflow: hidden;
  border-radius: .5rem;
  background: color-mix(in srgb, var(--color-text) 8%, transparent);
}
.gallery-grid__link {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  cursor: zoom-in;
}
.gallery-grid__link img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .4s ease;
}
.gallery-grid__link:hover img,
.gallery-grid__link:focus-visible img {
  transform: scale(1.05);
}
.gallery-grid__caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: .55rem .7rem;
  background: linear-gradient(to top, rgba(0,0,0,.65), rgba(0,0,0,0));
  color: #fff;
  font-size: .85rem;
  opacity: 0;
  transform: translateY(15%);
  transition: opacity .25s ease, transform .25s ease;
}
.gallery-grid__link:hover .gallery-grid__caption,
.gallery-grid__link:focus-visible .gallery-grid__caption {
  opacity: 1;
  transform: translateY(0);
}

/* Compact-Variante: kein Caption-Overlay, dichteres Grid */
.gallery-block.is-compact .gallery-grid__caption { display: none; }

/* ==========================================================
   Lightbox (Vollbild-Modal)
   ========================================================== */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .92);
  z-index: 9999;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem 1rem;
  animation: gal-fade .2s ease both;
}
.gallery-lightbox.is-open { display: flex; }
@keyframes gal-fade { from { opacity: 0; } to { opacity: 1; } }

.gallery-lightbox__stage {
  position: relative;
  width: 100%;
  max-width: 1100px;
  max-height: calc(100vh - 6rem);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-lightbox__img {
  max-width: 100%;
  max-height: calc(100vh - 8rem);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  border-radius: .25rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.gallery-lightbox__caption {
  margin-top: .75rem;
  color: #f9fafb;
  font-size: .92rem;
  text-align: center;
  max-width: 720px;
  padding: 0 1rem;
  min-height: 1.4em;
}

.gallery-lightbox__btn {
  position: absolute;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border: 0;
  width: 48px; height: 48px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, transform .15s ease;
  backdrop-filter: blur(4px);
}
.gallery-lightbox__btn:hover { background: rgba(255, 255, 255, .25); transform: scale(1.05); }
.gallery-lightbox__prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.gallery-lightbox__next { right: 1rem; top: 50%; transform: translateY(-50%); }
.gallery-lightbox__prev:hover { transform: translateY(-50%) scale(1.05); }
.gallery-lightbox__next:hover { transform: translateY(-50%) scale(1.05); }
.gallery-lightbox__close { top: 1rem; right: 1rem; width: 44px; height: 44px; }
.gallery-lightbox__counter {
  position: absolute;
  top: 1.25rem; left: 1.25rem;
  color: #f9fafb;
  font-size: .9rem;
  background: rgba(255, 255, 255, .1);
  padding: .35rem .75rem;
  border-radius: 1rem;
  backdrop-filter: blur(4px);
}

@media (max-width: 600px) {
  .gallery-lightbox__prev, .gallery-lightbox__next { width: 40px; height: 40px; }
  .gallery-lightbox__prev { left: .25rem; }
  .gallery-lightbox__next { right: .25rem; }
}

/* ==========================================================================
   Layout: Vorher / Nachher (Slider)
   ========================================================================== */
.gallery-ba {
  display: grid;
  gap: 2rem;
}
.gallery-ba__item { margin: 0; }
.gallery-ba__compare {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: .4rem;
  user-select: none;
  background: var(--color-secondary, #f1f5f9);
  cursor: ew-resize;
}
.gallery-ba__compare::after { content: ''; display: block; padding-bottom: 62%; } /* 16:10 Verhältnis */
.gallery-ba__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  pointer-events: none;
}
.gallery-ba__after-wrap {
  position: absolute; top: 0; right: 0; bottom: 0;
  overflow: hidden;
  width: 50%;
  pointer-events: none;
}
.gallery-ba__after-wrap .gallery-ba__img {
  /* Bild im after-wrap muss sich an die volle Container-Breite ausrichten */
  width: calc(100% / var(--ba-after-w, .5));
  right: 0; left: auto;
}
/* Einfacher: feste Breite anpassen */
.gallery-ba__after-wrap .gallery-ba__img--after {
  width: 100vw;
  max-width: 900px;
  right: 0;
  position: absolute;
}
.gallery-ba__handle {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 4px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15), 0 4px 16px rgba(0,0,0,.25);
  cursor: ew-resize;
  transform: translateX(-50%);
  z-index: 5;
}
.gallery-ba__handle-line { display: none; }
.gallery-ba__handle-grip {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 38px; height: 38px;
  background: #ffffff;
  color: var(--color-primary, #0a6ebd);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.gallery-ba__label {
  position: absolute;
  top: 1rem;
  padding: .25rem .65rem;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-radius: 1rem;
  pointer-events: none;
  z-index: 4;
}
.gallery-ba__label--before { left: 1rem; }
.gallery-ba__label--after  { right: 1rem; }
.gallery-ba__caption {
  margin-top: .75rem;
  text-align: center;
  font-size: .92rem;
  color: var(--color-text, #1f2937);
  opacity: .85;
}

/* ==========================================================================
   Layout: Slideshow
   ========================================================================== */
.gallery-slideshow {
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  background: var(--color-secondary, #f1f5f9);
  border-radius: .4rem;
  overflow: hidden;
}
.gallery-slideshow__track {
  position: relative;
  /* --gallery-aspect wird im PHP gesetzt: "16 / 9" | "4 / 3" | "1 / 1" | "auto" */
  aspect-ratio: var(--gallery-aspect, 16 / 9);
}
/* "auto"-Seitenverhältnis: keine fixe Höhe, Höhe = Höhe des ersten Bildes */
.gallery-slideshow[style*="--gallery-aspect:auto"] .gallery-slideshow__track {
  aspect-ratio: auto;
  min-height: 240px;
}
.gallery-slideshow__slide {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-slideshow__slide.is-active { opacity: 1; pointer-events: auto; }
/* Link um das Slide-Bild — Default-Stile resetten, damit der Slide klickbar
   wird ohne den Layout-Flow zu stören. */
.gallery-slideshow__link {
  display: block;
  width: 100%;
  height: 100%;
  cursor: zoom-in;
}
.gallery-slideshow__slide img {
  width: 100%; height: 100%;
  /* Default jetzt CONTAIN (kein Crop). Wird durch --gallery-fit überschrieben:
     contain = Letterbox, keine Bildbereiche werden abgeschnitten.
     cover   = Bild füllt Rahmen, schneidet Über-/Unterhang weg. */
  object-fit: var(--gallery-fit, contain);
  display: block;
}
/* Bei contain bekommt der Hintergrund eine dezente Box-Farbe, damit
   Letterbox-Ränder nicht störend wirken. */
.gallery-slideshow[data-fit="contain"] .gallery-slideshow__slide {
  background: rgba(0,0,0,.04);
}
.gallery-slideshow__slide figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 1rem 1.25rem;
  background: linear-gradient(to top, rgba(0,0,0,.7), rgba(0,0,0,0));
  color: #fff;
  font-size: .92rem;
}
.gallery-slideshow__nav {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: 0;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
  z-index: 3;
}
.gallery-slideshow__nav:hover { background: rgba(0,0,0,.85); }
.gallery-slideshow__nav--prev { left: 1rem; }
.gallery-slideshow__nav--next { right: 1rem; }
.gallery-slideshow__dots {
  position: absolute;
  left: 0; right: 0; bottom: 1rem;
  display: flex; gap: .35rem; justify-content: center;
  z-index: 3;
}
.gallery-slideshow__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,.5);
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.gallery-slideshow__dot:hover { background: rgba(255,255,255,.85); }
.gallery-slideshow__dot.is-active { background: #fff; transform: scale(1.4); }

/* ==========================================================================
   Layout: Masonry (CSS-columns)
   ========================================================================== */
.gallery-masonry {
  list-style: none;
  padding: 0; margin: 0;
  column-count: 3;
  column-gap: 1rem;
}
@media (max-width: 800px) { .gallery-masonry { column-count: 2; } }
@media (max-width: 480px) { .gallery-masonry { column-count: 1; } }
.gallery-masonry__item {
  break-inside: avoid;
  margin-bottom: 1rem;
}
.gallery-masonry__item .gallery-grid__link {
  display: block;
  cursor: zoom-in;
  border-radius: .4rem;
  overflow: hidden;
  position: relative;
}
.gallery-masonry__item img {
  width: 100%; height: auto; display: block;
  transition: transform .3s ease;
}
.gallery-masonry__item .gallery-grid__link:hover img { transform: scale(1.03); }
.gallery-masonry__item figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: .55rem .7rem;
  background: linear-gradient(to top, rgba(0,0,0,.65), transparent);
  color: #fff;
  font-size: .82rem;
  opacity: 0;
  transition: opacity .25s ease;
}
.gallery-masonry__item .gallery-grid__link:hover figcaption { opacity: 1; }

/* ==========================================================================
   Layout: Polaroid
   ========================================================================== */
.gallery-polaroid {
  list-style: none;
  padding: 1.5rem 0; margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
  align-items: start;
}
.gallery-polaroid__item {
  margin: 0;
  transform: rotate(var(--rot, 0deg));
  transition: transform .25s ease, box-shadow .25s ease;
}
.gallery-polaroid__item:hover {
  transform: rotate(0deg) scale(1.04);
  z-index: 2;
}
.gallery-polaroid__item .gallery-grid__link {
  display: block;
  background: #fff;
  padding: .7rem .7rem 0;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  cursor: zoom-in;
}
.gallery-polaroid__img {
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: #f3f4f6;
}
.gallery-polaroid__img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(.95) contrast(.97);
}
.gallery-polaroid__caption {
  padding: .7rem .25rem .85rem;
  text-align: center;
  font-family: 'Caveat', 'Brush Script MT', cursive;
  font-size: 1.15rem;
  color: #374151;
  font-weight: 500;
}

/* ==========================================================================
   Layout: Lookbook (großes Bild + Thumbnail-Strip)
   ========================================================================== */
.gallery-lookbook {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
}
@media (max-width: 700px) {
  .gallery-lookbook { grid-template-columns: 1fr; }
}
.gallery-lookbook__main {
  position: relative;
  background: var(--color-secondary, #f1f5f9);
  border-radius: .4rem;
  overflow: hidden;
  aspect-ratio: 4 / 3;
}
.gallery-lookbook__main img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .3s ease;
}
.gallery-lookbook__main figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: .85rem 1.1rem;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent);
  color: #fff;
  font-size: .92rem;
  min-height: 1.4em;
}
.gallery-lookbook__thumbs {
  list-style: none; padding: 0; margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: .55rem;
  max-height: 100%;
  overflow-y: auto;
}
@media (max-width: 700px) {
  .gallery-lookbook__thumbs {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    max-height: none;
  }
}
.gallery-lookbook__thumb {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-radius: .3rem;
  overflow: hidden;
  position: relative;
  aspect-ratio: 1 / 1;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color .15s ease, opacity .15s ease;
}
.gallery-lookbook__thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-lookbook__thumb:not(.is-active) { opacity: .55; }
.gallery-lookbook__thumb:hover { opacity: 1; }
.gallery-lookbook__thumb.is-active {
  opacity: 1;
  outline-color: var(--color-primary, #0a6ebd);
}

/* ==========================================================================
   Layout: Speisekarte (Menu)
   ========================================================================== */
.gallery-menu {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}
.gallery-menu__item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1.25rem;
  align-items: center;
  padding-bottom: 1.5rem;
  border-bottom: 1px dashed color-mix(in srgb, var(--color-text, #1f2937) 18%, transparent);
}
.gallery-menu__item:last-child { border-bottom: 0; }
.gallery-menu__media {
  width: 140px; height: 140px;
  border-radius: .35rem;
  overflow: hidden;
  background: var(--color-secondary, #f1f5f9);
}
.gallery-menu__media img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-menu__head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: .35rem;
}
.gallery-menu__title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--color-primary, #0a6ebd);
  flex: 1;
}
/* Klassische Speisekarten-Optik: Punkte zwischen Titel und Preis */
.gallery-menu__head::after {
  content: '';
  flex: 0 0 auto;
  border-bottom: 2px dotted color-mix(in srgb, var(--color-text, #1f2937) 25%, transparent);
  margin: 0 .5rem;
  flex: 1;
  align-self: end;
  height: 0;
  margin-bottom: .35rem;
}
.gallery-menu__price {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text, #1f2937);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  order: 3;
}
.gallery-menu__title { order: 1; flex: 0 0 auto; }
.gallery-menu__head::after { order: 2; }
.gallery-menu__desc {
  margin: 0;
  font-size: .95rem;
  line-height: 1.55;
  color: var(--color-text, #1f2937);
  opacity: .8;
}
@media (max-width: 600px) {
  .gallery-menu__item { grid-template-columns: 90px 1fr; gap: 1rem; }
  .gallery-menu__media { width: 90px; height: 90px; }
  .gallery-menu__title { font-size: 1.05rem; }
}

/* ==========================================================================
   Layout: Produkt-Karten
   ========================================================================== */
.gallery-products {
  list-style: none;
  padding: 0; margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
}
.gallery-products__item {
  background: var(--color-background, #ffffff);
  border: 1px solid color-mix(in srgb, var(--color-text, #1f2937) 10%, transparent);
  border-radius: .5rem;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}
.gallery-products__item:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .08);
}
.gallery-products__item .gallery-grid__link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: zoom-in;
}
.gallery-products__media {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--color-secondary, #f1f5f9);
}
.gallery-products__media img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .35s ease;
}
.gallery-products__item:hover .gallery-products__media img { transform: scale(1.04); }
.gallery-products__body {
  padding: 1rem 1.1rem 1.1rem;
}
.gallery-products__title {
  margin: 0 0 .35rem;
  font-size: 1.05rem;
  color: var(--color-text, #1f2937);
  line-height: 1.3;
}
.gallery-products__desc {
  margin: 0 0 .65rem;
  font-size: .85rem;
  color: var(--color-text, #1f2937);
  opacity: .75;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gallery-products__price {
  display: inline-block;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-primary, #0a6ebd);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Layout: Portfolio
   ========================================================================== */
.gallery-portfolio {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4rem;
  max-width: 1100px;
  margin: 0 auto;
}
.gallery-portfolio__item {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 2.5rem;
  align-items: center;
}
.gallery-portfolio__item.is-flipped {
  grid-template-columns: 1fr 1.4fr;
}
.gallery-portfolio__item.is-flipped .gallery-portfolio__media { order: 2; }
.gallery-portfolio__item.is-flipped .gallery-portfolio__body  { order: 1; }
.gallery-portfolio__media {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: .5rem;
  background: var(--color-secondary, #f1f5f9);
  cursor: zoom-in;
}
.gallery-portfolio__media img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.gallery-portfolio__media:hover img { transform: scale(1.04); }
.gallery-portfolio__body {
  padding: 1rem 0;
}
.gallery-portfolio__title {
  margin: 0 0 .85rem;
  font-size: clamp(1.4rem, 3vw, 2rem);
  color: var(--color-primary, #0a6ebd);
  line-height: 1.2;
}
.gallery-portfolio__desc {
  margin: 0;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-text, #1f2937);
  opacity: .85;
}
@media (max-width: 800px) {
  .gallery-portfolio { gap: 2.5rem; }
  .gallery-portfolio__item,
  .gallery-portfolio__item.is-flipped {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .gallery-portfolio__item.is-flipped .gallery-portfolio__media { order: 1; }
  .gallery-portfolio__item.is-flipped .gallery-portfolio__body  { order: 2; }
}
