:root {
  --paper: #f8f4ee;
  --ink: #2c2723;
  --muted: #7d7268;
  --accent: #8a6a46;
  --line: #e4dbcf;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}

h1 {
  margin: 0;
  font: 400 clamp(2rem, 6vw, 3.25rem)/1.1 var(--serif);
  letter-spacing: 0.01em;
}

a { color: inherit; }

.button,
button[type="submit"] {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.7rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: 500 1rem/1.2 var(--sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button small { font-size: 0.75rem; opacity: 0.85; font-weight: 400; }
.button:hover, button[type="submit"]:hover { filter: brightness(1.08); }

/* Login */
.login {
  max-width: 26rem;
  margin: 18vh auto 0;
  padding: 0 1.5rem;
  text-align: center;
}
.lead { color: var(--muted); margin: 1rem 0 2rem; }
.login form { display: grid; gap: 0.75rem; text-align: left; }
.login label { font-size: 0.875rem; color: var(--muted); }
.login input {
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #fff;
  font: inherit;
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login button { justify-self: stretch; margin-top: 0.5rem; }
.error { margin: 0; color: #a3402f; font-size: 0.875rem; }

/* Headers */
.page-header {
  display: grid;
  justify-items: center;
  gap: 1.25rem;
  padding: 3rem 1.5rem 2rem;
  text-align: center;
}
.back { justify-self: start; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--ink); }

/* Album overview */
.albums {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: 1.5rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}
.album-card { display: grid; gap: 0.25rem; text-decoration: none; }
.album-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 0.5rem;
  background: var(--line);
  transition: transform 0.2s ease;
}
.album-card:hover img { transform: scale(1.015); }
.album-title { margin-top: 0.5rem; font: 1.375rem/1.2 var(--serif); }
.album-meta { color: var(--muted); font-size: 0.875rem; }

/* Justified photo grid: every tile grows in proportion to its aspect ratio,
   so tiles in one row share a height. */
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0 0.375rem 4rem;
}
.grid::after { content: ""; flex-grow: 1000000; }
.grid a {
  flex-grow: calc(var(--ratio) * 100);
  flex-basis: calc(var(--ratio) * 14rem);
  aspect-ratio: var(--ratio);
  background: var(--line);
}
.grid img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 40rem) {
  .grid a { flex-basis: calc(var(--ratio) * 8rem); }
}

/* Lightbox */
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #111;
  color: #fff;
}
.lightbox::backdrop { background: #111; }
.lightbox[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
body:has(.lightbox[open]) { overflow: hidden; }
.lightbox-track {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.lightbox-track::-webkit-scrollbar { display: none; }
.lightbox-slide {
  flex: 0 0 100%;
  margin: 0;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}
.lightbox-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 1rem;
}
@media (max-width: 40rem) {
  .lightbox-slide img { padding: 0; }
}
.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
}
.lightbox-counter { color: #bbb; font-size: 0.875rem; min-width: 4rem; }
.lightbox button {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}
.lightbox-bar button { min-width: 4rem; text-align: right; }
.lightbox-nav {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  padding: 1.5rem 1rem;
  font-size: 2.5rem !important;
  opacity: 0.7;
}
.lightbox-nav:hover { opacity: 1; }
.lightbox-nav.prev { left: 0; }
.lightbox-nav.next { right: 0; }
@media (hover: none) {
  .lightbox-nav { display: none; }
}
