/* ==========================================================
   PAGE: Vereinsgalerie
   Jahresauswahl, Eventkarten, Detailansicht und Lightbox
   ========================================================== */

/* ----------------------------------------------------------
   Grundlayout
   ---------------------------------------------------------- */

main.gallery {
  padding: 40px 0 80px;
}

.gallery .container {
  width: min(2100px, calc(100% - 3rem));
  max-width: none;
  margin: 0 auto;
  padding: 0;
}

.gallery h2 {
  margin: 0 0 18px;
  text-align: center;
}

.gallery .spacer {
  height: 16px;
}

@media (min-width: 768px) {
  .gallery .spacer {
    height: 24px;
  }
}

/* ----------------------------------------------------------
   Jahresauswahl
   ---------------------------------------------------------- */

.years-strip {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: center;
  gap: 12px;
  padding: 12px 12px 16px;
  border-radius: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06) inset;
  background: var(--surface, rgba(255, 255, 255, 0.06));
  backdrop-filter: saturate(120%) blur(2px);
}

.years-strip::-webkit-scrollbar {
  height: 8px;
}

.years-strip::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
}

.year-item {
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--chip-bg, rgba(255, 255, 255, 0.08));
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background 0.2s ease;
}

.year-item:hover {
  transform: translateY(-3px) scale(1.12);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.18);
}

.year-item[aria-current="true"] {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  background: #0b6cff;
  color: white;
  border-color: transparent;
}

.timeline-line {
  height: 2px;
  margin: 8px 0 22px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.12),
    rgba(0, 0, 0, 0.08) 30%,
    rgba(0, 0, 0, 0.12)
  );
}

/* ----------------------------------------------------------
   Jahresübersicht / Eventkarten
   ---------------------------------------------------------- */

.preview-area {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.year-grid {
  display: grid;
  grid-template-columns: 1fr;
  justify-content: center;
  gap: 18px;
  padding: 12px;
}

@media (min-width: 640px) {
  .year-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 380px));
  }
}

@media (min-width: 980px) {
  .year-grid {
    grid-template-columns: repeat(auto-fit, minmax(340px, 390px));
    justify-content: center;
  }
}

.event-card {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.06);
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease;
  will-change: transform;
}

.event-card:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 20px 36px rgba(0, 0, 0, 0.18);
  border-color: rgba(0, 0, 0, 0.16);
}

.event-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  object-fit: cover;
  transition:
    transform 0.4s cubic-bezier(0.2, 0.6, 0.2, 1),
    filter 0.4s;
  will-change: transform;
}

.event-card:hover .event-media,
.event-card:focus-visible .event-media {
  transform: scale(1.18);
}

.event-body {
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.event-title {
  font-weight: 700;
}

/* ----------------------------------------------------------
   Detailansicht
   ---------------------------------------------------------- */

.event-detail {
  margin-top: 26px;
}

/* Trennlinie zwischen Ordner-Auswahl und geöffneter Galerie */
.event-detail:not(.hidden)::before {
  content: "";
  display: block;
  height: 2px;
  margin: 0 0 22px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.12),
    rgba(0, 0, 0, 0.08) 30%,
    rgba(0, 0, 0, 0.12)
  );
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.detail-title {
  font-weight: 800;
  font-size: 1.1rem;
}

.detail-close {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  opacity: 0.8;
}

.detail-close:hover {
  opacity: 1;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 18px;
}

#detail-images-wrap,
#detail-videos-col {
  min-width: 0;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.images-grid img {
  width: 100%;
  aspect-ratio: 16 / 10;
  height: auto;
  border-radius: 10px;
  display: block;
  object-fit: cover;
  cursor: zoom-in;
}

@media (min-width: 1024px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr) 430px;
  }

  .images-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1500px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr) 460px;
  }

  .images-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

.event-detail.single-col .detail-grid {
  grid-template-columns: 1fr !important;
}

.event-detail.single-col .images-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* ----------------------------------------------------------
   Videos
   ---------------------------------------------------------- */

.videos-col {
  position: relative;
}

@media (min-width: 1024px) {
  .videos-col {
    position: sticky;
    top: 90px;
    align-self: start;
  }
}

.video-card {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

video {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
}

.video-title {
  margin-top: 6px;
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
}

/* ----------------------------------------------------------
   Ladeanzeige
   ---------------------------------------------------------- */

.gallery-loading {
  grid-column: 1 / -1;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(11, 108, 255, 0.08);
  border: 1px solid rgba(11, 108, 255, 0.18);
  font-weight: 700;
}

.gallery-loading-tile {
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06),
    rgba(0, 0, 0, 0.12),
    rgba(0, 0, 0, 0.06)
  );
  background-size: 220% 100%;
  animation: galleryPulse 1.1s linear infinite;
}

@keyframes galleryPulse {
  from {
    background-position: 220% 0;
  }

  to {
    background-position: -220% 0;
  }
}

/* ----------------------------------------------------------
   Hilfsklassen
   ---------------------------------------------------------- */

.hidden {
  display: none !important;
}

body.no-scroll {
  overflow: hidden;
}

/* ----------------------------------------------------------
   Lightbox
   ---------------------------------------------------------- */

.lb {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.lb.hidden {
  display: none;
}

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
}

.lb-inner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.lb-stage {
  position: relative;
  width: 100dvw;
  height: 100dvh;
  overflow: hidden;
  display: block;
}

.lb-layer,
.lb-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
}

.lb-layer {
  opacity: 0;
  transition: opacity 500ms ease;
  will-change: opacity;
}

.lb-layer.show {
  opacity: 1;
}

.lb-video {
  display: none;
  background: transparent;
}

.lb-btn {
  position: absolute;
  z-index: 2;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition:
    background 0.2s ease,
    opacity 0.25s ease;
  user-select: none;
  backdrop-filter: blur(2px);
}

.lb-btn:not(.lb-play):hover {
  background: rgba(0, 0, 0, 0.5);
}

.lb-close {
  top: 16px;
  right: 16px;
  font-size: 20px;
}

.lb-prev {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
}

.lb-next {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
}

.lb-controls {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 5;
}

.lb-controls .lb-btn {
  position: static;
}

.lb-play {
  font-size: 22px;
  padding: 12px 16px;
}

.lb-play.faded,
.lb-cross.faded {
  opacity: 0;
  pointer-events: none;
}

.lb-cross {
  font-size: 16px;
  padding: 10px 12px;
  opacity: 0.95;
}

.lb-cross.active {
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  color: #fff;
}

.lb-counter {
  position: absolute;
  left: 16px;
  bottom: 16px;
  color: #fff;
  opacity: 0.92;
  background: rgba(0, 0, 0, 0.32);
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 600;
  z-index: 5;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.lb-hint {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.95rem;
}

.lb-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translate(-50%, -10px);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
  opacity: 0;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  z-index: 6;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.lb-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ----------------------------------------------------------
   Responsive
   ---------------------------------------------------------- */

@media (max-width: 900px) {
  .gallery .container {
    width: min(100% - 2rem, 100%);
  }

  .year-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}

@media (max-width: 700px) {
  main.gallery {
    padding: 28px 0 60px;
  }

  .gallery .container {
    width: calc(100% - 1.5rem);
  }

  .gallery h2 {
    text-align: center;
  }

  .years-strip {
    justify-content: start;
    padding: 10px 10px 14px;
  }

  .year-item {
    padding: 9px 15px;
  }

  .year-grid {
    grid-template-columns: 1fr;
    padding: 10px 0;
  }

  .detail-header {
    align-items: flex-start;
  }

  .images-grid,
  .event-detail.single-col .images-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .images-grid,
  .event-detail.single-col .images-grid {
    grid-template-columns: 1fr;
  }

  .lb-counter {
    left: 10px;
    bottom: 10px;
    font-size: 0.85rem;
  }

  .lb-hint {
    width: calc(100% - 2rem);
    text-align: center;
  }
}