:root {
  --gap: 10px;
  --max-width: 2000px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 24px 48px;
  font-family: "Lucida Console", Monaco, monospace;
  color: #555;
  background: #fff;
}

.site-header {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 0 24px;
}

.site-header h1 {
  font-size: .8rem;
  font-weight: 600;
  margin: 0 0 6px;
}

.site-header .links {
  font-size: 0.8rem;
  margin: 0;
}

.site-header a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.site-header a:hover {
  opacity: 0.6;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
}

/*
  Grid masonry: a fine row unit (grid-auto-rows) plus gallery.js
  setting each item's grid-row-end span from its real aspect
  ratio. dense packing closes gaps left by 2-column-wide items.
  Landscape images are randomly given .span-2 in gallery.js.
*/
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 10px;
  gap: var(--gap);
  grid-auto-flow: row dense;
}

.gallery-item {
  overflow: hidden;
}

.gallery-item.span-2 {
  grid-column: span 2;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  /* Row spans are computed to match the image's real aspect
     ratio, so this only ever absorbs a few px of rounding —
     it's a safety net, not a crop. */
  object-fit: cover;
  border-radius: 2px;
  background: #f2f2f2; /* placeholder color while loading */
}

@media (max-width: 1300px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .gallery {
    grid-template-columns: 1fr;
  }
  .gallery-item.span-2 {
    grid-column: span 1;
  }
  body {
    padding: 0 16px 32px;
  }
}
