:root {
  --paper: #f3eee3;
  --card: #fbf8f1;
  --ink: #1d1b17;
  --muted: #5a554a;
  --rule: #cfc6b2;
  --accent: #b8360c;
  --green: #0f5a49;
  --focus: #0b3d91;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sign: "Avenir Next Condensed", "Franklin Gothic Medium", "Helvetica Neue", Arial, sans-serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --pad: clamp(16px, 4vw, 48px);
  --c: #17457a;
}

.cat-Culture { --c: #5e2750; }
.cat-Food { --c: #a8330b; }
.cat-Movement { --c: #17457a; }
.cat-People { --c: #1d5a3a; }
.cat-Places { --c: #74490a; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.lock { overflow: hidden; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 var(--ui);
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }

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

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 6px;
}
.skip:focus { top: 12px; }

/* Masthead */
.masthead { border-bottom: 3px solid var(--ink); }
.strip {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 8px var(--pad);
  font: 600 12px/1.3 var(--sign); letter-spacing: .12em; text-transform: uppercase;
  background: var(--ink); color: var(--paper);
}
.brand { display: flex; align-items: center; gap: 18px; padding: 22px var(--pad) 18px; }
.mark { width: 64px; height: 64px; flex: none; }
.mark-bg { fill: var(--green); }
.mark-line { stroke: #f3eee3; stroke-width: 2; }
.mark-kerb { stroke: #ffd98a; stroke-width: 5; stroke-linecap: round; }
.mark-arrow { fill: none; stroke: #f3eee3; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.wordmark {
  font: 800 clamp(44px, 9vw, 92px)/.9 var(--serif);
  letter-spacing: -.03em;
}
.tagline {
  margin-top: 6px;
  font: 600 13px/1.3 var(--sign); letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent);
}

main { padding: 0 var(--pad) 48px; max-width: 1440px; margin: 0 auto; }

.intro { padding: 36px 0 24px; max-width: 760px; }
.intro h2 { font: 700 clamp(26px, 3.4vw, 40px)/1.15 var(--serif); letter-spacing: -.01em; }
.intro p { margin-top: 10px; color: var(--muted); font-size: 18px; }

/* Toolbar */
.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px auto;
  gap: 14px 16px;
  align-items: end;
  padding: 18px 0 20px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.field label {
  display: block; margin-bottom: 4px;
  font: 700 12px/1.3 var(--sign); letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.field input, .field select {
  width: 100%; min-height: 48px; padding: 8px 14px;
  background: var(--card); border: 2px solid var(--ink); border-radius: 8px;
  font-size: 16px;
}
.field input::placeholder { color: #6b665a; }
.field select { appearance: none; padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.saved-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 8px 16px;
  background: var(--card); border: 2px solid var(--ink); border-radius: 8px;
  font-weight: 600; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.saved-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.saved-toggle .count {
  min-width: 24px; padding: 0 7px; border-radius: 12px; text-align: center;
  background: var(--ink); color: var(--paper); font-size: 13px; line-height: 24px;
}
.saved-toggle:hover { background: #efe7d4; }
.saved-toggle[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.saved-toggle[aria-pressed="true"] svg { fill: currentColor; }
.saved-toggle[aria-pressed="true"] .count { background: #fff; color: var(--green); }

.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 6px 16px; border-radius: 999px;
  background: transparent; border: 2px solid var(--ink); cursor: pointer;
  font: 700 13px/1 var(--sign); letter-spacing: .1em; text-transform: uppercase;
}
.chip:hover { background: #efe7d4; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* Results */
.results { padding-top: 28px; }
.results:focus { outline: none; }
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.results-head h2 { font: 800 13px/1.3 var(--sign); letter-spacing: .18em; text-transform: uppercase; }
#count { color: var(--muted); font-size: 15px; }
.loading { color: var(--muted); padding: 40px 0; }

.list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px 28px; }
.list.front { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.list.front .card { grid-column: span 4; }
.list.front .card.lead { grid-column: 1 / -1; }
.list.front .card:nth-child(2),
.list.front .card:nth-child(3),
.list.front .card:nth-child(7),
.list.front .card:nth-child(8) { grid-column: span 6; }

.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--card); border: 2px solid var(--ink); border-radius: 12px; overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 0 var(--ink); }
.card:focus-within { box-shadow: 0 0 0 3px var(--focus); }
.art { background: var(--c); aspect-ratio: 5 / 3; overflow: hidden; border-bottom: 2px solid var(--ink); }
.art svg { display: block; width: 100%; height: 100%; }
.art .p { fill: var(--paper); }
.art .pc { fill: var(--c); }
.art .ps { fill: none; stroke: var(--paper); stroke-linecap: round; stroke-linejoin: round; }
.art .warm { fill: #ffd98a; }

.card-body { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 20px; flex: 1; }
.kicker {
  font: 700 13px/1.3 var(--sign); letter-spacing: .14em; text-transform: uppercase; color: var(--c);
}
.kicker span { color: var(--muted); }
.card h3 { font: 700 clamp(22px, 2vw, 27px)/1.2 var(--serif); letter-spacing: -.005em; text-wrap: balance; }
.open-item {
  all: unset; cursor: pointer; display: inline;
}
.open-item::after { content: ""; position: absolute; inset: 0; }
.open-item:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.card:has(.open-item:focus-visible) { outline: none; }
.card:hover h3 { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.summary { color: var(--muted); }
.meta { margin-top: auto; padding-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 14px; color: var(--muted); }
.meta b { color: var(--ink); font-weight: 600; }
.badge {
  display: none; align-items: center; gap: 6px;
  font: 700 12px/1 var(--sign); letter-spacing: .1em; text-transform: uppercase; color: var(--green);
}
.badge svg { width: 14px; height: 14px; fill: currentColor; }
.card.is-saved .badge { display: inline-flex; margin-left: auto; }

.card.lead { flex-direction: row; }
.card.lead .art { flex: 1.15; aspect-ratio: auto; min-height: 340px; border-bottom: 0; border-right: 2px solid var(--ink); }
.card.lead .card-body { flex: 1; justify-content: center; padding: 32px 36px; gap: 14px; }
.card.lead h3 { font-size: clamp(30px, 3.2vw, 46px); line-height: 1.1; }
.card.lead .summary { font-size: 19px; }
.card.lead .meta { margin-top: 8px; }

/* Empty */
.empty {
  grid-column: 1 / -1; text-align: center; padding: 56px 20px;
  border: 2px dashed var(--ink); border-radius: 12px; background: var(--card);
}
.empty h3 { font: 700 28px/1.2 var(--serif); }
.empty p { margin: 8px auto 20px; max-width: 46ch; color: var(--muted); }
.btn {
  min-height: 48px; padding: 8px 22px; border-radius: 8px; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 2px solid var(--ink); font-weight: 700;
}
.btn:hover { background: #3a362d; }

.foot {
  border-top: 3px solid var(--ink); padding: 24px var(--pad) 40px;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 32px;
  color: var(--muted); font-size: 14px;
}
.foot strong { color: var(--ink); font-family: var(--serif); font-size: 17px; }

/* Reader dialog */
dialog.reader {
  width: min(780px, calc(100vw - 48px)); max-width: none;
  height: calc(100dvh - 48px); max-height: none;
  margin: auto; padding: 0; overflow: auto; overscroll-behavior: contain;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 14px;
  box-shadow: 0 10px 0 rgba(29, 27, 23, .25);
}
dialog.reader::backdrop { background: rgba(29, 27, 23, .62); }
dialog.reader[open] { animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.reader-bar {
  position: sticky; top: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--card); border-bottom: 2px solid var(--ink);
}
.reader-bar .btn-ghost, .reader-bar .save {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 6px 16px; border-radius: 8px; cursor: pointer;
  border: 2px solid var(--ink); background: var(--card); font-weight: 700;
}
.reader-bar .btn-ghost:hover, .reader-bar .save:hover { background: #efe7d4; }
.reader-bar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.reader-bar .save[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.reader-bar .save[aria-pressed="true"] svg { fill: currentColor; }

.reader .art { aspect-ratio: 16 / 6; }
.article { padding: 32px clamp(20px, 6vw, 64px) 56px; }
.article .kicker { font-size: 14px; }
.article h2 { margin-top: 10px; font: 800 clamp(32px, 5.2vw, 52px)/1.08 var(--serif); letter-spacing: -.02em; text-wrap: balance; }
.deck { margin-top: 16px; font: italic 400 clamp(19px, 2.4vw, 23px)/1.4 var(--serif); color: var(--muted); }
.byline {
  margin: 22px 0 28px; padding: 12px 0; border-block: 1px solid var(--ink);
  display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 15px; color: var(--muted);
}
.byline b { color: var(--ink); }
.prose { max-width: 62ch; }
.prose p { font: 400 clamp(18px, 2vw, 20px)/1.7 var(--serif); margin-bottom: 1.1em; }
.prose p:first-child::first-letter {
  float: left; font: 800 3.4em/.85 var(--serif); padding: 6px 10px 0 0; color: var(--c);
}
.end-bar { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--ink); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; color: var(--muted); font-size: 15px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 1100px) {
  .list, .list.front { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list.front .card, .list.front .card:nth-child(n) { grid-column: auto; }
  .list.front .card.lead { grid-column: 1 / -1; }
  .card.lead .art { min-height: 280px; }
}

@media (max-width: 720px) {
  body { font-size: 16px; }
  .strip .strip-mid, .strip span:last-child { display: none; }
  .brand { gap: 12px; padding-top: 18px; }
  .mark { width: 48px; height: 48px; }
  .tagline { font-size: 11px; letter-spacing: .12em; }
  .intro { padding: 24px 0 16px; }
  .intro p { font-size: 16px; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .field-search { grid-column: 1 / -1; }
  .saved-toggle { justify-content: center; }
  .chips { display: none; }
  .list, .list.front { grid-template-columns: 1fr; gap: 22px; }
  .list.front .card.lead { grid-column: auto; }
  .card.lead { flex-direction: column; }
  .card.lead .art { min-height: 0; aspect-ratio: 5 / 3; border-right: 0; border-bottom: 2px solid var(--ink); }
  .card.lead .card-body { padding: 18px 20px 20px; }
  .card.lead h3 { font-size: 28px; }
  .card.lead .summary { font-size: 17px; }
  dialog.reader { width: 100vw; height: 100dvh; max-width: none; max-height: none; border: 0; border-radius: 0; }
  .reader .art { aspect-ratio: 5 / 3; }
  .reader-bar { padding: 8px 12px; }
  .reader-bar .btn-ghost .long { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card:hover { transform: none; }
}
