:root {
  --bg: #0e0e0f;
  --fg: #f2f2f3;
  --muted: #8b8b90;
  --line: #26262a;
  --gap: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* A class that sets `display` outranks the browser's rule for [hidden], which
   silently leaves "hidden" elements on screen. Settle it once, globally. */
[hidden] { display: none !important; }

/* Deliberately NOT smooth: a category jump can span 60,000px, and animating
   through it drags every row in between past the lazy-load observer, queueing
   hundreds of image requests ahead of the ones the visitor actually lands on. */

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Assistant", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

/* ---------- site header ---------- */

.site-head {
  padding: 40px 24px 28px;
  text-align: center;
}

.site-head h1 {
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 300;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.site-head p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.05em;
}

/* ---------- home: gallery cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px;
  padding: 20px clamp(16px, 4vw, 48px) 80px;
  max-width: 1600px;
  margin: 0 auto;
}

.card { display: block; }

.card-img {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #1a1a1c;
  border-radius: 3px;
}

.card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.7s cubic-bezier(0.2, 0, 0.2, 1);
}

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

.card-body { padding: 14px 2px 0; text-align: center; }

.card-body h2 {
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.card-body span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.empty, .loading {
  padding: 90px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
}

/* ---------- gallery cover ---------- */

.cover {
  position: relative;
  height: min(78vh, 760px);
  overflow: hidden;
  background: #1a1a1c;
}

.cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  /* Which part of the photo survives the crop — set per device. */
  object-position: var(--pos-x, 50%) var(--pos-y, 50%);
}

.cover::after {
  content: "";
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, var(--scrim, 0.3));
}

.cover-text {
  position: absolute;
  z-index: 2;
  transform: translate(50%, -50%);   /* RTL: right-anchored */
  text-align: center;
  width: max-content;
  max-width: 88vw;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.4);
}

.cover-text.dark { color: #111; text-shadow: 0 2px 24px rgba(255, 255, 255, 0.35); }

/* Caption typography is chosen per gallery; --tscale scales the pair together
   so the date never drifts away from the names. */
.cover-text { font-family: var(--tfont, inherit); }

.cover-text h1 {
  font-size: calc(clamp(30px, 6vw, 62px) * var(--tscale, 1));
  font-weight: var(--tweight, 300);
  letter-spacing: 0.1em;
  line-height: 1.15;
}

.cover-text span {
  display: block;
  margin-top: calc(12px * var(--tscale, 1));
  font-size: calc(clamp(12px, 1.6vw, 15px) * var(--tscale, 1));
  letter-spacing: 0.3em;
  opacity: 0.9;
}

.font-assistant { --tfont: "Assistant", sans-serif; }
.font-heebo     { --tfont: "Heebo", sans-serif; }
.font-frank     { --tfont: "Frank Ruhl Libre", serif; }
.font-secular   { --tfont: "Secular One", sans-serif; }

/* ---------- sticky category nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(14, 14, 15, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 clamp(8px, 3vw, 24px);
  justify-content: center;
}

.nav-inner::-webkit-scrollbar { display: none; }

.nav a {
  flex: 0 0 auto;
  padding: 16px 16px;
  font-size: 14px;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color 0.2s;
  white-space: nowrap;
}

.nav a:hover { color: var(--fg); }
.nav a.active { color: var(--fg); border-bottom-color: var(--fg); }

/* ---------- justified photo grid ---------- */

.section { padding: 0 clamp(6px, 2vw, 20px); }

.section h2 {
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.28em;
  color: var(--muted);
  text-align: center;
  padding: 54px 0 24px;
  scroll-margin-top: 54px;
}

.row {
  display: flex;
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.cell {
  position: relative;
  overflow: hidden;
  background: #1a1a1c;
  cursor: pointer;
  flex: 0 0 auto;
}

/* A cell waiting for its thumbnail breathes, so an empty grid reads as
   "arriving" rather than "broken". Stops the moment the image lands. */
.cell:not(.ready) {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { background: #1a1a1c; }
  50%      { background: #232327; }
}

@media (prefers-reduced-motion: reduce) {
  .cell:not(.ready) { animation: none; }
}

.cell img {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.cell img.in { opacity: 1; }

@media (hover: hover) {
  .cell::after {
    content: "";
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.22);
    opacity: 0;
    transition: opacity 0.25s;
  }
  .cell:hover::after { opacity: 1; }
}

.foot {
  padding: 70px 24px 60px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.1em;
  border-top: 1px solid var(--line);
  margin-top: 60px;
}

.foot a { border-bottom: 1px solid var(--line); padding-bottom: 2px; }

.share {
  display: block;
  margin: 22px auto 0;
  padding: 12px 24px;          /* comfortable tap target on a phone */
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.share:hover { color: var(--fg); border-color: var(--muted); }
.share.done { color: #6ee7a8; border-color: #6ee7a8; }

.draft {
  background: #3d2f00;
  color: #ffd76a;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
}

/* ---------- lightbox ---------- */

.lb {
  position: fixed; inset: 0;
  z-index: 100;
  background: rgba(8, 8, 9, 0.97);
  display: none;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.lb.open { display: flex; }

.lb img {
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.lb-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px; height: 56px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s;
}

.lb-btn:hover { background: rgba(255, 255, 255, 0.18); }
.lb-prev { right: 20px; }
.lb-next { left: 20px; }

.lb-close {
  position: absolute;
  top: 18px; left: 20px;
  width: 46px; height: 46px;
  font-size: 24px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.lb-count {
  position: absolute;
  top: 24px; right: 24px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.1em;
}

@media (max-width: 640px) {
  .lb-btn { width: 44px; height: 44px; font-size: 20px; }
  .lb-prev { right: 8px; }
  .lb-next { left: 8px; }
}
