/* ==========================================================================
   md-lightbox — Moo Digital's standard lightbox. See README.md.

   Styled from the 11ty template's Part 1 tokens (--ink, --white, --accent,
   --radius-pill, --font-body ...), each with a fallback so it still works on
   a page without them. To restyle for one site, override the --mdlb-*
   values below in Part 10 of style.css rather than editing this file.
   ========================================================================== */

.md-lightbox{
  --mdlb-backdrop:color-mix(in srgb, var(--ink, #0a0a0a) 97%, transparent);
  --mdlb-text:var(--white, #fff);
  --mdlb-muted:var(--ink-muted, #a8a8a8);
  --mdlb-control-bg:color-mix(in srgb, var(--ink, #0a0a0a) 65%, transparent);
  --mdlb-control-bg-hover:var(--ink, #0a0a0a);
  --mdlb-focus:var(--accent, #00ff00);   /* focus colour the template uses on dark sections */
  --mdlb-font:var(--font-body, system-ui, sans-serif);
  --mdlb-round:var(--radius-pill, 999px);
  --mdlb-media-radius:var(--radius, 0);
  --mdlb-gutter:16px;                    /* space either side of the picture */
  --mdlb-bar:3.75rem;                    /* space above and below it, for the close button and counter */
  --mdlb-caption-space:0px;
  --mdlb-speed:.2s;
}
@media (min-width:700px){
  .md-lightbox{--mdlb-gutter:var(--space-2xl, 3rem)}
}
.md-lightbox.has-caption{--mdlb-caption-space:5.25rem}

/* The dialog is the backdrop: it fills the screen, so a click that lands on
   it rather than on the picture closes it. */
.md-lightbox{
  position:fixed;inset:0;
  width:100%;height:100%;max-width:none;max-height:none;
  margin:0;padding:0;border:0;
  background:var(--mdlb-backdrop);
  color:var(--mdlb-text);
  font:400 1rem/1.5 var(--mdlb-font);
  overflow:hidden;
  touch-action:none;                     /* gestures are ours, not the browser's */
  overscroll-behavior:contain;
}
.md-lightbox[open]{display:block;animation:mdlb-fade var(--mdlb-speed) ease-out}
.md-lightbox::backdrop{background:transparent}
html:has(.md-lightbox[open]){overflow:hidden}

.md-lightbox :focus-visible{outline:4px solid var(--mdlb-focus);outline-offset:2px}

.mdlb-stage{
  position:absolute;inset:0;
  display:grid;place-items:center;
  padding:var(--mdlb-bar) var(--mdlb-gutter);
}
.mdlb-figure{
  margin:0;
  display:flex;flex-direction:column;align-items:center;gap:.75rem;
  max-width:100%;
}

/* The frame shrinks to fit the picture, so the edge zones and arrows sit
   inside the picture rather than out on the backdrop. */
.mdlb-frame{position:relative;line-height:0}
.mdlb-media{
  display:block;
  width:auto;height:auto;
  max-width:calc(100vw - 2 * var(--mdlb-gutter));
  max-height:calc(100dvh - 2 * var(--mdlb-bar) - var(--mdlb-caption-space));
  border-radius:var(--mdlb-media-radius);
  transform-origin:50% 50%;
  transition:transform var(--mdlb-speed) ease-out, opacity var(--mdlb-speed) ease-out;
  user-select:none;-webkit-user-select:none;
  animation:mdlb-fade var(--mdlb-speed) ease-out;
}
img.mdlb-media{cursor:zoom-in}
.md-lightbox.is-zoomed img.mdlb-media{cursor:grab}
.md-lightbox.is-dragging .mdlb-media{transition:none}
.md-lightbox.is-zoomed.is-dragging img.mdlb-media{cursor:grabbing}
video.mdlb-media{background:#000;min-width:min(640px, calc(100vw - 2 * var(--mdlb-gutter)))}

/* Edge zones: the outer 20% of the picture each side is a button. */
.mdlb-zone{
  position:absolute;top:0;bottom:0;
  width:max(20%, 3rem);
  display:flex;align-items:center;
  margin:0;padding:0 .5rem;border:0;
  background:none;color:var(--mdlb-text);
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  transition:opacity var(--mdlb-speed);
}
.mdlb-prev{left:0;justify-content:flex-start}
.mdlb-next{right:0;justify-content:flex-end}
.mdlb-zone:focus-visible{outline-offset:-4px}
.is-video .mdlb-zone{bottom:4.5rem}                 /* keep clear of the video controls */
.is-single .mdlb-zone,
.is-single .mdlb-counter{display:none}
.is-zoomed .mdlb-zone{opacity:0;pointer-events:none}

.mdlb-arrow,
.mdlb-close{
  display:grid;place-items:center;
  width:2.75rem;height:2.75rem;
  border-radius:var(--mdlb-round);
  background:var(--mdlb-control-bg);
  color:var(--mdlb-text);
  transition:background-color var(--mdlb-speed);
}
.mdlb-zone:hover .mdlb-arrow,
.mdlb-close:hover{background:var(--mdlb-control-bg-hover)}
.md-lightbox svg{width:1.5rem;height:1.5rem;fill:none;stroke:currentColor;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}

.mdlb-close{
  position:absolute;top:.5rem;right:.5rem;
  width:3rem;height:3rem;
  margin:0;padding:0;border:0;
  cursor:pointer;
}
.mdlb-counter{
  position:absolute;top:0;left:var(--mdlb-gutter);
  margin:0;line-height:var(--mdlb-bar);
  font-size:.9rem;font-variant-numeric:tabular-nums;
  color:var(--mdlb-muted);
}
.mdlb-caption{
  max-width:min(var(--measure, 34em), 100%);
  text-align:center;font-size:.95rem;
  display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;line-clamp:3;
  overflow:hidden;
}
.mdlb-caption[hidden]{display:none}

/* Loading: a spinner appears only if the picture takes more than a moment. */
.md-lightbox.is-loading .mdlb-stage::after{
  content:"";position:absolute;top:50%;left:50%;
  width:2.5rem;height:2.5rem;margin:-1.25rem 0 0 -1.25rem;
  border:3px solid color-mix(in srgb, var(--mdlb-text) 25%, transparent);
  border-top-color:var(--mdlb-text);
  border-radius:50%;
  opacity:0;
  animation:mdlb-spin .8s linear infinite, mdlb-show 0s .25s forwards;
}

@keyframes mdlb-fade{from{opacity:0}}
@keyframes mdlb-spin{to{transform:rotate(1turn)}}
@keyframes mdlb-show{to{opacity:1}}

@media (prefers-reduced-motion:reduce){
  .md-lightbox{--mdlb-speed:0s}
  .md-lightbox.is-loading .mdlb-stage::after{animation:mdlb-show 0s .25s forwards}
}
