/* Lightbox de galería — blur del fondo; chrome igual al menú */

dialog.media-lightbox {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  padding: 5.5rem var(--grid-margin);
  border: none;
  background: transparent;
  color: var(--texto);
  box-sizing: border-box;
}

dialog.media-lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

dialog.media-lightbox::backdrop {
  background: rgba(17, 17, 17, 0.8);
}

html.lightbox-open .site-header,
html.lightbox-open main,
html.lightbox-open footer,
html.lightbox-open #menu {
  filter: blur(20px);
}

html.lightbox-open #hamburger,
html.lightbox-open .btn-up-to-top,
html.lightbox-open .dot-nav {
  visibility: hidden;
}

.media-lightbox__figure {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  height: 100%;
  max-width: min(100%, calc(100vw - 2 * var(--grid-margin) - 2 * 54px - 1.5rem));
  margin: 0;
}

.media-lightbox__caption {
  margin: 0;
  max-width: 100%;
  font-family: var(--serif-it, Georgia, serif);
  font-size: 16px;
  font-style: italic;
  font-weight: 400;
  line-height: 1.4;
  color: var(--grey-0);
  text-align: center;
}

.media-lightbox__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Close: misma X y posición que #hamburger */
.media-lightbox__close {
  position: fixed;
  top: var(--hamburger-top, calc((var(--header-nav-height, 83px) - var(--hamburger-size, 44px)) / 2));
  right: var(--hamburger-right, 1.8rem);
  z-index: 2;
  width: var(--hamburger-size, 44px);
  height: var(--hamburger-size, 44px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.media-lightbox__close .ham-linea {
  background-color: var(--grey-0);
}

.media-lightbox__close .ham-linea:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.media-lightbox__close .ham-linea:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.media-lightbox__close .ham-linea:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* Flechas: círculo del btn-up-to-top (54px, filete 1px) sin sombra */
.media-lightbox__nav {
  position: fixed;
  top: 50%;
  z-index: 2;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  padding: 15px;
  border: 1px solid var(--grey-40);
  border-radius: 27px;
  background: var(--grey-70);
  cursor: pointer;
  transform: translateY(-50%);
  color: var(--grey-10);
  font-family: var(--serif);
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.media-lightbox__nav--prev {
  left: var(--grid-margin);
}

.media-lightbox__nav--next {
  right: var(--grid-margin);
}

.media-lightbox__nav-icon {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
}

.media-lightbox__nav:hover {
  background: var(--grey-0);
  border-color: var(--grey-40);
  color: var(--grey-40);
}

.media-lightbox__nav:active {
  background: var(--grey-10);
  border-color: var(--grey-40);
  color: var(--grey-40);
}

.media-lightbox__close:focus,
.media-lightbox__nav:focus {
  outline: none;
}

.media-lightbox__close:focus-visible {
  outline: 2px solid var(--grey-0);
  outline-offset: 3px;
}

.media-lightbox__nav:focus-visible {
  outline: 2px solid var(--grey-70);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce), (prefers-reduced-transparency: reduce) {
  html.lightbox-open .site-header,
  html.lightbox-open main,
  html.lightbox-open footer,
  html.lightbox-open #menu {
    filter: none;
  }

  dialog.media-lightbox::backdrop {
    background: rgba(17, 17, 17, 0.92);
  }
}
