:root {
  --bg: #0b0d10;
  --surface: #101418;
  --text: #e6edf3;
  --muted: #9fb0c0;
  --primary: #4f9cff;
  --accent: #7c4dff;
  --ring: rgba(79, 156, 255, 0.45);
  --shadow: rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: linear-gradient(180deg, var(--bg), #0e1116 35%, #0b0d10);
  color: var(--text);
}

.site-header {
  padding: 2rem 1rem 1rem;
  text-align: center;
}
.site-header h1 {
  margin: 0 0 .25rem;
  font-size: clamp(1.5rem, 2.5vw + 1rem, 2.25rem);
}
.site-header .tagline {
  margin: 0 auto 1rem;
  color: var(--muted);
}

.filters {
  display: flex;
  gap: .5rem;
  padding: .5rem;
  background: color-mix(in srgb, var(--surface), transparent 25%);
  border-radius: .75rem;
  box-shadow: 0 6px 20px var(--shadow), inset 0 1px 0 rgba(255,255,255,.04);
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  flex-wrap: wrap;
  justify-content: center;
}
.filter-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  color: var(--text);
  padding: .5rem .85rem;
  border-radius: .5rem;
  cursor: pointer;
  transition: transform .12s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
  white-space: nowrap; 
}
.filter-btn:hover { transform: translateY(-1px); }
.filter-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}
.filter-btn.active {
  border-color: color-mix(in srgb, var(--primary), white 15%);
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary), transparent 65%), rgba(255,255,255,.03));
}

.gallery {
  --col: 300px; 
  width: min(1200px, 100% - 2rem);
  margin: 1rem auto 4rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--col), 1fr));
  gap: 1rem;
}

.gallery-item { margin: 0; }
.thumb {
  display: block;
  padding: 0;
  width: 100%;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: .9rem;
  overflow: hidden;
  position: relative;
  box-shadow: 0 10px 30px var(--shadow), inset 0 1px 0 rgba(255,255,255,.04);
  transform: translateZ(0); 
}
.thumb img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  transition: transform .5s ease;
}
.thumb figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: .75rem 1rem;
  color: #fff;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.65));
  transform: translateY(0);
  transition: transform .35s ease, opacity .35s ease;
  opacity: .95;
}
.thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(800px 400px at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,.10), transparent 60%);
  opacity: 0;
  transition: opacity .3s ease;
}
.thumb:hover img { transform: scale(1.06); }
.thumb:hover::after { opacity: 1; }

.gallery-item {
  transition: transform .35s ease, opacity .3s ease;
}
.gallery-item.is-hidden {
  opacity: 0;
  transform: scale(.96);
  pointer-events: none;
  display: none; 
}

.lightbox[aria-hidden="true"] { display: none; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
}
body.lb-open {
  overflow: hidden;
}
body.lb-open > :not(#lightbox) {
  pointer-events: none;
  user-select: none;
}
.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(2px);
}
.lightbox__content {
  position: absolute;
  inset: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  height: 100dvh; 
  width: 100vw;
}
.lightbox__figure {
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.lightbox__img {
  flex: 1 1 auto;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain; 
}
.lightbox__img.is-cover { object-fit: cover; }
.lightbox__caption {
  width: 100%;
  padding: .65rem 1rem calc(.9rem + env(safe-area-inset-bottom));
  color: #fff;
  text-align: center;
  background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.55));
  overflow-wrap: anywhere;
  max-height: 22dvh; 
  overflow-y: auto;
}
.lightbox__close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  font-size: 2rem;
  width: 2.25rem;
  height: 2.25rem;
  line-height: 2rem;
  color: var(--text);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;

  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.lightbox__nav:hover { box-shadow: 0 2px 12px rgba(0,0,0,.4); }
.lightbox__prev { left: .75rem; }
.lightbox__next { right: .75rem; }

.lightbox__counter {
  position: absolute;
  top: calc(.75rem + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  background: rgba(0,0,0,.35);
  padding: .2rem .5rem;
  border-radius: .375rem;
}

/* Responsive */
@media (max-width: 720px) {
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    max-width: calc(100% - 2rem);
    padding-bottom: .6rem;
  }
  .filters::-webkit-scrollbar { height: 6px; }
  .filters::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 999px; }
  .filter-btn { flex: 0 0 auto; }
  .lightbox__content { inset: 0; }
}

@media (max-width: 500px) {
  .gallery { --col: 140px; }
}
