/* =====================================================================
   Site stylesheet
   ---------------------------------------------------------------------
   1. Fonts
   2. Design tokens (change the look here)
   3. Base
   4. Site header and navigation
   5. Homepage essay list
   6. Essay and page layout
   7. Essay body: prose, headings, quotations, footnotes, media
   8. Essay navigation (newer / older)
   9. Utilities, accessibility, print
   ===================================================================== */


/* 1. Fonts ------------------------------------------------------------
   EB Garamond, self-hosted (SIL Open Font License, see assets/fonts/OFL.txt).
   Variable weight 400–700. Subset to Latin + Latin Extended, keeping small
   capitals and old-style numerals. */

@font-face {
  font-family: "EB Garamond";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/eb-garamond-roman.woff2") format("woff2");
}

@font-face {
  font-family: "EB Garamond";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/eb-garamond-italic.woff2") format("woff2");
}


/* 2. Design tokens ---------------------------------------------------- */

:root {
  /* Colour: aged paper, iron-gall ink, a muted rubric for links.
     Contrast on --paper: ink 14.1:1, ink-muted 5.4:1, accent 8.4:1. */
  --paper:        #f2ead8;  /* page background */
  --ink:          #211c16;  /* body text */
  --ink-muted:    #6a5c4c;  /* dates, labels, secondary text */
  --accent:       #6e2f1f;  /* links, footnote markers ("rubric" red-brown) */
  --accent-hover: #4f2216;
  --rule:         #cbbd9f;  /* hairline dividers */
  --rule-strong:  #a8977a;  /* quotation rule, link underlines */
  --tint:         rgba(110, 92, 60, 0.07);  /* code and table header wash */
  --selection:    #e3d5b5;

  /* Type */
  --font-text: "EB Garamond", Garamond, "Iowan Old Style", "Palatino Linotype",
               Palatino, "Book Antiqua", Georgia, serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --text-size: clamp(1.1875rem, 1.05rem + 0.55vw, 1.375rem);  /* 19px → 22px */
  --leading:   1.6;
  --tracking-caps: 0.08em;  /* letter-spacing for small-capital labels */

  /* Layout */
  --measure: 31em;          /* reading column, roughly 65–70 characters per line */
  --gutter:  1.25rem;       /* minimum side margin on small screens */
  --space:   1.6em;         /* base vertical rhythm */
}


/* 3. Base ------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background-color: var(--paper);
  background-image: url("paper-grain.svg");  /* faint paper fibre; see README */
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--text-size);
  font-weight: 400;
  line-height: var(--leading);
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection); color: var(--ink); }

/* Garamond's true bold is heavy on screen; a semibold reads as emphasis. */
b, strong { font-weight: 600; }

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 0.18em;
}

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

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

/* Shared "small capitals" label style: site name, navigation, dates. */
.caps {
  font-variant-caps: all-small-caps;
  font-variant-numeric: oldstyle-nums;
  letter-spacing: var(--tracking-caps);
}

.wrap {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}


/* 4. Site header and navigation --------------------------------------
   One line: name and subtitle on the left, menu on the right, over a
   hairline. On narrow screens the menu drops to a second line. */

.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4em 1.75em;
  padding-top: 2.5rem;
}

/* The hairline spans the text column, under the whole header. */
.site-header::after {
  content: "";
  flex-basis: 100%;
  margin-top: 1.1rem;
  border-top: 1px solid var(--rule);
}

.site-id {
  margin: 0;
}

.site-name {
  color: var(--ink);
  font-size: 1.15em;
  text-decoration: none;
  white-space: nowrap;
}

.site-name:hover { color: var(--ink); }

/* Subtitle beside the name: quiet italic. */
.site-tagline {
  margin-left: 0.5em;
  color: var(--ink-muted);
  font-size: 0.9em;
  font-style: italic;
  white-space: nowrap;
}

.site-nav {
  font-size: 0.9em;
}

.site-nav ul {
  display: flex;
  gap: 1.1em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  color: var(--ink-muted);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
}

.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
}

main {
  padding-block: 3rem 5rem;
}


/* 5. Homepage essay list --------------------------------------------- */

.essay-list {
  margin: -0.7em 0 0;
  padding: 0;
  list-style: none;
}

.essay-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5em;
  padding-block: 0.7em;
  border-bottom: 1px solid var(--rule);
}

.essay-list a {
  color: var(--ink);
  text-decoration: none;
}

.essay-list a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
}

/* Dates as YYYY.MM.DD in even-width figures, so they line up. */
.essay-list time {
  flex-shrink: 0;
  color: var(--ink-muted);
  font-size: 0.8em;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* About page: the closing "find me elsewhere" line. */
.page .prose p.elsewhere {
  margin-top: 2em;
  padding-top: 1.25em;
  border-top: 1px solid var(--rule);
  text-align: center;
}

.empty-note {
  color: var(--ink-muted);
  font-style: italic;
  text-align: center;
}


/* 6. Essay and page layout ------------------------------------------- */

.entry-header {
  margin-bottom: 2.5em;
  text-align: center;
}

.entry-title {
  margin: 0;
  font-size: 2.1em;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

.entry-author {
  margin: 0.75em 0 0;
  font-style: italic;
}

/* Date as YYYY.MM.DD, matching the homepage list. */
.entry-date {
  margin: 0.75em 0 0;
  color: var(--ink-muted);
  font-size: 0.8em;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0.04em;
}

.entry-author + .entry-date { margin-top: 0.2em; }

.entry-header::after {
  content: "";
  display: block;
  width: 2.5em;
  margin: 1.75em auto 0;
  border-top: 1px solid var(--rule-strong);
}


/* 7. Essay body ------------------------------------------------------- */

.prose {
  hanging-punctuation: first;
  overflow-wrap: break-word;
}

/* All pages, essays included, use spaced paragraphs: a blank line between
   paragraphs and no first-line indent (the owner's choice). */
.prose p { margin: 0; }
.entry .prose p + p,
.page .prose p + p { margin-top: 1em; }

.prose h2,
.prose h3,
.prose h4 {
  margin: 2.2em 0 0.6em;
  line-height: 1.25;
  font-weight: 500;
  text-wrap: balance;
}

.prose h2 { font-size: 1.3em; }
.prose h3 { font-size: 1.1em; font-style: italic; }
.prose h4 {
  font-size: 1em;
  font-variant-caps: all-small-caps;
  letter-spacing: var(--tracking-caps);
}

.prose ul,
.prose ol,
.prose blockquote,
.prose figure,
.prose pre,
.prose table,
.prose img {
  margin-block: var(--space);
}

.prose ul,
.prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.3em; }
.entry .prose li p + p,
.page .prose li p + p { text-indent: 0; margin-top: 0.6em; }

.prose blockquote {
  margin-inline: 0;
  padding-left: 1.25em;
  border-left: 1px solid var(--rule-strong);
  font-size: 0.95em;
}

.entry .prose blockquote p + p,
.page .prose blockquote p + p { text-indent: 0; margin-top: 0.8em; }

/* Section break (a line of three dashes in Markdown): three spaced
   asterisks, the traditional book "dinkus". */
.prose hr {
  margin: 2.2em 0;
  border: 0;
  text-align: center;
  line-height: 1;
}

.prose hr::after {
  content: "*\2002*\2002*";
  color: var(--ink-muted);
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

/* Image with caption: in Markdown, an image line followed directly (no
   blank line) by an italic caption line. The pair is one paragraph, which
   is centred and set small, like a plate caption in a book. */
.entry .prose p:has(> img),
.page .prose p:has(> img) {
  margin-block: var(--space);
  text-align: center;
  text-indent: 0;
  color: var(--ink-muted);
  font-size: 0.85em;
  line-height: 1.45;
}

.prose p:has(> img) img { margin-block: 0 0.6em; }

.entry .prose p:has(> img) + p { text-indent: 0; }

.prose code,
.prose pre {
  font-family: var(--font-mono);
  font-size: 0.8em;
}

.prose code {
  padding: 0.1em 0.3em;
  background: var(--tint);
  border-radius: 2px;
}

.prose pre {
  padding: 1em 1.2em;
  overflow-x: auto;
  background: var(--tint);
  line-height: 1.5;
}

.prose pre code { padding: 0; background: none; font-size: 1em; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  font-variant-numeric: lining-nums tabular-nums;
}

.prose th,
.prose td {
  padding: 0.4em 0.75em;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.prose th {
  border-bottom-color: var(--rule-strong);
  font-weight: 500;
}

/* Footnote references in the text: small, in the rubric colour. */
.prose sup {
  line-height: 0;
  font-size: 0.7em;
}

.prose a.footnote {
  padding-inline: 0.1em;
  text-decoration: none;
  font-variant-numeric: lining-nums;
}

/* Footnotes collected at the end of the essay. */
.prose .footnotes {
  margin-top: 3.5em;
  padding-top: 1.25em;
  border-top: 1px solid var(--rule);
  font-size: 0.85em;
  line-height: 1.5;
}

.prose .footnotes ol { padding-left: 1.4em; margin: 0; }
.prose .footnotes li::marker { color: var(--ink-muted); }
.prose .footnotes li + li { margin-top: 0.6em; }

.prose a.reversefootnote {
  margin-left: 0.3em;
  text-decoration: none;
}


/* 8. Essay navigation ------------------------------------------------- */

.entry-nav {
  margin-top: 4em;
  padding-top: 1.5em;
  border-top: 1px solid var(--rule);
}

.entry-nav p { margin: 0 0 0.6em; }

.entry-nav .label {
  display: inline-block;
  min-width: 4.5em;
  color: var(--ink-muted);
}

.entry-nav .home {
  margin-top: 0;
  text-align: center;
}


/* 9. Utilities, accessibility, print --------------------------------- */

.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  padding: 0.4em 0.8em;
  background: var(--paper);
  color: var(--accent);
  transform: translateY(-200%);
}

.skip-link:focus { transform: none; }

/* Hidden visually but still read aloud by screen readers. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 34rem) {
  .site-header { padding-top: 1.75rem; }
  main { padding-top: 2.25rem; }
  .entry-title { font-size: 1.75em; }

  .essay-list li { gap: 1em; }
}

@media print {
  body { background: none; font-size: 11pt; }
  .site-nav, .entry-nav, .skip-link { display: none; }
  .site-header { padding-top: 0; }
  a { color: inherit; text-decoration: none; }
}
