/* The Writings' shared layout: a piece's page is set in its own theme (its theme.css, inlined by tools/writings.mjs),
   which fills in these tokens and styles whatever makes it itself. This is the reading underneath: the measure, the
   masthead, figures, quotes, code, lists, the notes and their popovers. */
:root {
  --paper: #fbf9f4; --ink: #1d1a17; --muted: #6f675d; --accent: #b33a26; --line: color-mix(in srgb, var(--ink) 16%, transparent);
  --face: Georgia, 'Times New Roman', serif; --body: Georgia, 'Times New Roman', serif; --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  --size: 20px; --leading: 1.68; --measure: 38rem;
}
*, *::before, *::after { box-sizing: border-box; }
/* Past either end of the page (under a phone's floating toolbar, or as it bounces) the browser paints the root's
   background, so the root takes the colour of the site's bar and footer band (header.js's --page, by day and at night, as
   they are), and the body carries the piece's own paper: the footer then runs right to the edge, whatever the piece. */
html { background: #efe6d2; -webkit-text-size-adjust: 100%; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { background: #191613; } }
:root[data-theme="dark"] { background: #191613; }
/* the footer's band sits over any light or pattern a theme lays behind the page */
body.writing > site-footer { position: relative; z-index: 5; }
body.writing { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font: var(--size)/var(--leading) var(--body); font-kerning: normal;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.writing main { padding: clamp(30px, 5vw, 64px) max(22px, env(safe-area-inset-right, 0px)) clamp(56px, 9vw, 110px) max(22px, env(safe-area-inset-left, 0px)); }
.piece { max-width: var(--measure); margin: 0 auto; }
.writing a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.writing a:hover { color: var(--accent); }
.writing :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* the masthead */
.masthead { margin-bottom: clamp(26px, 4.5vw, 44px); }
.kicker { margin: 0 0 14px; color: var(--muted); font: 500 14px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.kicker .dot { margin: 0 .35em; opacity: .6; }
.masthead h1 { margin: 0; font: 400 clamp(38px, 7vw, 64px)/1.04 var(--face); letter-spacing: -.015em; text-wrap: balance; }
.subtitle { margin: 14px 0 0; font: italic 400 clamp(20px, 3vw, 26px)/1.3 var(--face); color: var(--muted); text-wrap: balance; }
.dek { margin: 18px 0 0; font-size: 1.08em; color: var(--muted); text-wrap: pretty; }

/* the text */
.text p, .text ul, .text ol, .text pre, .text figure, .text blockquote { margin: 0 0 1.15em; }
.text p { text-wrap: pretty; hanging-punctuation: first; }
.text h2, .text h3, .text h4 { font-family: var(--face); font-weight: 500; line-height: 1.2; text-wrap: balance; scroll-margin-top: 90px; }
.text h2 { margin: 2.2em 0 .6em; font-size: 1.6em; }
.text h3 { margin: 1.9em 0 .5em; font-size: 1.25em; }
.text h4 { margin: 1.6em 0 .4em; font-size: 1.05em; }
.text > .part:first-child > :first-child { margin-top: 0; }   /* the text starts straight under the masthead */
.text ul, .text ol { padding-left: 1.2em; }
.text li { margin: .35em 0; }
.text li::marker { color: var(--accent); }
.text strong { font-weight: 600; }
/* A quote, set the same way in every piece so it never reads as the author's own words: quieter, in italics, against a
   rule, with its source under it in small capitals. A theme recolours it (--quote, --quote-rule) rather than restyling it. */
.text blockquote { margin: 1.7em 0; padding: .1em 0 .1em 1.1em; border-left: 3px solid var(--quote-rule, var(--ink)); color: var(--quote, var(--muted)); }
.text blockquote p { margin: 0; font-style: italic; font-size: .94em; line-height: 1.55; text-wrap: pretty; }
.text blockquote p:last-child:not(:only-child) { margin-top: .6em; font: 600 11.5px/1.4 var(--mono); font-style: normal; letter-spacing: .14em; text-transform: uppercase; color: var(--ink); }
.text blockquote p:last-child:not(:only-child) * { font-weight: inherit; font-style: normal; }
.text blockquote p:last-child:not(:only-child)::before { content: "— "; }
.text img, .text video { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 4px; }
.text figure { margin: 1.8em 0; }
.text figcaption { margin-top: .6em; color: var(--muted); font-size: .8em; line-height: 1.45; text-align: center; }
.text pre { overflow-x: auto; padding: 14px 16px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 6%, transparent); font: 15px/1.55 var(--mono); white-space: pre-wrap; }
.text code { font-family: var(--mono); font-size: .88em; }
.text .part + .part { margin-top: 2.4em; padding-top: 2.4em; border-top: 1px solid var(--line); }

/* footnote marks, and the notes */
.footnote-ref { font-size: .62em; line-height: 0; vertical-align: super; margin-left: 1px; }
.footnote-ref a { padding: 0 2px; font-family: var(--mono); font-weight: 600; color: var(--accent); text-decoration: none; }
.notes { margin-top: 3.2em; padding-top: 1.4em; border-top: 1px solid var(--line); color: var(--muted); font-size: .8em; line-height: 1.55; }
.notes h2 { margin: 0 0 .8em; font: 500 14px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.notes ol { padding-left: 1.4em; }
.notes li { margin: .5em 0; overflow-wrap: anywhere; }
.notes li:target { color: var(--ink); }
.footnote-backref { text-decoration: none; margin-left: .3em; }
/* a note, opened in place by its mark */
.fn-pop { position: absolute; z-index: 20; width: min(360px, calc(100vw - 32px)); padding: 12px 14px; border-radius: 8px; background: var(--paper); color: var(--ink);
  font: 15px/1.5 var(--body); box-shadow: 0 0 0 1px var(--line), 0 14px 34px -12px rgba(0, 0, 0, .35); overflow-wrap: anywhere; }
.fn-pop .n { margin-right: .4em; font: 600 13px var(--mono); color: var(--accent); }
.fn-pop .footnote-backref { display: none; }

/* take it with you, at the end of every piece: download a PDF, copy the Markdown, or download it */
.takeaway { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 3em 0 0; font: 500 14px/1 var(--mono); letter-spacing: .04em; }
.takeaway a, .takeaway button { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border: 0; border-radius: 999px; cursor: pointer; text-decoration: none;
  color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); box-shadow: inset 0 0 0 1px var(--line); font: inherit; transition: background-color .15s, color .15s; }
.takeaway a:hover, .takeaway button:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.takeaway svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.takeaway .done { color: var(--accent); }

/* paragraphs that fade in as they come into view, where a theme asks for it (data-reveal on <body>) */
[data-reveal] .text .part > * { transition: opacity .9s ease, transform .9s cubic-bezier(.2, .8, .2, 1); }
[data-reveal] .text .part > .hidden { opacity: 0; transform: translateY(12px); }

@media (max-width: 560px) { :root { --size: 18.5px; } .text pre { font-size: 13.5px; } }

/* Printed (and the PDF each piece offers): a plain document, whatever the piece looks like on screen. Its own typefaces,
   but black on white, the title, author and date at the top, and the text set close, as a document is; the screen's
   furniture (the bar, the footer, any theme's lights, the buttons) left off. A theme can add to this under its own
   @media print. */
.byline { display: none; }
@media print {
  @page { size: Letter; margin: 22mm 22mm 20mm; }
  :root { --paper: #fff !important; --ink: #16140f !important; --muted: #5f5a52 !important; --accent: #6b4a2a !important; --line: #d6d2cb !important; }
  html:root { padding-top: 0 !important; }
  html, body.writing { background: #fff !important; color: var(--ink); font-size: var(--print-size, 12pt) !important; line-height: 1.5 !important; }
  body > :not(main), .takeaway, .footnote-backref, .kicker, .masthead::before, .masthead::after { display: none !important; }
  .writing main { padding: 0 !important; overflow: visible !important; }
  .piece { max-width: none !important; }
  .writing a { color: inherit !important; background: none !important; text-decoration: underline; text-decoration-color: #b7b1a8; }
  /* the head */
  .masthead { margin: 0 0 16pt !important; padding: 0 0 12pt !important; text-align: left !important; border-bottom: .75pt solid var(--line); }
  .masthead h1 { font-size: 26pt !important; line-height: 1.15 !important; letter-spacing: 0 !important; text-transform: none !important; font-style: normal !important;
    color: var(--ink) !important; text-shadow: none !important; }
  .masthead h1 * { display: inline !important; margin: 0 !important; font: inherit !important; letter-spacing: 0 !important; text-transform: none !important;
    color: inherit !important; -webkit-text-stroke: 0 !important; transform: none !important; }
  .masthead h1 .or { margin: 0 .25em !important; }
  .subtitle { margin: 4pt 0 0 !important; font-size: 15pt !important; color: var(--muted) !important; }
  .dek { margin: 6pt 0 0 !important; padding: 0 !important; border: 0 !important; font-size: 1em !important; }
  .byline { display: block; margin: 8pt 0 0; color: var(--muted); font: 11pt/1.4 var(--body); letter-spacing: .02em; }
  .byline .dot { margin: 0 .3em; }
  .byline .permalink { font-size: 10pt; text-decoration: none !important; color: var(--muted) !important; }
  /* the text */
  .text > .part, .text .part > * { opacity: 1 !important; transform: none !important; filter: none !important; }
  .text p, .text ul, .text ol, .text pre, .text figure, .text blockquote { margin: 0 0 .7em !important; }
  .text p { font-size: 1em !important; text-align: left !important; color: var(--ink) !important; text-shadow: none !important; }
  .text h2 { margin: 18pt 0 6pt !important; font-size: 16pt !important; }
  .text h3 { margin: 14pt 0 5pt !important; font-size: 13.5pt !important; }
  .text h4 { margin: 12pt 0 4pt !important; font-size: 12pt !important; }
  .text h2, .text h3, .text h4 { break-after: avoid; color: var(--ink) !important; text-transform: none !important; letter-spacing: 0 !important; }
  .text blockquote { position: static !important; margin: 8pt 0 !important; padding: 0 0 0 10pt !important; border: 0 !important; border-left: 1.5pt solid var(--line) !important;
    background: none !important; color: var(--ink) !important; text-align: left !important; }
  .text blockquote::before { display: none !important; }
  .text blockquote p, .text blockquote p:first-child { margin: 0 0 2pt !important; font: italic 1em/1.45 var(--body) !important; letter-spacing: 0 !important; text-transform: none !important; color: inherit !important; }
  .text blockquote p:last-child:not(:only-child) { font: .9em/1.4 var(--body) !important; color: var(--muted) !important; }
  .text figure { margin: 10pt 0 !important; break-inside: avoid; }
  .text figure img, .text img { max-height: 3.4in; width: auto !important; max-width: 100% !important; border-radius: 0 !important; box-shadow: none !important; }
  .text figcaption { display: block !important; margin-top: 4pt !important; font-size: 10pt !important; }
  .text pre { padding: 7pt 9pt !important; font-size: 9.5pt !important; line-height: 1.4 !important; background: #f4f2ee !important; border: 0 !important; box-shadow: none !important; break-inside: avoid; }
  .text ul, .text ol { padding-left: 1.3em; }
  .text li { margin: .2em 0 !important; }
  .text .part + .part { margin-top: 10pt !important; padding-top: 0 !important; border: 0 !important; }
  .text .part + .part::before { content: "* * *" !important; display: block !important; width: auto !important; height: auto !important; margin: 0 0 10pt !important;
    background: none !important; box-shadow: none !important; border: 0 !important; text-align: center; color: var(--muted); font: 10pt var(--body); letter-spacing: .3em; }
  .text .part[data-part="1"] > p:first-child::first-letter { float: none !important; font-size: inherit !important; margin: 0 !important; color: inherit !important; text-shadow: none !important; }
  .notes { margin-top: 18pt !important; padding-top: 9pt !important; font-size: 10pt !important; break-before: auto; }
  .notes h2 { font-size: 10pt !important; }
}}
@media (prefers-reduced-motion: reduce) { [data-reveal] .text .part > * { transition: none; } [data-reveal] .text .part > .hidden { opacity: 1; transform: none; } }
