:root {
  color-scheme: light;
  --paper: #fff;
  --ink: #1c1e21;
  --muted: #71767d;
  --line: #e4e6e9;
  --accent: #0063dc;
  --gutter: clamp(0.75rem, 2.5vw, 2rem);
  --row-height: 220px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

body.lightbox-open {
  overflow: hidden;
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

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

.page-heading,
.album-heading {
  padding: 1.5rem var(--gutter) 1.25rem;
}

.page-heading__row,
.album-heading__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
}

.page-heading__updated,
.album-heading__dates {
  color: var(--muted);
  font-size: 0.8rem;
}

.album-heading__count {
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  background: var(--line);
  font-size: 0.75rem;
  font-weight: 600;
}

.album-heading__dates:empty {
  display: none;
}

.page-heading h1,
.album-heading h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.page-heading p {
  max-width: 60ch;
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.page-heading p:empty {
  display: none;
}

.album-heading__back {
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

.album-heading__back a {
  color: var(--muted);
  text-decoration: none;
}

.album-heading__back a:hover {
  text-decoration: underline;
}

.album-heading__description {
  max-width: 60ch;
  margin: 0.6rem 0 0;
  font-size: 0.95rem;
}

.album-heading__description:empty {
  display: none;
}

.album-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.5rem 1rem;
  padding: 0.5rem var(--gutter) 3rem;
}

.album-card {
  display: block;
  text-decoration: none;
}

.album-card__cover {
  position: relative;
  display: block;
}

.album-card__count {
  position: absolute;
  right: 0.35rem;
  bottom: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  background: rgb(0 0 0 / 0.62);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
}

.album-card img,
.album-card__placeholder {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: 4px;
  background: var(--line);
  object-fit: cover;
}

.album-card:hover img {
  opacity: 0.93;
}

.album-card__title {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.album-card:hover .album-card__title {
  text-decoration: underline;
}

.album-card__dates {
  display: block;
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.album-card__dates:empty {
  display: none;
}

.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0.25rem var(--gutter) 3rem;
}

.photo-grid::after {
  content: "";
  flex-grow: 1000000;
  flex-basis: 0;
}

.photo {
  min-width: 0;
  margin: 0;
  flex-grow: calc(var(--ar) * 100);
  flex-basis: calc(var(--ar) * var(--row-height));
}

.photo button {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: var(--line);
  cursor: zoom-in;
}

.photo__caption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: -webkit-box;
  overflow: hidden;
  padding: 1.75rem 0.6rem 0.45rem;
  color: #fff;
  background: linear-gradient(transparent, rgb(0 0 0 / 62%));
  font-size: 0.8rem;
  line-height: 1.35;
  text-align: left;
  opacity: 0;
  transition: opacity 150ms ease;
  pointer-events: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.photo button:hover .photo__caption,
.photo button:focus-visible .photo__caption {
  opacity: 1;
}

.photo img {
  width: 100%;
  height: 100%;
  aspect-ratio: var(--ar);
  object-fit: cover;
  transition: opacity 150ms ease;
}

.photo button:hover img {
  opacity: 0.93;
}

.not-found {
  display: flex;
  min-height: 80vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  text-align: center;
}

.not-found p {
  color: var(--muted);
  font-size: 0.85rem;
}

.not-found h1 {
  margin: 0 0 1.5rem;
  font-size: 2rem;
  font-weight: 700;
}

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: #f2f3f5;
  background: #121316;
}

.lightbox::backdrop {
  background: #121316;
}

.lightbox__frame {
  display: grid;
  grid-template:
    "top top" 3rem
    "stage panel" minmax(0, 1fr)
    "thumbs panel" auto
    / minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  padding: 0 var(--gutter);
  column-gap: var(--gutter);
}

.lightbox__top {
  display: flex;
  grid-area: top;
  align-items: center;
  justify-content: space-between;
}

.lightbox__counter {
  color: #a9adb4;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.lightbox__icon-button {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  place-items: center;
  color: #f2f3f5;
  background: none;
  cursor: pointer;
}

.lightbox__icon-button:hover {
  background: rgb(255 255 255 / 12%);
}

.lightbox__icon-button svg {
  width: 1.2rem;
  height: 1.2rem;
}

.lightbox__stage {
  position: relative;
  display: flex;
  grid-area: stage;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.lightbox__stage img[data-lightbox-image] {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform 200ms ease;
}

.lightbox__image--zoomed {
  cursor: zoom-out !important;
  transform: scale(var(--zoom-scale, 2));
}

.lightbox__nav {
  position: absolute;
  z-index: 1;
  top: 50%;
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  place-items: center;
  color: #f2f3f5;
  background: rgb(18 19 22 / 55%);
  cursor: pointer;
  opacity: 0.75;
  transform: translateY(-50%);
  transition: opacity 150ms ease;
}

.lightbox__nav:hover {
  opacity: 1;
}

.lightbox__nav svg {
  width: 1.3rem;
  height: 1.3rem;
}

.lightbox__nav--previous {
  left: 0.5rem;
}

.lightbox__nav--next {
  right: 0.5rem;
}

.lightbox__panel {
  grid-area: panel;
  width: 17rem;
  padding: 0.25rem 0 1rem;
  overflow-y: auto;
  font-size: 0.85rem;
}

.lightbox__panel[hidden] {
  display: none;
}

.lightbox__description {
  margin: 0 0 1.1rem;
  line-height: 1.5;
}

.lightbox__meta {
  display: grid;
  gap: 0.55rem;
  color: #a9adb4;
  font-size: 0.8rem;
}

.lightbox__meta-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.lightbox__meta-row svg {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
  opacity: 0.85;
  transform: translateY(0.12rem);
}

.lightbox__map {
  position: relative;
  display: block;
  height: 10rem;
  margin-top: 1.1rem;
  border-radius: 6px;
  overflow: hidden;
  background: #2a2c31;
}

.lightbox__map img {
  position: absolute;
  top: calc(50% + var(--tile-y));
  left: calc(50% + var(--tile-x));
  width: 256px;
  max-width: none;
  height: 256px;
}

.lightbox__map-marker {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 0.7rem;
  height: 0.7rem;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgb(0 0 0 / 45%);
  transform: translate(-50%, -50%);
}

.lightbox__map-attribution {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 0;
  padding: 0.1rem 0.35rem;
  color: #d5d7db;
  background: rgb(18 19 22 / 55%);
  font-size: 0.6rem;
}

.lightbox__thumbs {
  display: flex;
  grid-area: thumbs;
  align-items: center;
  gap: 4px;
  padding: 0.6rem 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.lightbox__thumbs button {
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: none;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 150ms ease;
}

.lightbox__thumbs button:hover {
  opacity: 0.85;
}

.lightbox__thumbs img {
  display: block;
  width: 3rem;
  height: 3rem;
  border-radius: 3px;
  object-fit: cover;
}

.lightbox__thumb--active {
  opacity: 1 !important;
  outline: 2px solid #f2f3f5;
  outline-offset: 1px;
}

@media (max-width: 640px) {
  :root {
    --row-height: 150px;
  }

  .album-list {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem 0.75rem;
  }

  .lightbox__frame {
    grid-template:
      "top" 3rem
      "stage" minmax(0, 1fr)
      "thumbs" auto
      "panel" auto
      / minmax(0, 1fr);
  }

  .lightbox__panel {
    width: auto;
    max-height: 32dvh;
    padding-bottom: 1.25rem;
  }

  .lightbox__thumbs img {
    width: 2.5rem;
    height: 2.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
