:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6b6860;
  --accent: #2f5d50;
  --accent-text: #ffffff;
  --gap: 10px;
}



@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1f1e1c;
    --text: #ecebe6;
    --muted: #9c998f;
    --accent: #7fbfa9;
    --accent-text: #0f1a16;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 24px 16px 12px;
  max-width: 1400px;
  margin: 0 auto;
}
h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.01em; }
.meta { color: var(--muted); font-size: 0.875rem; }
main { max-width: 1400px; margin: 0 auto; padding: 0 16px 48px; }
.empty { color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--gap);
}
.tile {
  all: unset;
  cursor: zoom-in;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
}
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.tile:hover img { transform: scale(1.04); }
.sentinel { height: 1px; grid-column: 1 / -1; }

/* Lightbox */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.82);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 10;
  animation: fade 0.15s ease;
}
.viewer {
  position: relative;
  margin: 0;
  max-width: min(1200px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
}
.viewer img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  background: #000;
}
.viewer figcaption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
}
.viewer figcaption .meta { display: block; }
.close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.55);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.download {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 600;
}
.download:hover { filter: brightness(1.08); }

.backdrop.no-anim { animation: none; }

/* Image area with previous / next arrows */
.stage {
  position: relative;
  display: flex;
  justify-content: center;
  background: #000;
}
.nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.5);
  color: #fff;
  font-size: 34px;
  line-height: 44px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.nav:hover { background: rgb(0 0 0 / 0.75); }
.nav:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.nav.prev { left: 12px; }
.nav.next { right: 12px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.download.secondary {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--muted);
}

@media (max-width: 560px) {
  .nav { width: 40px; height: 40px; font-size: 28px; line-height: 36px; }
  .nav.prev { left: 6px; }
  .nav.next { right: 6px; }
  .viewer figcaption { flex-direction: column; align-items: stretch; }
  .actions { justify-content: stretch; }
  .actions .download { flex: 1; text-align: center; }
}

/* Slideshow progress bar along the bottom of the photo */
.progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}
.viewer.playing .progress.run { animation: progress 5s linear forwards; }
.play { cursor: pointer; font: inherit; border: 0; }

@keyframes progress { to { transform: scaleX(1); } }
@keyframes fade { from { opacity: 0; } }


@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .tile { border-radius: 4px; }
}