/*
 * Traum Cafe: Galerie.
 * Sofortbilder liegen schräg auf einer hellen Leinendecke; gallery.js lässt sie
 * fallen und öffnet sie groß. Abschnitt und Tisch: sections.css. Tokens: hero.css.
 */

.gallery__inner {
  width: min(100%, 72rem);
  margin-inline: auto;
}

.gallery__head {
  display: grid;
  justify-items: center;
  gap: 1rem;
  text-align: center;
}

.gallery__hint {
  margin: 0;
  color: var(--muted);
}

.gallery__hint-touch {
  display: none;
}

@media (hover: none), (pointer: coarse) {
  .gallery__hint-hover {
    display: none;
  }

  .gallery__hint-touch {
    display: inline;
  }
}

/* ---------- Sofortbilder ---------- */

.gallery__prints {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: clamp(1.75rem, 3.5vw, 3.25rem) clamp(1.25rem, 3vw, 3rem);
  margin: 2.75rem 0 0;
  padding: 0;
  list-style: none;
}

/* Liegeplatz: leicht versetzt und schräg (Werte im HTML) */
.print {
  --sx: 4px;
  --sy: 6px;

  position: relative;
  translate: var(--dx, 0) var(--dy, 0);
}

.print:hover,
.print:focus-within {
  z-index: 2;
}

.print__shadow {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 4px;
  background: #000;
  opacity: 0.3;
  filter: blur(9px);
  transform: translate(var(--sx), var(--sy)) rotate(var(--rot, 0deg));
  transition:
    transform 0.35s var(--ease-out),
    opacity 0.35s;
}

.print__body {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  padding: 0.55rem 0.55rem 0;
  border: 0;
  border-radius: 4px;
  background: #fbfaf7;
  color: var(--ink);
  font: inherit;
  cursor: zoom-in;
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.35s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.print__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: color-mix(in oklab, var(--ink) 6%, var(--bg));
}

.print--landscape .print__img {
  aspect-ratio: 5 / 4;
}

.print__caption {
  display: block;
  padding: 0.65rem 0.25rem 0.8rem;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 1.3vw, 1.1rem);
  font-weight: 700;
  font-stretch: 75%;
  line-height: 1.1;
  text-align: center;
  text-transform: uppercase;
}

/* Darüberfahren: Foto hebt sich etwas und richtet sich auf */
@media (hover: hover) and (pointer: fine) {
  .print:not(.is-falling):hover .print__body {
    transform: rotate(calc(var(--rot, 0deg) * 0.3)) scale(1.05);
  }

  .print:not(.is-falling):hover .print__shadow {
    opacity: 0.22;
    transform: translate(calc(var(--sx) * 2.5), calc(var(--sy) * 2.5)) rotate(calc(var(--rot, 0deg) * 0.3)) scale(1.06);
  }
}

.print__body:focus-visible {
  outline: 3px solid var(--tomato-text);
  outline-offset: 4px;
}

/* Vor dem Fallen (gallery.js) nicht zu sehen, aber mit der Tastatur erreichbar */
.print.is-waiting {
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .print__body,
  .print__shadow {
    transition: none;
  }
}

/* ---------- Groß ansehen ---------- */

/* Die Seite dahinter scrollt nicht mit */
html:has(.lightbox[open]) {
  overflow: hidden;
  scrollbar-gutter: stable;
}

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.lightbox[open] {
  display: grid;
  place-items: center;
}

.lightbox::backdrop {
  background: rgb(20 14 10 / 0.82);
}

.lightbox__frame {
  margin: 0;
  padding: 0.75rem 0.75rem 0;
  border-radius: 6px;
  background: #fbfaf7;
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.6);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

/* Größe aus dem Seitenverhältnis (--ar aus gallery.js): steht sofort, auch bevor das
   große Bild geladen ist; seitlich bleibt Platz für die Pfeile */
.lightbox__img {
  display: block;
  width: min(calc(100vw - 11rem), 56rem, calc((100dvh - 11rem) * var(--ar, 0.8)));
  height: auto;
  margin-inline: auto;
  aspect-ratio: var(--ar, 0.8);
  object-fit: cover;
  -webkit-user-drag: none;
}

.lightbox__caption {
  padding: 0.85rem 0.25rem 1rem;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  font-stretch: 75%;
  text-align: center;
  text-transform: uppercase;
}

.lightbox__count {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  margin: 0;
  color: #fffdfb;
  font-variant-numeric: tabular-nums;
  translate: -50% 0;
}

.lightbox__close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  border-color: rgb(255 255 255 / 0.35);
  background: rgb(255 255 255 / 0.12);
  color: #fffdfb;
}

.lightbox__nav {
  position: fixed;
  top: 50%;
  display: grid;
  place-items: center;
  width: 3.25rem;
  aspect-ratio: 1;
  padding: 0;
  border: 1.5px solid rgb(255 255 255 / 0.35);
  border-radius: 50%;
  background: rgb(255 255 255 / 0.12);
  color: #fffdfb;
  cursor: pointer;
  translate: 0 -50%;
  transition: background-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.lightbox__nav:hover,
.lightbox__close:hover {
  border-color: rgb(255 255 255 / 0.6);
  background: rgb(255 255 255 / 0.26);
  color: #fffdfb;
}

.lightbox__nav .icon {
  width: 1.4rem;
  height: 1.4rem;
}

.lightbox__nav--prev {
  left: 1rem;
}

.lightbox__nav--prev .icon {
  rotate: 90deg;
}

.lightbox__nav--next {
  right: 1rem;
}

.lightbox__nav--next .icon {
  rotate: -90deg;
}

.lightbox__close:focus-visible,
.lightbox__nav:focus-visible {
  outline: 3px solid #fffdfb;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  .lightbox[open] .lightbox__frame {
    animation: lightbox-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
}

@keyframes lightbox-in {
  from {
    opacity: 0;
    transform: scale(0.94) rotate(-2deg);
  }
}

/* ---------- Tablet und Handy ---------- */

/* Tablet: drei Spalten, die letzte Reihe mit zwei Fotos mittig */
@media (min-width: 641px) and (max-width: 960px), (min-width: 641px) and (max-width: 1199px) and (orientation: portrait) {
  .gallery__prints {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .print {
    grid-column: span 2;
  }

  .print:nth-child(7) {
    grid-column: 2 / span 2;
  }
}

@media (max-width: 640px) {
  .gallery__prints {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem 1rem;
  }

  .print__body {
    padding: 0.4rem 0.4rem 0;
  }

  .print__caption {
    padding: 0.5rem 0.15rem 0.6rem;
    font-size: 0.85rem;
  }

  /* Pfeile unten statt seitlich, damit sie das Foto nicht verdecken */
  .lightbox__nav {
    top: auto;
    bottom: 0.75rem;
    translate: none;
  }

  .lightbox__img {
    width: min(calc(100vw - 3rem), calc((100dvh - 12rem) * var(--ar, 0.8)));
  }
}

/* Sehr schmale Handys: Beschriftungen in einer Zeile */
@media (max-width: 360px) {
  .print__caption {
    font-size: 0.75rem;
  }
}

/* Handy quer: wenig Höhe, also schlanker Rahmen, Zähler oben, Pfeile seitlich */
@media (max-height: 500px) and (orientation: landscape) {
  .lightbox__frame {
    padding: 0.5rem 0.5rem 0;
  }

  .lightbox__img {
    width: min(calc(100vw - 11rem), calc((100dvh - 4.75rem) * var(--ar, 0.8)));
  }

  .lightbox__caption {
    padding: 0.35rem 0.25rem 0.45rem;
    font-size: 1rem;
  }

  .lightbox__count {
    top: 1.6rem;
    bottom: auto;
    left: 1rem;
    translate: none;
  }

  .lightbox__nav {
    top: 50%;
    bottom: auto;
    translate: 0 -50%;
  }
}
