/* ---------- Tokens ---------- */
:root {
  --ground: #f6f4fb;
  --paper: #ffffff;
  --ink: #2b2a3d;
  --ink-soft: #6b6885;
  --ink-faint: #a5a2bd;
  --line: #e6e2f1;

  --peach: #ffd6bf;
  --butter: #fff0b3;
  --mint: #c4ebd8;
  --sky: #c9e4f8;
  --lilac: #dcd4f7;

  --tint: var(--lilac);

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Nunito Sans", "Segoe UI", system-ui, sans-serif;

  --radius-s: 6px;
  --radius-m: 12px;
  --radius-pill: 999px;
  --measure: 60ch;
}

/* Decade colour coding: the page picks up the tint of whichever decade is selected. */
[data-decade="1980"] { --tint: var(--peach); }
[data-decade="1990"] { --tint: var(--butter); }
[data-decade="2000"] { --tint: var(--mint); }
[data-decade="2010"] { --tint: var(--sky); }
[data-decade="2020"] { --tint: var(--lilac); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: light; background: var(--ground); }

/* Background lives on <html> only: a body background would paint over the
   negative-z-index block behind the year numeral. */
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
  border-radius: var(--radius-s);
}

main, .masthead, .colophon {
  width: min(100% - 3rem, 1240px);
  margin-inline: auto;
}

/* ---------- Masthead ---------- */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block: 1.75rem 0.5rem;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-variation-settings: "SOFT" 80, "opsz" 48;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.masthead-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ---------- Shelf (year picker) ---------- */
.shelf {
  padding-block: 1.5rem 2rem;
  border-bottom: 1px solid var(--line);
}

.year-hero {
  display: grid;
  grid-template-columns: max-content auto;
  grid-template-rows: auto auto;
  justify-content: start;
  align-items: end;
  column-gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.year-numeral {
  grid-row: 1 / span 2;
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-variation-settings: "SOFT" 100, "opsz" 144;
  font-size: clamp(5rem, 16vw, 11rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  font-variant-numeric: lining-nums;
  position: relative;
  padding-inline: 0.06em;
}

/* the pastel block behind the numeral is the one loud thing on the page */
.year-numeral::before {
  content: "";
  position: absolute;
  inset: 22% -0.05em 4% -0.05em;
  background: var(--tint);
  border-radius: var(--radius-m);
  z-index: -1;
}

.year-steppers {
  display: flex;
  gap: 0.5rem;
  align-self: start;
  padding-top: 0.5rem;
}

.stepper {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  font-size: 1.5rem;
  line-height: 1;
  display: grid;
  place-items: center;
  padding-bottom: 0.15rem;
}

.stepper:hover:not(:disabled) { background: var(--tint); }
.stepper:disabled { opacity: 0.35; cursor: default; }

.year-summary {
  margin: 0;
  max-width: 28ch;
  color: var(--ink-soft);
  font-size: 0.95rem;
  padding-bottom: 0.65rem;
}

/* Decade tabs */
.decades {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.decade {
  --swatch: var(--lilac);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  font-weight: 600;
  font-size: 0.95rem;
}

.decade::before {
  content: "";
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: var(--swatch);
}

.decade[data-decade="1980"] { --swatch: var(--peach); }
.decade[data-decade="1990"] { --swatch: var(--butter); }
.decade[data-decade="2000"] { --swatch: var(--mint); }
.decade[data-decade="2010"] { --swatch: var(--sky); }
.decade[data-decade="2020"] { --swatch: var(--lilac); }

.decade[aria-pressed="true"] {
  background: var(--swatch);
  border-color: transparent;
}

/* Year chips */
.years {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.year {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 4.6rem;
  justify-content: space-between;
}

.year .count {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.year[data-empty="true"] { opacity: 0.45; }
.year[data-empty="true"] .count { visibility: hidden; }

.year:hover { border-color: var(--ink-faint); }

.year[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  opacity: 1;
}

.year[aria-pressed="true"] .count { color: rgba(255, 255, 255, 0.75); visibility: visible; }

/* ---------- Issues grid ---------- */
.issues { padding-block: 2rem 3rem; }

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

.issue {
  display: block;
  text-decoration: none;
  border-radius: var(--radius-m);
  outline-offset: 6px;
}

.cover {
  position: relative;
  aspect-ratio: 210 / 297;
  border-radius: var(--radius-s);
  background: var(--tint);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(43, 42, 61, 0.06), 0 10px 24px -14px rgba(43, 42, 61, 0.35);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.issue:hover .cover,
.issue:focus-visible .cover {
  transform: translateY(-3px);
  box-shadow: 0 1px 0 rgba(43, 42, 61, 0.06), 0 16px 28px -14px rgba(43, 42, 61, 0.45);
}

.issue-date {
  margin: 0.7rem 0 0;
  font-family: var(--serif);
  font-weight: 600;
  font-variation-settings: "SOFT" 60, "opsz" 18;
  font-size: 1.05rem;
  line-height: 1.25;
}

.issue-meta {
  margin: 0.15rem 0 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.issue-pub {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--tint);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Skeletons */
.skeleton .cover {
  background: linear-gradient(100deg, var(--line) 30%, var(--paper) 50%, var(--line) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  box-shadow: none;
}

.skeleton .bar {
  height: 0.9rem;
  border-radius: 4px;
  background: var(--line);
  margin-top: 0.8rem;
  width: 65%;
}

.skeleton .bar.short { width: 40%; height: 0.7rem; margin-top: 0.45rem; }

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

/* Notices: empty & error */
.notice {
  max-width: var(--measure);
  padding: 1.5rem 1.75rem;
  border-radius: var(--radius-m);
  background: var(--paper);
  border: 1px solid var(--line);
}

.notice h2 {
  margin: 0 0 0.35rem;
  font-family: var(--serif);
  font-weight: 600;
  font-variation-settings: "SOFT" 80, "opsz" 32;
  font-size: 1.5rem;
  line-height: 1.2;
}

.notice p { margin: 0; color: var(--ink-soft); }

.notice .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pill {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--tint);
  font-weight: 600;
  font-size: 0.9rem;
}

.pill:hover { border-color: var(--ink-faint); }

/* ---------- Colophon ---------- */
.colophon {
  padding-block: 1rem 2.5rem;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.colophon p { margin: 0; max-width: var(--measure); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  main, .masthead, .colophon { width: min(100% - 2rem, 1240px); }

  .year-hero {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    row-gap: 0.75rem;
  }

  .year-numeral { grid-row: auto; }
  .year-steppers { padding-top: 0; }
  .year-summary { padding-bottom: 0; }

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

@media (prefers-reduced-motion: reduce) {
  .cover, .stepper { transition: none; }
  .skeleton .cover { animation: none; }
  .issue:hover .cover, .issue:focus-visible .cover { transform: none; }
}
