/* ── Light / Dark tokens ── */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-hover: #f9fafb;
  --border: #e5e7eb;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-hover: 0 8px 24px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #1e2234;
  --border: #2a2d3a;
  --text: #e8eaf0;
  --text-muted: #8b8fa8;
  --accent: #60a5fa;
  --shadow: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-hover: 0 8px 32px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

/* ── Header ── */
header {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1.2;
}

header p {
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-size: 0.9rem;
  max-width: 400px;
  margin-inline: auto;
  line-height: 1.5;
}

/* ── Theme toggle ── */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  box-shadow: var(--shadow);
  transition: background 0.2s, border-color 0.2s;
}
.theme-toggle:hover {
  border-color: var(--accent);
}

/* ── Gallery ── */
.gallery-wrap {
  flex: 1;
  padding: 2rem 1.5rem 3rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  max-width: 960px;
  margin: 0 auto;
}

.gallery-message {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.gallery-message.error { color: #ef4444; }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}

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

/* ── Card thumbnail ── */
.card-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  overflow: hidden;
  position: relative;
}

.card-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-thumb .placeholder-icon {
  opacity: 0.15;
}

/* ── Card body ── */
.card-body {
  padding: 1rem 1.15rem 1.15rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
}

/* ── Badges ── */
.badge-lib {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
}

.tag {
  font-size: 0.6rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.25rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}
footer a:hover { text-decoration: underline; }

/* ── Map page: shared back button ── */
.back-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.back-btn:hover {
  border-color: var(--accent);
}

/* ── Mobile ── */
@media (max-width: 600px) {
  header { padding: 2rem 1rem 1.5rem; }
  .gallery-wrap { padding: 1.25rem 1rem 2.5rem; }
  .gallery { grid-template-columns: 1fr; gap: 1rem; }
}
