:root {
  --paper: #f3eee3;
  --paper-2: #ebe4d4;
  --card: #fbf8f1;
  --ink: #1c1a17;
  --ink-2: #4a453d;
  --rule: #1c1a17;
  --accent: #b83a24;
  --focus: #0b57d0;
  --culture: #e8b64c;
  --food: #e5805a;
  --movement: #86abc8;
  --people: #e8a9a5;
  --places: #93bba8;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html.locked { overflow: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-tap-highlight-color: rgba(184, 58, 36, .18);
  overflow-x: hidden;
}

button, input, select { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }

.wrap { width: 100%; max-width: 1360px; margin-inline: auto; padding-inline: var(--gutter); }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

.skip {
  position: absolute; left: 12px; top: -80px; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 10px 16px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- Masthead ---------- */
.masthead { border-bottom: 3px double var(--rule); padding-bottom: clamp(16px, 3vw, 28px); }
.topline {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding-block: 12px; border-bottom: 1px solid var(--rule);
  font-size: .8125rem; letter-spacing: .08em; text-transform: uppercase;
}
.dateline { margin: 0; font-weight: 600; }
.list-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px;
  background: none; border: 0; padding: 4px 2px; text-transform: inherit; letter-spacing: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px;
}
.list-link:hover { color: var(--accent); text-decoration-thickness: 2px; }

.pill {
  display: inline-grid; place-items: center; min-width: 1.6em; height: 1.6em; padding-inline: .45em;
  background: var(--ink); color: var(--paper); border-radius: 99px;
  font-size: .75rem; font-weight: 700; letter-spacing: 0; font-variant-numeric: tabular-nums;
}

.nameplate {
  display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 0 clamp(20px, 4vw, 64px);
  padding-top: clamp(14px, 2.5vw, 28px);
}
.nameplate h1 {
  margin: 0; font-family: var(--serif); font-weight: 700; font-size: clamp(3.4rem, 11.5vw, 9.5rem);
  line-height: .9; letter-spacing: -.035em;
}
.nameplate h1 span { font-style: italic; font-weight: 400; color: var(--accent); }
.tagline {
  margin: 0 0 .6rem; max-width: 30ch; font-family: var(--serif); font-size: clamp(1rem, 1.6vw, 1.3rem);
  line-height: 1.35; color: var(--ink-2); text-wrap: pretty;
}

/* ---------- Controls ---------- */
.controls { padding-block: 20px 8px; }
.fields { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: 12px 16px; align-items: end; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: .75rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
input[type="search"], select {
  width: 100%; min-height: 48px; padding: 8px 14px; background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 0; font-size: 1rem;
}
select {
  appearance: none; -webkit-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% - 22px) 52%, calc(100% - 16px) 52%;
  background-size: 6px 6px; background-repeat: no-repeat;
}
input[type="search"]::placeholder { color: #6b645a; opacity: 1; }
input[type="search"]:hover, select:hover { background-color: #fff; }

.saved-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 8px 16px;
  background: var(--card); border: 2px solid var(--ink); font-weight: 700; white-space: nowrap;
  transition: transform .15s ease, background-color .15s ease, color .15s ease;
}
.saved-toggle svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.saved-toggle:hover { background: #fff; transform: translateY(-2px); }
.saved-toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.saved-toggle[aria-pressed="true"] svg { fill: currentColor; }
.saved-toggle[aria-pressed="true"] .pill { background: var(--paper); color: var(--ink); }

.chips { display: flex; gap: 8px; margin-top: 14px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 14px;
  background: transparent; border: 1.5px solid var(--ink); border-radius: 99px; font-size: .9rem; font-weight: 600;
  transition: background-color .15s ease, color .15s ease;
}
.chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--ink)); border: 1.5px solid var(--ink); }
.chip small { font-size: .75rem; opacity: .75; font-variant-numeric: tabular-nums; }
.chip:hover { background: var(--paper-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip[aria-pressed="true"] i { border-color: var(--paper); }

/* ---------- Story grid ---------- */
.stories { padding-block: 16px 72px; scroll-margin-top: 12px; }
.stories:focus { outline: none; }
.stories-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--rule); padding-top: 14px; margin-bottom: 20px; }
.stories-head h2 { margin: 0; font-family: var(--serif); font-size: 1.75rem; letter-spacing: -.01em; }
.status { margin: 0; font-size: .9rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 28px 24px; }
.card { position: relative; grid-column: span 4; min-width: 0; display: flex; flex-direction: column; background: var(--card); border: 2px solid var(--ink); transition: transform .18s ease; }
.card[data-pos="0"] { grid-column: span 8; }
.card[data-pos="1"] { grid-column: span 4; }
.grid[data-count="1"] .card { grid-column: 1 / -1; }
.card:hover { transform: translateY(-3px); }
.card:has(.open:focus-visible) { outline: 3px solid var(--focus); outline-offset: 4px; }
.card .art { aspect-ratio: 4 / 2.6; border-bottom: 2px solid var(--ink); overflow: hidden; background: var(--paper-2); }
.card .art svg, .reader .art svg { display: block; width: 100%; height: 100%; }
.card[data-pos="0"] { flex-direction: row; }
.card[data-pos="0"] .art { position: relative; flex: 1.25 1 0; aspect-ratio: auto; min-height: 340px; border-bottom: 0; border-right: 2px solid var(--ink); }
.card[data-pos="0"] .art svg { position: absolute; inset: 0; }
.card[data-pos="0"] .txt { flex: 1 1 0; justify-content: center; padding: clamp(20px, 3vw, 40px); }
.card[data-pos="0"] h3 { font-size: clamp(1.8rem, 2.8vw, 2.6rem); }
.grid[data-count="1"] .card[data-pos="0"] .art { flex: 1 1 0; }

.txt { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 20px; flex: 1; min-width: 0; }
.kicker { display: flex; align-items: center; gap: 10px; margin: 0; font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.kicker .dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--c); }
.saved-mark { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; background: var(--accent); color: #fff; padding: 2px 8px; letter-spacing: .06em; position: relative; z-index: 2; }
.card h3 { margin: 0; font-family: var(--serif); font-size: 1.4rem; line-height: 1.16; letter-spacing: -.01em; text-wrap: balance; overflow-wrap: anywhere; }
.open { all: unset; cursor: pointer; display: inline; }
.open:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.open::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card:hover .open { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: var(--accent); }
.summary { margin: 0; color: var(--ink-2); font-family: var(--serif); font-size: 1.02rem; line-height: 1.45; text-wrap: pretty; }
.meta { margin: auto 0 0; padding-top: 6px; font-size: .8125rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.meta b { color: var(--ink); font-weight: 700; }

.empty { text-align: center; padding: 56px 16px; max-width: 520px; margin-inline: auto; }
.empty svg { color: var(--accent); }
.empty h3 { font-family: var(--serif); font-size: 1.8rem; margin: 12px 0 6px; }
.empty p { margin: 0 0 20px; color: var(--ink-2); text-wrap: pretty; }
.btn { min-height: 48px; padding: 8px 22px; background: var(--ink); color: var(--paper); border: 2px solid var(--ink); font-weight: 700; transition: background-color .15s ease, color .15s ease; }
.btn:hover { background: var(--accent); border-color: var(--accent); }

.foot { border-top: 3px double var(--rule); padding-block: 28px 40px; font-size: .875rem; color: var(--ink-2); }
.foot .wrap { display: flex; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; align-items: baseline; }
.foot p { margin: 0; }
.brand-foot { font-family: var(--serif); font-size: 1.4rem; font-weight: 700; color: var(--ink); font-style: italic; }

/* ---------- Reader (dialog) ---------- */
.reader {
  position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; border: 0; border-left: 3px solid var(--ink);
  width: min(52rem, 100%); max-width: 100%; height: 100dvh; max-height: 100dvh;
  background: var(--card); color: var(--ink); overflow-y: auto; overscroll-behavior: contain;
}
.reader:not([open]) { display: none; }
.reader::backdrop { background: rgba(28, 26, 23, .55); }
.reader[open] { animation: slide-in .28s cubic-bezier(.2, .8, .2, 1); }
.reader[open]::backdrop { animation: fade-in .28s ease; }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.detail .bar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px clamp(16px, 4vw, 40px); padding-top: max(10px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 2px solid var(--ink);
}
.bar button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 16px;
  background: var(--card); border: 2px solid var(--ink); font-weight: 700;
  transition: background-color .15s ease, color .15s ease;
}
.bar button:hover { background: var(--paper-2); }
.bar button svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; flex: none; }
.bar .save[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.bar .save[aria-pressed="true"] svg { fill: currentColor; }
.reader .art { aspect-ratio: 16 / 7; border-bottom: 2px solid var(--ink); overflow: hidden; }
.article-head, .article-body { padding-inline: clamp(18px, 5vw, 56px); }
.article-head { padding-top: clamp(24px, 4vw, 40px); }
.article-head h2 { margin: 12px 0 14px; font-family: var(--serif); font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.08; letter-spacing: -.02em; text-wrap: balance; overflow-wrap: anywhere; }
.standfirst { margin: 0 0 18px; font-family: var(--serif); font-size: clamp(1.15rem, 2.4vw, 1.4rem); line-height: 1.4; font-style: italic; color: var(--ink-2); text-wrap: pretty; }
.byline { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 12px 0; border-block: 1px solid var(--ink); font-size: .875rem; font-variant-numeric: tabular-nums; }
.byline b { font-weight: 700; }
.article-body { padding-top: 26px; padding-bottom: calc(56px + env(safe-area-inset-bottom)); font-family: var(--serif); font-size: clamp(1.1rem, 2vw, 1.25rem); line-height: 1.7; }
.article-body p { margin: 0 0 1.15em; max-width: 36em; text-wrap: pretty; }
.article-body p:first-child::first-letter { float: left; font-size: 4.2em; line-height: .82; padding: .06em .1em 0 0; font-weight: 700; color: var(--accent); }
.article-body .end { display: block; width: 14px; height: 14px; background: var(--accent); border-radius: 50%; margin-top: 8px; }
.article-body .close-bottom { margin-top: 28px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .card, .card[data-pos="1"] { grid-column: span 6; }
  .card[data-pos="0"] { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .nameplate { grid-template-columns: 1fr; }
  .tagline { margin-top: 10px; max-width: 34ch; }
  .fields { grid-template-columns: 1fr 1fr; }
  .field-search { grid-column: 1 / -1; }
  .saved-toggle { padding-inline: 10px; }
  .grid { gap: 22px; }
  .card, .card[data-pos="0"], .card[data-pos="1"] { grid-column: 1 / -1; }
  .card[data-pos="0"] { flex-direction: column; }
  .card[data-pos="0"] .art { flex: none; min-height: 0; aspect-ratio: 4 / 2.6; border-right: 0; border-bottom: 2px solid var(--ink); }
  .card[data-pos="0"] .txt { padding: 18px 20px 20px; justify-content: flex-start; }
  .card[data-pos="0"] h3 { font-size: 1.7rem; }
  .reader { border-left: 0; width: 100%; }
  .reader .art { aspect-ratio: 16 / 9; }
  .bar .label-long { display: none; }
}

@media (max-width: 400px) {
  .saved-toggle span:not(.pill) { font-size: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
