/* Hedera layout: a text column and, on wide screens, a margin for notes.
   hedera.css supplies the typeface, block paragraphs and integration rules. */

:root {
  color-scheme: light dark;
  --paper: light-dark(#fbfaf6, #16171a);
  --ink: light-dark(#1d1c1a, #e8e5dd);
  --ink-2: light-dark(#57554f, #b0aca3);
  --ink-3: light-dark(#8d897f, #7f7c75);
  --rule: light-dark(#e4e1d8, #2c2d31);
  --wash: light-dark(#f2f0e9, #1e1f23);
  --accent: light-dark(#3a5d8f, #94b4de);
  --accent-soft: light-dark(rgb(58 93 143 / 0.36), rgb(148 180 222 / 0.4));
  --select: light-dark(#dce5f1, #2b3a52);
  --serif: Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --fs-s: 19px;
  --fs-m: 20px;
  --fs-l: 21px;
  --fs-xl: 22px;
  --fs: var(--fs-s);
  --lh: 1.52;
  --measure: 30;
  --text: calc(var(--fs) * var(--measure));
  --gap: calc(var(--fs) * 2.4);
  --margin: calc(var(--fs) * 10.5);
  --indent: 1.45em;
  --top: clamp(3.2rem, 9vw, 6.5rem);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@media (min-width: 760px) { :root { --fs: var(--fs-m); } }
@media (min-width: 1120px) { :root { --fs: var(--fs-l); } }
@media (min-width: 1440px) { :root { --fs: var(--fs-xl); } }

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

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--fs);
  line-height: var(--lh);
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-kerning: normal;
  font-feature-settings: "kern", "liga", "calt";
  text-rendering: optimizeLegibility;
  hanging-punctuation: first allow-end;
}
:root[data-theme="dark"] body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: var(--select); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 1px; }
.sc { font-variant-caps: all-small-caps; letter-spacing: 0.07em; }

.skip {
  position: absolute; left: 1rem; top: -3rem; padding: 0.4em 0.8em;
  background: var(--paper); color: var(--accent); z-index: 10;
}
.skip:focus { top: 1rem; }

/* ---------- frame: a text column and, on wide screens, a margin ---------- */

.frame { width: min(100% - 2.6rem, var(--text)); margin-inline: auto; }

@media (min-width: 1120px) {
  .frame { width: calc(var(--text) + var(--gap) + var(--margin)); }
  .spread {
    display: grid;
    grid-template-columns: var(--text) var(--margin);
    column-gap: var(--gap);
    align-items: start;
  }
  .main-col { grid-column: 1; min-width: 0; }
  .margin-col { grid-column: 2; }
}

/* ---------- masthead ---------- */

.mast { padding-top: 1.7rem; }
.mast-inner {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 0.4rem 1.5rem;
}
.mast-name {
  font-variant-caps: all-small-caps; letter-spacing: 0.14em;
  text-decoration: none; color: var(--ink);
}
.mast-nav {
  display: flex; flex-wrap: wrap; gap: 0.2rem 1.1em;
  font-variant-caps: all-small-caps; letter-spacing: 0.1em; font-size: 0.9em;
}
.mast-nav a { color: var(--ink-2); text-decoration: none; transition: color 0.15s; }
.mast-nav a:hover, .mast-nav a[aria-current] { color: var(--accent); }
.toggle {
  font: inherit; letter-spacing: inherit; font-variant-caps: inherit;
  background: none; border: 0; padding: 0; margin: 0; cursor: pointer; color: var(--ink-3);
}
.toggle:hover { color: var(--accent); }
@media (max-width: 520px) { .mast-nav { font-size: 0.8em; gap: 0.2rem 0.95em; } }

/* ---------- home ---------- */

.intro { margin-top: var(--top); }
.intro-lead {
  margin: 0; font-weight: 400;
  font-size: clamp(1.36em, 1.06em + 1vw, 1.62em); line-height: 1.32;
  max-width: 21em; text-wrap: pretty;
}
.intro-lead .name { font-variant-caps: all-small-caps; letter-spacing: 0.07em; }
.elsewhere { margin: 1.3rem 0 0; font-size: 0.82em; line-height: 1.5; color: var(--ink-3); }
.elsewhere a { color: var(--ink-2); text-decoration: none; white-space: nowrap; transition: color 0.15s; }
.elsewhere a:hover { color: var(--accent); }
@media (min-width: 1120px) { .intro-aside .elsewhere { margin-top: 0.55rem; } }

.divider { margin-top: clamp(2.6rem, 6vw, 3.8rem); margin-bottom: 0; }
.divider p { margin: 0; line-height: 1; }

.contents { margin-top: clamp(2.8rem, 7vw, 4.4rem); }
.year { margin: 0 0 1.7em; }
.year-num {
  margin: 0 0 0.3em; font-size: 1em; font-weight: 400; line-height: inherit;
  font-variant-numeric: oldstyle-nums proportional-nums;
}
.toc, .subjects ol { list-style: none; margin: 0; padding: 0; }
.toc li { padding: 0.11em 0; line-height: 1.36; text-wrap: pretty; }
.toc a, .subjects a, .prevnext a { text-decoration: none; transition: color 0.15s; }
.toc a:hover, .subjects a:hover, .prevnext a:hover { color: var(--accent); }
.toc .d { color: var(--ink-3); font-size: 0.84em; white-space: nowrap; margin-left: 0.35em; }

/* ---------- index & other pages ---------- */

.page-head { margin-top: var(--top); margin-bottom: 2.2em; }
.page-dek { margin: 0.8em 0 0; color: var(--ink-2); font-size: 1em; max-width: 30em; text-wrap: pretty; }
.page-dek a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent-soft); text-underline-offset: 0.16em; text-decoration-thickness: 1px; }
.index .subjects { margin-bottom: 3em; }
.subjects li { padding: 0.1em 0; line-height: 1.36; break-inside: avoid; }
@media (min-width: 760px) { .subjects ol { columns: 2; column-gap: 2.2em; } }
.subject { margin: 0 0 2.2em; scroll-margin-top: 1.5rem; }
.subject-name { margin: 0 0 0.4em; font-size: 1.2em; font-weight: 400; line-height: 1.25; }

/* ---------- the essay ---------- */

.essay-head { margin-top: var(--top); margin-bottom: 2.2em; }
.essay-title {
  margin: 0; font-weight: 400; font-size: clamp(1.95em, 1.3em + 2.1vw, 2.6em);
  line-height: 1.08; letter-spacing: -0.01em; text-wrap: balance;
}
.essay-date { margin: 0.85em 0 0; font-size: 0.86em; color: var(--ink-2); }

.prose { text-wrap: pretty; }
@media (min-width: 1120px) { .prose { width: var(--text); } }
@media (min-width: 760px) {
  .prose { hyphens: auto; -webkit-hyphens: auto; hyphenate-limit-chars: 10 4 4; }
}

.prose p { margin: 0; }
.prose p + p { text-indent: var(--indent); }
.prose > :is(h1, h2, h3, h4, blockquote, ul, ol, figure, pre, table, hr, iframe, .video, div:not(.footnotes)),
.prose > p:has(> img:only-child) {
  margin-block: 1.15em;
}
.prose > :first-child { margin-top: 0; }

.prose h1, .prose h2 {
  font-size: 1.28em; font-weight: 400; font-style: italic; line-height: 1.22;
  margin: 1.9em 0 0.5em !important; text-align: left; text-wrap: balance; hyphens: manual;
}
.prose h1 { font-size: 1.42em; }
.prose h3, .prose h4 {
  font-size: 1em; font-weight: 400; font-variant-caps: all-small-caps; letter-spacing: 0.09em;
  margin: 1.6em 0 0.35em !important; text-align: left;
}
.prose p.as-head {
  font-weight: 400; font-variant-caps: all-small-caps; letter-spacing: 0.09em;
  margin: 1.6em 0 0.35em; text-indent: 0;
}
.prose p.as-head strong, .prose p.as-head b { font-weight: inherit; }
.prose :is(h1, h2, h3, h4, .as-head) + p { text-indent: 0; }

.prose a {
  color: var(--ink);
  text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: 0.17em;
  text-decoration-color: var(--accent-soft); transition: color 0.15s, text-decoration-color 0.15s;
}
.prose a:hover { color: var(--accent); text-decoration-color: currentColor; }

.prose blockquote { margin-left: 1.45em; margin-right: 0; padding: 0; color: var(--ink-2); font-size: 0.95em; }
.prose blockquote p + p { text-indent: 1.2em; }
.prose blockquote + p { text-indent: 0; }

.prose ul, .prose ol { padding-left: 1.35em; text-align: left; }
.prose li { margin: 0.28em 0; }
.prose li p { text-indent: 0 !important; }
.prose li::marker { color: var(--ink-3); }

.prose strong, .prose b { font-weight: 600; }
.prose em i, .prose i em { font-style: normal; }

.prose code {
  font-family: var(--mono); font-size: 0.78em; padding: 0.06em 0.3em;
  background: var(--wash); border-radius: 3px; hyphens: none;
}
.prose pre {
  font-family: var(--mono); font-size: 0.72em; line-height: 1.6; text-align: left; hyphens: none;
  background: var(--wash); padding: 1.1em 1.3em; overflow-x: auto; border-radius: 3px; tab-size: 4;
}
.prose pre code { font-size: inherit; padding: 0; background: none; border-radius: 0; }

.prose img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.prose p:has(> img) { text-indent: 0; text-align: center; }

.prose table { border-collapse: collapse; width: 100%; font-size: 0.86em; text-align: left; font-variant-numeric: lining-nums tabular-nums; }
.prose th, .prose td { padding: 0.35em 0.6em; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose th { font-weight: 400; font-variant-caps: all-small-caps; letter-spacing: 0.08em; }

.prose > hr { border: 0; height: auto; margin-block: 1.6em; text-align: center; }
.prose > hr::after { content: "\00b7\2002\00b7\2002\00b7"; color: var(--ink-3); }

.prose iframe { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border: 0; }

.prose p.derived {
  font-size: 0.8em; line-height: 1.42; font-style: italic; color: var(--ink-3);
  text-indent: 0; text-align: left; hyphens: manual; margin: 0 0 0.6em;
}
.prose p.derived a { color: var(--ink-2); }

/* note references & sidenotes */
.prose sup { font-size: 0.64em; line-height: 0; vertical-align: 0.52em; font-variant-numeric: lining-nums; }
.prose sup a { color: var(--accent); text-decoration: none; padding: 0 0.08em; }
.prose sup.sup-seq::before { content: ","; color: var(--ink-3); }
.sidenote { display: none; }

@media (min-width: 1120px) {
  .prose p.derived, .sidenote {
    float: right; clear: right; width: var(--margin);
    margin-right: calc(-1 * (var(--margin) + var(--gap)));
  }
  .prose p.derived { margin-top: 0.25em; margin-bottom: 0; font-size: 0.78em; }
  .sidenote {
    display: block; margin-top: 0.3em; margin-bottom: 0.9em;
    font-size: calc(var(--fs) * 0.78); line-height: 1.42;
    color: var(--ink-2); text-indent: 0; text-align: left; hyphens: manual; font-style: normal;
    font-weight: 400; font-variant-caps: normal; letter-spacing: normal;
    border-radius: 2px; transition: background-color 0.6s;
  }
  .sidenote a { color: var(--ink-2); overflow-wrap: anywhere; }
  .sidenote .sn-num { color: var(--accent); margin-right: 0.35em; }
  .sidenote.flash { background: var(--select); transition: none; }
  .has-sidenotes .footnotes,
  .has-sidenotes p.footnote,
  .has-sidenotes hr:has(+ p.footnote) { display: none; }
}

/* endnotes (narrow screens, or variants without a margin) */
.prose .footnotes { margin-top: 2.6em; font-size: 0.84em; color: var(--ink-2); text-align: left; hyphens: manual; }
.prose .footnotes hr, .prose > hr:has(+ p.footnote) {
  width: 5em; margin: 2.6em 0 1.1em; border: 0; border-top: 1px solid var(--rule); text-align: left;
}
.prose > hr:has(+ p.footnote)::after { content: none; }
.prose .footnotes ol { padding-left: 1.4em; }
.prose .footnotes li { margin: 0.4em 0; }
.prose .footnotes li::marker { color: var(--accent); }
.prose .footnotes a, .prose p.footnote a { overflow-wrap: anywhere; }
.prose .footnote-backref { text-decoration: none; color: var(--ink-3); }
.prose p.footnote { font-size: 0.84em; color: var(--ink-2); text-indent: 0; text-align: left; margin: 0.35em 0; hyphens: manual; }
.prose p.footnote sup a { color: var(--accent); margin-right: 0.35em; }

.endmark { color: var(--accent); white-space: nowrap; margin-left: 0.5em; }
.endmark-block { text-align: left !important; text-indent: 0 !important; }

/* ---------- after the essay ---------- */

.essay-foot { margin-top: 3.4em; }
@media (min-width: 1120px) { .essay-foot > * { width: var(--text); } }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 2em; }
.prevnext .dir { display: block; font-size: 0.8em; color: var(--ink-3); margin-bottom: 0.15em; }
.prevnext a { line-height: 1.3; display: inline-block; }
.prevnext .next { text-align: right; }
.prevnext:not(:has(.next a)) { grid-template-columns: 1fr; }
.prevnext:not(:has(.prev a)) .prev { display: none; }
.prevnext:not(:has(.prev a)) { grid-template-columns: 1fr; }

main { padding-bottom: clamp(4.5rem, 11vw, 7.5rem); }

@media print {
  .mast, .essay-foot, figure.video, .skip, .derived { display: none !important; }
  :root { --fs-s: 11.5pt; --fs-m: 11.5pt; --fs-l: 11.5pt; --fs-xl: 11.5pt; color-scheme: light; }
  .frame, .prose { width: auto !important; }
  .sidenote { display: none !important; }
  .has-sidenotes .footnotes, .has-sidenotes p.footnote { display: block !important; }
}
