/*
 * Weekend Index — archive-print catalogue direction.
 * Each event is a numbered plate (Fig. 01 …) in a ruled ledger.
 */

:root {
  --bg: #f6f3ec;
  --surface: #fcfbf7;
  --ink: #1c1a17;
  --muted: #5b564d;
  --rule: #d9d2c3;
  --accent: #7a2e22;
  --accent-ink: #fcfbf7;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;
  --s-10: 128px;

  --radius: 2px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --gutter: 20px;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: clip;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.wrap {
  width: min(1200px, 100%);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.label {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Header ---------- */

.masthead {
  border-bottom: 1px solid var(--ink);
}

.masthead .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding-block: var(--s-4);
}

.brand {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  padding-block: 10px;
}

.shortlist-count {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
}

.shortlist-count output {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--ink);
  padding: 2px 10px;
  min-width: 2.5em;
  text-align: center;
}

/* ---------- Hero ---------- */

.hero {
  padding-block: var(--s-9) var(--s-8);
}

.hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: var(--s-6);
  align-items: end;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.75rem, 7.4vw, 7.5rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin-top: var(--s-4);
}

.hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero-lede {
  max-width: 44ch;
  margin-top: var(--s-5);
  color: var(--muted);
}

.hero-count {
  font-family: var(--serif);
  font-size: clamp(9rem, 22vw, 18rem);
  line-height: 0.8;
  letter-spacing: -0.06em;
  color: var(--ink);
  text-align: right;
  margin: 0;
  opacity: 1;
}

.hero-plate {
  border-top: 1px solid var(--ink);
  padding-top: var(--s-3);
  display: flex;
  justify-content: space-between;
  gap: var(--s-4);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  grid-column: 1 / -1;
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero h1,
.hero-count,
.hero-lede {
  animation: settle 700ms var(--ease) both;
}

.hero-count {
  animation-delay: 90ms;
}

.hero-lede {
  animation-delay: 180ms;
}

/* ---------- Controls ---------- */

.browse {
  padding-block: var(--s-8) var(--s-10);
  border-top: 1px solid var(--ink);
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
  gap: var(--s-4);
  align-items: end;
  margin-bottom: var(--s-6);
}

.field {
  display: grid;
  gap: var(--s-2);
}

.field label {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.browse-title {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 3.6vw, 2.75rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: var(--s-6);
}

.noscript {
  padding: var(--s-4);
  border: 1px solid var(--ink);
  margin-bottom: var(--s-6);
}

.field input,
.field select {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 16px;
  width: 100%;
}

.field input::placeholder {
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 200ms var(--ease), color 200ms var(--ease), transform 200ms var(--ease);
}

.btn:active {
  transform: scale(0.97);
}

.btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

.btn:focus-visible,
.field input:focus-visible,
.field select:focus-visible,
.brand:focus-visible,
.detail-close:focus-visible,
.save-item:focus-visible,
.empty-reset:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.results-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-4);
  padding-block: var(--s-3);
  border-bottom: 1px solid var(--ink);
}

/* ---------- Ledger of plates ---------- */

.ledger {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plate {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: var(--s-4);
  align-items: baseline;
  padding-block: var(--s-5);
  border-bottom: 1px solid var(--rule);
  transition: background-color 200ms var(--ease);
}

.plate-fig {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  padding-top: 6px;
}

.plate-title {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.plate-summary {
  margin-top: var(--s-2);
  color: var(--muted);
  max-width: 62ch;
}

.plate-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  margin-top: var(--s-3);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}

.plate-side {
  display: grid;
  justify-items: end;
  gap: var(--s-2);
  text-align: right;
}

.plate-saved {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.plate-saved[hidden] {
  display: none;
}

.open-item {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 200ms var(--ease), color 200ms var(--ease), transform 200ms var(--ease);
}

.open-item:active {
  transform: scale(0.97);
}

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

/* ---------- Empty state ---------- */

.empty-state {
  padding-block: var(--s-8);
  border-bottom: 1px solid var(--rule);
  display: grid;
  gap: var(--s-4);
  justify-items: start;
}

.empty-state[hidden] {
  display: none;
}

.empty-state h2 {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  font-weight: 500;
}

.empty-reset {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 200ms var(--ease), background-color 200ms var(--ease);
}

.empty-reset:active {
  transform: scale(0.97);
}

/* ---------- Detail dialog ---------- */

.detail {
  width: min(760px, calc(100% - 2 * var(--gutter)));
  max-height: calc(100dvh - 2 * var(--s-5));
  margin: auto;
  padding: var(--s-6);
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  overflow-y: auto;
}

.detail::backdrop {
  background: rgb(28 26 23 / 0.55);
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: var(--s-4);
  border-bottom: 1px solid var(--ink);
  padding-bottom: var(--s-4);
}

.detail-head .label {
  padding-top: 12px;
}

.detail-close {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 200ms var(--ease), background-color 200ms var(--ease);
}

.detail-close:active {
  transform: scale(0.97);
}

.detail h2 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 4vw, 2.75rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-top: var(--s-5);
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4) var(--s-6);
  margin: var(--s-5) 0;
  padding: 0;
}

.detail-facts div {
  border-top: 1px solid var(--rule);
  padding-top: var(--s-2);
}

.detail-facts dt {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-facts dd {
  margin: 2px 0 0;
  font-size: 17px;
}

.body {
  max-width: 62ch;
}

.body p + p {
  margin-top: var(--s-4);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-4);
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--ink);
}

.save-note {
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Colophon ---------- */

.colophon {
  border-top: 1px solid var(--ink);
  padding-block: var(--s-6);
}

.colophon .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-3);
}

/* ---------- Hover (fine pointers only) ---------- */

@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    background: var(--ink);
    color: var(--bg);
  }

  .btn[aria-pressed="true"]:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
  }

  .plate:hover {
    background: var(--surface);
  }

  .open-item:hover {
    background: var(--ink);
    color: var(--bg);
  }

  .detail-close:hover {
    background: var(--ink);
    color: var(--bg);
  }

  .empty-reset:hover {
    background: var(--accent);
    border-color: var(--accent);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .hero .wrap {
    grid-template-columns: 1fr;
  }

  .hero-count {
    text-align: left;
    font-size: clamp(7rem, 40vw, 11rem);
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .controls .field:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .hero {
    padding-block: var(--s-7) var(--s-6);
  }

  .hero h1 {
    font-size: clamp(2.4rem, 12vw, 3.4rem);
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .plate {
    grid-template-columns: 1fr;
    gap: var(--s-2);
  }

  .plate-side {
    justify-items: start;
    text-align: left;
  }

  .plate-fig {
    padding-top: 0;
  }

  .detail {
    padding: var(--s-5);
  }

  .detail-facts {
    grid-template-columns: 1fr;
  }

  .detail-head {
    flex-direction: column;
  }
}

/* ---------- Reduced motion: keep opacity, drop transform ---------- */

@media (prefers-reduced-motion: reduce) {
  .hero h1,
  .hero-count,
  .hero-lede {
    animation: fade-only 300ms linear both;
    animation-delay: 0ms;
  }

  .btn,
  .open-item,
  .detail-close,
  .empty-reset,
  .plate {
    transition-duration: 1ms;
  }

  .btn:active,
  .open-item:active,
  .detail-close:active,
  .empty-reset:active {
    transform: none;
  }
}

@keyframes fade-only {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
