/* ════════════════════════════════════════════
   Reset & tokens
════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:       #e8a800;
  --accent-dark:  #c99000;
  --text:         #ffffff;
  --text-muted:   #888;
  --bg:           #313132;
  /* --bg:           #ffffff; */
  --card-bg:      #1c1c1c;
  --card-border:  #2a2a2a;
  --shadow-card:  0 2px 10px rgba(0,0,0,.45), 0 6px 24px rgba(0,0,0,.35);
  --shadow-hover: 0 6px 24px rgba(0,0,0,.6),  0 14px 40px rgba(0,0,0,.45);
  --radius:       8px;
  --font-head:    'Montserrat', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --transition:   .25s ease;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ════════════════════════════════════════════
   Hero header
════════════════════════════════════════════ */
.site-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px 28px;
  background: #313132;
  /* background: #ffffff; */
  text-align: center;
}

/* Blends the white logo background into the dark canvas */
.site-header .logo img {
  height: 130px;
  width: auto;
  display: block;
  margin: 0 auto;
  mix-blend-mode: screen;
}

.page-title {
  font-family: var(--font-head);
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  margin-top: 16px;
  line-height: 1;
}

.back-link {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--transition);
}
.back-link:hover { color: var(--accent-dark); }

/* ════════════════════════════════════════════
   Sort bar
════════════════════════════════════════════ */
.sort-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 22px 20px 10px;
  background: var(--bg);
}

.sort-btn {
  font-family: var(--font-head);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #1e1e1e;
  border: 1.5px solid #2e2e2e;
  padding: 9px 24px;
  border-radius: 50px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition),
              background var(--transition), box-shadow var(--transition);
}
.sort-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.sort-btn.active {
  color: #000;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 14px rgba(232,168,0,.4);
}

/* ════════════════════════════════════════════
   Status messages
════════════════════════════════════════════ */
#gallery-loading,
#gallery-error {
  text-align: center;
  padding: 80px 20px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: .03em;
}
#gallery-error { display: none; color: #e05555; }

.spinner {
  display: inline-block;
  width: 38px; height: 38px;
  border: 3px solid #2a2a2a;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════
   Masonry grid
════════════════════════════════════════════ */
#grid {
  list-style: none;
  column-count: 4;
  column-gap: 14px;
  padding: 18px 18px 80px;
}
@media (max-width: 1100px) { #grid { column-count: 3; } }
@media (max-width: 720px)  { #grid { column-count: 2; } }
@media (max-width: 440px)  { #grid { column-count: 1; } }

/* ── Cards ── */
#grid li {
  break-inside: avoid;
  margin-bottom: 14px;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity    .5s ease calc(var(--i, 0) * 55ms),
    transform  .5s ease calc(var(--i, 0) * 55ms),
    box-shadow var(--transition);
}
#grid li.visible {
  opacity: 1;
  transform: translateY(0);
}
#grid li:hover {
  box-shadow: var(--shadow-hover);
}
#grid li a {
  display: block;
  cursor: zoom-in;
}

/* ── Lazy blur-up ── */
#grid li img {
  display: block;
  width: 100%;
  height: auto;
  filter: blur(10px);
  transform: scale(1.04);
  transition: filter .45s ease, transform .4s ease;
}
#grid li img.loaded {
  filter: none;
  transform: scale(1);
}
#grid li:hover img.loaded {
  transform: scale(1.03);
}

/* ════════════════════════════════════════════
   Back to top
════════════════════════════════════════════ */
#back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 54px; height: 54px;
  font-size: 1.8rem;
  line-height: 1;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(232,168,0,.5);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .3s ease, transform .3s ease, background .2s;
  z-index: 200;
  pointer-events: none;
  font-family: var(--font-body);
}
#back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#back-to-top:hover { background: var(--accent-dark); }

/* ════════════════════════════════════════════
   Lightbox
════════════════════════════════════════════ */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,.95);
  z-index: 999;
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
  backdrop-filter: blur(6px);
}
#lightbox.open { display: flex; }

#lightbox img {
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 10px 60px rgba(0,0,0,.9);
  animation: lbIn .22s ease;
  cursor: default;
}
@keyframes lbIn {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: scale(1); }
}

#lightbox-close {
  position: fixed;
  top: 18px; right: 22px;
  font-size: 2.2rem;
  color: #fff;
  cursor: pointer;
  opacity: .65;
  transition: opacity .2s;
  background: none; border: none;
  font-family: var(--font-body);
}
#lightbox-close:hover { opacity: 1; }

#lightbox-prev,
#lightbox-next {
  position: fixed;
  top: 50%; transform: translateY(-50%);
  font-size: 2.4rem;
  color: #fff;
  opacity: .55;
  cursor: pointer;
  background: none; border: none;
  padding: 10px 20px;
  transition: opacity .2s;
  user-select: none;
  font-family: var(--font-body);
}
#lightbox-prev:hover,
#lightbox-next:hover { opacity: 1; }
#lightbox-prev { left: 10px; }
#lightbox-next { right: 10px; }