/* TSGO Galerie – Raster + Vollbildansicht */

.tsgo-gallery {
  --g-gap: clamp(6px, 1vw, 12px);
  --g-radius: 10px;
  --g-accent: var(--tsgo-accent, #d7261e);
  margin: 1.5rem 0 2rem;
}

.tsgo-gallery__meta {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem;
  margin-bottom: .9rem; color: var(--tsgo-muted, #5b6676); font-size: .9rem;
}
.tsgo-gallery__meta strong { color: var(--tsgo-ink, #1d2733); font-size: 1rem; margin-right: .75rem; }

/*
 * Raster mit fester Spaltenzahl; die Zeilenhöhe ergibt sich aus Spaltenbreite × Kachelformat.
 * Hochkant-Fotos belegen zwei Zeilen, damit sie fast vollständig sichtbar bleiben.
 */
.tsgo-gallery { container-type: inline-size; --g-cols: 2; --g-ratio: .75; }
@container (min-width: 520px) { .tsgo-gallery__grid { --g-cols: 3; } }
@container (min-width: 760px) { .tsgo-gallery__grid { --g-cols: 4; } }
@container (min-width: 1100px) { .tsgo-gallery__grid { --g-cols: 5; } }
.tsgo-gallery--3-2 { --g-ratio: .6667; }
.tsgo-gallery--1-1 { --g-ratio: 1; }

.tsgo-gallery__grid {
  display: grid; grid-template-columns: repeat(var(--g-cols), minmax(0, 1fr));
  grid-auto-rows: calc((100cqi - (var(--g-cols) - 1) * var(--g-gap)) / var(--g-cols) * var(--g-ratio));
  grid-auto-flow: row dense;
  gap: var(--g-gap); margin: 0; padding: 0; list-style: none;
}
.tsgo-gallery__grid li { margin: 0; min-width: 0; }
.tsgo-gallery__grid li.is-portrait { grid-row: span 2; }

.tsgo-gallery__item {
  position: relative; display: block; overflow: hidden; border-radius: var(--g-radius);
  background: #e9edf3; width: 100%; height: 100%; cursor: zoom-in;
}

.tsgo-gallery .tsgo-gallery__item img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 0 !important;
  transition: transform .35s ease, filter .35s ease;
}
.tsgo-gallery__item::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: inset 0 0 0 3px transparent; transition: box-shadow .2s;
}
.tsgo-gallery .tsgo-gallery__item:hover img { transform: scale(1.04); }
.tsgo-gallery__item:focus-visible { outline: none; }
.tsgo-gallery__item:focus-visible::after { box-shadow: inset 0 0 0 3px var(--g-accent); }

/* Originalformat als Mauerwerk */
.tsgo-gallery--natural .tsgo-gallery__grid { display: block; columns: 4 220px; column-gap: var(--g-gap); }
.tsgo-gallery--natural .tsgo-gallery__grid li { break-inside: avoid; margin-bottom: var(--g-gap); }
.tsgo-gallery--natural .tsgo-gallery__item { height: auto; }
.tsgo-gallery--natural .tsgo-gallery__item img, .tsgo-gallery.tsgo-gallery--natural .tsgo-gallery__item img { position: static; height: auto; }

.tsgo-gallery__empty { padding: 1rem 1.25rem; border-radius: 10px; background: #f3f6fb; color: #5b6676; }

/* ---------- Vollbild ---------- */
.tsgo-lb {
  position: fixed; inset: 0; z-index: 2000; display: grid; grid-template-rows: auto 1fr auto;
  background: rgba(8, 12, 20, .96); color: #fff; touch-action: pan-y;
  opacity: 0; transition: opacity .2s ease;
}
.tsgo-lb.is-open { opacity: 1; }
.tsgo-lb[hidden] { display: none; }

.tsgo-lb__bar {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: max(.5rem, env(safe-area-inset-top)) .75rem .5rem;
}
.tsgo-lb__count { font-variant-numeric: tabular-nums; font-size: .95rem; opacity: .85; padding-left: .25rem; }
.tsgo-lb__tools { display: flex; gap: .25rem; }

.tsgo-lb__btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; text-decoration: none;
  transition: background-color .2s;
}
.tsgo-lb__btn:hover, .tsgo-lb__btn:focus-visible { background: rgba(255, 255, 255, .22); color: #fff; outline: none; }
.tsgo-lb__btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.tsgo-lb__stage { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; }
.tsgo-lb__img {
  max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  user-select: none; -webkit-user-drag: none; transition: transform .25s ease, opacity .2s ease;
}
.tsgo-lb__img.is-loading { opacity: .35; }
.tsgo-lb__stage.is-dragging .tsgo-lb__img { transition: none; }

.tsgo-lb__nav { position: absolute; top: 50%; transform: translateY(-50%); width: 56px; height: 56px; }
.tsgo-lb__nav--prev { left: .75rem; }
.tsgo-lb__nav--next { right: .75rem; }

.tsgo-lb__strip {
  display: flex; gap: 6px; overflow-x: auto; padding: .5rem .75rem max(.75rem, env(safe-area-inset-bottom));
  scrollbar-width: thin; scroll-behavior: smooth;
}
.tsgo-lb__strip button {
  flex: 0 0 auto; width: 64px; height: 48px; padding: 0; border: 2px solid transparent; border-radius: 6px;
  overflow: hidden; background: #222; opacity: .55; cursor: pointer; transition: opacity .2s, border-color .2s;
}
.tsgo-lb__strip button[aria-current="true"] { opacity: 1; border-color: var(--g-accent); }
.tsgo-lb__strip button:hover { opacity: .9; }
.tsgo-lb__strip img { width: 100%; height: 100%; object-fit: cover; display: block; }

@media (max-width: 640px), (pointer: coarse) {
  .tsgo-lb__nav { display: none; }
  .tsgo-lb__strip button { width: 52px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .tsgo-lb, .tsgo-lb__img, .tsgo-gallery__item img { transition: none; }
}

html.tsgo-lb-open { overflow: hidden; }
