/* Bildergalerie: Teaser im Chat und Vollbild-Ansicht.
   Gestaltung bewusst zurückhaltend: Schwarz-Weiß, ein dezenter orangefarbener
   Akzent (derselbe Punkt wie im Rad), keine Animationen in der Galerie. */

:root {
  --gallery-accent: var(--rolodex-active-dot, #ff694a);
  --gallery-bg: #0c0c0c;
  --gallery-ink: #ecece9;
}

/* Teaser in der Antwort */
.chat-gallery {
  width: min(93%, 520px, var(--cover-max, 520px));
  margin: clamp(10px, 2.6vw, 16px) 0 0;
  animation: answer-in 420ms ease both;
}

.chat-gallery-cover {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: #f1f1f1;
  line-height: 0;
  cursor: pointer;
  overflow: hidden;
}

.chat-gallery-cover img {
  display: block;
  width: 100%;
  height: auto;
}

.chat-gallery-caption {
  margin-top: 14px;
}

/* Gleiche Sprache wie die Einträge im Projekte Menü: Text, kleiner orangefarbener Pfeil
   (.project-arrow aus projekte.css), kein Unterstrich, kein Kasten */
.chat-gallery-more {
  display: inline-flex;
  align-items: center;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--ink, #171717);
  font-family: var(--font-sans, Arial, sans-serif);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: -0.01em;
  cursor: pointer;
}

.chat-gallery-more .project-arrow {
  margin-left: 0.5em;
  vertical-align: 0;
}

.chat-gallery-more:hover .project-arrow,
.chat-gallery-more:focus-visible .project-arrow {
  transform: translate(2px, -2px);
}

.chat-gallery-cover:focus-visible,
.chat-gallery-more:focus-visible {
  outline: 2px solid var(--gallery-accent);
  outline-offset: 3px;
}

/* Vollbild */
html.gallery-open,
html.gallery-open body {
  overflow: hidden;
}

.gallery {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--gallery-bg);
  color: var(--gallery-ink);
  font-family: var(--font-sans, Arial, sans-serif);
  overscroll-behavior: contain;
}

@supports (height: 100dvh) {
  .gallery {
    height: 100dvh;
  }
}

.gallery[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.gallery::backdrop {
  background: var(--gallery-bg);
}

.gallery-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding:
    max(10px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    4px
    max(20px, env(safe-area-inset-left));
}

.gallery-count {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 14px;
  font-weight: 300;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.gallery-count::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gallery-accent);
}

.gallery button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.gallery button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gallery-close {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  opacity: 0.85;
}

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

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

/* Die Bildfläche selbst bekommt keinen Rahmen, Pfeiltasten wirken im ganzen Dialog */
.gallery-track:focus {
  outline: none;
}

.gallery-track {
  display: flex;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior: contain;
  touch-action: pan-x;
  scrollbar-width: none;
}

.gallery-track::-webkit-scrollbar {
  display: none;
}

.gallery-slide {
  position: relative;
  flex: 0 0 100%;
  min-width: 0;
  margin: 0;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

/* Die Bildfläche liegt fest zwischen Leiste und unterem Rand (inklusive Home Indicator).
   Ihre Größe hängt nicht vom Bild ab, deshalb gibt es beim Laden und Blättern keine Sprünge. */
.gallery-slide picture {
  position: absolute;
  top: 12px;
  right: max(clamp(14px, 4vw, 84px), env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(clamp(14px, 4vw, 84px), env(safe-area-inset-left));
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
}

/* source erzeugt sonst eine zusätzliche Gitterzeile und schiebt das Bild nach unten */
.gallery-slide source {
  display: none;
}

.gallery-slide img {
  grid-area: 1 / 1;
  display: block;
  width: 100%;
  height: 100%;
  max-width: var(--max-w);
  max-height: var(--max-h);
  object-fit: contain;
}

/* Nur in der Vorschau, sitzt in der Leiste und berührt die Bildfläche nicht */
.gallery-held {
  flex: 1;
  margin: 0 8px;
  color: var(--gallery-accent);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-align: center;
  visibility: hidden;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgb(255 255 255 / 28%) !important;
  border-radius: 50%;
  background: rgb(12 12 12 / 55%) !important;
  transform: translateY(-50%);
  transition: border-color 160ms ease, opacity 160ms ease;
}

.gallery-prev {
  left: clamp(12px, 2.4vw, 32px);
}

.gallery-next {
  right: clamp(12px, 2.4vw, 32px);
}

.gallery-nav:not(:disabled):hover {
  border-color: var(--gallery-accent) !important;
}

.gallery-nav:disabled {
  opacity: 0.22;
  cursor: default;
}

/* Auf Touch Geräten wird gewischt, die Pfeile bleiben weg */
@media (hover: none), (pointer: coarse) {
  .gallery-nav {
    display: none;
  }
}
