/* Night-sky gallery (sky.html). The whole page, top bar included, uses a
   wider column than the rest of the site so the photos have room and the
   title lines up with the gallery's edge. */

.page-wide {
  max-width: 1128px;
}

.page-wide .lede {
  max-width: 640px;
}

.page-wide > footer {
  margin-top: 56px;
}

.sky h3:first-child {
  margin-top: 0;
}

/* ---------- Grid ---------- */

/* Without the script (or before it runs) photos wrap at roughly equal height. */
.sky-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 10px;
}

.sky-grid:not(.is-justified) > .shot {
  flex: var(--ar) 1 calc(var(--ar) * 200px);
}

/* With the script, each row fills the width and its photos share one height. */
.sky-grid.is-justified {
  flex-direction: column;
  flex-wrap: nowrap;
}

.sky-row {
  display: flex;
  gap: 10px;
}

.sky-row > .shot {
  flex: var(--ar) 1 0;
}

.shot {
  min-width: 0;
  margin: 0;
}

.shot a {
  display: block;
  overflow: hidden;
  border-radius: 4px;
  background: #0b0c0e;
}

.shot img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: var(--ar);
  object-fit: cover;
  transition:
    opacity 160ms ease,
    transform 300ms ease;
}

.shot a:hover img {
  opacity: 0.88;
  transform: scale(1.015);
}

.shot figcaption {
  margin-top: 6px;
  line-height: 1.4;
}

.shot-title {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.shot-meta {
  display: block;
  color: var(--faint);
  font-size: 12.5px;
}

/* ---------- Related research ---------- */

.sky-related {
  margin-top: 28px;
}

.page-header + .sky-related + .sky {
  margin-top: 36px;
}

.sky-card {
  max-width: 692px;
}

/* The card holds several links, so only the title is clickable. */
.sky-card:hover {
  border-color: var(--rule);
  background: none;
}

.sky-card .note-card-title {
  color: var(--text);
}

.sky-card .note-card-title:hover {
  color: var(--link);
  text-decoration: none;
}

.sky-card .note-card-text {
  margin: 0;
}

.collab {
  margin-left: 1px;
  color: var(--faint);
}

.sky > .note {
  margin-top: 28px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Viewer ---------- */

html:has(.viewer[open]) {
  overflow: hidden;
}

.viewer {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(5, 6, 8, 0.96);
  color: #e6e6e4;
}

.viewer::backdrop {
  background: rgba(5, 6, 8, 0.96);
}

.viewer figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  margin: 0;
  padding: 56px 72px 24px;
}

.viewer img {
  display: block;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.viewer figcaption {
  flex: none;
  text-align: center;
  line-height: 1.4;
}

.viewer .shot-title {
  color: #e6e6e4;
  font-size: 15px;
}

.viewer .shot-meta {
  color: #9a9fa5;
  font-size: 13px;
}

.viewer-btn {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #c9ccd0;
  cursor: pointer;
}

.viewer-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.viewer-btn:focus-visible {
  outline: 2px solid #8ab4f8;
  outline-offset: 2px;
}

.viewer-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.viewer-close {
  top: 10px;
  right: 12px;
}

.viewer-prev,
.viewer-next {
  top: 50%;
  margin-top: -22px;
}

.viewer-prev {
  left: 14px;
}

.viewer-next {
  right: 14px;
}

/* ---------- Narrow screens ---------- */

@media (max-width: 600px) {
  .sky-row {
    gap: 6px;
  }

  .sky-grid {
    gap: 12px 6px;
  }

  .shot-title {
    font-size: 13px;
  }

  .shot-meta {
    font-size: 12px;
  }

  /* Swipe to move between photos; arrows would cover the image. */
  .viewer-prev,
  .viewer-next {
    display: none;
  }

  .viewer figure {
    padding: 56px 12px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shot img {
    transition: none;
  }

  .shot a:hover img {
    transform: none;
  }
}
