*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0a0a;
  --bg-surface: #111;
  --text: #e0e0e0;
  --text-muted: #777;
  --accent: #fff;
  --gap: 5px;
  --row-height: 300px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- Loading spinner (class-toggled, not [hidden]) --- */

.loading {
  display: none;
  justify-content: center;
  align-items: center;
  padding: 6rem 0;
}

.loading.active {
  display: flex;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid #222;
  border-top-color: #555;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Hero --- */

.hero {
  position: relative;
  width: 100%;
  height: 70vh;
  min-height: 400px;
  max-height: 900px;
  overflow: hidden;
  cursor: pointer;
  display: none;
}

.hero.visible {
  display: block;
}

.hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.hero-img.active {
  opacity: 1;
}

.hero-fade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, var(--bg) 0%, rgba(10,10,10,0.4) 35%, transparent 60%),
    linear-gradient(to bottom, rgba(10,10,10,0.3) 0%, transparent 15%);
  pointer-events: none;
}

.hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2.5rem 3rem;
  pointer-events: none;
}

.hero-overlay h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  font-weight: 400;
  color: var(--accent);
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.hero-overlay p {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.5rem;
  max-width: 500px;
  line-height: 1.5;
}

.hero-overlay p:empty {
  display: none;
}

.album-count {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.35);
}

/* --- Justified grid --- */

.grid {
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--gap);
}

.grid-row {
  display: flex;
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.grid-row:last-child {
  margin-bottom: 0;
}

.grid-item {
  position: relative;
  overflow: hidden;
  border-radius: 2px;
  background: var(--bg-surface);
  cursor: pointer;
  /* width set via JS flex-basis */
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.grid-item:hover img {
  transform: scale(1.04);
}

/* Hover overlay */
.grid-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.3) 0%,
    transparent 50%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.grid-item:hover::after {
  opacity: 1;
}

/* Staggered reveal on scroll */
.grid-row {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.grid-row.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* --- Lightbox --- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.lightbox.active {
  visibility: visible;
  opacity: 1;
}

.lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  padding: 3rem 4rem;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 2px;
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.lightbox-content img.loading {
  opacity: 0.3;
  filter: blur(10px);
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-size: 2rem;
  padding: 1rem;
  z-index: 1001;
  transition: color 0.15s ease;
  line-height: 1;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  color: var(--accent);
}

.lightbox-close {
  top: 0;
  right: 0;
  font-size: 2.5rem;
}

.lightbox-prev {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
}

.lightbox-next {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
}

/* --- Setup / Error --- */

.setup-prompt,
.error {
  max-width: 480px;
  margin: 4rem auto;
  padding: 2rem;
  text-align: center;
  background: var(--bg-surface);
  border-radius: 8px;
}

.setup-prompt h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  font-weight: 500;
}

.setup-prompt p {
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.setup-prompt pre {
  background: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-size: 0.85rem;
  overflow-x: auto;
  text-align: left;
}

.setup-prompt code {
  background: var(--bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

.error {
  color: #e57373;
}

/* --- Responsive --- */

@media (max-width: 900px) {
  :root {
    --row-height: 220px;
  }

  .hero {
    height: 50vh;
    min-height: 280px;
  }

  .hero-overlay {
    padding: 1.5rem 2rem;
  }
}

@media (max-width: 600px) {
  :root {
    --row-height: 160px;
  }

  .hero {
    height: 45vh;
    min-height: 240px;
  }

  .hero-overlay {
    padding: 1.25rem 1.5rem;
  }

  .hero-overlay p {
    font-size: 0.85rem;
  }

  .lightbox-content {
    padding: 3rem 0.25rem;
  }

  .lightbox-prev,
  .lightbox-next {
    font-size: 2rem;
    padding: 0.5rem;
  }
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
