/* ============================================================
   [1] BASE — MOBILE  (< 600px)
   ============================================================ */

#galerie {
  background: var(--surface);
}

/* ── Grid ───────────────────────────────────────────────── */

.gallery-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

.gallery-item {
  background: var(--surface-card);
  overflow: hidden;
  position: relative;
  min-width: 0;
  aspect-ratio: unset;
}

.gallery-item img {
  width: 100%;
  height: auto;
  object-fit: unset;
  display: block;
  transition: filter 0.4s ease;
}

/* Hero + wide-2col: fixed 4:3 on mobile */
.gallery-item--hero,
.gallery-item--wide-2col {
  grid-column: auto;
  aspect-ratio: 4 / 3;
}

.gallery-item--hero img,
.gallery-item--wide-2col img {
  height: 100%;
  object-fit: cover;
}

/* ── Corner-bracket hover effect ────────────────────────── */

.gallery-item::before,
.gallery-item::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--accent-bright);
  border-style: solid;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-item::before {
  top: 12px;
  left: 12px;
  border-width: 2px 0 0 2px;
}

.gallery-item::after {
  bottom: 12px;
  right: 12px;
  border-width: 0 2px 2px 0;
}

.gallery-item:hover::before,
.gallery-item:hover::after {
  opacity: 1;
}

.gallery-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-dim);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ── Gallery more ───────────────────────────────────────── */

.gallery-more {
  margin-top: 1rem;
  padding: 1.1rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface-card);
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
}

.gallery-more__text {
  min-width: 0;
}

.gallery-more__title {
  font-size: clamp(1.15rem, 2.4vw, 1.6rem);
  line-height: 1.05;
  margin-top: 0.55rem;
  margin-bottom: 0.55rem;
}

.gallery-more__desc {
  max-width: 52ch;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--ink-dim);
}

.gallery-more__action {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.gallery-more__btn {
  width: 100%;
  justify-content: center;
  white-space: normal;
  font-size: 0.65rem;
}

/* ── Gallery page: page-header ──────────────────────────── */

.page-header {
  margin-top: var(--nav-height);
  padding: 1.5rem 0 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-mid);
}

.page-header .eyebrow { margin-bottom: 0.6rem; }

.page-header h1 {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.02em;
}

.page-header p {
  margin-top: 0;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--ink-dim);
  max-width: 60ch;
}

/* ── Galerie section ────────────────────────────────────── */

.galerie-section { padding: 1.5rem 0 2rem; }

.gallery-header { margin-bottom: 1rem; }

.galerie-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 1rem;
  transition: color var(--transition);
}

.galerie-back:hover  { color: var(--accent); }
.galerie-back::before { content: '←'; font-size: 0.9rem; }

.galerie-cta {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--surface-mid);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: flex-start;
}

.galerie-cta .display {
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin-top: 0.4rem;
}

.galerie-cta p {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink-dim);
  max-width: 56ch;
}

p.galerie-cta__title { line-height: 1.2; padding-bottom: 0.75rem; }

.galerie-cta-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  flex-direction: row;
  align-items: flex-start;
  flex-shrink: 1;
}

.galerie-cta-actions .btn-primary,
.galerie-cta-actions .btn-secondary {
  width: 100%;
  justify-content: center;
}


/* ============================================================
   [2] TABLET  (≥ 600px)
   ============================================================ */

@media (min-width: 600px) {

  /* ── Grid: 2 columns ──────────────────────────────────── */

  .page-header { padding: 2.5rem 0 1.5rem; }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .gallery-item {
    aspect-ratio: 1 / 1;
  }

  .gallery-item img {
    height: 100%;
    object-fit: cover;
  }

  /* Hero: spans full 2-col width, img static (no absolute fill) */
  .gallery-item--hero {
    grid-column: span 2;
    aspect-ratio: unset;
  }

  .gallery-item--hero img {
    position: static;
    inset: unset;
    height: auto;
    object-fit: unset;
  }

  /* Wide-2col: stays 1 col on tablet, square */
  .gallery-item--wide-2col {
    grid-column: auto;
    aspect-ratio: 1 / 1;
  }

  .gallery-item--wide-2col img {
    position: static;
    inset: unset;
    height: 100%;
    object-fit: cover;
  }

  /* ── Gallery more: 1-col layout ──────────────────────── */

  .gallery-more {
    margin-top: 1.5rem;
    padding: 1.5rem 1.75rem;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
  }

  .gallery-more__action {
    justify-content: flex-start;
  }

  .btn-secondary.gallery-more__btn { font-size: 0.8rem; }

  .gallery-more__title {
    margin-bottom: 0.7rem;
  }

  .gallery-more__desc {
    font-size: 0.85rem;
  }

  .gallery-more__btn {
    width: auto;
    white-space: nowrap;
    font-size: unset;
  }

  /* ── Galerie CTA: row layout ──────────────────────────── */

  .galerie-cta {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 2rem;
  }

  .galerie-cta-actions {
    flex-shrink: 0;
    flex-direction: column;
    align-items: flex-end;
  }

  .galerie-cta-actions .btn-primary,
  .galerie-cta-actions .btn-secondary {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================================
   [3] DESKTOP  (≥ 900px)
   ============================================================ */

@media (min-width: 900px) {

  /* ── Grid: 3 columns ──────────────────────────────────── */

  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  /* Hero: absolute fill in 3-col grid */
  .gallery-item--hero {
    aspect-ratio: unset;
  }

  .gallery-item--hero img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Wide-2col: spans 2 cols, absolute fill */
  .gallery-item--wide-2col {
    grid-column: span 2;
    aspect-ratio: unset;
  }

  .gallery-item--wide-2col img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .galerie-cta { padding: 2.5rem; margin-top: 2.5rem; }
  .galerie-section { padding: 3rem 0 4rem; }

  /* ── Gallery more: 2-col layout ──────────────────────── */

  .gallery-more {
    margin-top: 1.5rem;
    padding: 1.5rem 1.75rem;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.5rem 2rem;
    align-items: center;
  }

  .gallery-more__action {
    justify-content: flex-end;
  }
}

/* ── Gallery section titles ─────────────────────────────── */

.gallery-section-title {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.gallery-section-title--videos {
  margin-top: 2.5rem;
}

/* ── Photo grid — 3:4 portrait (840×1120) ───────────────── */

.gallery-grid--photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.gallery-grid--photos .gallery-item {
  aspect-ratio: 3 / 4;
}

.gallery-grid--photos .gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

/* ── Video grid — 3:4 portrait ──────────────────────────── */

.gallery-grid--videos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  content-visibility: auto;
  contain-intrinsic-size: 0 2000px;
}

.gallery-grid--videos .gallery-item {
  aspect-ratio: 3 / 4;
  cursor: pointer;
}

/* Static poster image injected by HTML (or JS fallback) */
.gallery-item--video img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Hidden <video> used only for JS poster-frame fallback */
.gallery-item--video video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Play button overlay */
.gallery-item__play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: opacity 0.25s ease;
}

.gallery-item--video:hover .gallery-item__play,
.gallery-item--video:focus-visible .gallery-item__play {
  opacity: 0.75;
}

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

/* ── Lightbox video element ─────────────────────────────── */

#lightbox-video {
  max-width: min(480px, 90vw);
  max-height: 85vh;
  width: auto;
  height: auto;
  border-radius: 2px;
}

/* ── Lightbox loading spinner ───────────────────────────── */

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

#lightbox.lb-loading::after {
  content: '';
  position: absolute;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, .2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lb-spin .7s linear infinite;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  #lightbox.lb-loading::after {
    animation: none;
    opacity: .5;
  }
}

/* ── Tablet ≥ 600px ─────────────────────────────────────── */

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

  .gallery-section-title--videos {
    margin-top: 3rem;
  }
}

/* ── Desktop ≥ 900px ────────────────────────────────────── */

@media (min-width: 900px) {
  .gallery-grid--photos {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .gallery-grid--videos {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .gallery-section-title--videos {
    margin-top: 4rem;
  }
}
