:root {
  --bg: #111;
  --fg: #eee;
  --muted: #999;
  --accent: #e63227;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, sans-serif;
}

header {
  padding: 1rem max(1rem, calc((100% - 1400px) / 2 + 1rem));
  border-bottom: 1px solid #333;
}

h1 { margin: 0; font-size: 1.5rem; text-transform: uppercase; letter-spacing: 0.05em; }
h1 span { color: var(--accent); }
h1 a { color: inherit; text-decoration: none; }
header p { margin: 0.25rem 0 0.5rem; color: var(--muted); }

nav { display: flex; flex-direction: column; gap: 0.35rem; }
.decade { display: grid; grid-template-columns: repeat(10, 3.75rem); }
header nav a, header nav span { text-align: center; }
.decade > :first-child { grid-column-start: var(--first); }
nav a, nav .current { padding: 0.1rem 0.4rem; color: var(--fg); text-decoration: none; font-weight: 600; }
nav a:hover { color: var(--accent); }
nav .current { background: var(--accent); }
nav .empty { padding: 0.1rem 0.4rem; color: #555; font-weight: 600; }


main { padding: 0 1rem 3rem; max-width: 1400px; margin: 0 auto; }

/* Barra dell'anno: l'anno a sinistra, i mesi accanto; resta fissa in cima mentre si scorre,
   col mese visibile evidenziato (months.js). */
.yearbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 -1rem;
  padding: 0.6rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid #333;
}
h2 { flex-shrink: 0; font-size: 1.5rem; margin: 0; color: var(--accent); }
.months { flex-direction: row; flex-wrap: wrap; gap: 0.25rem; }
.months a { padding: 0.2rem 0.6rem; color: var(--muted); text-decoration: none; text-transform: capitalize; }
.months a:hover { color: var(--accent); }
.months a.active { background: var(--accent); color: var(--fg); }
h3 { scroll-margin-top: 4rem; }
h3 { margin: 1.5rem 0 0.75rem; text-transform: capitalize; color: var(--muted); font-weight: 500; }

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

.card { display: flex; flex-direction: column; color: inherit; text-decoration: none; }
.thumb { display: flex; align-items: flex-end; justify-content: center; aspect-ratio: 4 / 5; }
.frame { position: relative; width: min(100%, calc(var(--ratio) * 125%)); aspect-ratio: var(--ratio); }
.card img { display: block; width: 100%; height: 100%; transition: transform 0.15s; }
.card:hover img { transform: scale(1.03); }
.count {
  position: absolute;
  bottom: 0;
  right: 0;
  line-height: 1.4;
  padding: 0.1rem 0.4rem;
  background: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}
.date { margin-top: 0.4rem; font-size: 0.8rem; color: var(--muted); }
.title { font-size: 0.9rem; overflow-wrap: anywhere; }

@media (max-width: 600px) {
  header { position: static; padding: 0.75rem 1rem 0.25rem; }
  h1 { font-size: 1.1rem; }
  header p { margin: 0.1rem 0 0.25rem; font-size: 0.8rem; }
  /* Anni e mesi su una riga che scorre; i decenni in ordine cronologico, da sinistra a destra. */
  header nav, section .months {
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, transparent, #000 1rem, #000 calc(100% - 1rem), transparent);
  }
  header nav::-webkit-scrollbar, section .months::-webkit-scrollbar { display: none; }
  header nav { flex-direction: row-reverse; margin: 0 -1rem; padding: 0 1rem; }
  .decade { display: flex; flex-shrink: 0; }
  header nav a, header nav .current, header nav .empty { padding: 0.5rem 0.4rem; }
  .yearbar { gap: 0; margin-top: 0.5rem; padding: 0.4rem 0 0.4rem 1rem; }
  h2 { font-size: 1.1rem; padding-right: 0.25rem; border-right: 1px solid #333; }
  section .months { flex: 1; min-width: 0; flex-wrap: nowrap; gap: 0.25rem; padding: 0 1rem; }
  section .months a { flex-shrink: 0; padding: 0.35rem 0.5rem; }
  h3 { scroll-margin-top: 3.5rem; }
}

.lightbox {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.92);
  color: var(--fg);
}
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: transparent; }
.lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; max-width: calc(100vw - 7rem); }
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 5rem);
  max-height: calc(100dvh - 5rem);
  object-fit: contain;
  outline: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 2.5rem rgba(255, 255, 255, 0.25);
}
.lightbox figure a { display: contents; cursor: zoom-in; }
.lightbox figcaption { margin-top: 0.75rem; color: var(--muted); }
.lightbox button {
  background: none;
  border: 0;
  color: var(--fg);
  font-size: 3rem;
  cursor: pointer;
  padding: 0 1rem;
}
.lightbox button:hover { color: var(--accent); }
.lightbox .close { position: absolute; top: 0.5rem; right: 0.5rem; font-size: 2.5rem; }

@media (max-width: 600px) {
  .lightbox figure { max-width: 100vw; }
  .lightbox img { outline: 0; box-shadow: none; }
  .lightbox figcaption { padding: 0 1rem; text-align: center; }
  .lightbox .prev, .lightbox .next {
    position: absolute;
    bottom: 0;
    z-index: 1;
    padding: 0.5rem 1.25rem;
  }
  .lightbox .prev { left: 0; }
  .lightbox .next { right: 0; }
}
