:root {
  --bg: #f3f3f1;
  --fg: #0a0a0a;
  --line: rgba(0, 0, 0, .12);
  --tile: #e4e4e2;
  --pad: clamp(16px, 2.6vw, 36px);
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #f2f2f2;
  --line: rgba(255, 255, 255, .12);
  --tile: #161616;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
  transition: background .5s, color .5s;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus, a:focus { outline: none; }
button:focus-visible, a:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }

/* ── Header ─────────────────────────────── */
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px var(--pad);
}
.brand { font-weight: 500; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tag { font-weight: 400; opacity: .45; margin-left: 6px; }
.tools { display: flex; align-items: center; gap: 22px; }
.layouts { display: flex; gap: 2px; }
.toolbar .layouts { padding-left: 8px; margin-left: 2px; border-left: 1px solid var(--line); height: 22px; align-items: center; }
.layouts button { padding: 6px; opacity: .35; transition: opacity .2s; display: grid; }
.layouts button:hover, .layouts button[aria-pressed="true"] { opacity: 1; }
.layouts svg { fill: none; stroke: currentColor; stroke-width: 1.3; }
.layouts button[aria-pressed="true"] svg { fill: currentColor; }

.theme-toggle { width: 32px; height: 32px; margin: -9px; display: grid; place-items: center; }
.theme-toggle span {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
  transition: transform .5s var(--ease);
}
[data-theme="dark"] .theme-toggle span { transform: rotate(180deg); }

/* ── Pages ──────────────────────────────── */
:root[data-page="home"] .collection,
:root[data-page="collection"] .home { display: none; }

/* ── Home: gallery wall ─────────────────── */
.home { overflow-y: auto; padding: 0 var(--pad) calc(var(--pad) * 3); }
/* Featured slideshow */
.hero {
  position: relative; overflow: hidden; background: var(--tile);
  height: min(calc(100dvh - 160px), 860px); min-height: 380px;
}
.hero-slides { position: absolute; inset: 0; will-change: transform; } /* the drift only reveals space above the scroll area, so no headroom needed */
.hero-slide {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transform: scale(1.06);
  transition: opacity 1.6s var(--ease), transform 7.5s linear;
}
.hero-slide.on { opacity: 1; transform: scale(1); }
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, .55), transparent 45%);
}
.hero-caption {
  will-change: transform, opacity;
  position: absolute; left: clamp(20px, 3vw, 44px); bottom: clamp(22px, 3.4vw, 48px); z-index: 1;
  display: flex; flex-direction: column; gap: 6px; color: #fff;
}
.hero-no { font-size: 11px; letter-spacing: .16em; opacity: .75; font-variant-numeric: tabular-nums; }
.hero-name { font-family: var(--serif); font-style: italic; font-size: clamp(44px, 7vw, 104px); line-height: .95; }
.hero-name.in { animation: nameIn .9s var(--ease); }
@keyframes nameIn { from { opacity: 0; transform: translateY(14px); } }
.hero-cta { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; margin-top: 8px; opacity: .85; }
.hero-cta span { display: inline-block; transition: transform .35s var(--ease); }
.hero-caption:hover .hero-cta span { transform: translateX(5px); }
.hero-dots {
  position: absolute; right: clamp(20px, 3vw, 44px); bottom: clamp(26px, 3.4vw, 52px); z-index: 1;
  display: flex; gap: 6px;
}
.hero-dots button { width: 28px; height: 20px; display: grid; align-items: center; }
.hero-dots button span { display: block; height: 2px; background: rgba(255, 255, 255, .35); position: relative; overflow: hidden; }
.hero-dots button span::after { content: ""; position: absolute; inset: 0; background: #fff; transform: scaleX(0); transform-origin: left; }
.hero-dots button.on span::after { animation: fill 6s linear forwards; }
@keyframes fill { to { transform: scaleX(1); } }

/* Scroll cue: small and quiet, in the dark band under the featured photo */
.scroll-cue {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin: 14px auto clamp(40px, 6vw, 88px);
  font-size: 9px; letter-spacing: .24em; text-transform: uppercase;
  opacity: .4; transition: opacity .3s;
}
.scroll-cue:hover { opacity: .8; }
.scroll-cue i { position: relative; display: block; width: 1px; height: 26px; background: var(--line); overflow: hidden; }
.scroll-cue i::after {
  content: ""; position: absolute; left: 0; top: 0; width: 100%; height: 40%;
  background: currentColor; animation: cue 2.4s cubic-bezier(.6, 0, .3, 1) infinite;
}
@keyframes cue { from { transform: translateY(-100%); } to { transform: translateY(260%); } }

.home-foot {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: clamp(80px, 10vw, 140px); padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase; opacity: .5;
}

.wall-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 14px; margin-bottom: clamp(24px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
}
.wall-head h2 { font: inherit; }
.wall-count { opacity: .45; }
.wall + .wall-head { margin-top: clamp(72px, 10vw, 140px); }

.wall {
  display: grid; gap: clamp(36px, 5vw, 80px) clamp(20px, 3.4vw, 56px);
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.tile { grid-column: span 2; }
.tile:nth-child(7n + 1), .tile:nth-child(7n + 2), .tile:nth-child(7n + 6), .tile:nth-child(7n + 7) { grid-column: span 3; }
.tile:nth-child(7n + 1) .tile-frame, .tile:nth-child(7n + 2) .tile-frame,
.tile:nth-child(7n + 6) .tile-frame, .tile:nth-child(7n + 7) .tile-frame { aspect-ratio: 3 / 2; }
.tile { display: block; animation: hang 1s var(--ease) backwards; }
@keyframes hang { from { opacity: 0; transform: translateY(24px); } }
.tile-frame { position: relative; display: block; aspect-ratio: 4 / 5; overflow: hidden; background: var(--tile); }
.tile-frame img {
  /* taller than its frame so it can drift for the parallax effect */
  position: absolute; left: 0; top: -18%; width: 100%; height: 136%; object-fit: cover;
  translate: 0 var(--py, 0); will-change: translate;
  transition: scale 1.4s var(--ease);
}
.tile-label { display: flex; align-items: baseline; gap: 12px; margin-top: 12px; font-size: 12px; }
.tile-no { opacity: .4; font-variant-numeric: tabular-nums; }
.tile-name { font-family: var(--serif); font-size: 22px; line-height: 1; }
.tile-count { margin-left: auto; opacity: .45; }

/* With a mouse: the name only appears over the photo on hover */
@media (hover: hover) {
  .tile-label {
    position: absolute; inset: 0; margin: 0;
    flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    color: #fff; text-align: center; pointer-events: none;
    opacity: 0; transition: opacity .6s var(--ease);
  }
  .tile { position: relative; }
  .tile-frame::after {
    content: ""; position: absolute; inset: 0;
    background: rgba(0, 0, 0, .42); opacity: 0; transition: opacity .6s var(--ease);
  }
  .tile:hover .tile-frame::after, .tile:focus-visible .tile-frame::after { opacity: 1; }
  .tile:hover .tile-label, .tile:focus-visible .tile-label { opacity: 1; }
  .tile:hover img { scale: 1.035; }
  .tile-name { font-size: clamp(30px, 3vw, 48px); font-style: italic; }
  .tile-no { order: -1; opacity: .7; letter-spacing: .16em; }
  .tile-count { margin: 0; opacity: .8; letter-spacing: .16em; text-transform: uppercase; font-size: 10px; }
  /* label is positioned over the frame, so give the tile the frame's shape */
  .tile-label { bottom: auto; height: 100%; }
}

@media (max-width: 1000px) {
  .wall { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wall .tile { grid-column: span 1; }
  .wall .tile:nth-child(7n + 1) { grid-column: span 2; }
}

/* ── Collection page ────────────────────── */
.collection { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); min-height: 0; min-width: 0; }
/* scoped to series pages: an unscoped rule here outranks the home page's "hide .collection" */
:root[data-page="collection"][data-layout="grid"] .collection { display: block; overflow-y: auto; overscroll-behavior: contain; }

/* Sticky glass bar: everything for the page in one slim row; photos scroll under it */
.col-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-direction: column; min-width: 0;
  padding: 10px var(--pad);
  border-bottom: 1px solid transparent; transition: border-color .3s;
}
/* The blur lives on a pseudo-element: backdrop-filter on .col-head itself would make it
   the containing block for the phone filter sheet (position: fixed) and trap it. */
.col-head::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: color-mix(in srgb, var(--bg) 58%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(1.6); backdrop-filter: blur(22px) saturate(1.6);
}
.collection.scrolled .col-head { border-bottom-color: var(--line); }
.filters-open .col-head { z-index: 16; } /* above the phone scrim */
.bar { display: flex; align-items: center; gap: 14px; min-height: 40px; min-width: 0; }
.back {
  flex: none; width: 32px; height: 32px; border-radius: 999px; border: 1px solid var(--line);
  display: grid; place-items: center; transition: border-color .25s, background .25s, color .25s;
}
.back:hover { border-color: currentColor; }
.back svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.col-name { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.col-title { font-family: var(--serif); font-weight: 400; font-style: italic; font-size: clamp(24px, 2.3vw, 30px); line-height: 1; white-space: nowrap; }
.col-count { opacity: .45; font-size: 12px; white-space: nowrap; }

/* Sort + filter: one quiet row, details tucked away */
.toolbar { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.filter-btn, .sort-btn, .chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 12px; white-space: nowrap;
  transition: border-color .25s, background .25s, color .25s, opacity .25s;
}
.filter-btn:hover, .sort-btn:hover, .chip:hover { border-color: currentColor; }
.filter-btn svg, .sort-btn svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.filters-open .filter-btn { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.badge {
  display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-right: -6px;
  border-radius: 999px; background: var(--fg); color: var(--bg); font-size: 10px; font-variant-numeric: tabular-nums;
}
.filters-open .badge { background: var(--bg); color: var(--fg); }
.badge[hidden] { display: none; }
.sort-btn { flex: none; }
.sort-btn svg { transition: transform .45s var(--ease); }
.sort-btn[data-dir="oldest"] svg { transform: rotate(180deg); }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 28px; padding: 0 10px 0 12px; border-color: transparent; background: color-mix(in srgb, var(--fg) 10%, transparent); animation: chipIn .35s var(--ease); }
.chip span { opacity: .5; font-size: 14px; line-height: 1; }
.chip:hover span { opacity: 1; }
.chip-clear { background: none; opacity: .55; }
.chip-clear:hover { opacity: 1; border-color: transparent; text-decoration: underline; text-underline-offset: 4px; }
@keyframes chipIn { from { opacity: 0; transform: scale(.9); } }

/* Panel: smooth height animation via grid rows 0fr → 1fr */
.filters { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s var(--ease); }
.filters-open .filters { grid-template-rows: 1fr; }
.filters-inner { overflow: hidden; min-height: 0; }
.filters-body {
  display: flex; flex-wrap: wrap; gap: 18px clamp(28px, 4vw, 56px);
  padding: 18px 0 6px;
  opacity: 0; transform: translateY(-6px); transition: opacity .3s, transform .45s var(--ease);
}
.filters-open .filters-body { opacity: 1; transform: none; transition-delay: .08s; }
.fgroup { border: 0; min-width: 0; }
.fgroup legend { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; opacity: .45; margin-bottom: 10px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  height: 30px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 12px; display: inline-flex; align-items: center; gap: 7px;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
}
.pill span { opacity: .45; font-size: 10px; font-variant-numeric: tabular-nums; }
.pill:hover { border-color: currentColor; }
.pill:active { transform: scale(.96); }
.pill[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.pill[aria-pressed="true"] span { opacity: .6; }
.pill:disabled { opacity: .25; cursor: default; border-color: var(--line); }
.filters-head, .filters-foot { display: none; }
.scrim { display: none; }

.empty { padding: 40px 0; opacity: .7; }
.empty button { text-decoration: underline; text-underline-offset: 4px; }

/* Slideshow strip */
.strip {
  display: flex; align-items: center; gap: clamp(16px, 3vw, 48px);
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  padding-inline: 50vw;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  transition: opacity .25s;
}
.strip::-webkit-scrollbar { display: none; }
.photo { flex: none; scroll-snap-align: center; cursor: pointer; opacity: .25; transition: opacity .5s var(--ease); }
.photo.active { opacity: 1; cursor: zoom-in; }
.photo img {
  display: block;
  height: min(58vh, 680px); width: auto;
  max-width: 84vw; object-fit: contain;
  user-select: none; -webkit-user-drag: none;
}

/* Grid */
.grid { padding: 14px var(--pad) var(--pad); }
.grid figure { scroll-margin: 80px 0 20px; }
.grid .cols { columns: 4 240px; column-gap: clamp(10px, 1.4vw, 20px); }
.grid figure {
  break-inside: avoid; margin-bottom: clamp(10px, 1.4vw, 20px);
  cursor: zoom-in; overflow: hidden; background: var(--tile);
}
.grid img { display: block; width: 100%; height: auto; transition: transform .8s var(--ease); }
.grid figure:hover img { transform: scale(1.03); }

:root[data-layout="grid"] .strip,
:root[data-layout="grid"] .bottom,
:root:not([data-layout="grid"]) .grid { display: none; }

.bottom {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  padding: var(--pad);
}
.caption { display: flex; flex-direction: column; min-width: 0; }
.title { font-family: var(--serif); font-size: clamp(22px, 2.4vw, 32px); line-height: 1.1; }
.meta { opacity: .45; }
.controls { display: flex; align-items: center; gap: 18px; font-variant-numeric: tabular-nums; }
.controls button { font-size: 18px; padding: 6px; transition: opacity .2s; }
.controls button:disabled { opacity: .2; cursor: default; }
.count { opacity: .6; white-space: nowrap; }

/* ── Single-photo viewer ────────────────── */
.viewer {
  position: fixed; inset: 0; z-index: 20;
  background: var(--bg);
  display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px; align-items: center;
  opacity: 0; transition: opacity .3s;
}
.viewer[hidden] { display: none; }
.viewer.open { opacity: 1; }
.viewer figure {
  height: 100dvh; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 64px 0 24px; gap: 14px;
}
.viewer img {
  max-width: 100%; max-height: calc(100dvh - 150px); object-fit: contain;
  user-select: none; transition: opacity .25s;
}
.viewer img.loading { opacity: .3; }
.viewer figcaption { display: flex; gap: 14px; align-items: baseline; }
.v-title { font-family: var(--serif); font-size: 22px; }
.v-meta { opacity: .5; white-space: pre; }
.v-prev, .v-next { height: 100%; font-size: 18px; opacity: .45; transition: opacity .2s; }
.v-prev:hover, .v-next:hover, .v-close:hover { opacity: 1; }
.v-prev:disabled, .v-next:disabled { opacity: .1; cursor: default; }
.v-close { position: absolute; z-index: 2; top: calc(var(--pad) - 10px); right: calc(var(--pad) - 12px); padding: 10px 12px; opacity: .6; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }

@media (max-width: 700px) {
  .top .tag { display: none; }
  .wall { grid-template-columns: 1fr; }
  .wall .tile, .wall .tile:nth-child(7n + 1) { grid-column: auto; }
  .hero { height: 68dvh; min-height: 320px; }
  .hero-dots { left: 20px; right: auto; bottom: 14px; }
  .hero-caption { bottom: 40px; }
  .grid .cols { columns: 2; }
  .bar { flex-wrap: wrap; row-gap: 10px; }
  .toolbar { order: 3; width: 100%; margin-left: 0; }
  .sort-btn { margin-left: auto; }
  .title { font-size: 22px; }
  /* filters become a bottom sheet */
  .filters {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    display: block; max-height: 80dvh; overflow-y: auto;
    background: var(--bg); border-radius: 18px 18px 0 0;
    padding: 8px var(--pad) calc(var(--pad) + env(safe-area-inset-bottom));
    transform: translateY(105%); transition: transform .45s var(--ease);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .35);
  }
  .filters::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 10px; }
  .filters-open .filters { transform: none; }
  .filters-inner { overflow: visible; }
  .filters-body { flex-direction: column; gap: 22px; opacity: 1; transform: none; padding: 8px 0 20px; }
  .filters-head { display: flex; justify-content: space-between; align-items: center; font-family: var(--serif); font-size: 26px; }
  .filters-close { font-family: var(--sans); font-size: 12px; opacity: .6; }
  .filters-foot { display: flex; gap: 10px; position: sticky; bottom: 0; background: var(--bg); padding-top: 10px; }
  .clear-btn { height: 44px; padding: 0 18px; opacity: .7; }
  .show-btn { flex: 1; height: 44px; border-radius: 999px; background: var(--fg); color: var(--bg); font-weight: 500; }
  .pill { height: 36px; padding: 0 15px; font-size: 13px; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 14; background: rgba(0, 0, 0, .45);
    opacity: 0; pointer-events: none; transition: opacity .35s;
  }
  .filters-open .scrim { opacity: 1; pointer-events: auto; }
  .filter-btn .label-hide { display: none; }
  .viewer { grid-template-columns: minmax(0, 1fr); }
  .v-prev, .v-next { display: none; }
  .viewer figure { padding: 64px 16px 24px; }
  .viewer figcaption { flex-direction: column; align-items: center; gap: 2px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
