/* =========================================================
   IWWIT Bildergalerie v1.2
   Footer-Steuerung rechts + Lightbox Desktop-Fix
   ========================================================= */

.iwwit-gallery {
  --iwwit-gallery-card-bg: #ffffff;
  --iwwit-gallery-primary: #2c3e50;
  --iwwit-gallery-accent: #5084ab;
  --iwwit-gallery-text: #333333;
  --iwwit-gallery-muted: #666666;
  --iwwit-gallery-border: #e6e8ea;
  --iwwit-gallery-control-bg: #ffffff;
  --iwwit-gallery-caption-bg: rgba(255, 255, 255, 0.72);

  width: 100% !important;
  max-width: none !important;

  margin: 24px 0 40px !important;
  padding: 0 !important;

  color: var(--iwwit-gallery-text);

  font-family:
    var(
      --wp--preset--font-family--barlow-semi-condensed,
      var(--font-family, 'Barlow Semi Condensed', Arial, sans-serif)
    );

  scroll-margin-top: 160px;
}

.iwwit-article-content > .iwwit-gallery,
.wp-block-post-content > .iwwit-gallery,
.entry-content > .iwwit-gallery,
main .iwwit-gallery {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.iwwit-gallery,
.iwwit-gallery *,
.iwwit-gallery *::before,
.iwwit-gallery *::after {
  box-sizing: border-box;
}

body.pcdark-mode .iwwit-gallery,
html.pcdark-mode body .iwwit-gallery {
  --iwwit-gallery-card-bg: #1c1c1e;
  --iwwit-gallery-primary: #ffffff;
  --iwwit-gallery-accent: #78a9c8;
  --iwwit-gallery-text: #e1e1e1;
  --iwwit-gallery-muted: #a1a1a6;
  --iwwit-gallery-border: #333333;
  --iwwit-gallery-control-bg: #1c1c1e;
  --iwwit-gallery-caption-bg: rgba(28, 28, 30, 0.72);
}

.iwwit-gallery__intro {
  width: 100%;
  margin: 0 0 20px !important;
  padding: 0 !important;
}

.iwwit-gallery__title {
  margin: 0 0 8px !important;
  padding: 0 !important;
  color: var(--iwwit-gallery-primary) !important;
  font-family: inherit !important;
  font-size: clamp(1.45rem, 2vw, 1.85rem) !important;
  line-height: 1.12 !important;
  font-weight: 600 !important;
  letter-spacing: -0.015em;
}

.iwwit-gallery__description {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  color: var(--iwwit-gallery-muted) !important;
  font-family: inherit !important;
  font-size: clamp(0.98rem, 1.2vw, 1.08rem) !important;
  line-height: 1.5 !important;
  font-weight: 400 !important;
}

.iwwit-gallery__description p {
  margin: 0 !important;
}

.iwwit-gallery__rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: stretch;
  gap: 14px;
  width: 100%;
  margin: 0 !important;
  padding: 2px 2px 8px !important;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color:
    color-mix(in srgb, var(--iwwit-gallery-accent) 35%, transparent)
    transparent;
  cursor: grab;
}

.iwwit-gallery__rail.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
  user-select: none;
}

.iwwit-gallery__rail::-webkit-scrollbar {
  height: 6px;
}

.iwwit-gallery__rail::-webkit-scrollbar-track {
  background: transparent;
}

.iwwit-gallery__rail::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background:
    color-mix(
      in srgb,
      var(--iwwit-gallery-accent) 35%,
      transparent
    );
}

.iwwit-gallery__item {
  position: relative;
  height: clamp(210px, 27vw, 330px);
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  scroll-snap-align: start;
  border: 1px solid var(--iwwit-gallery-border);
  border-radius: 18px;
  background: var(--iwwit-gallery-card-bg);
}

.iwwit-gallery__item--portrait {
  width: clamp(150px, 18vw, 230px);
}

.iwwit-gallery__item--square {
  width: clamp(210px, 27vw, 330px);
}

.iwwit-gallery__item--landscape {
  width: clamp(310px, 42vw, 520px);
}

.iwwit-gallery__link {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: inherit;
  background: transparent !important;
  color: inherit;
  cursor: zoom-in;
  appearance: none;
  -webkit-appearance: none;
}

.iwwit-gallery__image {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  object-fit: cover;
  object-position: center;
  transform: scale(1);
  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.2s ease;
}

.iwwit-gallery__link:hover .iwwit-gallery__image {
  transform: scale(1.035);
}

.iwwit-gallery__link:focus-visible {
  outline: 3px solid var(--iwwit-gallery-accent);
  outline-offset: -3px;
}

.iwwit-gallery__caption {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--iwwit-gallery-border);
  border-radius: 10px;
  background: var(--iwwit-gallery-caption-bg);
  color: var(--iwwit-gallery-text);
  font-family: inherit;
  font-size: 0.84rem;
  line-height: 1.25;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

/* Footer: Hinweis links, Buttons rechts */
.iwwit-gallery__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  margin: 14px 0 0 !important;
  padding: 0 !important;
}

.iwwit-gallery__hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  color: var(--iwwit-gallery-primary);

  font-family: inherit;
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 600;

  letter-spacing: -0.01em;
}

.iwwit-gallery__hint::before {
  content: "↔";

  color: var(--iwwit-gallery-accent);

  font-size: 1.05rem;
  line-height: 1;
  font-weight: 600;
}

.iwwit-gallery__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 !important;
  padding: 0 !important;
}

.iwwit-gallery__control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--iwwit-gallery-border);
  border-radius: 50%;
  background: var(--iwwit-gallery-control-bg);
  color: var(--iwwit-gallery-accent);
  font-family: inherit;
  font-size: 1.65rem;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease,
    opacity 0.2s ease,
    transform 0.2s ease;
}

.iwwit-gallery__control:hover:not(:disabled) {
  border-color: var(--iwwit-gallery-accent);
  transform: translateY(-1px);
}

.iwwit-gallery__control:disabled {
  cursor: default;
  opacity: 0.3;
}

.iwwit-gallery__control:focus-visible {
  outline: 2px solid var(--iwwit-gallery-accent);
  outline-offset: 2px;
}

/* Lightbox */
html.iwwit-gallery-lightbox-open {
  overflow: hidden;
}

.iwwit-gallery__lightbox[hidden] {
  display: none !important;
}

.iwwit-gallery__lightbox {
  position: fixed;
  z-index: 999999;
  inset: 0;
  display: grid;
  grid-template-columns:
    minmax(48px, 88px)
    minmax(0, 1fr)
    minmax(48px, 88px);
  align-items: center;
  width: 100vw;
  height: 100dvh;
  padding: 28px;
  background: rgba(0, 0, 0, 0.92);
}

.iwwit-gallery__lightbox-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  padding: 24px 0;
}

.iwwit-gallery__lightbox-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 150px);
  margin: 0;
  padding: 0;
  object-fit: contain;
  border-radius: 14px;
  user-select: none;
  touch-action: pan-y;
}

.iwwit-gallery__lightbox-caption {
  max-width: 900px;
  margin: 14px auto 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.10);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: center;
}

.iwwit-gallery__lightbox-counter {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1;
}

.iwwit-gallery__lightbox-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 0;
  padding: 0;
  justify-self: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  color: #ffffff;
  font-family: inherit;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.iwwit-gallery__lightbox-nav:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.55);
}

.iwwit-gallery__lightbox-nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.iwwit-gallery__lightbox-close {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.30);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  color: #ffffff;
  font-family: inherit;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.iwwit-gallery__lightbox-nav:focus-visible,
.iwwit-gallery__lightbox-close:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

.iwwit-article-content h2.iwwit-gallery__title {
  margin-top: 0 !important;
}

.iwwit-gallery--empty {
  padding: 14px 16px !important;
  border: 1px dashed var(--iwwit-gallery-border);
  border-radius: 14px;
  background: var(--iwwit-gallery-card-bg);
  color: var(--iwwit-gallery-muted);
}

@media (max-width: 900px) {
  .iwwit-gallery__item {
    height: clamp(190px, 31vw, 270px);
  }

  .iwwit-gallery__item--portrait {
    width: clamp(140px, 21vw, 195px);
  }

  .iwwit-gallery__item--square {
    width: clamp(190px, 31vw, 270px);
  }

  .iwwit-gallery__item--landscape {
    width: clamp(275px, 47vw, 400px);
  }

  .iwwit-gallery__lightbox {
    grid-template-columns: 54px minmax(0, 1fr) 54px;
    padding: 22px;
  }

  .iwwit-gallery__lightbox-nav {
    width: 44px;
    height: 44px;
    font-size: 1.9rem;
  }
}

@media (max-width: 700px) {
  .iwwit-gallery {
    margin-top: 20px !important;
    margin-bottom: 32px !important;
  }

  .iwwit-gallery__intro {
    margin-bottom: 16px !important;
  }

  .iwwit-gallery__title {
    font-size: 1.35rem !important;
  }

  .iwwit-gallery__description {
    font-size: 0.98rem !important;
  }

  .iwwit-gallery__rail {
    gap: 10px;
  }

  .iwwit-gallery__item {
    height: clamp(180px, 58vw, 250px);
    border-radius: 14px;
  }

  .iwwit-gallery__item--portrait {
    width: clamp(135px, 42vw, 185px);
  }

  .iwwit-gallery__item--square {
    width: clamp(180px, 58vw, 250px);
  }

  .iwwit-gallery__item--landscape {
    width: clamp(270px, 82vw, 350px);
  }

  .iwwit-gallery__footer {
    margin-top: 12px !important;
  }

  .iwwit-gallery__hint {
    font-size: 1.1rem;
  }

  .iwwit-gallery__control {
    width: 36px;
    height: 36px;
    font-size: 1.5rem;
  }

  .iwwit-gallery__caption {
    right: 7px;
    bottom: 7px;
    left: 7px;
    padding: 6px 8px;
    font-size: 0.78rem;
  }

  .iwwit-gallery__lightbox {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 54px 14px 22px;
  }

  .iwwit-gallery__lightbox-stage {
    width: 100%;
    padding: 0 0 54px;
  }

  .iwwit-gallery__lightbox-image {
    max-width: 100%;
    max-height: calc(100dvh - 180px);
    border-radius: 10px;
  }

  .iwwit-gallery__lightbox-caption {
    max-width: 92vw;
    margin-top: 12px;
    font-size: 0.88rem;
  }

  .iwwit-gallery__lightbox-nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 40px;
    height: 40px;
    font-size: 1.75rem;
    transform: translateY(-50%);
  }

  .iwwit-gallery__lightbox-prev {
    left: 10px;
  }

  .iwwit-gallery__lightbox-next {
    right: 10px;
  }

  .iwwit-gallery__lightbox-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 420px) {
  .iwwit-gallery__lightbox-prev {
    left: 6px;
  }

  .iwwit-gallery__lightbox-next {
    right: 6px;
  }

  .iwwit-gallery__lightbox-nav {
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.44);
    font-size: 1.55rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .iwwit-gallery__image,
  .iwwit-gallery__control {
    transition: none;
  }

  .iwwit-gallery__rail {
    scroll-behavior: auto;
  }
}
