:root {
  --paper: #e9ede6;
  --paper-2: #dde3d9;
  --ink: #101b36;
  --muted: #475170;
  --signal: #ffc72c;
  --focus: #1d4ed8;

  --c-Culture: #7d2a63;
  --c-Food: #a8321f;
  --c-Movement: #1a5aa8;
  --c-People: #7a5200;
  --c-Places: #1b6e45;

  --display: "Avenir Next Condensed", "Helvetica Neue Condensed", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --ui: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --text: "Iowan Old Style", "Charter", "Palatino Linotype", Palatino, Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 96px; }
html.is-locked { overflow: hidden; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 1rem;
  line-height: 1.5;
}
h1, h2, h3, p, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
button, input, select { font: inherit; color: inherit; }
.wrap { width: min(1120px, 100% - 40px); margin-inline: auto; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.masthead :focus-visible, .reader-bar :focus-visible { outline-color: var(--signal); }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--signal); color: var(--ink); padding: 10px 14px; font-weight: 700;
}
.skip:focus { top: 12px; }

/* Masthead: a destination sign */
.masthead { background: var(--ink); color: var(--paper); border-bottom: 8px solid var(--signal); }
.masthead-inner { padding: 36px 0 28px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 40px; }
.wordmark {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(4rem, 13vw, 9.5rem);
  line-height: .86;
  letter-spacing: -.02em;
  color: var(--signal);
}
.tagline { max-width: 22ch; font-family: var(--text); font-size: 1.25rem; line-height: 1.3; padding-bottom: 8px; }

/* Toolbar */
.toolbar { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 2px solid var(--ink); }
.toolbar-inner { display: grid; grid-template-columns: 1fr 220px auto; gap: 16px; align-items: end; padding: 14px 0; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: .875rem; font-weight: 600; }
.field input, .field select {
  height: 46px; padding: 0 12px; width: 100%;
  background: #fff; border: 2px solid var(--ink); border-radius: 4px;
}
.field select { appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 20px, calc(100% - 14px) 20px;
  background-size: 6px 6px; background-repeat: no-repeat; }
.saved-toggle {
  height: 46px; display: inline-flex; align-items: center; gap: 8px; padding: 0 16px;
  background: transparent; border: 2px solid var(--ink); border-radius: 4px; cursor: pointer; font-weight: 700;
}
.saved-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.saved-toggle[aria-pressed="true"] { background: var(--ink); color: var(--signal); }
.saved-toggle[aria-pressed="true"] svg { fill: currentColor; }
.saved-count {
  min-width: 24px; height: 24px; padding: 0 6px; display: inline-grid; place-items: center;
  border-radius: 12px; background: var(--ink); color: var(--paper); font-size: .8125rem;
}
.saved-toggle[aria-pressed="true"] .saved-count { background: var(--signal); color: var(--ink); }

/* Results */
.results-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 32px 0 12px; }
.results-title { font-family: var(--display); font-weight: 700; font-size: 1.75rem; line-height: 1; }
.results-status { color: var(--muted); font-size: .9375rem; }

/* Route: stories as stops on a line */
.route { padding-bottom: 56px; }
.stop { display: grid; grid-template-columns: 112px 36px minmax(0, 1fr); column-gap: 20px; }
.when { padding-top: 6px; text-align: right; font-weight: 600; font-size: .9375rem; line-height: 1.25; color: var(--muted); }
.when b { display: block; font-family: var(--display); font-size: 2rem; line-height: 1; color: var(--ink); }
.rail { position: relative; }
.rail::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: var(--ink); }
.stop:first-child .rail::before { top: 18px; }
.stop:last-child .rail::before { bottom: auto; height: 18px; }
.stop:only-child .rail::before { display: none; }
.dot {
  position: absolute; left: 50%; top: 10px; width: 24px; height: 24px; margin-left: -12px;
  border-radius: 50%; background: var(--paper); border: 4px solid var(--ink);
}
.stop.is-saved .dot { background: var(--signal); }

.story { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 8px 28px; padding: 0 0 40px; }
.story-thumb { grid-column: 2; grid-row: 1 / span 3; width: 150px; height: 150px; border-radius: 4px; overflow: hidden; }
.story-thumb svg { display: block; width: 100%; height: 100%; }
.story-meta { grid-column: 1; display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: .9375rem; color: var(--muted); padding-top: 4px; }
.cat { font-weight: 800; color: var(--cat); }
.story-title { grid-column: 1; font-family: var(--display); font-weight: 700; font-size: clamp(1.75rem, 3vw, 2.25rem); line-height: 1.05; letter-spacing: -.005em; text-wrap: balance; }
.open {
  all: unset; cursor: pointer; display: inline;
}
.open::after { content: ""; position: absolute; inset: 0 0 24px 0; }
.open:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.story:hover .open { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 5px; text-decoration-color: var(--signal); }
.story-summary { grid-column: 1; font-family: var(--text); font-size: 1.125rem; line-height: 1.55; max-width: 52ch; }
.saved-badge { display: none; font-weight: 700; color: var(--ink); background: var(--signal); padding: 0 8px; border-radius: 3px; }
.stop.is-saved .saved-badge { display: inline-block; }

.stop.lead .story { grid-template-columns: minmax(0, 1fr) 280px; padding-bottom: 56px; }
.stop.lead .story-thumb { width: 280px; height: 280px; }
.stop.lead .story-title { font-size: clamp(2.25rem, 4.6vw, 3.75rem); line-height: .98; }
.stop.lead .story-summary { font-size: 1.3125rem; }

/* Empty */
.empty { max-width: 520px; margin: 24px 0 72px; padding: 28px; border: 2px dashed var(--ink); border-radius: 4px; }
.empty[hidden] { display: none; }
.empty h3 { font-family: var(--display); font-size: 1.75rem; line-height: 1.1; margin-bottom: 6px; }
.empty p { color: var(--muted); margin-bottom: 18px; }
.btn {
  height: 46px; padding: 0 20px; border: 2px solid var(--ink); border-radius: 4px;
  background: var(--ink); color: var(--paper); font-weight: 700; cursor: pointer;
}
.btn:hover { background: #24335f; }

.foot { background: var(--paper-2); border-top: 2px solid var(--ink); padding: 24px 0 32px; color: var(--muted); font-size: .9375rem; }
.foot p { max-width: 64ch; }

/* Reader dialog */
.reader {
  margin: 0 0 0 auto; padding: 0; border: 0; border-left: 4px solid var(--ink);
  width: min(780px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  background: var(--paper); color: var(--ink); overflow-y: auto; overscroll-behavior: contain;
}
.reader::backdrop { background: rgba(16, 27, 54, .6); }
.reader[open] { animation: slide-in .22s ease-out; }
@keyframes slide-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }

.reader-bar {
  position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 24px; background: var(--ink); color: var(--paper); border-bottom: 6px solid var(--signal);
}
.reader-bar .btn { background: transparent; border-color: var(--paper); height: 44px; }
.reader-bar .btn:hover { background: rgba(255,255,255,.12); }
.reader-bar .save-btn { display: inline-flex; align-items: center; gap: 8px; }
.reader-bar .save-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.reader-bar .save-btn[aria-pressed="true"] { background: var(--signal); border-color: var(--signal); color: var(--ink); }
.reader-bar .save-btn[aria-pressed="true"] svg { fill: currentColor; }

.detail { padding: 0 0 56px; }
.detail-art { height: 160px; }
.detail-art svg { display: block; width: 100%; height: 100%; }
.detail-head { padding: 28px 32px 8px; }
.detail-head .story-meta { padding: 0 0 10px; }
.detail-title { font-family: var(--display); font-weight: 800; font-size: clamp(2.25rem, 6vw, 3.5rem); line-height: .98; text-wrap: balance; }
.detail-dek { margin-top: 16px; font-family: var(--text); font-style: italic; font-size: 1.3125rem; line-height: 1.45; color: var(--muted); max-width: 40ch; }
.detail-body { padding: 16px 32px 0; }
.detail-body p { font-family: var(--text); font-size: 1.1875rem; line-height: 1.75; max-width: 62ch; margin-top: 1.1em; }
.detail-end { margin: 40px 32px 0; padding-top: 20px; border-top: 4px solid var(--ink); display: flex; gap: 12px; flex-wrap: wrap; }
.detail-end .btn.alt { background: transparent; color: var(--ink); }
.detail-end .btn.alt:hover { background: var(--paper-2); }

/* Mobile */
@media (max-width: 760px) {
  .wrap { width: min(1120px, 100% - 32px); }
  .masthead-inner { padding: 24px 0 20px; }
  .tagline { font-size: 1.0625rem; }
  .toolbar { position: static; }
  .toolbar-inner { grid-template-columns: 1fr 1fr; }
  .field-search { grid-column: 1 / -1; }
  .saved-toggle { justify-content: center; }
  .results-bar { padding-top: 24px; }

  .stop { grid-template-columns: 24px minmax(0, 1fr); column-gap: 12px; }
  .when { grid-column: 2; grid-row: 1; text-align: left; padding: 0 0 4px; display: flex; gap: 8px; align-items: baseline; }
  .when b { font-size: 1.5rem; }
  .rail { grid-column: 1; grid-row: 1 / span 2; }
  .story { grid-column: 2; grid-row: 2; grid-template-columns: minmax(0, 1fr); padding-bottom: 32px; }
  .story-thumb, .stop.lead .story-thumb { grid-column: 1; grid-row: auto; order: -1; width: 100%; height: 88px; margin-bottom: 6px; }
  .stop.lead .story-thumb { height: 140px; }
  .stop.lead .story { grid-template-columns: minmax(0, 1fr); }
  .story-summary, .stop.lead .story-summary { font-size: 1.0625rem; }
  .dot { top: 6px; width: 20px; height: 20px; margin-left: -10px; border-width: 3px; }
  .stop:first-child .rail::before { top: 14px; }
  .stop:last-child .rail::before { height: 14px; }

  .reader { border-left: 0; width: 100vw; }
  .reader-bar { padding: 10px 16px; }
  .detail-head { padding: 22px 16px 4px; }
  .detail-body { padding: 8px 16px 0; }
  .detail-body p { font-size: 1.125rem; }
  .detail-end { margin: 32px 16px 0; }
  .detail-art { height: 110px; }
}

@media (prefers-reduced-motion: reduce) {
  .reader[open] { animation: none; }
  html { scroll-behavior: auto; }
}
