/* Praxis: praxis.jasonregimen.com. One stylesheet; build.py cuts the editor rules (after the last big marker) from the public copy.
   Book page: one serif column (~66 characters), footnotes as margin sidenotes, warm paper, one oxblood accent.
   Type: Source Serif 4 (variable, opsz + wght) from ../static/fonts/fonts.css, Georgia fallback. No sans face. */

/* ---------- palette + scale ---------- */
:root {
  --paper: #f8f5ee;      /* warm paper */
  --paper-2: #f2ede3;    /* dock, figure ground */
  --ink: #1f1b16;        /* text, 15.7:1 on paper */
  --ink-2: #4a433a;      /* dek, sidenotes, quotes, 9.0:1 */
  --muted: #6f675b;      /* dates, labels, 5.1:1 */
  --rule: #ddd5c6;       /* hairlines */
  --rule-2: #c9bfad;     /* stronger hairline (inputs) */
  --accent: #9d2b1f;     /* oxblood: links, title rule, small-caps labels, 6.9:1 */
  --accent-soft: color-mix(in srgb, var(--accent) 30%, transparent);
  --on-accent: #fbf7f0;
  --select: #ead6c3;
  --w-body: 400;         /* variable weight: dark mode sets it lighter */
  --w-head: 600;

  --measure: 660px;      /* ~66 characters of 20px Source Serif */
  --sn: 260px;           /* sidenote column */
  --gap: 48px;           /* text-to-margin gap */
  --pad: 24px;           /* page side padding */
  --body: 20px;
  --lh: 1.55;

  --serif: "Source Serif 4", "Source Serif 4 Variable", "Source Serif Pro", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

/* Dark is its own palette (warm charcoal, ivory text, a lighter brick accent), not an inversion. */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --paper: #1a1816; --paper-2: #221f1c; --ink: #e6dfd2; --ink-2: #bdb4a5; --muted: #918878;
    --rule: #34302a; --rule-2: #4a443c; --accent: #e07a62; --on-accent: #1a1816; --select: #4a3128;
    --w-body: 370; --w-head: 560; color-scheme: dark;
  }
}
:root.dark {
  --paper: #1a1816; --paper-2: #221f1c; --ink: #e6dfd2; --ink-2: #bdb4a5; --muted: #918878;
  --rule: #34302a; --rule-2: #4a443c; --accent: #e07a62; --on-accent: #1a1816; --select: #4a3128;
  --w-body: 370; --w-head: 560; color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -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(--body); line-height: var(--lh); font-weight: var(--w-body);
  font-optical-sizing: auto; font-kerning: normal; font-variant-numeric: oldstyle-nums proportional-nums;
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--select); }
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px;
  text-decoration-color: var(--accent-soft); text-underline-offset: .18em; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3, h4 { font-weight: var(--w-head); line-height: 1.2; margin: 0; text-wrap: balance; }
p { margin: 0; }
.dek, figcaption, .sidenote, .tagline, .reply p { text-wrap: pretty; }
img, svg { max-width: 100%; height: auto; }
.sc { font-variant-caps: all-small-caps; letter-spacing: .06em; font-variant-numeric: oldstyle-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- site header + footer ---------- */
header.site {
  max-width: calc(var(--measure) + 2 * var(--pad)); margin: 0 auto; padding: 30px var(--pad) 0; text-align: center;
}
.wordmark {
  display: inline-block; color: var(--ink); text-decoration: none; font-size: 25px; font-weight: 620;
  letter-spacing: -.005em; line-height: 1;
}
.wordmark:hover { color: var(--accent); }
header.site::after {
  content: ""; display: block; height: 1px; background: var(--rule); margin-top: 22px;
}

footer.site {
  max-width: calc(var(--measure) + 2 * var(--pad)); margin: 96px auto 0; padding: 0 var(--pad) 48px;
  color: var(--muted); font-size: 15px; line-height: 1.6; text-align: center;
}
footer.site::before { content: ""; display: block; height: 1px; background: var(--rule); margin-bottom: 22px; }
footer.site nav { font-variant-caps: all-small-caps; letter-spacing: .07em; font-size: 17px; }
footer.site nav a { color: var(--ink-2); text-decoration: none; margin: 0 .55em; }
footer.site nav a:hover { color: var(--accent); }
footer.site p { margin-top: 8px; }

/* ---------- home: masthead + list ---------- */
.masthead { max-width: calc(var(--measure) + 2 * var(--pad)); margin: 0 auto; padding: 76px var(--pad) 0; text-align: center; }
.masthead h1 {
  font-size: 68px; line-height: 1; font-weight: 560; letter-spacing: -.018em;
}
.masthead h1 a { color: inherit; text-decoration: none; }
.masthead .rule { display: block; width: 44px; height: 2px; background: var(--accent); margin: 22px auto 18px; border: 0; }
.masthead .byline { font-size: 18px; color: var(--ink-2); font-variant-caps: all-small-caps; letter-spacing: .1em; }
.masthead .tagline { font-style: italic; font-size: 21px; line-height: 1.45; color: var(--ink-2); max-width: 30em; margin: 18px auto 0; }
.masthead nav { margin-top: 26px; font-variant-caps: all-small-caps; letter-spacing: .08em; font-size: 18px; }
.masthead nav a { color: var(--ink-2); text-decoration: none; margin: 0 .6em; }
.masthead nav a:hover, .masthead nav a[aria-current] { color: var(--accent); }

.listing { max-width: calc(var(--measure) + 2 * var(--pad)); margin: 64px auto 0; padding: 0 var(--pad); }
.listing > header { margin-bottom: 8px; }
.year { margin-top: 48px; }
.year:first-of-type { margin-top: 0; }
.year > h2 {
  font-size: 18px; font-weight: 600; color: var(--accent); letter-spacing: .1em;
  font-variant-caps: all-small-caps; font-variant-numeric: lining-nums;
  display: flex; align-items: center; gap: 14px; margin-bottom: 6px;
}
.year > h2::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
ol.posts { list-style: none; margin: 0; padding: 0; }
.entry {
  display: grid; grid-template-columns: 4.6em minmax(0, 1fr); column-gap: 16px;
  padding: 15px 0 16px; border-bottom: 1px solid var(--rule);
}
.entry:last-child { border-bottom: 0; }
.entry time {
  grid-column: 1; grid-row: 1; padding-top: 3px; color: var(--muted); font-size: 16px; white-space: nowrap;
  font-variant-numeric: oldstyle-nums tabular-nums;
}
.entry .title {
  grid-column: 2; font-size: 21px; line-height: 1.3; font-weight: 600; color: var(--ink); text-decoration: none;
  text-wrap: balance;
}
.entry a.title:hover { color: var(--accent); }
.entry .dek { grid-column: 2; margin-top: 3px; font-size: 17px; line-height: 1.45; color: var(--ink-2); font-style: italic; }
.entry .kind {
  font-size: 15px; font-weight: 600; color: var(--accent); font-variant-caps: all-small-caps; letter-spacing: .09em;
  margin-left: .5em; white-space: nowrap; vertical-align: 1px;
}
.entry.note .title { font-weight: 500; }

/* page heads for topic / about */
.page-head { max-width: calc(var(--measure) + 2 * var(--pad)); margin: 0 auto; padding: 64px var(--pad) 0; }
.label { color: var(--accent); font-size: 17px; font-weight: 600; font-variant-caps: all-small-caps; letter-spacing: .1em; }
.label a { text-decoration: none; }
.page-head h1 { font-size: 50px; line-height: 1.08; letter-spacing: -.015em; margin-top: 6px; }
.page-head .dek { margin-top: 14px; font-style: italic; font-size: 22px; line-height: 1.45; color: var(--ink-2); }
.page-head .count { margin-top: 14px; color: var(--muted); font-size: 16px; }
.page-head + .listing { margin-top: 40px; }
.topic-cloud { max-width: calc(var(--measure) + 2 * var(--pad)); margin: 56px auto 0; padding: 0 var(--pad); }
.topic-cloud h2 { font-size: 17px; color: var(--muted); font-weight: 600; font-variant-caps: all-small-caps; letter-spacing: .1em; }
.topic-cloud ul { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 18px; }
.topic-cloud li span { color: var(--muted); font-size: 15px; margin-left: .25em; }

/* ---------- post (essay + note) ---------- */
.post { max-width: calc(var(--measure) + 2 * var(--pad)); margin: 0 auto; padding: 0 var(--pad); }
.post > * { max-width: var(--measure); }
.post-head { padding-top: 64px; }
.post-head .label { margin-bottom: 10px; }
.post-head h1 { font-size: 52px; line-height: 1.07; letter-spacing: -.016em; }
.note .post-head h1 { font-size: 42px; }
.post-head .dek { margin-top: 18px; font-style: italic; font-size: 23px; line-height: 1.42; color: var(--ink-2); }
.post-head .meta {
  margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--rule); position: relative;
  display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: baseline;
  font-size: 17px; font-variant-caps: all-small-caps; letter-spacing: .07em; color: var(--muted);
}
.post-head .meta::before { /* the title rule: a short accent bar over the hairline */
  content: ""; position: absolute; left: 0; top: -1px; width: 44px; height: 2px; background: var(--accent);
}
.post-head .meta a { text-decoration: none; }
.post-head .meta a:hover { text-decoration: underline; }
.post-head .meta .topics a + a::before { content: ", "; color: var(--muted); }
.badge {
  color: var(--accent); border: 1px solid var(--accent); border-radius: 3px; padding: 0 .45em 1px;
  font-weight: 600; letter-spacing: .09em; line-height: 1.3;
}

/* contents (long essays) */
.toc { margin-top: 36px; padding: 16px 0 18px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.toc h2 { font-size: 16px; font-weight: 600; color: var(--accent); font-variant-caps: all-small-caps; letter-spacing: .1em; }
.toc ol { list-style: none; margin: 6px 0 0; padding: 0; counter-reset: toc; font-size: 17px; line-height: 1.4; }
.toc li { counter-increment: toc; display: flex; gap: .6em; padding: 4px 0; }
.toc li::before { content: counter(toc, upper-roman) "."; min-width: 1.9em; color: var(--muted); font-size: 15px; padding-top: 1px; font-variant-numeric: lining-nums; }
.toc a { color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--accent); }

/* body text */
.post-body { margin-top: 40px; hyphens: manual; }
.post-body p { margin: 0; }
.post-body p + p { text-indent: 1.4em; }
.post-body > p:first-child::first-line { font-variant-caps: small-caps; letter-spacing: .035em; }
.post-body h2 {
  font-size: 28px; line-height: 1.22; letter-spacing: -.008em; margin: 56px 0 14px; scroll-margin-top: 24px;
}
.post-body h3 { font-size: 21px; font-style: italic; font-weight: 500; margin: 34px 0 8px; }
.post-body ul, .post-body ol { margin: 14px 0; padding-left: 1.4em; }
.post-body li + li { margin-top: 6px; }
.post-body blockquote {
  margin: 24px 0 24px 1.4em; padding: 0; font-size: 19px; line-height: 1.55; color: var(--ink-2);
}
.post-body blockquote p + p { text-indent: 0; margin-top: .7em; }
.post-body blockquote cite {
  display: block; margin-top: 8px; font-style: normal; font-size: 16px; color: var(--muted);
  font-variant-caps: all-small-caps; letter-spacing: .07em;
}
.post-body blockquote cite::before { content: "— "; }
.post-body hr { border: 0; text-align: center; margin: 36px 0; height: auto; }
.post-body hr::before { content: "⁂"; color: var(--muted); font-size: 20px; }

/* aside / callout: hairlines and a small-caps label, no colour block */
.post-body aside.callout {
  margin: 30px 0; padding: 16px 0 18px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-size: 18px; line-height: 1.55; color: var(--ink-2);
}
.callout .callout-title {
  display: block; margin-bottom: 4px; color: var(--accent); font-size: 16px; font-weight: 600;
  font-variant-caps: all-small-caps; letter-spacing: .1em;
}
.callout p + p { text-indent: 0; margin-top: .6em; }

/* figure */
.post-body figure { margin: 34px 0; }
.post-body figure .plate { background: var(--paper-2); border: 1px solid var(--rule); padding: 18px 18px 10px; }
.post-body figure img { display: block; width: 100%; }
.post-body figcaption { margin-top: 10px; font-size: 15px; line-height: 1.45; color: var(--muted); }
.post-body figcaption b { color: var(--ink-2); font-weight: 600; font-variant-caps: all-small-caps; letter-spacing: .07em; }
/* chart colours for inline SVG figures */
.chart text { fill: var(--muted); font-family: var(--serif); font-size: 13px; }
.chart .axis { stroke: var(--rule-2); stroke-width: 1; fill: none; }
.chart .grid { stroke: var(--rule); stroke-width: 1; fill: none; }
.chart .line-a { stroke: var(--accent); stroke-width: 2.25; fill: none; }
.chart .line-b { stroke: var(--ink-2); stroke-width: 1.5; fill: none; stroke-dasharray: 5 4; }
.chart .lbl-a { fill: var(--accent); font-style: italic; font-size: 14px; }
.chart .lbl-b { fill: var(--ink-2); font-style: italic; font-size: 14px; }

/* ---------- sidenotes (Tufte checkbox technique, CSS only) ---------- */
.sidenote-number {
  color: var(--accent); font-size: .62em; line-height: 0; vertical-align: .62em; font-weight: 600;
  font-variant-numeric: lining-nums; padding: 0 .1em 0 .12em; position: relative;
}
input.margin-toggle { display: none; }
.sidenote {
  float: right; clear: right; width: var(--sn); margin-right: calc(-1 * (var(--sn) + var(--gap)));
  margin-top: .3em; margin-bottom: 1em;
  font-size: 15px; line-height: 1.47; color: var(--ink-2); text-indent: 0; hyphens: manual;
  font-variant-numeric: oldstyle-nums;
}
.sidenote .sn-n { color: var(--accent); font-weight: 600; font-variant-numeric: lining-nums; margin-right: .3em; }
.sidenote a { overflow-wrap: anywhere; }

/* ---------- end of post: reply + previous/next ---------- */
.post-foot { margin-top: 56px; }
.reply { text-align: center; }
.reply::before { content: "⁂"; display: block; color: var(--muted); font-size: 20px; margin-bottom: 22px; }
.reply a {
  display: inline-block; font-size: 18px; font-weight: 600; letter-spacing: .09em; font-variant-caps: all-small-caps;
  text-decoration: none; border: 1px solid var(--accent-soft); border-radius: 3px; padding: 7px 18px 9px;
}
.reply a:hover { border-color: var(--accent); }
.reply p { margin-top: 10px; font-size: 16px; color: var(--muted); font-style: italic; }
.prevnext {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 48px; padding-top: 18px;
  border-top: 1px solid var(--rule);
}
.prevnext a { text-decoration: none; color: var(--ink); font-size: 18px; line-height: 1.35; font-weight: 600; }
.prevnext a:hover { color: var(--accent); }
.prevnext a span {
  display: block; margin-bottom: 4px; color: var(--muted); font-weight: 600; font-size: 15px;
  font-variant-caps: all-small-caps; letter-spacing: .09em;
}
.prevnext .next { text-align: right; }

/* ---------- about (placeholder) ---------- */
.prose { max-width: calc(var(--measure) + 2 * var(--pad)); margin: 40px auto 0; padding: 0 var(--pad); }
.prose p + p { text-indent: 1.4em; }
.placeholder {
  border: 1px dashed var(--rule-2); border-radius: 4px; padding: 20px 22px; color: var(--muted);
}
.placeholder .label { display: block; margin-bottom: 6px; }
.placeholder p + p { text-indent: 0; margin-top: .7em; }
.contact { max-width: calc(var(--measure) + 2 * var(--pad)); margin: 40px auto 0; padding: 0 var(--pad); }
.contact dl { display: grid; grid-template-columns: 7em 1fr; gap: 8px 18px; margin: 10px 0 0; font-size: 18px; }
.contact dt { color: var(--muted); font-variant-caps: all-small-caps; letter-spacing: .08em; font-size: 17px; padding-top: 1px; }
.contact dd { margin: 0; }

/* ---------- wide screens: notes in the right margin ---------- */
@media (min-width: 1000px) {
  .post { max-width: calc(var(--measure) + var(--gap) + var(--sn) + 2 * var(--pad)); }
}
/* widest: contents list in the left margin, text centred between the two margins */
@media (min-width: 1300px) {
  .post {
    max-width: none; display: grid; justify-content: center;
    grid-template-columns: var(--sn) minmax(0, var(--measure)) var(--sn); column-gap: var(--gap);
  }
  .post > * { grid-column: 2; }
  .post-head { grid-row: 1; }
  .post-body { grid-row: 2; }
  .post-foot { grid-row: 3; }
  .post > .toc {
    grid-column: 1; grid-row: 2 / span 2; align-self: start; position: sticky; top: 40px;
    margin-top: 46px; padding: 0 0 0 0; border: 0; max-width: 220px; justify-self: end; width: 100%;
  }
  .toc h2 { padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
  .toc ol { font-size: 15px; }
  .toc li::before { font-size: 13px; padding-top: 1px; }
}

/* ---------- narrow: sidenotes open on tap ---------- */
@media (max-width: 999px) {
  .sidenote { display: none; }
  input.margin-toggle {
    display: inline; position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none;
  }
  label.margin-toggle { cursor: pointer; }
  /* bigger touch target than the superscript itself */
  label.sidenote-number::after { content: ""; position: absolute; inset: -14px -10px; }
  label.margin-toggle:has(+ input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
  label.sidenote-number:has(+ input:checked) {
    color: var(--on-accent); background: var(--accent); border-radius: 2px; padding: 0 .22em; margin-left: .08em;
  }
  .margin-toggle:checked + .sidenote {
    display: block; float: none; clear: both; width: auto; margin: 12px 0 14px; padding: 2px 0 2px 16px;
    border-left: 2px solid var(--accent); font-size: 16.5px; line-height: 1.5;
  }
}

/* ---------- phone ---------- */
@media (max-width: 600px) {
  :root { --body: 18px; --pad: 20px; --lh: 1.58; }
  header.site { padding-top: 20px; }
  header.site::after { margin-top: 16px; }
  .wordmark { font-size: 23px; }
  .masthead { padding-top: 52px; }
  .masthead h1 { font-size: 52px; }
  .masthead .rule { margin: 18px auto 14px; }
  .masthead .tagline { font-size: 19px; }
  .masthead nav { font-size: 17px; margin-top: 20px; }
  .masthead nav a { margin: 0 .4em; }
  .listing { margin-top: 44px; }
  .entry { grid-template-columns: minmax(0, 1fr); padding: 14px 0 15px; }
  .entry .title { grid-column: 1; grid-row: 1; font-size: 20px; }
  .entry .dek { grid-column: 1; font-size: 16.5px; }
  .entry time { grid-column: 1; grid-row: 3; padding-top: 4px; font-size: 14.5px; }
  .post-head, .page-head { padding-top: 40px; }
  .post-head h1 { font-size: 36px; line-height: 1.1; }
  .note .post-head h1 { font-size: 32px; }
  .page-head h1 { font-size: 38px; }
  .post-head .dek, .page-head .dek { font-size: 20px; margin-top: 14px; }
  .post-head .meta { font-size: 16px; margin-top: 20px; }
  .post-body { margin-top: 30px; hyphens: auto; -webkit-hyphens: auto; hyphenate-limit-chars: 8 4 4; }
  .post-body > p:first-child { hyphens: manual; -webkit-hyphens: manual; }
  .toc { margin-top: 28px; padding: 12px 0 12px; }
  .toc ol { font-size: 16px; line-height: 1.35; }
  .toc li { padding: 3px 0; }
  .toc li::before { min-width: 1.7em; font-size: 14px; }
  .post-body h2 { font-size: 24px; margin-top: 44px; }
  .post-body blockquote { margin-left: 1em; font-size: 17.5px; }
  .post-body aside.callout { font-size: 17px; }
  .post-body figure .plate { padding: 12px 10px 6px; }
  .prevnext { grid-template-columns: 1fr; gap: 18px; }
  .prevnext .next { text-align: left; }
  .prevnext a { font-size: 17px; }
  footer.site { margin-top: 72px; }
  footer.site nav a { margin: 0 .35em; }
  .contact dl { grid-template-columns: 1fr; gap: 0; }
  .contact dd { margin-bottom: 10px; }
}

/* ---------- empty state; single prev/next ---------- */
.empty { text-align: center; color: var(--muted); font-style: italic; }
.prevnext .next:only-child { grid-column: 2; }
@media (max-width: 600px) { .prevnext .next:only-child { grid-column: 1; } }
