.slickpix-gallery {
  width: 100%;
  margin: 0;
  padding: 0;
  background: var(--base-3);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  /* Die Gesamthöhe der Galerie-Komponente */
  height: calc(100vh - 240px);
}
.logged-in .slickpix-gallery {
  height: calc(100vh - 280px);
}

/* ---------------------------------------------------------
   CONTROLS & INFO (Layer über der Galerie)
   --------------------------------------------------------- */
.spx-gallery-controls {
  position: fixed;
  bottom: 130px;
  right: 30px;
  z-index: 100;
}

.toggle-thumbnails {
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  border: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

.toggle-thumbnails:hover, .toggle-thumbnails:focus {
  background: rgba(0, 0, 0, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.spx-gallery-info {
  position: fixed;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 12px 30px;
  border-radius: 30px;
  backdrop-filter: blur(10px);
  z-index: 100;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.portfolio__position {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.current-image {
  font-weight: 700;
}

/* ---------------------------------------------------------
   MAIN VIEW (Horizontal Scroll)
   --------------------------------------------------------- */
.spx-gallery-main-view {
  display: flex;
  flex-wrap: nowrap; /* Erzwingt eine einzige Zeile */
  height: 100%; /* Nimmt die volle Höhe von .slickpix-gallery an */
  gap: 10px; /* Genau 10px Abstand zwischen den Elementen */
  position: absolute;
  inset: 0;
  z-index: 10;

  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;

  /* Padding rechts, damit das letzte Bild nicht am Rand klebt */
  padding: 0 60px 0 0;
  margin: 0;

  cursor: grab;
  user-select: none;
  background: var(--base-3);

  /* WICHTIG: Stellt sicher, dass Items am Anfang der Cross-Axis ausgerichtet sind */
  align-items: flex-start;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s ease;
  will-change: opacity, transform;
}

.spx-gallery-main-view:active {
  cursor: grabbing;
}

/* Scrollbar Styling */
.spx-gallery-main-view::-webkit-scrollbar {
  height: 10px;
}
.spx-gallery-main-view::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
.spx-gallery-main-view::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 5px;
}
.spx-gallery-main-view::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.5);
}

/* ---------------------------------------------------------
   HEADER (Links im Scroll-Bereich)
   --------------------------------------------------------- */
.spx-gallery-header {
    flex: 0 0 auto; /* Header hat feste Breite, schrumpft/wächst nicht */
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 50px;
    background: var(--base-3);
    margin-right: -10px;
    overflow: visible;
}

.spx-gallery-header-inner {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) rotate(-90deg);
	transform-origin: center center;
	text-align: center;
	white-space: nowrap;
}

.spx-gallery-text {
    font-size: 16px;
    line-height: 1.4;
    margin-top: 10px;
}

.spx-gallery-header h1 {
  font-size: inherit;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  color: var(--contrast);
}

.spx-gallery-meta {
  font-size: 18px;
  color: var(--contrast);
  opacity: .7;
}

/* ---------------------------------------------------------
   CONTEXT TEXT (nicht rotiert, neben dem Header)
   --------------------------------------------------------- */
.spx-gallery-context {
  flex: 0 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 40px 0 0;
  max-width: 480px;
  box-sizing: border-box;
}

.spx-gallery-context p {
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 1em;
}

.spx-gallery-context p:last-child {
  margin-bottom: 0;
}

/* ---------------------------------------------------------
   GALLERY ITEM (Der Kern der Lösung)
   --------------------------------------------------------- */
.spx-gallery-item {
  /* WICHTIG: Das Item darf nicht wachsen (grow: 0) und nicht schrumpfen (shrink: 0).
       Die Breite 'auto' wird durch den Inhalt (das Bild) bestimmt. */
  flex: 0 0 auto;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  display: block; /* Sicherstellen, dass es kein Flex-Container ist, der Platz verteilt */
}

.spx-gallery-item a {
  display: block; /* Link verhält sich wie ein Block */
  height: 100%; /* Füllt die volle Höhe des Items */
  text-decoration: none;
  box-shadow: none;
}

.spx-gallery-item img {
  /* DAS ENTSCHEIDENDE SETUP: */
  display: block; /* Verhindert "magic space" unter Inline-Bildern */
  height: auto; /* Kein Hochskalieren kleiner Bilder */
  width: auto; /* Browser berechnet die Breite proportional zur Höhe */

  /* Überschreibt WordPress/Theme Standards, die oft max-width: 100% setzen */
  max-width: 100% !important;
  max-height: 100% !important;

  object-fit: contain; /* Sicherheitsnetz: Bild wird niemals beschnitten */
  margin: 0;
  padding: 0;
}

/* ---------------------------------------------------------
   THUMBNAIL VIEW (Grid)
   --------------------------------------------------------- */
.spx-gallery-thumbnail-view {
  position: absolute;
  inset: 0;
  z-index: 20;
  padding: 40px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--base);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(28px);
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s ease;
  will-change: opacity, transform;
}

.spx-gallery-thumbnail-header {
  margin: 0 0 28px;
  text-align: center;
}

.spx-gallery-thumbnail-header h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 56px);
  line-height: 1.1;
  color: var(--contrast);
}

.spx-gallery-thumbnail-header .spx-gallery-meta {
  font-size: 18px;
}

.spx-gallery-thumbnail-grid {
  column-count: 6;
  column-gap: 20px;
}

.slickpix-gallery.show-thumbnails .spx-gallery-main-view {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-16px);
}

.slickpix-gallery.show-thumbnails .spx-gallery-thumbnail-view {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.spx-gallery-thumb {
  break-inside: avoid;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.spx-gallery-thumb:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.spx-gallery-thumb a {
  display: block;
  width: 100%;
}

.spx-gallery-thumb img {
  width: auto;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ---------------------------------------------------------
   LIGHTBOX
   --------------------------------------------------------- */
.slickpix-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  cursor: pointer;
}

.slickpix-lightbox img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  cursor: default;
}

.slickpix-lightbox-loader {
  position: absolute;
  width: 52px;
  height: 52px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spxLightboxSpin 0.8s linear infinite;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.slickpix-lightbox.is-loading .slickpix-lightbox-loader {
  opacity: 1;
}

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


.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: #ccc;
  font-size: 40px !important;
  padding: 0;
  cursor: pointer;
  z-index: 10000;
  transition: color 0.3s;
  background: transparent;
  border: none;
}

.lightbox-close:hover {
  color: #fff;
  background-color: transparent !important;
}

/* Pfeil-Navigation in der Lightbox */
.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: transparent !important;
  border: none;
  cursor: pointer;
  padding: 10px;
  color: #fff;
  z-index: 10000;
}


.lightbox-prev svg,
.lightbox-next svg {
  width: 32px;
  height: 32px;
  display: block;
}

.lightbox-prev {
  left: 30px;
}

.lightbox-next {
  right: 30px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  color: #ddd;
}

/* ---------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------- */
@media (max-width: 1200px) {
  .spx-gallery-thumbnail-grid {
    column-count: 3;
  }
  .spx-gallery-header {
    min-width: 350px;
    padding: 0 40px;
  }
  .spx-gallery-header h1 {
    font-size: 40px;
  }
  .spx-gallery-info {
    bottom: 20px;
    padding: 10px 24px;
  }
  .spx-gallery-controls {
    bottom: 20px;
    right: 20px;
  }
}

@media (max-width: 768px) {
  .slickpix-gallery {
    /* Mehr nutzbare Hoehe auf Mobile, damit der Footer nicht zu frueh sichtbar ist */
    height: calc(100vh - 160px);
    height: calc(100dvh - 160px);
  }
  .logged-in .slickpix-gallery {
    height: calc(100vh - 200px);
    height: calc(100dvh - 200px);
  }
  .spx-gallery-controls {
    display: none;
  }
  .spx-gallery-thumbnail-grid {
    column-count: 2;
  }
  .spx-gallery-header {
    min-width: 300px;
    padding: 0 30px;
  }
  .spx-gallery-header h1 {
    font-size: 32px;
  }
  .spx-gallery-meta {
    font-size: 16px;
  }
  .spx-gallery-info {
    padding: 8px 20px;
    font-size: 14px;
    bottom: 90px;
  }
  .spx-gallery-controls {
    bottom: 20px;
  }
}

@media (max-width: 480px) {
  .spx-gallery-thumbnail-view {
    padding: 20px 10px 28px;
  }
  .spx-gallery-thumbnail-grid {
    column-count: 1;
  }
  .spx-gallery-header {
    min-width: 250px;
    padding: 0 20px;
  }
  .spx-gallery-header h1 {
    font-size: 28px;
  }
}

/* ---------------------------------------------------------
   GALLERY ARCHIVES
   --------------------------------------------------------- */
.spx-gallery-archive-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 20px 56px;
}

.spx-gallery-archive-header {
  margin-bottom: 18px;
}

.spx-gallery-archive-layout {
  display: block;
}

.spx-gallery-archive-title {
  margin: 0;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1.05;
  color: var(--contrast);
}

.spx-gallery-archive-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 24px;
}

.spx-gallery-archive-filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 210px;
}

.spx-gallery-archive-filters select,
.spx-gallery-archive-filters button,
.spx-gallery-archive-filters a {
  height: 42px;
  border-radius: 8px;
  font: inherit !important;
  font-family: "Plus Jakarta Sans", sans-serif !important;
  font-size: 15px;
}

.spx-gallery-archive-filters select {
	padding: 0 12px;
	border: 1px solid var(--contrast);
	background: var(--base-2);
	color: var(--contrast);
	appearance: none;
}

.spx-gallery-archive-filters select option,
.spx-gallery-archive-filters select optgroup {
  font: inherit !important;
  font-family: "Plus Jakarta Sans", sans-serif !important;
  font-size: 15px !important;
}

.spx-gallery-archive-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.spx-gallery-archive-actions button {
	padding: 0 18px;
	border: none;
	background: var(--contrast-2);
	color: var(--base-3);
	cursor: pointer;
}
.spx-gallery-archive-actions button:hover {
  	background: var(--accent);
    color: #fff;
}
.spx-gallery-archive-actions a {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  text-decoration: none;
  border: 1px solid var(--contrast);
  color: var(--contrast);
}

.spx-gallery-archive-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.spx-gallery-card {
  background: var(--base);
  border: 1px solid var(--base-2);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease, background-color 0.28s ease;
}

.spx-gallery-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.spx-gallery-card-media {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

.spx-gallery-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.45s ease, filter 0.3s ease;
}

.spx-gallery-card-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
}

.spx-gallery-card-body {
  padding: 14px 14px 16px;
}

.spx-gallery-card-body h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  color: var(--contrast);
  transition: color 0.24s ease;
}

.spx-gallery-card-meta {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.spx-gallery-card-meta-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.72);
}

.spx-gallery-card-meta-label {
	color: var(--contrast);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  white-space: nowrap;
}

.spx-gallery-card-meta-value {
	color: var(--contrast-2);
}

.spx-gallery-archive-pagination {
  margin-top: 28px;
}

.spx-gallery-archive-pagination ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.spx-gallery-archive-pagination a,
.spx-gallery-archive-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--contrast);
}

.spx-gallery-archive-pagination .current {
  background: #fff;
  color: #111;
  border-color: #fff;
}

.spx-gallery-archive-empty {
  margin-top: 20px;
}

@media (min-width: 768px) {
  .spx-gallery-archive-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }

  .spx-gallery-archive-filters {
    position: sticky;
    top: 120px;
    display: grid;
    gap: 12px;
    margin-bottom: 0;
    padding: 14px;
    border: 1px solid var(--base-2);
    border-radius: 12px;
    background: var(--base);
  }

  .spx-gallery-archive-filters label {
    min-width: 0;
  }

  .spx-gallery-archive-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .spx-gallery-archive-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .spx-gallery-archive-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (hover: hover) and (pointer: fine) and (min-width: 768px) {
  .spx-gallery-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  }

  .spx-gallery-card:hover .spx-gallery-card-media img {
    transform: scale(1.035);
    filter: saturate(1.06) contrast(1.03);
  }

  .spx-gallery-card:hover .spx-gallery-card-body h2 {
    color: var(--contrast-3)
  }
}
