/* ==========================================================================
   sloppedin — editorial stylesheet
   Deadpan serious: The Economist meets NY Review of Books.
   Design is the straight man, copy is the comedian.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Custom properties
   Light theme default. Dark mode is a warm dark, not generic grey.
   --------------------------------------------------------------------------- */

:root {
  --color-bg: #f6f3ec;
  --color-text: #1a1a1a;
  --color-muted: #6b655a;
  --color-accent: #7a1e1e;
  --color-rule: #d4cfc3;

  --font-serif: "EB Garamond", Charter, Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  /* Single text-column width used everywhere prose appears. The old 65ch body
     column is gone — 75ch is the one canonical width for all text content. */
  --max-width-research: 75ch;
  --max-width-container: 900px;

  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2.5rem;
  --spacing-2xl: 4rem;
}


/* ---------------------------------------------------------------------------
   Reset & base
   --------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: clamp(15px, 2.6vw, 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.65;
  color: var(--color-text);
  background-color: var(--color-bg);
}


/* ---------------------------------------------------------------------------
   Typography
   --------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-text);
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-md);
}

p {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
}

a {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-color: var(--color-accent);
}

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

strong, b {
  font-weight: 700;
}

hr {
  border: none;
  border-top: 1px solid var(--color-rule);
  margin: var(--spacing-xl) 0;
}

code {
  font-family: var(--font-sans);
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.04);
  padding: 0.15em 0.35em;
}

blockquote {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-md) var(--spacing-lg);
  border-left: 1px solid var(--color-rule);
  color: var(--color-muted);
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}


/* ---------------------------------------------------------------------------
   Utility: small caps
   Used for metadata, labels, and footer. Inter handles this cleanly.
   --------------------------------------------------------------------------- */

.small-caps {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}

/* Inter is used for all chrome; tabular numerals keep dates and counts aligned. */
h1, h2, h3, h4, h5, h6,
.small-caps,
.post-meta,
.post-card time,
.masthead-roles,
.site-footer p,
.section-label,
.post-body th {
  font-variant-numeric: tabular-nums;
}


/* ---------------------------------------------------------------------------
   Layout — site-wide wrapper
   --------------------------------------------------------------------------- */

.site-wrap {
  max-width: var(--max-width-container);
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}


/* ---------------------------------------------------------------------------
   Site header / masthead
   Centered, authoritative, slightly old-fashioned.
   --------------------------------------------------------------------------- */

.site-header {
  text-align: center;
  /* Extra bottom padding gives the larger h1 room to breathe before the rule. */
  padding: var(--spacing-2xl) 0 var(--spacing-xl);
  margin-bottom: var(--spacing-lg);
}

/* The double rule spans the full site-wrap (chrome) width on every page.
   The narrower 75ch post column sits inside this chrome on post pages,
   visibly indented — that contrast is intentional, not a mistake. */
.site-header::after {
  content: "";
  display: block;
  border-bottom: 3px double var(--color-rule);
}

.site-header h1 {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 3.2rem;
  font-weight: 400;
  margin: 0;
  line-height: 1.2;
}

.site-header h1 a {
  text-decoration: none;
  color: var(--color-text);
}

.site-header h1 a:hover {
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
}

.site-header .tagline {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  /* Top margin separates the tagline from the italic serif title above;
     bottom margin creates breathing room before the double rule drawn
     by .site-header::after. */
  margin-top: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.site-header .masthead-roles {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-top: var(--spacing-xs);
}


/* ---------------------------------------------------------------------------
   Post grid — index page
   2-column on desktop, 1 column below ~700px.
   --------------------------------------------------------------------------- */

/* Intro paragraph above the post grid. Serif, slightly muted, sized between
   body prose and the section heading. Narrower than the 900px chrome because
   a long paragraph at full grid width is uncomfortable to read. */
.home-intro {
  max-width: var(--max-width-research);
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--color-muted);
  /* Centered within the 900px chrome so it sits under the centered masthead
     rather than glued to the left edge where it reads as misaligned. */
  margin: 0 auto var(--spacing-sm);
}

/* Preserve the large gap below the intro block as a whole, while keeping
   adjacent intros tightly grouped. */
.home-intro:last-of-type {
  margin-bottom: var(--spacing-xl);
}

.section-heading {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 400;
  margin: 0 0 var(--spacing-lg);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--color-rule);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-xl);
  margin-bottom: var(--spacing-2xl);
}


/* ---------------------------------------------------------------------------
   Post card
   No excerpt, minimal chrome. Hover is restrained.
   --------------------------------------------------------------------------- */

.post-card {
  display: flex;
  flex-direction: column;
  color: var(--color-text);
  text-decoration: none;
  border: 1px solid var(--color-rule);
  transition: opacity 0.15s ease;
}

.post-card:hover {
  opacity: 1;
}

.post-card:hover h2 {
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
}

.post-card img {
  width: 100%;
  display: block;
  /* Fixed landscape ratio gives all cards identical thumbnail heights. Crop
     from the top so the infographic headline/top portion is preserved; the
     bottom of the image is clipped rather than the headline. */
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: top;
  transition: opacity 0.2s ease;
}

.post-card:hover img {
  opacity: 0.9;
}

.post-card-body {
  padding: var(--spacing-md);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.post-card h2 {
  font-family: var(--font-sans);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 var(--spacing-xs);
  color: var(--color-text);
  text-decoration: none;
}

.post-card time {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  /* Push the date to the bottom of the card body regardless of title height,
     so dates align across cards in the same row. */
  margin-top: auto;
  /* Pad the top so the date isn't pressed against the title on short cards. */
  padding-top: var(--spacing-md);
}


/* ---------------------------------------------------------------------------
   Post page
   The post-page column is 75ch wide and centered. All prose children,
   including the infographic, are constrained to this same column width.
   --------------------------------------------------------------------------- */

.post-page {
  max-width: var(--max-width-research);
  margin: 0 auto;
}

.post-page > h1 {
  font-family: var(--font-serif);
  font-style: normal;
  font-size: 2.25rem;
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: var(--spacing-sm);
}

.post-meta {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: var(--spacing-xl);
}


/* ---------------------------------------------------------------------------
   Post infographic
   Constrained to the same 75ch text column as all other post content.
   --------------------------------------------------------------------------- */

.post-infographic {
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
  text-align: center;
}

.post-infographic a {
  display: block;
  text-decoration: none;
}

.post-infographic img {
  display: block;
  width: 100%;
  transition: opacity 0.15s ease;
}

.post-infographic a:hover img {
  opacity: 0.92;
}

.infographic-caption {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--color-muted);
  margin-top: var(--spacing-sm);
}


/* ---------------------------------------------------------------------------
   Section labels
   THE INSIGHT, THE EVIDENCE, EDITORIAL BRIEF — small caps, thin rule above.
   All labels share the same 75ch column as the rest of the post content.
   --------------------------------------------------------------------------- */

.section-label {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  border-top: 1px solid var(--color-rule);
  padding-top: var(--spacing-sm);
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-md);
}

/* Topic preface and body share the same 75ch column. */
.topic-preface,
.topic-body {
  max-width: var(--max-width-research);
}

.topic-preface {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-bottom: var(--spacing-md);
}

.topic-body {
  font-size: 0.95rem;
  color: var(--color-muted);
  margin-bottom: var(--spacing-xl);
}


/* ---------------------------------------------------------------------------
   Post body — rendered markdown
   Drop cap, first-line indents, no bottom margin between paragraphs.
   --------------------------------------------------------------------------- */

.post-body {
  max-width: var(--max-width-research);
  margin: 0 0 var(--spacing-2xl);
}

/* First paragraph gets the drop cap. */
.post-body > p:first-child::first-letter {
  float: left;
  font-family: var(--font-serif);
  font-size: 4.2rem;
  line-height: 0.75;
  padding-right: 0.1em;
  padding-top: 0.05em;
  color: var(--color-accent);
}

/* Every paragraph in the body gets no bottom margin. */
.post-body p {
  margin-bottom: 0;
}

/* Subsequent paragraphs get a first-line indent. */
.post-body > p + p {
  text-indent: 1.5em;
}

/* First paragraph has no indent because the drop cap handles it. */
.post-body > p:first-child {
  text-indent: 0;
}

.post-body h1 { font-size: 1.5rem; }
.post-body h2 { font-size: 1.25rem; }
.post-body h3 { font-size: 1.05rem; }

.post-body ul,
.post-body ol {
  padding-left: var(--spacing-xl);
  margin-bottom: var(--spacing-md);
}

.post-body li {
  margin-bottom: var(--spacing-xs);
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--spacing-lg) 0;
  font-size: 0.9rem;
}

.post-body th,
.post-body td {
  text-align: left;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--color-rule);
}

.post-body th {
  font-family: var(--font-sans);
  font-weight: 600;
}


/* ---------------------------------------------------------------------------
   Research section
   No colored box. Same 75ch column as the post body.
   --------------------------------------------------------------------------- */

/* No bottom border — the EDITORIAL BRIEF section-label rule above it
   already provides the visual separator between research and topic. */
.research-section {
  max-width: var(--max-width-research);
  margin: 0 0 var(--spacing-xl);
}

.research-section h1 {
  font-size: 1.4rem;
}

.research-section h2 {
  font-size: 1.15rem;
}

.research-section h3 {
  font-size: 1rem;
}

.research-section h4 {
  font-size: 0.9rem;
}


/* ---------------------------------------------------------------------------
   Reference — superscript bracketed number
   Markup: <sup class="ref"><a href="#ref-N">[N]</a></sup>
   --------------------------------------------------------------------------- */

.ref {
  font-family: var(--font-serif);
  font-size: 0.7em;
  vertical-align: super;
  line-height: 0;
  margin: 0 0.05em;
}

.ref a {
  color: var(--color-accent);
  text-decoration: none;
}

.ref a:hover {
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
}


/* ---------------------------------------------------------------------------
   References list
   Hanging indent, small serif. :target gets a thin left rule only.
   --------------------------------------------------------------------------- */

ol.references {
  list-style: decimal;
  padding-left: var(--spacing-xl);
  font-size: 0.85rem;
  line-height: 1.5;
  font-family: var(--font-serif);
}

ol.references li {
  margin-bottom: var(--spacing-sm);
  padding-left: var(--spacing-sm);
  border-left: 1px solid transparent;
  transition: border-color 0.2s ease;
}

ol.references li:target {
  border-left-color: var(--color-accent);
}



/* ---------------------------------------------------------------------------
   Site footer
   --------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--color-rule);
  padding: var(--spacing-xl) 0;
  margin-top: var(--spacing-2xl);
  text-align: center;
}

.site-footer p {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin: 0;
}


/* ---------------------------------------------------------------------------
   Responsive — single-column below ~700px
   --------------------------------------------------------------------------- */

@media (max-width: 700px) {
  .post-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
  }

  .site-header {
    padding: var(--spacing-xl) 0 var(--spacing-lg);
  }

  .post-page > h1 {
    font-size: 1.75rem;
  }

  /* No infographic override needed — the breakout was removed, so the
     infographic already flows naturally within the text column at all widths. */
}


/* ---------------------------------------------------------------------------
   Dark mode
   Warm dark, not generic grey. Follows OS preference, no toggle.
   --------------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1814;
    --color-text: #e8e4dc;
    --color-muted: #8a8578;
    --color-accent: #b94545;
    --color-rule: #3a3530;
  }

  a {
    color: var(--color-text);
  }

  code {
    background: rgba(255, 255, 255, 0.06);
  }

  .post-card {
    border-color: var(--color-rule);
  }

  .post-card:hover img {
    opacity: 0.85;
  }
}
