:root {
  --bg: #0b0b0e;
  --fg: #f4f4f7;
  --muted: #7d7d8a;
  --tile-bg: #17171d;
  --gap: 12px;
  --maxw: 1800px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.lb-open { overflow: hidden; }

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 20px 72px;
}

/* ---------- masonry ---------- */

.masonry {
  column-gap: var(--gap);
  columns: 4 300px;
}

.tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  break-inside: avoid;
  margin: 0 0 var(--gap);
  border-radius: 10px;
  overflow: hidden;
  background: var(--tile-bg) center / cover no-repeat;
  cursor: zoom-in;
  transform: translateZ(0); /* stops Safari repainting the blur on scroll */
}

.tile > img,
.tile > video {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}

.tile.loaded > img,
.tile.loaded > video { opacity: 1; }

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.08);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  pointer-events: none;
}

.tile:hover::after { opacity: 1; }

.tile:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

/* Small play badge on video tiles */
.tile.is-video::before {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 0;
  height: 0;
  z-index: 2;
  border-left: 11px solid rgba(255, 255, 255, 0.92);
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
}

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

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6, 6, 9, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.lightbox[hidden] { display: none; }
.lightbox.visible { opacity: 1; }

.lb-stage {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lb-stage img,
.lb-stage video {
  max-width: 100%;
  max-height: calc(100vh - 96px);
  width: auto;
  height: auto;
  display: block;
  border-radius: 6px;
}

.lb-close,
.lb-nav {
  position: absolute;
  z-index: 2;
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  color: var(--fg);
  cursor: pointer;
  border-radius: 999px;
  line-height: 1;
  transition: background 0.2s var(--ease);
}

.lb-close:hover,
.lb-nav:hover { background: rgba(255, 255, 255, 0.2); }

.lb-close {
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  font-size: 26px;
}

.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  font-size: 30px;
}

.lb-prev { left: 18px; }
.lb-next { right: 18px; }

.lb-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  main { padding: 14px 16px 48px; }
  .masonry { columns: 2 150px; }
  .lightbox { padding: 12px; }
  .lb-nav { width: 40px; height: 40px; font-size: 26px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile > img,
  .tile > video,
  .lightbox,
  .tile::after { transition: none; }
}
