:root {
  --bg: #14161a;
  --surface: #1e2127;
  --surface-quiet: #262a31;
  --text: #e8e6e3;
  --text-quiet: #9aa0a8;
  --accent: #d8a24a;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

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

header {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 1rem;
}

header h1 {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

header .subtitle {
  margin: 0.4rem 0 0;
  color: var(--text-quiet);
}

body > footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  color: var(--text-quiet);
  font-size: 0.9rem;
  text-align: center;
}

body > footer a {
  color: var(--accent);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0 0;
}

.search {
  padding: 0.55rem 0.85rem;
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--surface-quiet);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.95rem;
}

.search::placeholder {
  color: var(--text-quiet);
}

.search:focus,
#year-jump:focus {
  outline: none;
  border-color: var(--accent);
}

#year-jump {
  padding: 0.55rem 2rem 0.55rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--surface-quiet);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.95rem;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

#map {
  height: 380px;
  margin: 0 0 2rem;
  border-radius: var(--radius);
  filter: brightness(0.85) saturate(0.9);
}

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

.year-header {
  margin: 1.75rem 0 0.9rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--surface-quiet);
  color: var(--text-quiet);
  font-size: 0.95rem;
  font-weight: 600;
}

/* Each heading now lives alone inside its own <section id="year-YYYY">, so
   :first-of-type on .year-header itself would match all of them (each is
   trivially "first of its type" within its own parent). Scope to the first
   such section among main's children instead. */
main > section:first-of-type .year-header {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 120ms ease, background 120ms ease;
}

.card:hover,
.card:focus-visible {
  background: var(--surface-quiet);
  transform: translateY(-2px);
}

.card .cover {
  position: relative;
}

.card .cover > img,
.card .cover > .placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: var(--surface-quiet);
}

.card .placeholder {
  /* A neutral stand-in for albums whose cover could not be fetched. */
  background:
    linear-gradient(135deg, transparent 46%, var(--surface-quiet) 46% 54%, transparent 54%),
    var(--bg);
}

.route-badge {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  z-index: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--surface-quiet);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  transform-origin: bottom right;
  transition: transform 150ms ease;
}

.route-thumb {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
}

/* Enlarges in place, bounded by .card's own overflow:hidden (its rounded
   corners), rather than escaping over neighbouring cards - comfortably
   under the grid's 250px minimum column width. */
.route-badge:hover {
  transform: scale(3.5);
}

.card .meta {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.card .meta p {
  margin: 0;
}

.card .meta > p:not(.detail) {
  color: var(--text-quiet);
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .dates {
  margin: 0;
  color: var(--text-quiet);
  font-size: 0.78rem;
}

.card[hidden] {
  display: none;
}

.card .detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-quiet);
  font-size: 0.8rem;
}

.badge {
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.empty {
  grid-column: 1 / -1;
  color: var(--text-quiet);
  padding: 2rem 0;
}

/* Leaflet's bits that must match the dark page. */
.leaflet-container {
  background: var(--surface);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--surface-quiet);
  color: var(--text);
}

/* Album pages (a/<id>/): optional map above the embedded Ente viewer. */
.album-page .back {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
}

.album-page a {
  color: var(--accent);
}

/* #map is styled above by id; match its specificity to override. */
#map.album-map {
  height: 320px;
  margin-bottom: 1rem;
}

.album-embed {
  display: block;
  width: 100%;
  height: 80vh;
  min-height: 480px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
}
