/* ---- Base ----------------------------------------------------------------- */

:root {
  --bg: #0e1116;
  --surface: #161b23;
  --surface-2: #1e252f;
  --border: #2a323e;
  --text: #e6e9ee;
  --muted: #8b95a3;
  --accent: #42a5f5;
  --accent-strong: #1565c0;
  --radius: 10px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

img { display: block; }

/* ---- Cabecera ------------------------------------------------------------- */

.site-header {
  text-align: center;
  padding: 2.4rem 1rem 1.2rem;
}

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

.site-header h1::after {
  content: "";
  display: block;
  width: 64px;
  height: 3px;
  margin: 0.5rem auto 0;
  border-radius: 2px;
  background: var(--accent);
}

.subtitle {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

/* ---- Filtros -------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem 1.4rem;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  padding: 0.35rem 0.9rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chip:hover { border-color: var(--accent); }

.chip.active {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

.chip .count {
  margin-left: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.chip.active .count { color: #bbdefb; }

/* ---- Rejilla -------------------------------------------------------------- */

.gallery {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.2rem 3rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
}

.card {
  appearance: none;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.card:hover,
.card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-thumb {
  display: block;
  aspect-ratio: 320 / 120;
  background: #fff;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-name {
  padding: 0.45rem 0.6rem 0.55rem;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loading,
.error,
.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 3rem 0;
}

.error { color: #ef5350; }

/* ---- Lightbox ------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lightbox[hidden] { display: none; }

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.88);
  backdrop-filter: blur(2px);
}

.lb-figure {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: min(1000px, 94vw);
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

#lb-img {
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
}

.lb-caption {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 0.9rem 1.1rem 1rem;
  overflow-y: auto;
}

.lb-caption h2 {
  margin: 0;
  font-size: 1.15rem;
}

.lb-cat {
  margin: 0.15rem 0 0;
  color: var(--accent);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.lb-desc {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.lb-count {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.lb-btn {
  position: absolute;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(22, 27, 35, 0.85);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.lb-btn:hover { border-color: var(--accent); }

.lb-btn svg { width: 22px; height: 22px; }

.lb-prev { left: max(0.5rem, calc(50% - 560px)); }
.lb-next { right: max(0.5rem, calc(50% - 560px)); }

.lb-close {
  top: max(0.5rem, calc(50% - 46vh - 22px));
  right: 0.5rem;
  transform: none;
}

/* ---- Varios --------------------------------------------------------------- */

.noscript {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

@media (max-width: 560px) {
  .lb-prev, .lb-next { display: none; }
  .lb-caption { padding: 0.7rem 0.9rem 0.8rem; }
}
