:root {
  --paper:    #fcfcfa;
  --ink:      #1c1c1a;
  --muted:    #6b6f76;
  --hairline: #e4e2dc;
  --accent:   #3a5a6b;   /* restrained alpine slate — used sparingly */
  --viewer-bg:#0d0e10;
  --viewer-fg:#e8e8e6;
  --max:      1120px;
  --gap:      clamp(10px, 1.6vw, 20px);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Lato", "Helvetica Neue", Arial, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.viewer-open { overflow: hidden; }

#app {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 64px) clamp(16px, 4vw, 40px) 80px;
}

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

.page-head { margin: 0 0 clamp(20px, 4vw, 40px); }
h1 {
  font-weight: 300;
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  letter-spacing: -0.01em;
  margin: 0;
}
.intro { color: var(--muted); margin: 0.35em 0 0; max-width: 60ch; }

.back { margin: 0 0 clamp(14px, 2vw, 22px); font-size: 0.9rem; }
.back a { color: var(--muted); }

.section-head {
  font-weight: 400;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  margin: clamp(28px, 4vw, 48px) 0 var(--gap);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hairline);
}
.section-head:first-of-type { margin-top: 0; }

/* Grids -------------------------------------------------------------- */
.grid { display: grid; gap: var(--gap); }
.album-list { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
/* Album grid: fixed-height rows, centered, images uncropped.
   Every row is the same height; each row is centered horizontally. */
.photo-list.justified { display: flex; flex-direction: column; gap: var(--gap); }
.jrow { display: flex; gap: var(--gap); justify-content: center; align-items: center; }
.jrow .cell { flex: 0 0 auto; display: block; }
.shot {
  height: 100%; width: 100%;
  overflow: hidden;
  background: #efeee9;
  border: 1px solid var(--hairline);
  line-height: 0;
}
.shot img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.shot img.ready { opacity: 1; }
.cell:hover .shot img { opacity: 0.9; }

.cover-wrap {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #efeee9;
  border: 1px solid var(--hairline);
}
.cover-wrap img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
/* Fade thumbnails in once decoded. */
.cover-wrap img[src] { opacity: 1; }

.card { display: block; color: inherit; }
.card:hover { text-decoration: none; }
.card:hover .cover-wrap img { transform: scale(1.03); }
.caption { padding: 8px 2px 0; }
.card-title { display: block; font-size: 0.98rem; }
.count { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 1px; }

.cell { display: block; }

.empty, .message p { color: var(--muted); }

/* Focus visibility (quality floor) ----------------------------------- */
a:focus-visible, button:focus-visible, .cell:focus-visible, .card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Viewer ------------------------------------------------------------- */
.viewer {
  position: fixed; inset: 0; z-index: 100;
  background: var(--viewer-bg);
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.viewer-stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(8px, 3vw, 40px);
}
.viewer-img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  opacity: 0; transition: opacity 0.25s ease;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.viewer-img.loaded { opacity: 1; }

/* Caption and counter overlay the image's corners, so they don't steal
   height from the photo. Counter sits bottom-right. */
.viewer-caption, .viewer-counter {
  position: absolute; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}
.viewer-caption {
  left: 0; max-width: 68%;
  color: var(--viewer-fg);
  font-size: 0.98rem;
}
.viewer-counter {
  right: 0;
  color: #cfd3d7;
  font-size: 0.8rem; letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

.viewer button {
  position: absolute;
  background: transparent; border: 0;
  color: var(--viewer-fg);
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.viewer .close, .viewer .full {
  top: 0;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  font-size: 1.3rem; line-height: 1;
  opacity: 0.75;
  z-index: 3;                 /* always above the nav bands */
}
.viewer .close { right: 0; }
.viewer .full  { left: 0; font-size: 1.15rem; }
.viewer .full[aria-pressed="true"] { opacity: 1; }
.viewer .nav {
  top: 3.5rem;                /* start below the close / full buttons */
  bottom: 64px;
  width: clamp(52px, 12vw, 96px);
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
  opacity: 0.55;
  z-index: 2;
  transition: opacity 0.15s ease;
}
.viewer .nav.prev { left: 0; }
.viewer .nav.next { right: 0; }
.viewer button:hover { opacity: 1; }
.viewer button:disabled { opacity: 0.12; cursor: default; }

@media (hover: none) {
  /* On touch devices, swipe is primary; keep arrows discreet. */
  .viewer .nav { opacity: 0.3; }
}

/* Mobile in landscape: drop the vertical padding so a portrait photo uses the
   full height of the screen (only left/right insets kept for a notch). */
@media (orientation: landscape) and (pointer: coarse) {
  .viewer-stage {
    padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
  }
  .viewer .nav { top: 0; bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .cover-wrap img, .shot img { opacity: 1; }
  .viewer-img { opacity: 1; }
}
