/* ==========================================================================
   Toil for Toil: stylesheet
   Colours and fonts are set in :root. Change them there.
   ========================================================================== */

:root {
  --paper: #F5F6F3;
  --ink: #1C2421;
  --muted: #5E6762;
  --rule: #D9DDD8;
  --bench: #2D5A4A;      /* accent: links, active topic */
  --brass: #8A6A22;      /* paragraph numbers, corrections */
  --highlight: #E9E4D2;  /* linked paragraph */
  --correction: #C2361F; /* the red-pen correction in the logo and correction notes */

  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --marker: "Permanent Marker", "Marker Felt", "Segoe Print", "Bradley Hand", cursive;

  --page: 46rem;
  --measure: 38rem;
  --gutter: 1.25rem;
  --pnum-space: 2.25rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141A18;
    --ink: #E4E8E5;
    --muted: #9BA5A0;
    --rule: #2B3431;
    --bench: #7CC2A6;
    --brass: #D4B15E;
    --highlight: #2C2B1F;
    --correction: #FF7A5C;
  }
}

/* ---------- Base ---------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

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

a:focus-visible {
  outline: 3px solid var(--bench);
  outline-offset: 3px;
  border-radius: 2px;
}

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

.wrap {
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

.skip {
  position: absolute;
  left: var(--gutter);
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  color: var(--paper);
  z-index: 10;
}
.skip:focus { top: 0.75rem; }

/* ---------- Masthead ---------- */

.masthead { border-bottom: 1px solid var(--rule); }

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 0.75rem 1.1rem;
}

/* ---------- Logo: "Wealth for Toil" with Wealth struck out and Toil written in ---------- */

.brand-title { margin: 0; font-size: inherit; font-weight: inherit; }

.brand {
  display: inline-block;
  padding-top: 0.82em;              /* room for the handwritten correction */
  font-family: var(--serif);
  font-weight: 700;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand--large { font-size: clamp(2.4rem, 9vw, 4.75rem); letter-spacing: -0.02em; }

.brand-struck { position: relative; display: inline-block; margin-right: 0.04em; color: var(--muted); }

.brand-strike {
  position: absolute;
  left: -4%;
  top: 34%;
  width: 107%;
  height: 0.42em;
  overflow: visible;
  pointer-events: none;
}
.brand-strike path {
  fill: none;
  stroke: var(--correction);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-fix {
  position: absolute;
  left: 50%;
  bottom: 76%;
  transform: translateX(-50%) rotate(-6deg);
  font-family: var(--marker);
  font-weight: 400;
  font-size: 0.72em;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--correction);
}

/* Home page: the correction is made as the page loads. */
.brand--large .brand-strike path {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: strike 0.45s 0.25s cubic-bezier(0.6, 0, 0.3, 1) forwards;
}
.brand--large .brand-fix {
  opacity: 0;
  animation: write-in 0.35s 0.65s ease-out forwards;
}
@keyframes strike { to { stroke-dashoffset: 0; } }
@keyframes write-in {
  from { opacity: 0; transform: translateX(-50%) translateY(0.15em) rotate(-10deg); }
  to   { opacity: 1; transform: translateX(-50%) rotate(-6deg); }
}

.site-nav { display: flex; gap: 1.25rem; }
.site-nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.9375rem; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); }

/* ---------- Home ---------- */

.intro {
  margin: 0;
  padding-top: 2.5rem;
  max-width: var(--measure);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.6;
  color: var(--muted);
}

.lead {
  padding-block: 2.25rem 2.75rem;
  border-bottom: 1px solid var(--rule);
}

.lead-title {
  margin: 0 0 1rem;
  font-size: clamp(2.25rem, 6.5vw, 3.5rem);
  line-height: 1.04;
  font-weight: 800;
  letter-spacing: -0.025em;
  max-width: 20ch;
  text-wrap: balance;
}
.lead-title a { color: inherit; text-decoration: none; }
.lead-title a:hover { text-decoration: underline; text-decoration-thickness: 3px; text-decoration-color: var(--bench); }

.lead-dek {
  margin: 0 0 1.25rem;
  max-width: var(--measure);
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.55;
  color: var(--muted);
}

.list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-top: 2.25rem;
}

.list-heading { margin: 0; font-size: 1rem; font-weight: 600; color: var(--muted); }

.topics { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.topics a {
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  padding-bottom: 0.15rem;
  border-bottom: 3px solid transparent;
}
.topics a:hover { color: var(--ink); }
.topics a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--bench); }

.post-list { list-style: none; margin: 0; padding: 0.5rem 0 1rem; }

.post {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.25rem 1.5rem;
  padding-block: 1.5rem;
}

.post-date {
  padding-top: 0.3rem;
  font-size: 0.875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.post-title {
  margin: 0 0 0.4rem;
  font-size: 1.375rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.post-title a { color: var(--ink); text-decoration: none; }
.post-title a:hover { text-decoration: underline; text-decoration-color: var(--bench); }

.post-dek {
  margin: 0 0 0.5rem;
  max-width: var(--measure);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--muted);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.meta-topic { font-weight: 600; text-decoration: none; }
.meta-topic:hover { text-decoration: underline; }

.empty { padding-block: 1.5rem; color: var(--muted); font-family: var(--serif); font-size: 1.0625rem; }

/* ---------- Article ---------- */

.article-header { padding-block: 3rem 2.25rem; }

.article-header h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 5.5vw, 3.25rem);
  line-height: 1.06;
  font-weight: 800;
  letter-spacing: -0.025em;
  max-width: 22ch;
  text-wrap: balance;
}

.dek {
  margin: 0 0 1.5rem;
  max-width: var(--measure);
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.55;
  color: var(--muted);
}

.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9375rem;
  color: var(--muted);
}
.byline .author { color: var(--ink); font-weight: 600; }
.byline a { font-weight: 600; text-decoration: none; }
.byline a:hover { text-decoration: underline; }

.prose {
  max-width: calc(var(--measure) + var(--pnum-space));
  padding-left: var(--pnum-space);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.7;
}

.prose > p { position: relative; margin: 0 0 1.25em; }

.prose h2 {
  margin: 2.25em 0 0.7em;
  font-family: var(--sans);
  font-size: 1.375rem;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.prose ul, .prose ol { margin: 0 0 1.25em; padding-left: 1.25em; }
.prose li + li { margin-top: 0.35em; }

.prose blockquote {
  margin: 1.5em 0;
  padding-left: 1.25rem;
  border-left: 3px solid var(--bench);
  font-style: italic;
}

/* Paragraph numbers (added by site.js). Click to copy a link to that paragraph. */
.pnum {
  position: absolute;
  top: 0;
  left: calc(var(--pnum-space) * -1);
  width: calc(var(--pnum-space) - 0.6rem);
  text-align: right;
  font: 600 0.8125rem/1.9125rem var(--sans);
  color: var(--brass);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.pnum:hover { text-decoration: underline; }
.pnum.is-copied { color: var(--bench); }
.pnum.is-copied::before { content: "✓ "; }

.prose > p.is-target {
  background: var(--highlight);
  box-shadow: 0 0 0 0.5rem var(--highlight);
  border-radius: 2px;
  transition: background-color 0.6s ease, box-shadow 0.6s ease;
}

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 0 1.5em; }

.prose table {
  border-collapse: collapse;
  min-width: 20rem;
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.4;
}
.prose caption {
  caption-side: top;
  text-align: left;
  padding-bottom: 0.5rem;
  font-weight: 600;
  color: var(--muted);
}
.prose th, .prose td {
  padding: 0.55rem 1.5rem 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}
.prose thead th { font-weight: 600; color: var(--muted); }
.prose .num { text-align: right; font-variant-numeric: tabular-nums; }
.prose tr.winner td { font-weight: 700; }

/* Corrections and sources */
.correction, .sources {
  max-width: calc(var(--measure) + var(--pnum-space));
  margin: 2.5rem 0 0;
  padding-left: var(--pnum-space);
  font-size: 0.9375rem;
  line-height: 1.6;
}
.correction p {
  margin: 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--correction);
}
.sources h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.sources ol { margin: 0; padding-left: 1.25rem; color: var(--muted); }

/* Related + pager */
.more {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}
.more-title { margin: 0 0 1rem; font-size: 1rem; font-weight: 600; color: var(--muted); }
.more-list { list-style: none; margin: 0 0 2.5rem; padding: 0; }
.more-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; padding-block: 0.5rem; }
.more-list a { font-weight: 600; color: var(--ink); text-decoration: none; }
.more-list a:hover { text-decoration: underline; text-decoration-color: var(--bench); }
.more-list time { font-size: 0.875rem; color: var(--muted); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.pager a { display: block; color: var(--ink); text-decoration: none; font-weight: 600; line-height: 1.35; }
.pager a:hover { text-decoration: underline; text-decoration-color: var(--bench); }
.pager span { display: block; margin-bottom: 0.25rem; font-size: 0.875rem; font-weight: 400; color: var(--muted); }
.pager-newer { text-align: right; grid-column: 2; }

/* ---------- Plain pages (about, 404) ---------- */

.page-header { padding-block: 3rem 1.5rem; }
.page-header h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 5.5vw, 3.25rem);
  line-height: 1.06;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.page-body { max-width: var(--measure); font-family: var(--serif); font-size: 1.125rem; line-height: 1.7; }
.page-body h2 { margin: 2em 0 0.6em; font-family: var(--sans); font-size: 1.25rem; }
.page-body p { margin: 0 0 1.1em; }

/* ---------- Manifesto ---------- */

.manifesto-lede {
  margin: 0;
  max-width: var(--measure);
  font-family: var(--serif);
  font-size: 1.3125rem;
  line-height: 1.6;
}
.manifesto-lede + .manifesto-lede { margin-top: 1em; }

.theses {
  list-style: none;
  counter-reset: thesis;
  max-width: var(--measure);
  margin: 2.75rem 0 0;
  padding: 0;
}

.thesis {
  counter-increment: thesis;
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  gap: 0 1rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 1rem;
}
.thesis::before {
  content: counter(thesis);
  font: 800 1.75rem/1.1 var(--sans);
  color: var(--brass);
  font-variant-numeric: tabular-nums;
}
.thesis h2 {
  margin: 0 0 0.45rem;
  font-size: 1.3125rem;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.thesis p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
}
.thesis:target { background: var(--highlight); box-shadow: 0 0 0 0.75rem var(--highlight); }

.manifesto-close {
  max-width: var(--measure);
  margin: 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
}

/* ---------- Footer ---------- */

.site-foot { margin-top: 4rem; border-top: 1px solid var(--rule); }
.foot-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 1.75rem 3rem;
  font-size: 0.875rem;
  color: var(--muted);
}
.foot-inner p { margin: 0; }

/* ---------- Responsive ---------- */

@media (min-width: 54rem) {
  /* Wide screens: paragraph numbers hang in the left margin. */
  .prose, .correction, .sources { padding-left: 0; max-width: var(--measure); }
  .pnum { left: -3rem; width: 2.25rem; }
}

@media (max-width: 34rem) {
  :root { --pnum-space: 1.9rem; }
  .thesis { grid-template-columns: 2rem 1fr; gap: 0 0.75rem; }
  .thesis::before { font-size: 1.375rem; }
  .post { grid-template-columns: 1fr; gap: 0.35rem; }
  .post-date { padding-top: 0; }
  .pager { grid-template-columns: 1fr; }
  .pager-newer { grid-column: 1; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .brand--large .brand-strike path { stroke-dashoffset: 0; }
  .brand--large .brand-fix { opacity: 1; }
}

@media print {
  .masthead, .site-foot, .more, .pnum, .skip { display: none; }
  body { background: #fff; color: #000; }
  .prose, .correction, .sources { padding-left: 0; }
}
