/* ==========================================================================
   Lightbox — click an image on a project page to see it larger. Used with
   lightbox.js on the company pages (thingtesting.html and airtame.html)
   and their case studies, loaded after site.css.

   A plain dialog the colour of the page, so the picture hangs on an empty
   wall, framed the way every page is. Along the top, where the site's name
   and the nav are, the project the picture belongs to with which of its
   pictures this is, and "Close". Along the bottom, where the footer has
   Copenhagen and the ways to get in touch, the picture's caption, and
   Previous and Next.
   ========================================================================== */

/* The pictures that open. They can be reached from the keyboard too. */
.is-zoomable {
  cursor: zoom-in;
}

.is-zoomable:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* Nothing behind it scrolls while it's open. */
html:has(.lightbox[open]) {
  overflow: hidden;
}

.lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0 var(--margin);
  overflow: hidden;
  overscroll-behavior: contain;
  border: 0;
  background: var(--color-background);
  color: var(--color-text-primary);
  cursor: zoom-out; /* a click anywhere closes it */
  font-size: var(--text-label-size);
  font-weight: 500;
  line-height: var(--text-label-line-height);
}

.lightbox::backdrop {
  background: transparent;
}

/* The dialog itself takes focus when it opens, so the arrow keys work
   straight away; a ring around the whole window would only be noise. */
.lightbox:focus-visible {
  outline: none;
}

/* Three rows: a bar along the top, the picture, a bar along the bottom.
   The bars are as tall as the header, 16px either side of a 20px line,
   unless a caption needs a second line on a phone. */
.lightbox[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
}

.lightbox-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gutter);
  min-width: 0;
  padding: 16px 0;
}

/* The picture at its own shape, as large as fits between the bars. */
.lightbox-image {
  place-self: center;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
}

/* A TV screenshot keeps its bezel. */
.lightbox-image.is-screen {
  border: 3px solid var(--color-bezel);
}

/* Top left: the project's name, then which of its pictures this is in a
   lighter grey, the way years follow a title. */
.lightbox-place {
  display: flex;
  gap: 6px;
  min-width: 0;
  margin: 0;
  color: var(--color-text-secondary);
}

/* Bottom left: the caption, in grey like the captions on the page. It has
   the bar's width, so even Airtame's longest stays on one line from 1024px
   up and the frame keeps still as you step; on a phone it wraps rather
   than being cut short. */
.lightbox-caption {
  min-width: 0;
  margin: 0;
  color: var(--color-text-secondary);
}

.lightbox-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lightbox-count {
  flex: none;
  color: var(--color-text-muted);
}

.lightbox-steps {
  display: flex;
  flex: none;
  gap: 16px; /* as between the nav's two pages */
}

.lightbox-steps[hidden] {
  display: none;
}

/* Close, Previous and Next: grey, darkening when you point at them. */
.lightbox-close,
.lightbox-step {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text-secondary);
  font: inherit;
  cursor: pointer;
  transition: color 0.125s ease-out;
}

@media (hover: hover) {
  .lightbox-close:hover,
  .lightbox-step:hover {
    color: var(--color-text-primary);
  }
}

.lightbox-close:focus-visible,
.lightbox-step:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Opening, the picture grows out of its place on the page as the page
   fades to the wall behind it; closing, it settles back. Stepping, one
   picture becomes the next. All in 400ms, easing in and out. With reduced
   motion lightbox.js doesn't name the picture, so the page only
   cross-fades. */
::view-transition-group(lightbox) {
  animation-duration: 0.4s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

:root.is-lightboxing::view-transition-old(root),
:root.is-lightboxing::view-transition-new(root) {
  animation-duration: 0.4s;
}
