/* Media archive lightbox.
   Loaded only on the media archive page. Everything here is scoped to the
   dialog or to .lb-ready, which the script adds once it has run - so with
   JavaScript off, none of this applies and the thumbnails stay plain links. */

/* ---- the hint on the thumbnails ------------------------------------- */

/* Only promise "opens here" once the script is actually running. */
.lb-ready .gallery a {
  position: relative;
}

.lb-ready .gallery a::after {
  content: "Click to enlarge";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.5rem 0.4rem;
  background: rgba(20, 16, 12, 0.82);
  color: #fdfbf7;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-align: center;
  opacity: 0;
  transition: opacity 120ms ease;
}

.lb-ready .gallery a:hover::after,
.lb-ready .gallery a:focus-visible::after {
  opacity: 1;
}

/* ---- page behind ----------------------------------------------------- */

html.lb-open,
html.lb-open body {
  overflow: hidden;
}

/* ---- backdrop -------------------------------------------------------- */

.lb-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 3vw, 2rem);
  background: rgba(18, 14, 10, 0.88);
  overflow-y: auto;
}

.lb-backdrop[hidden] { display: none; }

/* ---- dialog ---------------------------------------------------------- */

.lb-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(62rem, 100%);
  max-height: 100%;
  padding: clamp(1rem, 2.5vw, 1.6rem);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  animation: lb-in 140ms ease-out;
}

@keyframes lb-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---- the image ------------------------------------------------------- */

.lb-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 0;
}

.lb-img {
  display: block;
  max-width: 100%;
  /* Leave room for the close button, caption and button bar. */
  max-height: min(68vh, 50rem);
  margin: 0 auto;
  object-fit: contain;
  background: var(--paper);
  border: 1px solid var(--rule);
}

.lb-caption {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink-mid);
  text-align: center;
  max-width: 44rem;
  margin: 0 auto;
}

/* ---- buttons --------------------------------------------------------- */

/* Deliberately large and plainly worded. An icon-only "×" is a poor target
   and a worse label. */
.lb-btn {
  font: inherit;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.7rem 1.1rem;
  min-height: 2.9rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
}

.lb-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lb-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.lb-btn[hidden] { display: none; }

.lb-close {
  align-self: flex-end;
  font-weight: 600;
}

.lb-close span { font-size: 1.15em; vertical-align: -0.06em; }

.lb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
}

.lb-counter {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---- narrow screens -------------------------------------------------- */

@media (max-width: 34rem) {
  .lb-img { max-height: 54vh; }
  .lb-bar { justify-content: center; }
  .lb-counter { order: -1; width: 100%; text-align: center; }
  .lb-btn { flex: 1 1 auto; }
  .lb-close { width: 100%; }
}

/* ---- motion ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .lb-dialog { animation: none; }
  .lb-ready .gallery a::after { transition: none; }
}
