/*
 * Gemeinsame Galerie-Ansicht (templates/gallery/_view.twig, @app/gallery-view):
 * Werkzeugleiste (Filter, Sortierung, Ansicht), Zeilen-/Mosaik-Raster,
 * Einblenden der Bilder. Genutzt von Sammlungen und Mitgliederprofilen.
 */

.gv { --gv-label: var(--club-primary-text); }

/* Werkzeugleiste --------------------------------------------------------- */
.gv-toolbar { min-height: 2.25rem; margin-bottom: 1rem; }
.gv-toolbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1.25rem;
}
.gv-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .85rem;
  flex: 1 1 16rem;
  min-width: 0;
}
.gv-label {
  flex-shrink: 0;
  margin: 0;
  font-size: .85rem;
  font-weight: 300;
  white-space: nowrap;
  color: var(--gv-label);
}
.gv-chips { display: flex; flex-wrap: wrap; gap: .2rem .3rem; min-width: 0; }
.gv-chip {
  padding: .2rem .6rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.5;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.gv-chip:hover { border-color: var(--line); }
.gv-chip:focus-visible { outline: 2px solid var(--club-primary); outline-offset: 1px; }
.gv-chip.is-active { background: var(--club-primary); color: var(--club-on-primary); }
.gv-tag-select { display: none; width: auto; max-width: 100%; }

.gv-toolbar-end { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.gv-sort { display: flex; align-items: center; gap: .6rem; }
.gv-sort-select { width: auto; min-width: 10rem; }
.gv-layout { display: inline-flex; }
.gv-layout-btn {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--gv-label);
  transition: background-color .2s ease;
}
.gv-layout-btn + .gv-layout-btn { border-left: 0; }
.gv-layout-btn:hover { background: rgba(var(--club-primary-rgb), .08); }
.gv-layout-btn.is-active { background: rgba(var(--club-primary-rgb), .14); border-color: var(--club-primary); }
.gv-layout-btn + .gv-layout-btn.is-active { border-left: 1px solid var(--club-primary); }
.gv-layout-btn:focus-visible { outline: 2px solid var(--club-primary); outline-offset: 1px; z-index: 1; }
[data-bs-theme="dark"] .gv-layout-btn.is-active { background: rgba(255, 255, 255, .12); border-color: var(--club-accent-line); }

@media (max-width: 767.98px) {
  .gv-chips { display: none; }
  .gv-tag-select { display: block; }
  .gv-filter { flex-basis: auto; }
  .gv-toolbar-inner { gap: .5rem .75rem; }
  .gv-sort-select { min-width: 0; }
}

/* Raster ------------------------------------------------------------------ */
.gv-grid { position: relative; }

/* Ohne JavaScript bzw. bis zur Berechnung: einfache Zeilen per Flexbox */
.gv-grid--static { display: flex; flex-wrap: wrap; gap: 4px; }
.gv-grid--static::after { content: ""; flex-grow: 999999; }
.gv-grid--static .gv-item {
  position: relative;
  display: flex;
  flex-direction: column;
  flex-grow: var(--ar, 1.5);
  flex-basis: calc(var(--ar, 1.5) * 250px);
  aspect-ratio: var(--ar, 1.5);
  max-width: 100%;
}
@media (max-width: 575.98px) { .gv-grid--static .gv-item { flex-basis: calc(var(--ar, 1.5) * 165px); } }

/* Von gallery-view.js berechnete Positionen */
.gv-grid.is-laid-out .gv-item { position: absolute; }

.gv-item {
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  will-change: auto;
}
/* Bildrahmen: füllt die Kachel bis auf die Bildunterschrift */
.gv-media {
  position: relative;
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--surface-muted);
}
.gv-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .45s ease;
}
/* Einblenden beim Laden/Hereinscrollen – nur mit JavaScript (sonst bleiben Bilder sichtbar) */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .gv-item img {
    opacity: 0;
    translate: 0 10px;
    transition: opacity .6s ease, translate .6s cubic-bezier(.2, .8, .2, 1), transform .45s ease;
  }
  .gv-item.is-loaded.is-inview img { opacity: 1; translate: none; }
}
.gv-item:hover img, .gv-item:focus-visible img { transform: scale(1.05); }
.gv-item:focus-visible { outline: 3px solid var(--club-primary); outline-offset: -3px; z-index: 2; }
.gv-item:focus-visible img { opacity: 1; }

/* Platzhalter-Schimmer, bis das Bild da ist */
.gv-item:not(.is-loaded) .gv-media::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
  background-size: 200% 100%;
  animation: gv-shimmer 1.4s linear infinite;
}
[data-bs-theme="dark"] .gv-item:not(.is-loaded) .gv-media::before { background-image: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent); }
@keyframes gv-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.gv-empty { padding: 2rem 0; text-align: center; color: var(--ink-muted); }

@media (prefers-reduced-motion: reduce) {
  .gv-item:hover img, .gv-item:focus-visible img { transform: none; }
  .gv-item:not(.is-loaded) .gv-media::before { animation: none; }
}

/* Lightbox: Bildunterschrift (Titel, Fotograf, Schlagworte) gut lesbar */
.pswp { --pswp-bg: #000; }

/* Mitgliederprofil (gallery.captions): Titel-Overlay + Bildunterschrift ---- */
.gv--caption-line { --gv-cap-h: 1.9rem; }
/* Ohne JavaScript: Bildrahmen im Seitenverhältnis, Unterschrift darunter */
.gv--caption-line .gv-grid--static .gv-item { aspect-ratio: auto; }
.gv--caption-line .gv-grid--static .gv-media { aspect-ratio: var(--ar, 1.5); flex: 0 0 auto; }

.gv-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  padding: 1.6rem .65rem .5rem;
  background: linear-gradient(to top, rgba(0, 0, 0, .72), rgba(0, 0, 0, .35) 55%, transparent);
  color: #fff;
  font-size: .82rem;
  font-weight: 500;
  line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
  opacity: 0;
  translate: 0 .35rem;
  transition: opacity .25s ease, translate .25s ease;
  pointer-events: none;
}
.gv-item:hover .gv-title, .gv-item:focus-visible .gv-title { opacity: 1; translate: none; }
/* Touch-Geräte (kein Hover): Titel dauerhaft, dezent und kleiner */
@media (hover: none) {
  .gv-title {
    -webkit-line-clamp: 1;
    padding: 1.1rem .5rem .3rem;
    background: linear-gradient(to top, rgba(0, 0, 0, .55), transparent);
    font-size: .72rem;
    font-weight: 400;
    opacity: .92;
    translate: none;
  }
}
.gv-item:not(.is-loaded) .gv-title { opacity: 0; }

.gv-cap {
  flex: 0 0 var(--gv-cap-h, 1.9rem);
  display: block;
  height: var(--gv-cap-h, 1.9rem);
  padding: .3rem .15rem 0;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: .78rem;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: color .2s ease;
}
.gv-cap--none { font-style: italic; opacity: .7; }
.gv-item:hover .gv-cap { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .gv-title { transition: none; translate: none; }
}
.gv-collection-select { width: auto; max-width: 16rem; }
@media (max-width: 767.98px) { .gv-collection-select { max-width: 11rem; } }

/* Eigenes Bild, Freigabe ausstehend (sieht nur der Eigentümer) */
.gv-pending { position: absolute; top: .5rem; left: .5rem; z-index: 2; padding: .15rem .45rem; background: #d19a00; color: #1c1b1f; font-size: .72rem; font-weight: 700; letter-spacing: .02em; pointer-events: none; }
.gv-item.is-pending img { opacity: .8; }

/* Kachel „Bild hinzufügen“ als erstes Feld im Raster: grauer Rahmen, roter Knopf in der Mitte */
.gv-add-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; padding: 1rem;
  border: 1px solid var(--line); background: var(--surface-muted); text-align: center; cursor: default; }
.gv-grid--static .gv-add-tile { aspect-ratio: 4 / 3; }
.gv-add-hint { max-width: 22rem; font-size: .72rem; line-height: 1.35; color: var(--ink-muted); }
@media (max-width: 575.98px) { .gv-add-hint { display: none; } }
