:root {
  --bg: #f4f1ea;
  --fg: #1c1a17;
  --muted: #6f6a60;
  --line: #ddd7ca;
  --accent: #8a7a5c;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.10);
  --maxw: 1400px;
  --gap: clamp(.75rem, 1.6vw, 1.25rem);
  --page-pad: clamp(.75rem, 3vw, 2.5rem);
}

/* Every full-width section uses this, so the left and right edges agree from
   page to page. Tiles and cards then inset by half a gap, matching the gutter
   between them. */
.measure {
  width: min(100% - 2 * var(--page-pad), var(--maxw));
  margin-inline: auto;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --fg: #ece8e0;
    --muted: #968f82;
    --line: #2a2724;
    --accent: #b9a67f;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Top bar ----------
   Scrolls away with the page — deliberately not sticky. Set in the same
   monospace caps as the lightbox keywords, so it reads like the type stamped
   along a film rebate. */
.topbar {
  display: flex;
  justify-content: center;
  padding: clamp(1.5rem, 3.5vw, 2.5rem) 1rem 0;
}

.topbar ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(1.25rem, 4vw, 3rem);
  list-style: none;
  margin: 0;
  padding: 0;
}

.topbar a {
  display: inline-block;
  padding-bottom: .3rem;
  border-bottom: 1px solid transparent;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .7rem;
  letter-spacing: .24em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  transition: color .2s, border-color .2s;
}

.topbar a:hover { color: var(--fg); }

.topbar a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: currentColor;
}

/* ---------- Landing ----------
   One photograph filling the viewport on a dark ground, a single line of type
   centred over it, nothing to scroll. */
body.landing {
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #121110;
  color: #f7f5f0;
}

/* min-height: 0 allows the photograph to shrink to the viewport; a flex item
   otherwise refuses to go below its content size. */
.hero {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Transparent wrapper: takes the image's box exactly, so the whole frame is
   clickable without affecting how it sizes. */
.hero-photo {
  display: flex;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
}

/* contain — the whole frame, fitted to whichever axis constrains it. */
.hero img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Scrim: enough to carry the type over any photograph without flattening it. */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.45), rgba(0,0,0,.12) 32%, rgba(0,0,0,.20) 70%, rgba(0,0,0,.55));
}

/* Centred over the photograph. pointer-events: none so the whole frame stays
   clickable through the type. */
.hero-content {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.5rem;
  text-align: center;
  pointer-events: none;
}

.hero-title {
  margin: 0;
  font-size: clamp(2.6rem, 8vw, 4.75rem);
  font-weight: 500;
  letter-spacing: -.01em;
  line-height: 1.02;
  color: #f7f5f0;
  text-shadow: 0 1px 24px rgba(0,0,0,.45);
}

/* ---------- Masthead ---------- */
.masthead {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4.5rem) 1.5rem clamp(2rem, 5vw, 3.5rem);
  text-align: center;
}

.masthead h1 {
  margin: 0;
  font-size: clamp(2.6rem, 8vw, 4.75rem);
  font-weight: 500;
  letter-spacing: -.01em;
  line-height: 1.02;
}

.intro {
  margin: 1.4rem auto 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 1.02rem;
}

/* ---------- Gallery ----------
   Fixed columns. Photos keep their natural height and settle into whichever
   column is shortest, biased toward left-to-right order so a chronological
   sequence still reads in order.

   No horizontal padding here. Masonry positions tiles absolutely, so their
   percentage widths resolve against this element's padding box, while the
   static .grid-sizer resolves against its content box. Any padding makes the
   two disagree and the tiles overflow their column. The page gutter comes from
   width instead. */
.gallery {
  position: relative;
  padding: 1rem 0 2rem;
}

/* Column widths are plain percentages: calc() division by a custom property is
   invalid at computed-value time in some engines, which drops width to auto. */
.gallery .grid-sizer,
.gallery .tile {
  width: 50%;
}

@media (min-width: 700px) {
  .gallery .grid-sizer,
  .gallery .tile {
    width: 33.3333%;
  }
}

.gallery .tile {
  float: left; /* left-to-right flow when JS is unavailable */
  /* The gutter is padding inside each tile, so spacing is equal in every
     direction. border-box keeps the columns tiling the width exactly. */
  padding: 0 calc(var(--gap) / 2) var(--gap);
}

.gallery .grid-sizer {
  height: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

/* Contains the floats when JS is unavailable. */
.gallery::after {
  content: "";
  display: block;
  clear: both;
}

.tile {
  display: block;
  margin: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  transition: transform .35s cubic-bezier(.2,.7,.2,1);
}

.tile:hover,
.tile:focus-visible {
  transform: translateY(-3px);
  outline: none;
}

.tile img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
  background: var(--line);
  box-shadow: var(--shadow);
  transition: box-shadow .35s;
}

.tile:hover img,
.tile:focus-visible img {
  box-shadow: 0 4px 10px rgba(0,0,0,.12), 0 16px 40px rgba(0,0,0,.18);
}

/* ---------- Album index ---------- */
.cards {
  /* Half-gap inset matches the padding inside each masonry tile, so photographs
     and cards begin at exactly the same x. */
  padding: 1rem calc(var(--gap) / 2) 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: clamp(1.25rem, 3vw, 2.5rem);
}

.card { text-decoration: none; display: block; }

.card-img {
  display: block;
  overflow: hidden;
  border-radius: 3px;
  background: var(--line);
  box-shadow: var(--shadow);
  aspect-ratio: 4 / 3;
}

.card-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s cubic-bezier(.2,.7,.2,1);
}

.card:hover .card-img img { transform: scale(1.03); }

.card-meta { display: block; padding-top: .85rem; text-align: center; }

.card-title { display: block; font-size: 1.25rem; }

.card-count {
  display: block;
  margin-top: .25rem;
  font-size: .68rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- Footer / links ---------- */
.more {
  padding: 0 calc(var(--gap) / 2) 1rem;
  text-align: center;
  font-size: .72rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.more a { text-decoration: none; color: var(--accent); }
.more a:hover { text-decoration: underline; }

.footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: .82rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(.5rem, 3vw, 2.5rem);
  background: rgba(12,11,10,.94);
  opacity: 0;
  transition: opacity .25s ease;
}

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

.lb-figure {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

.lb-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 86vh;
  overflow: hidden;
}

#lb-img {
  max-width: 100%;
  max-height: 86vh;
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  background: #222;
  cursor: zoom-in;
}

/* Zoomed: a scrollable viewport over the full-size image, so trackpad, wheel
   and touch panning all work natively. */
.lb-stage.zoomed {
  width: 100%;
  height: 86vh;
  max-height: 86vh;
  overflow: auto;
  align-items: flex-start;
  justify-content: flex-start;
  cursor: grab;
  overscroll-behavior: contain;
}

.lb-stage.zoomed #lb-img {
  max-width: none;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
  cursor: grab;
}

.lb-stage.dragging,
.lb-stage.dragging #lb-img { cursor: grabbing; }

#lb-img.zoom-unavailable { cursor: default; }

.lb-zoomhint { color: #6f695f; }

.lb-caption {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  color: #b7b1a5;
  font-size: .74rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.lb-keywords { color: #8d867a; }

.lb-close,
.lb-nav {
  position: absolute;
  background: none;
  border: none;
  color: #f0ede6;
  cursor: pointer;
  opacity: .7;
  transition: opacity .2s, transform .2s;
  -webkit-tap-highlight-color: transparent;
}
.lb-close:hover, .lb-nav:hover { opacity: 1; }

.lb-close {
  top: clamp(.5rem, 2vw, 1.5rem);
  right: clamp(.75rem, 2.5vw, 2rem);
  font-size: 2.4rem;
  line-height: 1;
  width: 3rem;
  height: 3rem;
}

.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  font-size: clamp(2.5rem, 6vw, 4rem);
  line-height: 1;
  padding: 1rem;
  user-select: none;
}
.lb-prev { left: clamp(.25rem, 1.5vw, 1.5rem); }
.lb-next { right: clamp(.25rem, 1.5vw, 1.5rem); }
.lb-nav:hover { transform: translateY(-50%) scale(1.08); }

@media (max-width: 640px) {
  .lb-nav { font-size: 2.2rem; padding: .5rem; }
  .lb-caption { flex-direction: column; gap: .3rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
