@layer components {
  /* ======================
   * LIGHTBOX
   * ======================
   * Fullscreen image viewer dialog with navigation.
   * Extends native dialog element.
   */
  .lightbox {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background-color: oklch(0% 0 0 / 92%);
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .lightbox:not([open]) {
    display: none;
  }

  .lightbox[open] {
    display: flex;
  }

  .lightbox::backdrop {
    background-color: transparent;
  }

  /* Header with close button and counter */
  .lightbox__header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--block-space) var(--block-space-lg);
    background: linear-gradient(to bottom, oklch(0% 0 0 / 60%), transparent);
    z-index: 10;
  }

  .lightbox__counter {
    color: white;
    font-size: var(--text-sm);
    font-weight: 500;
  }

  .lightbox__actions {
    display: flex;
    gap: var(--inline-space);
  }

  .lightbox__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background-color: oklch(100% 0 0 / 15%);
    color: white;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color 0.15s ease;
    text-decoration: none;
  }

  .lightbox__btn:hover {
    background-color: oklch(100% 0 0 / 25%);
  }

  .lightbox__btn--close {
    font-size: var(--text-lg);
  }

  /* Image container */
  .lightbox__image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 4rem 3rem;
    overflow: hidden;
  }

  .lightbox__image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
  }

  /* Navigation arrows */
  .lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border: none;
    background-color: oklch(100% 0 0 / 15%);
    color: white;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color 0.15s ease, opacity 0.15s ease;
    font-size: var(--text-lg);
    z-index: 10;
  }

  .lightbox__nav:hover {
    background-color: oklch(100% 0 0 / 30%);
  }

  .lightbox__nav--prev {
    left: var(--block-space);
  }

  .lightbox__nav--next {
    right: var(--block-space);
  }

  .lightbox__nav[hidden] {
    display: none;
  }

  /* Caption */
  .lightbox__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--block-space) var(--block-space-lg);
    background: linear-gradient(to top, oklch(0% 0 0 / 60%), transparent);
    color: white;
    font-size: var(--text-sm);
    text-align: center;
  }

  .lightbox__caption[hidden] {
    display: none;
  }

  /* Mobile adjustments */
  @media (max-width: 639px) {
    .lightbox__header {
      padding: var(--block-space-sm) var(--block-space);
    }

    .lightbox__image-container {
      padding: 3rem 1rem;
    }

    .lightbox__nav {
      width: 2.5rem;
      height: 2.5rem;
      font-size: var(--text-base);
    }

    .lightbox__nav--prev {
      left: var(--block-space-sm);
    }

    .lightbox__nav--next {
      right: var(--block-space-sm);
    }
  }
}
