:root {
  --bg: #0a0c10;
  --text: #e8eaed;
  --muted: #98a1ab;
  --surface: #161a21;
  --accent: #ffffff;
  --gap: 10px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

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

/* ---- Header ---- */
.site-header {
  max-width: 1800px;
  margin: 0 auto;
  padding: 48px 16px 28px;
}

.site-header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 300;
  letter-spacing: 0.04em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---- Masonry-Raster ---- */
.gallery {
  columns: 4;
  column-gap: var(--gap);
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

@media (max-width: 1023px) {
  .gallery { columns: 3; }
}

@media (max-width: 639px) {
  .site-header { padding: 32px 12px 20px; }
  .gallery { columns: 2; padding: 0 12px 32px; }
}

.tile {
  display: block;
  margin: 0 0 var(--gap);
  break-inside: avoid;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
}

.tile img {
  display: block;
  width: 100%;
  height: auto;
  transition: filter 200ms ease, transform 300ms ease;
}

.tile:hover img {
  filter: brightness(1.1);
  transform: scale(1.015);
}

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

/* ---- Lightbox ---- */
body.lightbox-open { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
}

.lightbox[hidden] { display: none; }

.lightbox:not([hidden]) { animation: lightbox-fade 160ms ease-out; }

@keyframes lightbox-fade { from { opacity: 0; } }

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 8, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.lightbox-figure {
  position: relative;
  z-index: 1;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  max-width: min(94vw, 1600px);
  max-height: calc(100vh - 110px);
  max-height: calc(100dvh - 110px);
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(232, 234, 237, 0.25);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.lightbox-spinner[hidden] { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

.lightbox-error {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  padding: 12px 16px;
  border-radius: 8px;
}

.lightbox-error[hidden] { display: none; }

.lightbox-nav,
.lightbox-close {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(22, 26, 33, 0.6);
  color: var(--text);
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: background 150ms ease;
}

.lightbox-nav:hover,
.lightbox-close:hover { background: rgba(22, 26, 33, 0.9); }

.lightbox-nav:focus-visible,
.lightbox-close:focus-visible,
.lightbox-download:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; }
.lightbox-close { top: 16px; right: 16px; width: 44px; height: 44px; }

@media (max-width: 639px) {
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
  .lightbox-prev, .lightbox-next { width: 40px; height: 40px; }
  .lightbox-close { top: 10px; right: 10px; width: 40px; height: 40px; }
}

.lightbox-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(5, 6, 8, 0) 0%, rgba(5, 6, 8, 0.85) 60%);
}

.lightbox-counter {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}

.lightbox-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #0a0c10;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: opacity 150ms ease;
}

.lightbox-download:hover { opacity: 0.88; }
