/* ─── Variables ──────────────────────────────────────────────────────────────── */

:root {
  --gallery-img-border: #fff;
  --lightbox-bg: rgba(0, 0, 0, .95);
  --controls-gradient: rgba(0, 0, 0, 0.55);
  --btn-bg: rgba(255, 255, 255, .07);
  --btn-bg-hover: rgba(255, 255, 255, .15);
  --btn-sep: rgba(255, 255, 255, .14);
}

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

.m-p-g {
  max-width: 100%;
  margin: 0 auto;
}

/* ─── Thumbnails ─────────────────────────────────────────────────────────────── */

.m-p-g__thumbs-img {
  margin: 0;
  float: left;
  vertical-align: bottom;
  cursor: pointer;
  z-index: 1;
  position: relative;
  opacity: 0;
  filter: brightness(100%);
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  will-change: opacity;
  /* Only the fade-in (opacity) and hover (filter) animate — never the geometry.
     Sizes are set from the precomputed grid and must snap instantly, otherwise
     the layout appears to "grow"/jump into place over the transition. */
  transition: opacity .5s cubic-bezier(0.23, 1, 0.32, 1), filter .2s ease;
}

.m-p-g__thumbs-img.layout-completed {
  border: solid 1px var(--gallery-img-border);
  outline: solid 7px var(--gallery-img-border);
  outline-offset: -6px;
}

/* Sizing (layout-completed) is applied up-front from the precomputed ratios;
   the fade-in is gated on the actual pixels arriving, so each thumbnail appears
   in its already-fixed box without any reflow. */
.m-p-g__thumbs-img.loaded {
  opacity: 1;
}

.m-p-g__thumbs-img.hide {
  opacity: 0;
}

.m-p-g__thumbs-img:hover,
.m-p-g__thumbs-img:focus-visible {
  filter: brightness(105%);
  outline: solid 2px var(--gallery-img-border);
  outline-offset: -6px;
}

/* ─── Featured ("spotlight") images ──────────────────────────────────────────────
   Tagged in curation.js (VFE.featured); gallery.js marks each one with the
   .is-featured class and a data-featured attr (carried onto the fullscreen <img>
   too). No visual styling yet — the effect is being reworked; hook in here. */

/* ─── Fullscreen ─────────────────────────────────────────────────────────────── */

.m-p-g__fullscreen {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0);
  visibility: hidden;
  transition: background .25s ease-out, visibility .01s .5s linear;
  will-change: background, visibility;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.m-p-g__fullscreen.active {
  transition: background .25s ease-out, visibility .01s 0s linear;
  visibility: visible;
  background: var(--lightbox-bg);
}

.m-p-g__fullscreen-img {
  pointer-events: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  max-height: 90vh;
  max-width: 92vw;
  visibility: hidden;
  opacity: 0;
  outline: solid 4px var(--gallery-img-border);
  outline-offset: -3px;
  transition: opacity .3s ease-out, transform .3s cubic-bezier(0.23, 1, 0.32, 1), visibility 0s .3s;
}

.m-p-g__fullscreen-img.active {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition: opacity .3s ease-out, transform .3s cubic-bezier(0.23, 1, 0.32, 1);
}

.m-p-g__fullscreen-img.no-anim {
  transition: none !important;
}

/* ─── Controls ───────────────────────────────────────────────────────────────── */

.m-p-g__controls {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 200;
  height: 20vh;
  background: linear-gradient(to top, transparent 0%, var(--controls-gradient) 100%);
  opacity: 0;
  visibility: hidden;
  transition: opacity .5s cubic-bezier(0.23, 1, 0.32, 1), visibility .5s;
}

.m-p-g__controls.active {
  opacity: 1;
  visibility: visible;
}

.m-p-g__controls-close,
.m-p-g__controls-download,
.m-p-g__controls-arrow {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  background: none;
}

.m-p-g__controls-close:focus,
.m-p-g__controls-download:focus,
.m-p-g__controls-arrow:focus {
  outline: none;
}

.m-p-g__controls-arrow {
  position: absolute;
  z-index: 1;
  top: 0;
  width: 20%;
  height: 100vh;
  display: flex;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  opacity: 0;
}

.m-p-g__controls-arrow:hover {
  opacity: 1;
}

.m-p-g__controls-arrow--prev {
  left: 0;
  padding-left: 3vw;
  justify-content: flex-start;
}

.m-p-g__controls-arrow--next {
  right: 0;
  padding-right: 3vw;
  justify-content: flex-end;
}

.m-p-g__controls-actions {
  position: absolute;
  top: 3vh;
  right: 3vw;
  z-index: 5;
  display: flex;
  gap: 12px;
  align-items: center;
}

.m-p-g__controls-close,
.m-p-g__controls-download {
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.m-p-g__controls-album {
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.m-p-g__controls-sep {
  display: inline-block;
  width: 1px;
  height: 24px;
  background: var(--btn-sep);
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */

.m-p-g__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  background: var(--btn-bg);
  transition: background .25s ease-out;
}

.m-p-g__btn:hover {
  background: var(--btn-bg-hover);
}

.m-p-g__btn--album {
  width: auto;
  padding: 0 16px;
  gap: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #fff;
}

.m-p-g__thumbs {
  overflow: hidden;
}

/* ─── Alert ──────────────────────────────────────────────────────────────────── */

.m-p-g__alertBox {
  position: fixed;
  z-index: 999;
  max-width: 700px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  padding: 25px;
  border-radius: 3px;
  text-align: center;
  box-shadow: 0 6px 12px rgba(0, 0, 0, .23), 0 10px 40px rgba(0, 0, 0, .19);
  color: gray;
}

.m-p-g__alertBox h2 {
  color: red;
}
