/* The gallery that opens: six squares on a black page; open, one picture in the middle of the screen over a shade
   of its own colours, its name under it and a strip of small pictures. */
:root {
  --page: #000000;          /* the page */
  --ink: #f5f2ec;
  --muted: #8e8a83;
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

/* while a picture is open the page under it does not scroll */
html.is-locked {
  overflow: hidden;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Jost Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.gallery {
  width: min(660px, 100%);
}

/* the drawings live here once, and are used by the squares, the open pictures and the strip */
.gallery__sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.gallery__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery__grid li {
  min-width: 0;
}

.thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #151515;
  color: inherit;
  font: inherit;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}

.thumb__art {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.thumb__art svg,
.mini svg,
.slide__frame svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* the name, from the bottom of the square under the pointer */
.thumb__title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 30px 12px 11px;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.62));
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (hover: hover) {
  .thumb:hover .thumb__art {
    transform: scale(1.06);
  }

  .thumb:hover .thumb__title {
    opacity: 1;
    transform: none;
  }
}

.thumb:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.thumb:focus-visible .thumb__title {
  opacity: 1;
  transform: none;
}

/* the focus goes back to the square when the viewer closes: its ring shows only to who uses the keys */
html[data-using='pointer'] .thumb:focus-visible {
  outline: none;
}

html[data-using='pointer'] .thumb:focus-visible:not(:hover) .thumb__title {
  opacity: 0;
  transform: translateY(8px);
}

/* the square whose picture is open stays empty, ready to take it back */
.thumb.is-away {
  visibility: hidden;
}

.gallery__hint {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

@media (max-width: 560px) {
  .gallery__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}

/* ---------------------------------------------------------------- the viewer */
.viewer {
  --chrome: 0;              /* how much the name, the strip and the buttons show: set by the script */
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.viewer__shade {
  position: absolute;
  inset: 0;
  background: #000000;
  opacity: 0;
}

.viewer__track {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  will-change: transform;
}

.slide {
  position: absolute;
  top: 0;
  height: 100%;
  margin: 0;
}

.slide__frame {
  position: absolute;
  overflow: hidden;
  background: #151515;
  cursor: grab;
}

.viewer__caption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 86px;
  text-align: center;
  pointer-events: none;
  opacity: var(--chrome);
  transform: translateY(calc((1 - var(--chrome)) * 14px));
}

.viewer__title {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.viewer__line {
  margin: 6px 0 0;
  font-size: 15px;
  color: rgba(245, 242, 236, 0.66);
}

.viewer__strip {
  position: absolute;
  left: 50%;
  bottom: 22px;
  display: flex;
  gap: 8px;
  opacity: var(--chrome);
  transform: translate(-50%, calc((1 - var(--chrome)) * 10px));
}

.mini {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #151515;
  opacity: 0.42;
  cursor: pointer;
  transition: opacity 0.3s;
  -webkit-tap-highlight-color: transparent;
}

.mini[aria-current='true'] {
  opacity: 1;
}

@media (hover: hover) {
  .mini:hover {
    opacity: 0.85;
  }
}

.mini:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* the ring around the small picture that is open: moved by the script */
.viewer__ring {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 52px;
  height: 52px;
  border: 2px solid var(--ink);
  border-radius: 13px;
  pointer-events: none;
}

.viewer__btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  cursor: pointer;
  opacity: var(--chrome);
  transition: background-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

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

@media (hover: hover) {
  .viewer__btn:hover {
    background: rgba(255, 255, 255, 0.22);
  }
}

.viewer__btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.viewer__close {
  top: 12px;
  right: 12px;
}

/* in the middle of the space for the picture: 64 pixels over it, 160 under it (as in the script) */
.viewer__nav {
  top: calc((100% + 64px - 160px) / 2);
  margin-top: -22px;
}

.viewer__nav--prev {
  left: 16px;
}

.viewer__nav--next {
  right: 16px;
}

.viewer__nav:disabled {
  opacity: calc(var(--chrome) * 0.25);
  cursor: default;
}

@media (hover: none), (max-width: 560px) {
  .viewer__nav {
    display: none;
  }
}
