/* ==========================================================================
   Lightbox - assets/js/lightbox.js wraps content images in a button and
   opens them in a native <dialog>. Tokens only; no inline styles anywhere.
   Enqueued from functions.php on every page (2 KB; images are on most).
   ========================================================================== */

/* The trigger inherits nothing from the UA button: it is the image's box. */
.co-lightbox__trigger {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  color: inherit;
  font: inherit;
  line-height: 0;
}

.co-lightbox__trigger > img {
  width: 100%;
  height: auto;
}

.co-lightbox__trigger:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* The dialog. */
.co-lightbox {
  width: min(96vw, 1600px);
  max-width: none;
  max-height: 96vh;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.co-lightbox::backdrop {
  background: rgb(0 0 0 / 0.72);
  backdrop-filter: blur(2px);
}

.co-lightbox__figure {
  margin: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  max-height: 96vh;
}

.co-lightbox__img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(96vh - 4rem);
  object-fit: contain;
  background: var(--surface-page);
}

.co-lightbox__caption {
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  border-block-start: var(--border-width) solid var(--border-default);
}

.co-lightbox__close {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-end: var(--space-2);
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-primary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

.co-lightbox__close:hover {
  background: var(--surface-sunken);
}

.co-lightbox__close:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

@media (prefers-reduced-motion: no-preference) {
  .co-lightbox[open] {
    animation: co-lightbox-in 160ms ease-out;
  }
  @keyframes co-lightbox-in {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: none; }
  }
}
