:root {
  --bg: #ffffff;
  --ink: #24252a;
  --ink-soft: #6b6d76;
  --ink-faint: #9a9ca4;
  --rule: #e9e9ec;
  --gap: 5px;
  --row: 220px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---------- Header ---------- */

.hero {
  text-align: center;
  padding: clamp(3rem, 9vw, 6rem) 1.25rem clamp(2.5rem, 6vw, 4rem);
  max-width: 46rem;
  margin: 0 auto;
}

.portrait {
  width: clamp(150px, 34vw, 220px);
  height: clamp(150px, 34vw, 220px);
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto clamp(1.5rem, 4vw, 2.25rem);
  background: #f2f2f4;
}

.eyebrow {
  margin: 0 0 0.9rem;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.name {
  margin: 0 0 0.7rem;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: clamp(1.75rem, 6vw, 3rem);
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.dates {
  margin: 0 0 1.75rem;
  color: var(--ink-soft);
  font-size: clamp(0.9rem, 2.6vw, 1rem);
  letter-spacing: 0.04em;
}

.tagline {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: clamp(1.05rem, 3.2vw, 1.3rem);
  color: var(--ink-soft);
}

.tagline::before,
.tagline::after {
  content: "";
  display: block;
  width: 34px;
  height: 1px;
  background: var(--rule);
  margin: 1.75rem auto;
}

.tagline::after { margin-bottom: 0; }

/* ---------- Justified album ---------- */

.album {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  padding: 0 var(--gap);
  max-width: 1600px;
  margin: 0 auto;
}

/* Flexbox justified rows: each tile grows in proportion to its aspect ratio,
   so a filled row stretches to the full width with a common height. The last
   row is kept from stretching by a run of zero-height spacers (see app.js). */
.album .tile {
  position: relative;
  height: var(--row);
  flex: 1 1 auto;
  /* Without this, a wide photo's intrinsic width becomes the tile's minimum and
     it refuses to shrink, pushing the row past a narrow viewport. */
  min-width: 0;
  margin: 0;
  overflow: hidden;
  background: #f2f2f4;
  cursor: zoom-in;
  border: 0;
  padding: 0;
  border-radius: 2px;
}

.album .tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 320ms ease;
}

.album .tile img.loaded { opacity: 1; }

.album .spacer {
  height: 0;
  flex-grow: 1;
  pointer-events: none;
}

@media (hover: hover) {
  .album .tile:hover img { transform: scale(1.03); }
  .album .tile img { transition: opacity 320ms ease, transform 420ms ease; }
}

.album .tile:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

@media (max-width: 700px) {
  :root { --row: 140px; --gap: 4px; }
}

.notice {
  text-align: center;
  color: var(--ink-soft);
  padding: 3rem 1.25rem;
}

/* ---------- Footer ---------- */

.footer {
  max-width: 44rem;
  margin: 0 auto;
  padding: clamp(3.5rem, 9vw, 6rem) 1.5rem clamp(3rem, 7vw, 5rem);
  text-align: center;
  color: var(--ink-soft);
}

.thanks {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  text-wrap: pretty;
}

.footer-message {
  margin: 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 0.98rem;
  color: var(--ink-faint);
}

/* ---------- Back to top ---------- */

.to-top {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  color: var(--ink-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.09);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 40;
}

.to-top[hidden] { display: none; }
.to-top.show { opacity: 1; transform: none; }
.to-top svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: #0c0c0e;
  z-index: 50;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 200ms ease;
}

.lightbox[hidden] { display: none; }
.lightbox.open { opacity: 1; }

.lb-stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: clamp(0.5rem, 3vw, 2.5rem);
  pointer-events: none;
}

.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 200ms ease;
}

.lb-stage img.ready { opacity: 1; }

.lb-close,
.lb-nav {
  position: absolute;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: color 160ms ease;
  z-index: 2;
}

.lb-close:hover,
.lb-nav:hover,
.lb-close:focus-visible,
.lb-nav:focus-visible { color: #fff; }

.lb-close {
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.75rem, env(safe-area-inset-right));
  width: 46px;
  height: 46px;
}

.lb-close svg { width: 26px; height: 26px; fill: currentColor; }

.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 76px;
}

.lb-nav svg { width: 34px; height: 34px; fill: currentColor; }
.lb-prev { left: max(0.25rem, env(safe-area-inset-left)); }
.lb-next { right: max(0.25rem, env(safe-area-inset-right)); }

.lb-count {
  position: absolute;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  color: rgba(255, 255, 255, 0.42);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

@media (max-width: 700px) {
  .lb-nav { width: 44px; height: 64px; }
  .lb-nav svg { width: 27px; height: 27px; }
}

body.lb-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .album .tile:hover img { transform: none; }
}
