:root {
  --bg: #faf7f0;
  --bg-card: #ffffff;
  --text: #16130d;
  --text-muted: #6a6358;
  --rule: #d9d2c2;
  --accent: #8b1a1a;
  --serif: 'Fraunces', 'Georgia', serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --max: 1240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }

img { display: block; max-width: 100%; height: auto; }

/* ========= Masthead ========= */
.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.masthead-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px 24px 16px;
}
.masthead-rule { height: 2px; background: var(--text); }
.masthead-rule-top { margin-bottom: 8px; }
.masthead-rule-bottom { height: 1px; margin-top: 8px; }
.masthead-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 20px;
}
.masthead-title {
  font: 900 56px/0.95 var(--serif);
  letter-spacing: -0.02em;
  margin: 0;
  text-align: center;
  text-transform: uppercase;
  font-variation-settings: 'opsz' 144;
}
.masthead-issue, .masthead-date {
  font: 500 12px/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}
.masthead-issue { text-align: left; }
.masthead-date { text-align: right; }
.masthead-tagline {
  margin: 10px 0 0;
  text-align: center;
  font: italic 14px/1.4 var(--serif);
  color: var(--text-muted);
}
.masthead-nav {
  margin: 14px 0 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 22px;
  font: 500 12px/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.masthead-nav a {
  color: var(--text);
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: border-color .15s ease, color .15s ease;
}
.masthead-nav a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}
html { scroll-behavior: smooth; }
section[id] { scroll-margin-top: 16px; }

/* ========= Layout container ========= */
.hero, .secondary-heroes, .section, .colophon {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

/* ========= Hero ========= */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 32px;
  padding-top: 36px;
  padding-bottom: 36px;
  align-items: center;
}
.hero-image {
  position: relative;
  display: block;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--rule);
}
.hero-image img { width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 1; }
.hero-meta {
  font: 500 11px/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 14px;
}
.hero-source { border-right: 1px solid var(--rule); padding-right: 10px; margin-right: 10px; }
.hero-headline {
  font: 900 52px/1.02 var(--serif);
  letter-spacing: -0.015em;
  margin: 0 0 16px;
  font-variation-settings: 'opsz' 144;
}
.hero-summary {
  font: 400 18px/1.5 var(--serif);
  color: var(--text);
  margin: 0;
  max-width: 46ch;
}

/* ========= Secondary heroes ========= */
.secondary-heroes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  padding-top: 10px;
  padding-bottom: 40px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding-top: 28px;
  margin-top: 8px;
}

/* ========= Section headings ========= */
.section {
  padding-top: 44px;
  padding-bottom: 44px;
  border-top: 1px solid var(--rule);
}
.section:first-of-type { border-top: none; }
.section-title {
  font: 900 13px/1 var(--sans);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 28px;
  padding-bottom: 12px;
  border-bottom: 3px double var(--text);
}

/* ========= Section grid ========= */
/* 4-column grid; the lead card spans 2 cols × 2 rows, small cards fill
   the remaining cells and wrap naturally into aligned rows below. */
.section-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: auto;
  grid-auto-flow: row dense;
  gap: 28px;
  align-items: start;
}
.section-grid > .card-lead {
  grid-column: span 2;
  grid-row: span 2;
}

.section-top-tail .card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 28px;
  align-items: start;
}

/* ========= Cards ========= */
.card { display: flex; flex-direction: column; gap: 10px; }
.card-image {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--rule);
  aspect-ratio: 16/9;
}
.card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; position: relative; z-index: 1; }
.card-image:hover img { transform: scale(1.03); }

/* Placeholder pattern: subtle diagonal stripes + centered camera glyph.
   Applied to any image slot that is missing or failed to load. */
.card-image-empty,
.card-image:not(:has(img)) {
  background-image:
    repeating-linear-gradient(
      45deg,
      rgba(22,19,13,0.03) 0 8px,
      rgba(22,19,13,0.07) 8px 16px
    );
  background-color: var(--rule);
}
.card-image-empty::after,
.card-image:not(:has(img))::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a8a196' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='14' rx='1.5'/><circle cx='9' cy='11' r='2'/><path d='M21 17l-5-5-8 8'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 32px 32px;
  opacity: 0.55;
  pointer-events: none;
}
.card-meta {
  font: 500 10.5px/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}
.card-source { color: var(--accent); }
.card-paywall {
  margin-left: 8px;
  padding: 1px 6px;
  background: var(--text);
  color: var(--bg);
  border-radius: 2px;
  font-size: 9px;
}
.card-headline {
  font: 700 20px/1.2 var(--serif);
  letter-spacing: -0.01em;
  margin: 2px 0 0;
  font-variation-settings: 'opsz' 72;
}
.card-headline a:hover { color: var(--accent); }
.card-summary {
  font: 400 14.5px/1.5 var(--sans);
  color: var(--text-muted);
  margin: 4px 0 0;
}
.card-coverage {
  margin-left: 6px;
  padding: 1px 7px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 10px;
  font-size: 9.5px;
  letter-spacing: 0.05em;
}
.takes {
  list-style: none;
  margin: 10px 0 0;
  padding: 10px 0 0;
  border-top: 1px dotted var(--rule);
  font: 400 13px/1.4 var(--sans);
}
.take { padding: 3px 0; display: flex; gap: 8px; align-items: baseline; }
.take-source {
  font: 500 10px/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  flex: 0 0 auto;
  padding-top: 2px;
  min-width: 80px;
}
.take-headline { color: var(--text); }
.take-headline:hover { color: var(--accent); }

/* Lead card takes list a bit roomier */
.card-lead .takes { font-size: 14px; }
.card-lead .take-source { min-width: 90px; font-size: 10.5px; }

/* Hero takes list */
.hero .takes { font-size: 15px; margin-top: 18px; padding-top: 14px; }
.hero .take-source { min-width: 110px; font-size: 11px; }

/* Lead card (image on top, bigger type) */
.card-lead .card-image { aspect-ratio: 4/3; }
.card-lead .card-headline { font-size: 30px; line-height: 1.1; }
.card-lead .card-summary { font-size: 16px; }

/* Medium card (secondary heroes) */
.card-medium .card-image { aspect-ratio: 16/10; }
.card-medium .card-headline { font-size: 24px; line-height: 1.15; }
.card-medium .card-summary { font-size: 15px; }

/* Small card */
.card-small .card-image { aspect-ratio: 16/9; }
.card-small .card-headline { font-size: 17px; line-height: 1.25; }
.card-small .card-summary { font-size: 13.5px; line-height: 1.45; }

/* ========= HN raw section ========= */
.section-hn .hn-list {
  list-style: none;
  padding: 0;
  margin: 0;
  column-width: 340px;
  column-gap: 40px;
}
.hn-item {
  break-inside: avoid;
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dotted var(--rule);
  font: 400 14.5px/1.35 var(--sans);
}
.hn-rank {
  flex: 0 0 auto;
  font: 500 11.5px/1 var(--sans);
  color: var(--text-muted);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
  min-width: 22px;
}
.hn-link { color: var(--text); }
.hn-link:hover { color: var(--accent); text-decoration: none; }

/* ========= Colophon ========= */
.colophon {
  margin-top: 48px;
  padding-top: 24px;
  padding-bottom: 48px;
  border-top: 1px solid var(--rule);
  font: 400 12px/1.5 var(--sans);
  color: var(--text-muted);
  text-align: center;
}
.colophon p { margin: 4px 0; }

/* ========= Responsive ========= */
@media (max-width: 900px) {
  .masthead-title { font-size: 40px; }
  .masthead-row { grid-template-columns: 1fr; gap: 4px; text-align: center; }
  .masthead-issue, .masthead-date { text-align: center; }
  .hero { grid-template-columns: 1fr; gap: 20px; padding-top: 24px; padding-bottom: 24px; }
  .hero-headline { font-size: 36px; }
  .hero-summary { font-size: 16px; }
  .secondary-heroes { grid-template-columns: 1fr; gap: 24px; padding-top: 20px; padding-bottom: 24px; }
  .section { padding-top: 28px; padding-bottom: 28px; }
  .card-lead .card-headline { font-size: 24px; }
  .card-medium .card-headline { font-size: 20px; }
}

/* Section-grid responsive breakpoints */
@media (max-width: 1099px) {
  .section-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 799px) {
  .section-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
  .section-grid > .card-lead { grid-row: span 1; }
}
@media (max-width: 520px) {
  .section-grid { grid-template-columns: 1fr; }
  .section-grid > .card-lead { grid-column: span 1; }
}
