/* Larger photo view shared by the case studies (see js/lightbox.js) and the
   About Me gallery, so every page opens images the same way */

.lightbox-target {
  cursor: zoom-in;
  transition: filter 200ms ease;
}

.lightbox-target:hover {
  filter: brightness(1.03);
}

.lightbox-target:focus-visible {
  outline: 3px solid #9a62f6;
  outline-offset: 4px;
}

/* The native dialog traps focus and closes on Esc */
html:has(.lightbox[open]) {
  overflow: hidden;
}

.lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  box-sizing: border-box;
  margin: 0;
  padding: 72px 16px 24px;
  border: 0;
  color: #f5f1fa;
  background: transparent;
  font-family: "Plus Jakarta Sans", sans-serif;
}

.lightbox[open] {
  display: grid;
  place-items: center;
  animation: lightbox-fade 220ms ease;
}

.lightbox::backdrop {
  background: rgb(14 10 28 / 84%);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  animation: lightbox-fade 220ms ease;
}

.lightbox__figure {
  display: flex;
  max-width: 100%;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 0;
  padding: 0;
  animation: lightbox-grow 280ms cubic-bezier(0.2, 0, 0, 1);
}

.lightbox__image {
  display: block;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  object-fit: cover;
}

/* Set in full so the pages' own figcaption styles don't leak in */
.lightbox .lightbox__caption {
  display: block;
  width: auto;
  max-width: 60ch;
  margin: 0;
  padding: 0;
  color: #f5f1fa;
  font-family: inherit;
  font-size: 16px;
  font-style: normal;
  line-height: 1.5;
  text-align: center;
  opacity: 1;
}

/* Close, previous and next share one round button style */
.lightbox__button {
  position: fixed;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 50%;
  color: #ffffff;
  background: rgb(14 10 28 / 60%);
  cursor: pointer;
  transition: background-color 150ms ease, transform 150ms ease;
}

.lightbox__button:hover {
  background: rgb(154 98 246 / 45%);
}

.lightbox__button:active {
  transform: scale(0.94);
}

.lightbox__button:focus-visible {
  outline: 3px solid #c9a8ff;
  outline-offset: 3px;
}

.lightbox__button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.lightbox__close {
  top: 16px;
  right: 16px;
}

.lightbox__nav {
  top: 50%;
  display: none;
  margin-top: -22px;
}

.lightbox.has-nav .lightbox__nav {
  display: grid;
}

.lightbox__prev {
  left: 16px;
}

.lightbox__next {
  right: 16px;
}

/* Narrow screens: the arrows sit side by side under the caption so they
   never cover the image */
@media (max-width: 699px) {
  .lightbox.has-nav {
    padding-bottom: 92px;
  }

  .lightbox__nav {
    top: auto;
    bottom: 24px;
    margin-top: 0;
  }

  .lightbox__prev {
    left: calc(50% - 56px);
  }

  .lightbox__next {
    right: calc(50% - 56px);
  }
}

@keyframes lightbox-fade {
  from {
    opacity: 0;
  }
}

@keyframes lightbox-grow {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox__figure {
    animation-name: lightbox-fade;
  }

  .lightbox-target,
  .lightbox__button {
    transition: none;
  }
}
