:root {
  --bg: #0d0d0f;
  --surface: #18181c;
  --text: #ececf1;
  --muted: #8b8b98;
  --accent: #ff6a3d;
  --pad: clamp(12px, 3vw, 32px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.lb-open { overflow: hidden; }
[hidden] { display: none !important; }

#page { max-width: 1900px; margin: 0 auto; padding: 0 var(--pad) 64px; }

.top {
  --h1-size: clamp(2rem, 5vw, 3.4rem);
  display: flex; align-items: flex-start; justify-content: space-between; gap: clamp(12px, 3vw, 32px);
  padding: clamp(28px, 6vw, 64px) 0 clamp(16px, 3vw, 28px);
}
/* Fills whatever the logo leaves, so its width (and therefore how the text wraps) doesn't depend on the text. */
.top-text { flex: 1 1 0; min-width: 0; }
.top h1 { margin: 0; font-size: var(--h1-size); line-height: 1.05; letter-spacing: -0.02em; }
/* Top-right logo: --logo-w is its configured width; it shrinks on narrow screens. Nudged down to sit on the
   heading's first line rather than the top of the line box. */
.logo {
  flex: none; display: block; height: auto;
  width: min(var(--logo-w), 34vw);
  margin-top: calc(var(--h1-size) * 0.525 - 20px);
  user-select: none;
}
.tagline { margin: 10px 0 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.15rem); }
.count { margin: 6px 0 0; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; min-height: 1.2em; }

/* Masonry: cards are absolutely positioned by app.js from the aspect ratios in the manifest. */
.grid { position: relative; width: 100%; }
.card {
  position: absolute; top: 0; left: 0;
  margin: 0; padding: 0; border: 0; border-radius: 10px; overflow: hidden;
  background: var(--surface); color: inherit; font: inherit; text-align: left;
  cursor: zoom-in;
}
.card.is-video { cursor: pointer; }
.card img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .35s ease, transform .35s ease;
}
.card.ready img { opacity: 1; }
.card:hover img, .card:focus-visible img { transform: scale(1.03); }
.card:focus-visible, .lb-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.card.broken::after { content: "\26A0"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 1.6rem; }

/* Decorative fill for the empty space masonry sometimes leaves under a featured (2-column) item. */
.gap-filler { position: absolute; top: 0; left: 0; object-fit: contain; pointer-events: none; user-select: none; }

.card video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .3s ease; pointer-events: none;
}
.card.playing video { opacity: 1; }
.card.playing .play { opacity: 0; }
.play {
  transition: opacity .3s ease;
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 50%; background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px);
  pointer-events: none;
}
.play::before {
  content: ""; position: absolute; left: 18px; top: 13px;
  border-style: solid; border-width: 10px 0 10px 16px; border-color: transparent transparent transparent #fff;
}
.dur {
  position: absolute; right: 8px; top: 8px; padding: 2px 7px; border-radius: 6px;
  background: rgba(0, 0, 0, .6); font-size: .75rem; font-variant-numeric: tabular-nums; pointer-events: none;
}
.cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 12px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .78));
  font-size: .82rem; line-height: 1.35; pointer-events: none;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  opacity: 0; transition: opacity .2s ease;
}
.card:hover .cap, .card:focus-visible .cap { opacity: 1; }
@media (hover: none) { .cap { opacity: 1; } }

.status { text-align: center; color: var(--muted); margin: 28px 0 0; min-height: 1.5em; }
.status button {
  margin-left: 8px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--muted);
  background: none; color: var(--text); font: inherit; cursor: pointer;
}
.status button:hover { border-color: var(--accent); }

/* Lightbox */
.lb {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  background: rgba(6, 6, 8, .94); backdrop-filter: blur(6px);
}
.lb-stage { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 100vw; }
.lb-media { display: grid; place-items: center; }
.lb-media img, .lb-media video { display: block; border-radius: 6px; background: var(--surface); }
.lb-cap { max-width: min(70ch, 92vw); text-align: center; color: var(--muted); font-size: .9rem; min-height: 1.3em; }
.lb-cap .lb-text { display: block; color: var(--text); margin-bottom: 2px; white-space: pre-line; }
.lb-btn {
  position: fixed; z-index: 1; width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .08); color: #fff; font-size: 30px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; padding-bottom: 4px;
}
.lb-btn:hover { background: rgba(255, 255, 255, .18); }
.lb-close { top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
.lb-nav { top: 50%; margin-top: -24px; }
.lb-prev { left: max(10px, env(safe-area-inset-left)); }
.lb-next { right: max(10px, env(safe-area-inset-right)); }
@media (max-width: 600px) { .lb-nav { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); margin: 0; } }

@media (prefers-reduced-motion: reduce) {
  .card img, .cap, .card video, .play { transition: none; }
  .card:hover img, .card:focus-visible img { transform: none; }
}
