/* ==========================================================================
   Portfolio lightbox (full page, no site header / footer)
   Index: scrim & layout · top bar · stage (image, meta bar, arrows) · thumbnails
   Mobile-first; the arrows move outside the image from 75rem (1200px).
   ========================================================================== */

/* dark ground behind the work; the content starts at the top on phones and is centred from 48rem */
.lightbox {
  --lb-scrim: color-mix(in srgb, var(--ink) 94%, var(--navy));
  --lb-glass: var(--line-on-dark);
  --lb-line: var(--on-dark-15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: var(--sp-3);
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--sp-4) var(--gutter);
  color: var(--text-on-dark);
  background: var(--lb-scrim);
}
/* focus rings on the dark ground */
.lightbox :focus-visible { box-shadow: var(--focus-on-dark); }

/* ---- Top bar ----------------------------------------------------------- */
.lightbox__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: min(100%, 72rem);
}
.lightbox__author {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}
/* .avatar .avatar--sm .avatar--ring in the white-on-dark tone, no shadow */
.lightbox__avatar { --avatar-ring: var(--on-dark-15); box-shadow: none; }
.lightbox__who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .125rem var(--sp-2);
}
.lightbox__name { font-size: var(--fs-14); font-weight: 700; line-height: 1.45; }
.lightbox__field {
  padding: .125rem .625rem;
  font-size: var(--fs-12);
  font-weight: 700;
  line-height: 1.35;
  background: var(--burgundy);
  border-radius: var(--r-full);
}
.lightbox__cohort {
  flex-basis: 100%;
  font-size: var(--fs-12);
  line-height: 1.35;
  color: var(--on-dark-60);
}

.lightbox__tools {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-inline-start: auto;
}
.lightbox__count, .lightbox__tool {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  min-height: 2.75rem;
  padding-inline: var(--sp-3);
  font-size: var(--fs-12);
  line-height: 1.35;
  background: var(--lb-glass);
  border: 1px solid var(--lb-glass);
  border-radius: var(--r-12);
}
.lightbox__count { min-height: 1.875rem; color: var(--on-dark-95); white-space: nowrap; }
.lightbox__count::before {
  content: "";
  flex: none;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--amber);
}
.lightbox__tool { transition: background-color var(--t-fast) var(--ease); }
.lightbox__tool .icon { font-size: .75rem; }

/* round glass buttons: close, previous, next */
.lightbox__round {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  background: var(--lb-glass);
  border: 1px solid var(--lb-line);
  border-radius: 50%;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: background-color var(--t-fast) var(--ease), scale var(--t-fast) var(--ease);
}
.lightbox__round .icon { font-size: 1rem; }
.lightbox__round:active { scale: .95; }
.lightbox .lightbox__round:focus-visible { border-radius: 50%; }
@media (hover: hover) {
  .lightbox__round:hover, .lightbox__tool:hover { background: var(--on-dark-15); }
}

/* ---- Stage ------------------------------------------------------------- */
/* a size container, so the arrows can sit at half the image height (cqi = the stage width) */
.lightbox__stage { position: relative; container-type: inline-size; width: min(100%, 68.625rem); }
.lightbox__frame {
  overflow: clip;
  background: var(--ink);
  border: 1px solid var(--lb-line);
  border-radius: var(--r-16);
  box-shadow: var(--sh-xl);
}
.lightbox__image { width: 100%; aspect-ratio: 1096 / 579; object-fit: cover; }
/* in full-screen the whole work is shown, uncropped */
.lightbox__frame:fullscreen {
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
}
.lightbox__frame:fullscreen .lightbox__image {
  flex: 1;
  min-height: 0;
  aspect-ratio: auto;
  object-fit: contain;
}

.lightbox__meta {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-4);
  background: linear-gradient(to left, var(--navy), color-mix(in srgb, var(--navy) 80%, transparent));
  border-block-start: 1px solid var(--lb-glass);
}
.lightbox__text {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
  min-width: 0;
}
.lightbox__title { font-size: var(--fs-20); font-weight: 700; line-height: 1.4; }
.lightbox__tag {
  padding: .125rem var(--sp-2);
  font-size: var(--fs-12);
  font-weight: 700;
  line-height: 1.35;
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  border-radius: var(--r-4);
}
.lightbox__desc {
  flex-basis: 100%;
  font-size: var(--fs-14);
  line-height: 1.45;
  color: var(--on-dark-70);
}
.lightbox__cta {
  align-self: flex-start;
  padding-inline: var(--sp-5);
  font-size: var(--fs-12);
  font-weight: 400;
}
.lightbox__cta .icon { font-size: .875rem; }

/* arrows: over the image edges on small screens */
.lightbox__nav {
  position: absolute;
  inset-block-start: calc(50cqi * 579 / 1096);
  z-index: 1;
  translate: 0 -50%;
  width: 3rem;
  height: 3rem;
  color: var(--burgundy);
  background: var(--surface);
  box-shadow: var(--sh-lg);
}
.lightbox__nav .icon { font-size: .875rem; }
.lightbox__nav--prev { inset-inline-start: var(--sp-2); }
.lightbox__nav--next { inset-inline-end: var(--sp-2); }
.lightbox__nav--next .icon { rotate: 180deg; }

/* ---- Thumbnails -------------------------------------------------------- */
.lightbox__thumbs {
  display: flex;
  gap: var(--sp-3);
  max-width: 100%;
  padding: var(--sp-1) var(--sp-2);
  overflow-x: auto;
  scroll-padding-inline: var(--sp-2);
  scrollbar-width: thin;
}
.lightbox__thumb {
  display: block;
  flex: none;
  width: 5.25rem;
  overflow: clip;
  border: 2px solid var(--lb-line);
  border-radius: var(--r-12);
  opacity: .6;
  transition: opacity var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.lightbox__thumb img { width: 100%; aspect-ratio: 80 / 56; object-fit: cover; }
.lightbox__thumb[aria-current="true"] {
  opacity: 1;
  border-color: var(--amber);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--amber) 50%, transparent), var(--sh-md);
}
.lightbox .lightbox__thumb:focus-visible { border-radius: var(--r-12); opacity: 1; }
@media (hover: hover) {
  .lightbox__thumb:hover { opacity: 1; }
}

/* ---- Motion ----------------------------------------------------------------
   On load the frame scales in and the thumbnails slide in one after another (CSS only, one time).
   When the active image changes, portfolio-modal.js adds .is-swapping and the new image fades in
   (opacity only). */
@media (prefers-reduced-motion: no-preference) {
  .lightbox__frame { animation: lb-frame-in var(--t-slow) var(--ease) both; }
  .lightbox__thumbs > li { animation: lb-thumb-in var(--t-slow) var(--ease) both; }
  .lightbox__thumbs > li:nth-child(1) { animation-delay: .4s; }
  .lightbox__thumbs > li:nth-child(2) { animation-delay: .52s; }
  .lightbox__thumbs > li:nth-child(3) { animation-delay: .64s; }
  .lightbox__thumbs > li:nth-child(4) { animation-delay: .76s; }
  .lightbox__thumbs > li:nth-child(5) { animation-delay: .88s; }
  .lightbox__image.is-swapping { animation: lb-image-fade var(--t-med) var(--ease-soft) both; }
}
@keyframes lb-frame-in { from { opacity: 0; scale: .94; translate: 0 12px; } }
@keyframes lb-thumb-in { from { opacity: 0; translate: calc(var(--dir) * -28px) 0; } }
@keyframes lb-image-fade { from { opacity: 0; } }

/* ---- Phones: the thumbnail strip scrolls, so its edges fade out as a hint ---- */
@media (max-width: 40rem) {
  .lightbox__thumbs {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--sp-6), #000 calc(100% - var(--sp-6)), transparent);
    mask-image: linear-gradient(to right, transparent, #000 var(--sp-6), #000 calc(100% - var(--sp-6)), transparent);
  }
}

/* ---- ≥ 768px: content centred in the window; text and button side by side in the meta bar */
@media (min-width: 48rem) {
  .lightbox { justify-content: center; }
  .lightbox__meta {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-8);
    padding: var(--sp-5);
  }
  .lightbox__cta { flex: none; }
}

/* ---- ≥ 1200px: arrows outside the frame, as designed -------------------- */
@media (min-width: 75rem) {
  .lightbox__nav { inset-block-start: 50%; }
  .lightbox__nav--prev { inset-inline-start: -3.5rem; }
  .lightbox__nav--next { inset-inline-end: -3.5rem; }
}

/* English (LTR): previous sits on the left and next on the right, so the chevrons swap direction. */
[dir="ltr"] .lightbox__nav--prev .icon { rotate: 180deg; }
[dir="ltr"] .lightbox__nav--next .icon { rotate: 0deg; }
