/* Cinematic gallery overlay */
:root {
  --gallery-gold: #c9a227;
  --gallery-glass: rgba(255, 255, 255, 0.95);
  --gallery-backdrop: rgba(6, 6, 8, 0.92);
  --gallery-shadow: 0 36px 90px rgba(0, 0, 0, 0.7);
  --gallery-stage-width: min(1100px, 94vw);
  --gallery-stage-height: min(72vh, 720px);
  --gallery-thumb-gap: clamp(10px, 1vw, 22px);
  --gallery-nav-size: 48px;
}

.media-viewer {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.95)),
    var(--gallery-backdrop);
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 40px);
  backdrop-filter: blur(6px);
}

.media-viewer[hidden] {
  display: none;
}

.media-dialog {
  width: min(var(--gallery-stage-width), 100%);
  max-height: min(92vh, 100vh);
  background: rgba(8, 8, 8, 0.98);
  border-radius: 32px;
  padding: clamp(16px, 2vw, 32px);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2vw, 28px);
  box-shadow: var(--gallery-shadow);
  overflow: hidden;
}

.media-shell {
  width: 100%;
  max-height: var(--gallery-stage-height);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.media-stage {
  width: 100%;
  max-height: var(--gallery-stage-height);
  border-radius: 28px;
  overflow: hidden;
  background: radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 60%), #050505;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 32px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.media-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: opacity 260ms ease, transform 360ms ease;
  animation: galleryFade 340ms ease;
}

.media-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.02);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6);
}

@keyframes galleryFade {
  from {
    opacity: 0;
    transform: scale(1.04);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.nav-btn {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 10px 20px;
  cursor: pointer;
  box-shadow: 0 14px 20px rgba(0, 0, 0, 0.35);
  z-index: 12;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.media-nav-row {
  position: absolute;
  inset: auto 0 15% 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 clamp(16px, 3vw, 28px);
  pointer-events: none;
  gap: clamp(8px, 1vw, 18px);
}

.media-nav-row .nav-btn {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.12);
}

.nav-btn:hover,
.nav-btn:focus-visible {
  background: rgba(201, 162, 39, 0.15);
  color: #111;
  box-shadow: 0 0 20px rgba(201, 162, 39, 0.6);
}
.nav-btn:hover::before,
.nav-btn:focus-visible::before {
  border-color: transparent transparent transparent var(--gallery-gold);
}

.nav-btn.next:hover::before,
.nav-btn.next:focus-visible::before {
  border-color: transparent var(--gallery-gold) transparent transparent;
}


.lb-meta {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  color: #d7d7e0;
  font-size: 0.95rem;
}

.lb-info {
  flex: 1;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.lb-dl {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 8px 16px;
  background: transparent;
  color: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease;
}

.lb-dl:hover,
.lb-dl:focus-visible {
  background: rgba(201, 162, 39, 0.15);
  border-color: rgba(201, 162, 39, 0.8);
}

.close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.5);
  z-index: 14;
  transition: transform 200ms ease, background 200ms ease;
}

.close svg {
  width: 18px;
  height: 18px;
  fill: #050505;
}

.close:hover,
.close:focus-visible {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 1);
}

.thumb-row {
  width: 100%;
  max-width: var(--gallery-stage-width);
  margin: 0 auto;
  padding: clamp(10px, 1.8vw, 22px) clamp(12px, 3vw, 32px);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 32px;
  display: flex;
  gap: var(--gallery-thumb-gap);
  justify-content: center;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
}

.thumb-row .thumb {
  width: clamp(70px, 7vw, 100px);
  height: clamp(70px, 7vw, 100px);
  border-radius: 18px;
  object-fit: cover;
  border: 3px solid transparent;
  cursor: pointer;
  opacity: 0.75;
  scroll-snap-align: center;
  flex-shrink: 0;
  transition: transform 180ms ease, opacity 180ms ease, border-color 180ms ease;
}

.thumb-row .thumb.is-active,
.thumb-row .thumb:hover {
  opacity: 1;
  border-color: var(--gallery-gold);
  transform: translateY(-4px);
}

.thumb-row-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 0 clamp(12px, 2vw, 28px);
  margin-top: -6px;
}

.media-viewer,
.media-dialog,
.nav-btn,
.close {
  pointer-events: auto;
}

@media (max-width: 900px) {
  .media-viewer {
    align-items: flex-start;
    justify-content: flex-start;
    padding: 8px;
  }

  .media-dialog {
    width: min(100vw, 96vw);
    border-radius: 24px;
    padding: 14px;
  }

  .media-shell {
    height: auto;
  }

  .media-nav-row {
    position: static;
    inset: auto;
    width: 100%;
    margin-top: 6px;
    justify-content: space-between;
    pointer-events: auto;
  }

  .media-nav-row .nav-btn {
    flex: 1;
    margin: 0 6px;
    letter-spacing: 0.12em;
    font-size: 0.8rem;
  }

  .thumb-row {
    padding: 10px;
    gap: 10px;
    border-radius: 18px;
  }

  .thumb-row .thumb {
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 640px) {
  .lb-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .media-stage img,
  .nav-btn,
  .thumb-row .thumb {
    transition: none !important;
    animation: none !important;
  }
}
