@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --paper: #000;
  --ink: #fff;
  --muted: #a8a8a8;
  --hairline: #262626;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --gutter: clamp(12px, 2.5vw, 32px);
  --gap: clamp(6px, 0.8vw, 10px);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.4 "Space Grotesk", system-ui, sans-serif;
  font-feature-settings: "lnum", "locl";
  -webkit-font-smoothing: antialiased;
}
p { margin: 0; }
::selection { background: var(--ink); color: var(--paper); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
* { scrollbar-width: thin; scrollbar-color: var(--ink) transparent; }
code { border: 1px solid var(--hairline); padding: 3px 8px; border-radius: 4px; font-size: .9em; }

/* ── Header ──────────────────────────────── */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 24px;
  padding: 0 var(--gutter); min-height: 64px;
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
}
.head {
  position: sticky; top: 0; z-index: 5;
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
}
.head .bar { position: static; border-bottom: 0; }
.subbar { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 0 var(--gutter) 12px; }
.subbar[hidden] { display: none; }
.subbar::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 14px;
  background: transparent; color: var(--muted);
  border: 1px solid #333; border-radius: 9999px;
  font: 400 14px/1 "Space Grotesk", system-ui, sans-serif; cursor: pointer;
  transition: color .2s, border-color .2s, background-color .2s;
}
.chip:hover { color: var(--ink); border-color: #777; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.wordmark { flex: none; display: block; line-height: 0; }
.wordmark img { display: block; height: 30px; width: auto; }
#count { flex: none; margin-left: auto; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

#filters { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
#filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; min-height: 44px; padding: 0 12px;
  background: none; border: 0; cursor: pointer;
  font: 400 16px/1 "Space Grotesk", system-ui, sans-serif;
  color: var(--muted);
  box-shadow: inset 0 -2px 0 transparent;
  transition: color .2s, box-shadow .2s;
}
.filter:hover { color: var(--ink); }
.filter[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }

/* ── Gallery: dense grid, mixed tile sizes ── */
main { padding: var(--gap) var(--gutter) 64px; }
#grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: clamp(200px, 22vw, 360px);
  grid-auto-flow: dense;
  gap: var(--gap);
}
.tile {
  position: relative; display: block; padding: 0; border: 0;
  background: var(--hairline); overflow: hidden; cursor: zoom-in;
  grid-column: span 1; grid-row: span 1;
  animation: rise .8s var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 35ms);
}
.tile.big  { grid-column: span 2; grid-row: span 2; }
.tile.wide { grid-column: span 2; }
.tile.tall { grid-row: span 2; }
.tile img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform .8s var(--ease-out), filter .4s;
}
.tile:hover img { transform: scale(1.04); }

/* ── Footer ──────────────────────────────── */
footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px;
  padding: 24px var(--gutter);
  border-top: 1px solid var(--hairline);
  color: var(--muted); font-size: 14px;
}
footer a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  color: var(--ink); text-decoration: none;
  transition: opacity .2s;
}
footer a:hover { opacity: .65; }
footer svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
footer svg .dot { fill: currentColor; stroke: none; }

.more { display: flex; justify-content: center; padding: 40px 0 8px; }
.more[hidden] { display: none; }
.more-btn {
  min-height: 48px; padding: 0 32px;
  background: transparent; color: var(--ink);
  border: 1px solid #555; border-radius: 9999px;
  font: 400 16px/1 "Space Grotesk", system-ui, sans-serif; cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s, transform .25s var(--ease-out);
}
.more-btn:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.more-btn:active { transform: scale(.96); }

/* ── Empty state ─────────────────────────── */
.empty { max-width: 460px; margin: 20vh auto 0; text-align: center; }
.empty[hidden] { display: none; }
.empty h2 { margin: 0 0 8px; font-size: 26px; line-height: 1.2; letter-spacing: -.03em; }
.empty p { color: var(--muted); text-wrap: pretty; }

/* ── Lightbox: full black ────────────────── */
dialog#lightbox {
  border: 0; padding: 0; background: #000; color: #fff;
  max-width: none; max-height: none; width: 100vw; height: 100dvh;
  flex-direction: column;
}
dialog#lightbox[open] { display: flex; animation: fade .3s var(--ease-out); }
dialog#lightbox::backdrop { background: #000; }
.lb-well { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: var(--gutter) var(--gutter) 0; }
.lb-well img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.lb-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px var(--gutter) 16px; }
.lb-meta { min-width: 0; }
#lb-sub { font-size: 15px; color: #fff; font-variant-numeric: tabular-nums; }
.lb-controls { display: flex; gap: 8px; flex: none; }
.icon-btn {
  text-decoration: none;
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid #333; border-radius: 9999px; cursor: pointer;
  background: transparent; color: #fff;
  transition: background-color .2s, color .2s, transform .25s var(--ease-out);
}
.icon-btn:hover { background: #fff; color: #000; }
.icon-btn:active { transform: scale(.92); }
.icon-btn:focus-visible { outline-color: #fff; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Motion ──────────────────────────────── */
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 1000px) {
  #grid { grid-template-columns: repeat(3, 1fr); grid-auto-rows: clamp(180px, 30vw, 300px); }
}
@media (max-width: 700px) {
  .bar { flex-wrap: wrap; gap: 0 16px; padding-top: 8px; min-height: 0; }
  #count { margin-left: auto; }
  #filters { order: 3; flex-basis: 100%; margin: 0 -12px; padding: 0 12px; }
  #grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 44vw; }
}
