/* Gallery lightbox, built by js/lightbox.js as a modal <dialog closedby="any">. Without JavaScript the gallery
   links open the large image. The dialog is sized to its content so the ::backdrop around it can be clicked
   (light dismiss); the backdrop carries the dark overlay. */
@layer components {
  .c-lightbox { width: fit-content; max-width: 100dvw; max-height: 100dvh; padding: var(--space-4); border: 0; background: transparent; color: var(--on-inverse); }
  .c-lightbox[open] { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-2); }
  .c-lightbox::backdrop { background: var(--overlay); }
  /* Keep scroll gestures from reaching the page behind the modal (progressive enhancement, no body lock). */
  .c-lightbox:modal { overscroll-behavior: contain; }
  .c-lightbox::backdrop { overflow: hidden; overscroll-behavior: contain; }
  .c-lightbox__figure { display: grid; gap: var(--space-3); justify-items: center; min-width: 0; }
  .c-lightbox__img { max-width: 100%; max-height: calc(100dvh - 8rem); object-fit: contain; border-radius: var(--radius-sm); }
  .c-lightbox__caption { font-size: var(--fs-sm); text-align: center; color: var(--on-inverse-muted); }
  .c-lightbox__btn { display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap); min-height: var(--tap); border: 1px solid var(--on-inverse-muted); border-radius: var(--radius-md); background: var(--surface-inverse); color: var(--on-inverse); box-shadow: var(--btn-raise-quiet); transition: border-color var(--dur-2), color var(--dur-2), box-shadow var(--dur-2); }
  @media (hover: hover) {
    .c-lightbox__btn:hover { border-color: var(--accent-on-brand); color: var(--accent-on-brand); box-shadow: var(--btn-raise-quiet-hover); }
  }
  .c-lightbox__btn:active { box-shadow: var(--btn-quiet-pressed); }
  .c-lightbox__btn:focus-visible { outline-color: var(--focus-on-dark); }
  /* Narrow screens: the photo takes the full width and the arrows sit under it (DOM order stays previous, next). */
  @media (width < 30em) {
    .c-lightbox[open] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .c-lightbox__figure { grid-column: 1 / -1; grid-row: 1; }
    .c-lightbox [data-act="prev"] { justify-self: end; }
    .c-lightbox [data-act="next"] { justify-self: start; }
  }
  /* Fixed to the viewport corner (the dialog is in the top layer, so this stays above the backdrop). */
  .c-lightbox__close { position: fixed; inset-block-start: var(--space-4); inset-inline-end: var(--space-4); }
}
