/* Blockwork — warm editorial paper, Swiss grid, serif display */
@font-face {
  font-family: "DM Serif Display";
  src: url("assets/dm-serif.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.ttf") format("truetype");
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 400 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400 500; font-style: normal; font-display: swap;
}

:root {
  --paper: #FAF6EE;
  --paper-deep: #F3ECDD;
  --card: #FFFDF8;
  --ink: #201915;
  --ink-soft: #4A4239;
  --muted-ink: #6B5F52;
  --line: #E2D8C4;
  --line-strong: #201915;
  --accent: #C2410C;
  --accent-ink: #9A3412;
  --accent-soft: #FBE3CF;
  --gold: #B45309;
  --sage: #3F6212;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(32,25,21,.08), 0 8px 24px -12px rgba(32,25,21,.25);
  --font-display: "DM Serif Display", Georgia, "Times New Roman", serif;
  --font-sans: "DM Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Literata", Georgia, serif;
  --font-mono: "Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 400px at 50% -120px, #fff 0%, transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 26px, rgba(32,25,21,.015) 26px 27px),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
h1, h2, h3 { line-height: 1.08; text-wrap: balance; }

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

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  text-decoration: none; font-weight: 600; transition: top .18s ease;
}
.skip-link:focus { top: 12px; color: #fff; }

/* ---------- Masthead ---------- */
.masthead { border-bottom: 3px double var(--ink); }
.topbar {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted-ink);
  padding: 10px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: grid; gap: 6px 20px; align-items: center;
  grid-template-columns: auto 1fr;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 48px) 18px;
  max-width: 1200px; margin: 0 auto;
}
.brand-mark { grid-row: span 2; }
.brand-kicker {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--accent-ink); margin: 0; font-weight: 500;
}
.brand-name {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(48px, 9vw, 96px); margin: 0; letter-spacing: -0.01em;
}
.brand-tag {
  grid-column: 1 / -1; margin: 4px 0 0; max-width: 62ch;
  font-family: var(--font-body); font-size: clamp(16px, 2.2vw, 19px); color: var(--ink-soft);
}
.topic-nav {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px clamp(16px, 4vw, 48px) 16px;
  max-width: 1200px; margin: 0 auto;
}
.topic-nav-label {
  font-family: var(--font-mono); font-size: 12px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted-ink); margin-right: 4px;
}
.topic-nav button {
  font: 600 13px/1 var(--font-sans); color: var(--ink);
  background: transparent; border: 1.5px solid var(--ink);
  border-radius: 999px; padding: 9px 15px; min-height: 40px; cursor: pointer;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.topic-nav button:hover { background: var(--ink); color: var(--paper); }
.topic-nav button[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Layout ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px); }

/* ---------- Hero ---------- */
.hero { padding: clamp(20px, 4vw, 36px) 0 6px; }
.hero-card {
  display: grid; grid-template-columns: 1.05fr 1fr;
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.hero-media { position: relative; min-height: 280px; }
.hero-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-media figcaption {
  position: absolute; left: 10px; bottom: 10px;
  font-family: var(--font-mono); font-size: 11px;
  background: rgba(0,0,0,.62); color: #fff; padding: 4px 8px; border-radius: 6px;
}
.hero-body { padding: clamp(22px, 4vw, 44px); display: flex; flex-direction: column; gap: 12px; }
.hero-flag {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .16em;
  text-transform: uppercase; color: #F5B96B; margin: 0;
}
.hero-title { font-family: var(--font-display); font-weight: 400; font-size: clamp(30px, 4.4vw, 52px); margin: 0; }
.hero-standfirst { font-family: var(--font-body); font-size: 18px; color: #EDE4D3; margin: 0; }
.hero-meta { font-family: var(--font-mono); font-size: 12.5px; color: #CBBFA9; margin: 0; }
.hero-cta {
  align-self: flex-start; margin-top: 6px;
  background: var(--accent); color: #fff; border: none; border-radius: 999px;
  font: 700 15px var(--font-sans); padding: 13px 24px; min-height: 48px; cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}
.hero-cta:hover { background: #A83A0B; transform: translateY(-1px); }

/* ---------- Browse ---------- */
.browse { padding: 26px 0 10px; }
.browse-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-top: 2px solid var(--ink); padding-top: 14px;
}
.browse-head h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(28px, 4vw, 40px); margin: 0; }
.result-count { font-family: var(--font-mono); font-size: 13px; color: var(--muted-ink); margin: 0; }

.controls {
  display: grid; grid-template-columns: 1fr 220px auto; gap: 12px; align-items: end;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 16px 0 22px; box-shadow: var(--shadow);
}
.control label, .control-label {
  display: block; font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted-ink); margin-bottom: 7px;
}
.control input[type="search"], .control select {
  width: 100%; min-height: 48px; font: 500 16px var(--font-sans); color: var(--ink);
  background: var(--paper); border: 1.5px solid var(--ink); border-radius: 10px; padding: 10px 14px;
}
.control input[type="search"]:focus, .control select:focus { border-color: var(--accent); }
#savedFilter {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 10px; cursor: pointer;
  font: 700 14px var(--font-sans);
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  transition: background .16s ease, color .16s ease;
  white-space: nowrap;
}
#savedFilter:hover { background: var(--paper-deep); }
#savedFilter[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
#savedFilter[aria-pressed="true"] svg path { fill: currentColor; }

/* ---------- Cards grid ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease;
  position: relative;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-media { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--paper-deep); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.card:hover .card-media img { transform: scale(1.03); }
.chip {
  position: absolute; left: 12px; top: 12px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
  background: var(--paper); border: 1.5px solid var(--ink);
  padding: 5px 10px; border-radius: 999px;
}
.chip-food { background: #FDE9C8; }
.chip-places { background: #DFE8C8; }
.chip-people { background: #F6D9D2; }
.chip-movement { background: #D8E4F2; }
.chip-culture { background: #E7D8F2; }
.saved-ribbon {
  position: absolute; right: 12px; top: 12px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
  background: var(--ink); color: var(--paper); padding: 5px 10px; border-radius: 999px;
}
.card-body { padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.card-meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted-ink); margin: 0; }
.card-title { font-family: var(--font-display); font-weight: 400; font-size: 24px; margin: 0; }
.card-summary { font-family: var(--font-body); font-size: 15.5px; color: var(--ink-soft); margin: 0; flex: 1; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.read-time { font-family: var(--font-mono); font-size: 12px; color: var(--muted-ink); }
.btn { font-family: var(--font-sans); cursor: pointer; border-radius: 999px; }
.btn-open {
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  font-weight: 700; font-size: 14px; padding: 10px 18px; min-height: 44px;
  transition: background .16s ease, color .16s ease;
}
.btn-open:hover { background: var(--ink); color: var(--paper); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; border: 2px dashed var(--ink); border-radius: var(--radius);
  padding: 48px 24px; margin: 8px 0 24px; background: var(--card);
}
.empty-title { font-family: var(--font-display); font-size: 28px; margin: 0 0 8px; }
.empty-body { color: var(--ink-soft); margin: 0 0 20px; }
.btn-primary {
  background: var(--accent); border: none; color: #fff;
  font-weight: 700; font-size: 15px; padding: 13px 26px; min-height: 48px;
  transition: background .16s ease, transform .16s ease;
}
.btn-primary:hover { background: #A83A0B; transform: translateY(-1px); }

/* ---------- Colophon + footer ---------- */
.colophon { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 26px 0 8px; }
.colophon-card { border-top: 2px solid var(--ink); padding-top: 12px; }
.colophon-card h2 { font-family: var(--font-mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 8px; color: var(--accent-ink); }
.colophon-card p { margin: 0; color: var(--ink-soft); font-size: 15px; max-width: 52ch; }
.footer { border-top: 1px solid var(--line); margin-top: 26px; padding: 18px clamp(16px, 4vw, 48px) 34px; }
.footer p { max-width: 1200px; margin: 0 auto; font-family: var(--font-mono); font-size: 12px; color: var(--muted-ink); }

/* ---------- Detail overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(32, 25, 21, .55);
  overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(0px, 3vw, 32px);
  display: flex; justify-content: center; align-items: flex-start;
}
.overlay[hidden] { display: none; }
#detail {
  position: relative;
  background: var(--paper); color: var(--ink);
  width: min(800px, 100%); margin: clamp(0px, 3vh, 32px) auto;
  border-radius: 18px; box-shadow: 0 24px 80px rgba(0,0,0,.4);
  padding: clamp(22px, 5vw, 56px);
  animation: rise .28s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.progress { position: absolute; top: 0; left: 18px; right: 18px; height: 4px; background: var(--line); border-radius: 0 0 4px 4px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }
.detail-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.btn-ghost {
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  font-weight: 700; font-size: 14px; padding: 10px 18px; min-height: 44px;
  transition: background .16s ease, color .16s ease;
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-save {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--accent-ink); background: transparent; color: var(--accent-ink);
  font-weight: 700; font-size: 14px; padding: 10px 18px; min-height: 44px;
  transition: background .16s ease, color .16s ease;
}
.btn-save:hover { background: var(--accent-soft); }
.btn-save[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-save[aria-pressed="true"] svg path { fill: currentColor; }
.kicker {
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 10px;
}
#detailTitle { font-family: var(--font-display); font-weight: 400; font-size: clamp(32px, 5.4vw, 54px); margin: 0 0 12px; }
.byline { font-family: var(--font-mono); font-size: 13px; color: var(--muted-ink); margin: 0 0 20px; }
.detail-figure { margin: 0 0 24px; }
.detail-figure img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.detail-figure figcaption { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-ink); margin-top: 8px; }
.standfirst {
  font-family: var(--font-body); font-size: 21px; line-height: 1.5; color: var(--ink);
  border-left: 4px solid var(--accent); padding-left: 16px; margin: 0 0 22px;
}
.detail-body { font-family: var(--font-body); font-size: 18px; line-height: 1.75; color: #2B241D; }
.detail-body p { margin: 0 0 1.2em; max-width: 65ch; }
.detail-body p:first-of-type::first-letter {
  font-family: var(--font-display); font-size: 3.1em; float: left;
  line-height: .86; padding-right: 10px; color: var(--accent-ink);
}
.detail-foot { border-top: 2px solid var(--ink); margin-top: 28px; padding-top: 20px; display: flex; justify-content: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .hero-card { grid-template-columns: 1fr; }
  .hero-media { min-height: 220px; aspect-ratio: 16 / 9; }
}
@media (max-width: 680px) {
  .controls { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .colophon { grid-template-columns: 1fr; }
  .topbar-hide-sm { display: none; }
  #detail { border-radius: 0; margin: 0; min-height: 100%; }
  .overlay { padding: 0; }
  .detail-top { position: sticky; top: 0; background: var(--paper); padding: 10px 0; z-index: 2; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  #detail { animation: none; }
  .card:hover, .card:hover .card-media img, .hero-cta:hover, .btn-primary:hover { transform: none; }
}
