:root {
  --bg: #f7f7f5;
  --fg: #161616;
  --muted: #777774;
  --line: rgba(20, 20, 20, .11);
  --viewer-bg: #0e0e0e;
  --viewer-fg: #f3f3f1;
  --viewer-muted: #aaa9a5;
  --header-h: 64px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, a { -webkit-tap-highlight-color: transparent; }

.site-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 3vw, 40px);
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: inherit;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.photo-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

main { padding: clamp(14px, 2.4vw, 34px); }
.status {
  min-height: 42vh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}
.status[hidden] { display: none; }

.gallery {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(3px, .55vw, 8px);
  max-width: 1800px;
  margin: 0 auto;
}

.tile {
  border: 0;
  padding: 0;
  margin: 0;
  appearance: none;
  background: #e8e8e5;
  overflow: hidden;
  cursor: zoom-in;
  aspect-ratio: 1 / 1;
  position: relative;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 220ms ease, opacity 180ms ease;
  opacity: 0;
}
.tile img.loaded { opacity: 1; }
@media (hover: hover) {
  .tile:hover img { transform: scale(1.018); }
}
.tile:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.gallery-sentinel {
  width: 100%;
  height: 1px;
}
.gallery-sentinel[hidden] { display: none; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--viewer-bg);
  color: var(--viewer-fg);
  visibility: hidden;
  opacity: 0;
  transition: opacity 150ms ease, visibility 150ms linear;
}
.viewer.open { visibility: visible; opacity: 1; }
body.viewer-open { overflow: hidden; }

.viewer-topbar {
  position: absolute;
  inset: 0 0 auto 0;
  height: 64px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 12px;
  z-index: 5;
  pointer-events: none;
}
.icon-button {
  pointer-events: auto;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.22);
  color: white;
  font-size: 34px;
  font-weight: 200;
  line-height: 1;
  cursor: pointer;
}

.viewer-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px 68px 18px;
  overflow: hidden;
  position: relative;
  touch-action: none;
  overscroll-behavior: contain;
}
.viewer-stage img {
  max-width: 100%;
  max-height: calc(100dvh - 132px);
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  opacity: 0;
  transition: opacity 160ms ease;
  transform-origin: center center;
  will-change: transform;
}
.viewer-stage img.loaded { opacity: 1; }
.viewer-stage.zoomed { cursor: grab; }
.viewer-stage.zoomed.dragging { cursor: grabbing; }
.viewer-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  pointer-events: none;
  color: #8e8e8a;
  font-size: 12px;
  letter-spacing: .04em;
}
.viewer-loading[hidden] { display: none; }

.nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.76);
  width: 60px;
  height: 96px;
  font-size: 54px;
  font-weight: 200;
  cursor: pointer;
}
.nav-button:disabled { opacity: .15; cursor: default; }
.nav-prev { left: 0; }
.nav-next { right: 0; }

.meta {
  min-height: 96px;
  padding: 16px clamp(18px, 3vw, 42px) max(18px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.12);
  background: rgba(14,14,14,.96);
}
.meta-primary {
  font-size: clamp(13px, 1.25vw, 16px);
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  min-height: 23px;
}
.meta-secondary {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
  color: var(--viewer-muted);
  font-size: 11px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1400px) {
  .gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  :root { --header-h: 54px; }
  .site-header { padding: 0 14px; }
  .brand { font-size: 12px; }
  main { padding: 4px; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
  .viewer-stage { padding: 54px 0 10px; }
  .viewer-stage img { max-height: calc(100dvh - 168px); max-width: 100vw; }
  .nav-button { display: none; }
  .meta { min-height: 112px; padding: 13px 14px max(14px, env(safe-area-inset-bottom)); }
  .meta-primary { font-size: 13px; }
  .meta-secondary { font-size: 10.5px; gap: 3px 12px; }
}

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