.landing-gallery {
  background: radial-gradient(ellipse at 17% 12%, #122b3c 0%, transparent 48%), var(--surface);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(15px, 2.1vw, 26px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery-item {
  min-width: 0;
}

.gallery-frame {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  margin: 0;
}

.gallery-media {
  position: relative;
  min-height: 0;
  aspect-ratio: 1;
  overflow: hidden;
  background: #081019;
}

.gallery-media img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.gallery-media::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 15%;
  background: linear-gradient(transparent, #081019aa);
  pointer-events: none;
}

.gallery-frame figcaption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
}

.gallery-caption {
  min-width: 0;
  padding-block: 5px;
  color: var(--text);
  font: 550 clamp(14px, 1.4vw, 17px) / 1.3 var(--display-font);
  overflow-wrap: anywhere;
}

.gallery-enlarge {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-inline-end: 3px;
  text-decoration: none;
}

.gallery-enlarge::after {
  content: '';
  position: absolute;
  inset: 0;
  cursor: zoom-in;
}

.gallery-enlarge:focus-visible {
  outline: none;
}

.gallery-enlarge:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.gallery-enlarge-label {
  display: none;
  font-size: 14px;
}

.gallery-expand-icon {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.gallery-expand-icon::before,
.gallery-expand-icon::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  border: solid currentColor;
}

.gallery-expand-icon::before {
  top: 0;
  right: 0;
  border-width: 1px 1px 0 0;
}

.gallery-expand-icon::after {
  bottom: 0;
  left: 0;
  border-width: 0 0 1px 1px;
}

@media (hover: hover) {
  .gallery-frame:hover .gallery-media img {
    filter: brightness(1.11);
  }

  .gallery-frame:hover .gallery-caption {
    color: var(--accent);
  }
}

@media (min-width: 1120px) {
  .gallery-grid {
    grid-template-columns: minmax(0, 1.42fr) repeat(4, minmax(0, 1fr));
  }

  .gallery-item:first-child {
    grid-row: span 2;
  }

  .gallery-item:first-child .gallery-media {
    aspect-ratio: auto;
    min-height: 0;
  }

  .gallery-item:first-child .gallery-caption {
    font-size: 20px;
  }

  .gallery-enlarge-label {
    display: inline;
  }
}

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

.gallery-viewer-open {
  overflow: hidden;
}

.gallery-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  border: 0;
  background: radial-gradient(ellipse at 50% 46%, #142c3e 0%, transparent 67%), #071019;
  color: var(--text);
}

.gallery-viewer:not([open]) {
  display: none;
}

.gallery-viewer::backdrop {
  background: #071019;
}

.gallery-viewer-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.gallery-viewer-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: clamp(8px, 1.5vw, 23px);
  padding-block: max(7px, env(safe-area-inset-top)) 7px;
  padding-inline: clamp(12px, 3.7vw, 58px);
}

.gallery-viewer-header h2 {
  position: relative;
  margin: 0;
  padding-left: 13px;
  font-size: clamp(17px, 2.2vw, 28px);
  font-weight: 640;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.gallery-viewer-header h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.16em;
  height: 0.85em;
  width: 2px;
  background: var(--accent);
}

.gallery-viewer-count {
  color: #b9d7e3;
  font: 550 14px / 1.3 var(--display-font);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.gallery-viewer-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  justify-self: center;
  width: min(100%, 900px);
  gap: clamp(14px, 3vw, 55px);
  padding: 0 clamp(12px, 3.7vw, 58px) max(13px, env(safe-area-inset-bottom));
}

.gallery-viewer-picture {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  min-width: 0;
  min-height: 0;
  touch-action: pan-y pinch-zoom;
}

.gallery-viewer-picture img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}

.gallery-viewer-control {
  display: grid;
  place-items: center;
  align-self: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--accent);
  font:
    500 31px / 1 system-ui,
    sans-serif;
  cursor: pointer;
}

.gallery-viewer-close {
  width: 44px;
  height: 44px;
  font-size: 27px;
}

.gallery-viewer-control:hover,
.gallery-viewer-control:focus-visible {
  color: var(--text);
  background: #163041;
}

.gallery-viewer-control:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

@media (max-width: 700px) {
  .gallery-viewer-header {
    gap: 8px;
  }

  .gallery-viewer-stage {
    grid-template: minmax(0, 1fr) auto / repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding-inline: 10px;
    padding-bottom: max(5px, env(safe-area-inset-bottom));
  }

  .gallery-viewer-picture {
    grid-area: 1 / 1 / 2 / -1;
  }

  .gallery-viewer-prev,
  .gallery-viewer-next {
    grid-row: 2;
    width: 100%;
  }

  .gallery-viewer-prev {
    grid-column: 1;
  }

  .gallery-viewer-next {
    grid-column: 2;
  }
}
