/* ===========================
   MULTI-GALLERIES - Team-Grid Stil
   =========================== */

/* =====================
   Grid-Container Layout (wie team-grid)
   ===================== */

.multi-galleries {
  grid-column: full;
  width: 100%;
  margin-top: 2rem; /* Gleicher Abstand wie profil-cards */
  margin-bottom: 2rem; /* Gleicher Abstand wie profil-cards */
}

.galleries-grid {
  width: 100%;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 200px));
  gap: 1rem;
  margin-bottom: 2rem;
  justify-content: center;
  justify-items: stretch;
}

/* Desktop: Feste Thumbnail-Größe, immer zentriert */
@media (min-width: 1200px) {
  .galleries-grid {
    grid-template-columns: repeat(auto-fit, 220px);
    justify-content: center;
    max-width: calc(5 * 220px + 4 * 1rem);
    margin-left: auto;
    margin-right: auto;
  }
}

/* Tablet: Angepasstes Layout */
@media (min-width: 768px) and (max-width: 1199px) {
  .galleries-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  
  /* 5-6 Galerien: 3/3 Layout */
  .galleries-count-5,
  .galleries-count-6 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  /* 7-8 Galerien: 4/4 Layout */
  .galleries-count-7,
  .galleries-count-8 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Mobile: Kompakteres Layout */
@media (min-width: 480px) and (max-width: 767px) {
  .galleries-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
  
  /* 4+ Galerien: 2/2 Layout */
  .galleries-count-4,
  .galleries-count-5,
  .galleries-count-6 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ======================
   Einzelne Galerie-Kachel (wie team-profile)
   ====================== */

.gallery-preview {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.09);
  transition: transform 0.14s;
  background: var(--color-bg-alt);
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: none;
  cursor: pointer;
}

.gallery-preview:hover {
  transform: translateY(-4px) scale(1.015);
}

/* =========================
   Vorschaubild in der Kachel (wie team-profile img)
   ========================= */

.gallery-preview img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  flex: 1 1 auto;
  position: relative;
  background-color: var(--color-bg);
}

/* =================================
   Overlay-Container (wie team-profile-overlay)
   ================================= */

.gallery-overlay {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0;
  pointer-events: none;
  z-index: 2;
}

/* ==================
   Galerie-Titel im Overlay (wie team-profile-name)
   ================== */

.gallery-title {
  position: relative;
  color: #fff;
  font-size: 1.8rem;
  font-weight: 700;
  text-shadow:
    0 3px 14px rgba(0,0,0,0.85),
    0 1px 0 rgba(0,0,0,0.7);
  margin: 0 0 0.2em 1rem;
  line-height: 1.18;
  text-align: left;
  width: 90%;
  background: none;
  border-radius: 0;
  padding: 0;
  z-index: 4;
  display: block;
  white-space: normal;
  overflow: visible;
  word-break: keep-all;
  hyphens: none;
  transition: font-size 0.15s;
}

/* Modal Styles - Theme-aware Blur */
.gallery-modal {
  border: none;
  padding: 0;
  margin: 0;
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  background: transparent;
  color: var(--color-text);
}

.gallery-modal[open] {
  display: flex;
}

.gallery-modal::backdrop {
  background: color-mix(in srgb, var(--color-bg) 85%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.modal-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* Modal Header - Minimalistisch ohne Linien */
.modal-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  z-index: 20;
}

#modal-title {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin: 0;
  color: var(--color-text);
  text-shadow: 
    0 0 8px var(--color-bg),
    0 0 16px var(--color-bg),
    0 2px 4px rgba(0, 0, 0, 0.3);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2.5rem;
  color: var(--color-primary);
  cursor: pointer;
  z-index: 30;
  padding: 0.25rem 0.75rem;
  text-shadow:
    0 0 6px var(--color-bg),
    0 0 12px var(--color-border-heavy);
  transition: transform 0.2s ease, text-shadow 0.2s ease;
}

.modal-close:hover,
.modal-close:focus {
  outline: none;
  transform: scale(1.15);
  text-shadow:
    0 0 8px var(--color-bg),
    0 0 18px var(--color-border-heavy);
}

/* Modal Body */
.modal-body {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
  min-height: 0;
}

.image-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 0;
}

#modal-image {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 1rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#modal-image.loaded {
  opacity: 1;
}

/* Loading Spinner */
.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.loading-spinner::before {
  content: '';
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Navigation Buttons - Raeume-Stil */
.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 3rem;
  cursor: pointer;
  z-index: 10;
  padding: 0.5rem 1rem;
  text-shadow:
    0 0 6px var(--color-bg),
    0 0 12px var(--color-border-heavy);
  transition: transform 0.2s ease, text-shadow 0.2s ease;
}

.nav-btn:hover:not(:disabled),
.nav-btn:focus:not(:disabled) {
  outline: none;
  transform: translateY(-50%) scale(1.15);
  text-shadow:
    0 0 8px var(--color-bg),
    0 0 18px var(--color-border-heavy);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-prev {
  left: 2rem;
}

.nav-next {
  right: 2rem;
}

/* Modal Footer - Minimalistisch ohne Counter */
.modal-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2rem;
  text-align: center;
  z-index: 20;
}

.image-counter {
  display: none; /* Keine Bilderzahl anzeigen */
}

#image-caption {
  margin: 0;
  font-size: 1.1rem;
  color: var(--color-text);
  text-shadow: 
    0 0 8px var(--color-bg),
    0 0 16px var(--color-bg),
    0 2px 4px rgba(0, 0, 0, 0.3);
  display: none; /* Standardmäßig versteckt */
}

#image-caption:not(:empty) {
  display: block; /* Nur anzeigen wenn Inhalt vorhanden */
}

/* Responsive Design - wie team-grid */

/* Tablet/Kleinere Screens */
@media (max-width: 768px) {
  .galleries-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
  }
  
  .modal-header {
    padding: 1.5rem;
  }
  
  .nav-btn {
    font-size: 2.5rem;
    padding: 0.4rem 0.8rem;
  }
  
  .nav-prev {
    left: 1rem;
  }
  
  .nav-next {
    right: 1rem;
  }
  
  .modal-footer {
    padding: 1.5rem;
  }
}

/* Sehr kleine Screens - 1 Spalte wie team-grid */
@media (max-width: 480px) {
  .galleries-grid {
    grid-template-columns: 1fr; /* Nur 1 Spalte auf sehr kleinen Screens */
    gap: 1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .nav-btn {
    font-size: 2rem;
    padding: 0.3rem 0.6rem;
  }
  
  .nav-prev {
    left: 0.5rem;
  }
  
  .nav-next {
    right: 0.5rem;
  }
  
  #modal-title {
    font-size: 1.5rem;
  }
  
  .modal-header {
    padding: 1rem;
  }
  
  .modal-footer {
    padding: 1rem;
  }
}