:root {
  --bg:      #ffffff;
  --page:    #f6f7fa;
  --ink:     #151515;
  --ink-dim: #6b6b6b;
  --line:    #eaeaea;
  --accent:  #3b6ef5;
  --coral:   #ff7a59;
  --pastel-1: #cbe0ff;
  --pastel-2: #ffd9c4;
  --pastel-3: #e0d2ff;
  --pastel-4: #c6f0dc;
  --sans: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--page); }

body {
  font-family: var(--sans);
  background: var(--page);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ── header ── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding: 18px 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.header a.brand { font-weight: 700; font-size: 18px; }
.header a.brand .dot { color: var(--coral); }
.nav-links { display: flex; gap: 22px; font-size: 14px; }
.nav-links a { color: var(--ink-dim); }
.nav-links a:hover { color: var(--ink); }

/* ── page heading + filters ── */
.page-head {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 32px 0;
}
.page-head h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.025em; margin-bottom: 4px; }
.page-sub { color: var(--ink-dim); font-size: 15px; margin-bottom: 22px; }

.filters {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}
.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-tab {
  font-family: var(--sans);
  font-size: 14px; font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
}
.filter-tab.active { background: var(--accent); color: #fff; }
.filters select {
  font-family: var(--sans);
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink-dim);
}

/* ── card grid ── */
main { max-width: 1080px; margin: 0 auto; padding: 28px 32px 80px; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 32px;
  list-style: none;
}
.card { display: block; }
.card-thumb {
  aspect-ratio: 16 / 11;
  border-radius: 14px;
  padding: 20px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--pastel-1);
  overflow: hidden;
}
/* doubled .essay so the register beats the nth-child colour cycle regardless of
   where an essay lands in the grid — a tie on specificity loses to source order */
.card-grid > li .card-thumb.essay.essay { background: var(--parchment); }
.card-grid > li .card-thumb.essay.essay .card-thumb-title {
  font-family: "Lora", Georgia, serif;
  font-weight: 600; color: var(--essay-ink); font-size: 21px;
}
.card-grid > li .card-thumb.essay.essay .card-thumb-author { color: #6d6455; }
.card-grid > li:nth-child(4n+2) .card-thumb { background: var(--pastel-2); }
.card-grid > li:nth-child(4n+3) .card-thumb { background: var(--pastel-3); }
.card-grid > li:nth-child(4n+4) .card-thumb { background: var(--pastel-4); }
.card-thumb-title {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--ink);
  max-width: 82%;
  /* hard guard: a long title must never push the art out of the card */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-thumb-title .hl {
  background: #b8d0fb;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  padding: 0 4px;
  border-radius: 3px;
}
.card-thumb-foot {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin: 0 -18px -14px 0;
}
.card-thumb-author { font-size: 12px; font-weight: 600; color: var(--ink-dim); padding-bottom: 16px; }
.art {
  width: 138px; height: 138px; display: block; flex: none;
  transition: transform .25s cubic-bezier(.3,1.4,.5,1);
}
.card:hover .art { transform: rotate(-5deg) scale(1.07); }
.card-excerpt code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.88em; background: #ececf1; padding: 0 4px; border-radius: 3px;
}
footer span { font-weight: 600; color: var(--ink); }

.card-title {
  font-weight: 700; font-size: 17px;
  margin-top: 14px; display: block;
}
.card:hover .card-title { color: var(--accent); }
.card-excerpt { color: var(--ink-dim); font-size: 14px; margin-top: 6px; }
.card-meta {
  color: var(--ink-dim); font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  margin-top: 10px;
}

/* ── article ── */
article {
  max-width: 760px;
  margin: 40px auto 60px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 56px 64px 64px;
}
article .back { font-size: 13px; font-weight: 600; color: var(--ink-dim); display: inline-block; margin-bottom: 24px; }
.post-hero {
  aspect-ratio: 21 / 8;
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 32px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--pastel-1);
  overflow: hidden;
}
/* the hero has room for a full title — the 2-line card clamp must not apply here */
.post-hero .card-thumb-title {
  font-size: 30px; max-width: 74%;
  display: block; overflow: visible; -webkit-line-clamp: none;
}
.post-hero .art { width: 168px; height: 168px; }
article .back:hover { color: var(--accent); }
article h1 { font-weight: 800; font-size: 36px; margin-bottom: 10px; line-height: 1.2; letter-spacing: -0.02em; }
article .card-meta { margin-bottom: 36px; }
article > p:first-of-type { font-size: 18px; }
article p { margin: 16px 0; }
article code {
  font-family: ui-monospace, Consolas, monospace;
  background: var(--page);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.85em;
}
article pre {
  background: var(--page);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 20px 0;
}
article pre code { background: none; padding: 0; }

/* ── long-form essays: serif, wider measure, sober palette ── */
:root { --parchment: #e9e2d4; --essay-ink: #1f2733; }

article.essay { max-width: 800px; padding: 56px 72px 64px; }
article.essay p { font-family: "Lora", Georgia, serif; font-size: 18px; line-height: 1.75; margin: 20px 0; }
article.essay > p:first-of-type { font-size: 19px; }
article.essay h1 { font-size: 38px; line-height: 1.18; }
article h2 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.01em;
  margin: 44px 0 4px; line-height: 1.3;
}

/* prose links must be visible — the global `a { color: inherit }` hides them */
article p a, article li a, article td a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
article p a:hover, article li a:hover, article td a:hover { text-decoration-thickness: 2px; }

article.essay .post-hero.essay { background: var(--parchment); }
.post-hero.essay .card-thumb-title {
  font-family: "Lora", Georgia, serif;
  font-weight: 600; font-size: 32px; color: var(--essay-ink);
}
.post-hero.essay .card-thumb-author { color: #6d6455; }

.sources {
  font-size: 13.5px !important;
  line-height: 1.9 !important;
  color: var(--ink-dim);
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 44px !important;
}
.sources strong { color: var(--ink); }

.editorial-note {
  font-size: 14px !important;
  color: var(--ink-dim);
  font-style: italic;
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 40px !important;
}

article.essay blockquote {
  font-family: "Lora", Georgia, serif;
  font-size: 18px; line-height: 1.75; font-style: italic;
  margin: 28px 0; padding: 2px 0 2px 24px;
  border-left: 3px solid var(--accent);
  color: var(--ink-dim);
}

article table { border-collapse: collapse; width: 100%; margin: 24px 0; font-size: 14px; }
article th, article td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
article th { font-weight: 700; border-bottom: 2px solid var(--ink); white-space: nowrap; }
article td:first-child { font-weight: 600; white-space: nowrap; }

article ul { margin: 20px 0; padding-left: 22px; }
article li { margin: 10px 0; line-height: 1.6; }

footer {
  color: var(--ink-dim);
  font-size: 13px;
  text-align: center;
  padding: 30px;
  border-top: 1px solid var(--line);
}
