/* Lightbox v2 — gallery images in the core Popup <dialog>
   See core/assets/js/lightbox.js and core/templates/components/lightbox.php

   Full-screen, dark, image first: counter top left, toolbar top right beside
   Popup's own close button, arrows at the screen edges, thumbnail strip along
   the bottom. v1 is "lightbox - v1 (simple).css".

   ⚠ Loaded AFTER popup.css (page CSS follows the layout's static popup tag),
   which is what lets these rules win at equal specificity.
-------------------------------------------------- */

/* ------------------------------------------------------------
   The dialog — the whole viewport, dark
------------------------------------------------------------ */
dialog.popup--lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  background: rgba(14, 14, 14, .96);
  color: #fff;
  overflow: hidden;
}

dialog.popup--lightbox[open] { display: block; }

dialog.popup--lightbox::backdrop {
  background: rgba(0, 0, 0, .5);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.popup--lightbox .popup__panel {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.popup--lightbox .popup__body {
  height: 100%;
  color: #fff;
}

/* Popup's own ✕, moved into the top bar's right-hand corner.
   ⚠ color:#fff is stated here since 2.3.7 — popup.css's ✕ now takes the site's popup
   skin (dark on cor's and mhl's light box), which would vanish on this dark screen. */
.popup--lightbox .popup__head {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  margin: 0;
}

.popup--lightbox .popup__close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #fff;
  font-size: 1.9rem;
}

.popup--lightbox .popup__close:hover,
.popup--lightbox .popup__close:focus-visible {
  background: rgba(255, 255, 255, .14);
}

/* ------------------------------------------------------------
   ⚠ buttons.css styles EVERY <button> as the gold .btn — gradient,
   padding, shadow and a ► in ::after. Everything in here opts out.
------------------------------------------------------------ */
.popup--lightbox .popup__close::after,
.lightbox button::after { content: none; }

.lightbox button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #fff;
  font: inherit;
  line-height: 1;
  overflow: visible;
  transform: none;
  cursor: pointer;
}

.lightbox button:hover {
  background: transparent;
  box-shadow: none;
  color: #fff;
}

.lightbox button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.lightbox [hidden] { display: none !important; }

/* ------------------------------------------------------------
   Layout — top bar, image area, caption, thumbnails
------------------------------------------------------------ */
.lightbox {
  position: relative;
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr) auto auto;
  height: 100%;
}

.lightbox__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 64px 0 18px;   /* the right padding leaves room for Popup's ✕ */
}

.lightbox__counter {
  color: rgba(255, 255, 255, .85);
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
}

.lightbox__toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lightbox button.lightbox__tool {
  width: 44px;
  height: 44px;
}

.lightbox button.lightbox__tool:hover,
.lightbox button.lightbox__tool:focus-visible,
.lightbox button.lightbox__tool.is-active {
  background: rgba(255, 255, 255, .14);
}

.lightbox__icon { width: 24px; height: 24px; }

/* Two-state tools carry both icons; .is-active swaps them. */
.lightbox__icon--alt                          { display: none; }
.lightbox__tool.is-active .lightbox__icon--main { display: none; }
.lightbox__tool.is-active .lightbox__icon--alt  { display: block; }

/* ------------------------------------------------------------
   Image area
------------------------------------------------------------ */
.lightbox__main {
  position: relative;
  min-height: 0;
}

.lightbox__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 84px;   /* keeps the image clear of the arrows */
  overflow: hidden;
}

.lightbox__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}

/* Zoomed: the image at full size, scrolled or dragged around. */
.lightbox__stage.is-zoomed {
  display: block;
  padding: 0;
  overflow: auto;
  cursor: grab;
}
.lightbox__stage.is-zoomed .lightbox__image {
  max-width: none;
  max-height: none;
  margin: 0 auto;
  cursor: grab;
}
.lightbox__stage.is-zoomed.is-dragging,
.lightbox__stage.is-zoomed.is-dragging .lightbox__image { cursor: grabbing; }

/* Arrows at the screen edges, as the old lightbox had them. */
.lightbox button.lightbox__arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 56px;
  height: 56px;
  background: rgba(0, 0, 0, .6);
  transform: translateY(-50%);
}

.lightbox button.lightbox__arrow:hover,
.lightbox button.lightbox__arrow:focus-visible {
  background: rgba(0, 0, 0, .85);
  transform: translateY(-50%);
}

.lightbox__arrow--prev { left: 12px; }
.lightbox__arrow--next { right: 12px; }
.lightbox__arrow .lightbox__icon { width: 30px; height: 30px; }

/* ------------------------------------------------------------
   Caption and thumbnails
------------------------------------------------------------ */
.lightbox__caption {
  max-width: 900px;
  margin: 10px auto 0;
  padding: 0 18px;
  color: rgba(255, 255, 255, .9);
  font-size: .95rem;
  line-height: 1.5;
  text-align: center;
}

.lightbox__thumbs {
  position: relative;   /* offsetLeft of each thumbnail is measured from here */
  display: flex;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0 18px 14px;
  overflow-x: auto;
  scrollbar-width: thin;
}

/* Centred while they fit, scrollable from the first one when they do not —
   'justify-content: center' alone would cut off the start of a long strip. */
.lightbox__thumbs > :first-child { margin-left: auto; }
.lightbox__thumbs > :last-child  { margin-right: auto; }

.lightbox button.lightbox__thumb {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  overflow: hidden;
  opacity: .55;
  outline: 2px solid transparent;
  outline-offset: -2px;
  transition: opacity .2s ease;
}

.lightbox button.lightbox__thumb:hover { opacity: .85; }

.lightbox button.lightbox__thumb.is-current {
  opacity: 1;
  outline-color: #fff;
}

.lightbox__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* "Link copied" — shown by share() when there is no share sheet. */
.lightbox__toast {
  position: absolute;
  bottom: 110px;
  left: 50%;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .95);
  color: #111;
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity .2s ease;
}

.lightbox__toast.is-visible { opacity: 1; }

/* ------------------------------------------------------------
   Full screen — the PANEL goes full screen, not the <dialog>, which
   the Fullscreen spec refuses (see lightbox.js). Two separate rules,
   not one selector list: a browser that does not recognise one of
   the selectors would discard the whole rule.
------------------------------------------------------------ */
.popup--lightbox .popup__panel:fullscreen {
  width: 100%;
  height: 100%;
  background: #0e0e0e;
}

.popup--lightbox .popup__panel:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: #0e0e0e;
}

/* ------------------------------------------------------------
   Small screens
------------------------------------------------------------ */
@media only screen and (max-width: 600px) {
  .lightbox { grid-template-rows: 52px minmax(0, 1fr) auto auto; }
  .lightbox__bar { padding: 0 54px 0 12px; }
  .lightbox button.lightbox__tool { width: 38px; height: 38px; }
  .lightbox__stage { padding: 0 8px; }
  .lightbox button.lightbox__arrow { width: 40px; height: 40px; background: rgba(0, 0, 0, .45); }
  .lightbox__arrow--prev { left: 4px; }
  .lightbox__arrow--next { right: 4px; }
  .lightbox button.lightbox__thumb { width: 52px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox button.lightbox__thumb,
  .lightbox__toast { transition: none; }
}
