/* Facing Pages — croissanthology.com's book layout (homepage + Substack posts).
   Folded / phones: one column, notes under their paragraph. Unfolded / wide (720px+): two
   columns, the essay on the left and its notes and figures on the right. Colours follow the reader's device unless they pick ○ or ●. */

:root {
  --wide-at: 720;
  --night: #100e14;
  --page: #18151d;
  --ink: #ebe6f2;
  --ink-soft: #c0b8ce;
  --muted: #8f87a0;
  --accent: #f4a63c;
  --accent-ink: #f4a63c;
  --berry: #f96a7a;
  --lav: #ab9ec2;
  --rule: #322c3b;
  --spine: rgba(0, 0, 0, .55);
  --flash: #3a3046;
  --ph-bg: #1f1b25; --ph-line: #3a3344; --ph-ink: #9890a8;
  --display: "Poiret One", "Josefin Sans", "Century Gothic", sans-serif;
  --body: "Literata", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  --gutter-l: max(18px, env(safe-area-inset-left, 0px));
  --gutter-r: max(18px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --night: #e4dde9; --page: #f0ebf4; --ink: #24202b; --ink-soft: #4f4860; --muted: #786f87;
    --accent: #f4a63c; --accent-ink: #a5650c; --berry: #cf3f58; --lav: #77698f; --rule: #dad4e4; --spine: rgba(60, 40, 90, .22); --flash: #ece4f5;
    --ph-bg: #f0edf5; --ph-line: #d9d2e4; --ph-ink: #786f87;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --night: #e4dde9; --page: #f0ebf4; --ink: #24202b; --ink-soft: #4f4860; --muted: #786f87;
  --accent: #f4a63c; --accent-ink: #a5650c; --berry: #cf3f58; --lav: #77698f; --rule: #dad4e4; --spine: rgba(60, 40, 90, .22); --flash: #ece4f5;
  --ph-bg: #f0edf5; --ph-line: #d9d2e4; --ph-ink: #786f87;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--page); }
body { margin: 0; background: var(--page); color: var(--ink); font: 17px/1.62 var(--body); font-optical-sizing: auto; }
a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 400; text-wrap: balance; }

.book { position: relative; max-width: 30rem; margin: 0 auto; padding: 1.8rem var(--gutter-r) 3rem var(--gutter-l); }
.runfoot { display: flex; justify-content: space-between; align-items: baseline; margin: 2rem 0 0; font-family: var(--display); font-size: .74rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.runfoot .pg { font-family: var(--body); letter-spacing: 0; text-transform: none; font-style: italic; }
.theme { text-transform: uppercase; letter-spacing: .18em; text-decoration: underline; text-decoration-style: dotted; }

/* ------------------------------------------------ home */
.leaf { display: flex; flex-direction: column; min-width: 0; }
.titling { text-align: center; display: flex; flex-direction: column; gap: .45rem; margin: 1.6rem 0 1.7rem; }
.titling h1 { font-family: var(--display); text-transform: uppercase; letter-spacing: .26em; font-size: clamp(1.35rem, 6.4vw, 1.75rem); padding-left: .26em; }
.titling h1 .anth { color: var(--berry); }  /* two-tone: CROISS in ink, ANTHOLOGY in the drop cap's berry */
.intro p { margin: 0; text-indent: 1.3em; text-align: justify; hyphens: auto; }
.intro p:first-child { text-indent: 0; }
.intro .addr { hyphens: manual; }  /* break at the spaces, never inside gmail.com */

.toc { margin-top: 2.6rem; gap: 1.4rem; }
.toc h2 { font-family: var(--display); text-transform: uppercase; letter-spacing: .26em; font-size: 1.1rem; text-align: center; padding-left: .26em; }
.toc h3 { font-size: .78rem; font-variant-caps: all-small-caps; letter-spacing: .12em; color: var(--muted); font-size: .95rem; margin-bottom: .35rem; }
.leaders, .plainlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.leaders li { font-size: .92rem; line-height: 1.38; }
.leaders li a { text-decoration: none; }
.leaders a, .toc .try {
  display: flex; align-items: last baseline; gap: .45em; text-decoration: none; font-size: .92rem; line-height: 1.38;
}
.leaders .t, .toc .try .t { flex: 0 1 auto; min-width: 0; }
.dots { flex: 1 1 1.5em; min-width: 1.5em; border-bottom: 1.5px dotted color-mix(in srgb, var(--muted) 70%, transparent); transform: translateY(-.28em); }
.folio { flex: none; color: var(--accent-ink); font-variant-numeric: tabular-nums; font-size: .86em; }
.leaders a:hover .t { text-decoration: underline; text-decoration-color: var(--accent-ink); }
.toc .try { font-style: italic; padding: .55rem 0; border-block: 1px solid var(--rule); }
.toc .try .folio { font-style: normal; }
.plainlist { flex-direction: row; flex-wrap: wrap; gap: .2rem 1.1rem; font-size: .92rem; }
.more { display: inline-block; margin-top: .35rem; font-size: .84rem; font-style: italic; color: var(--muted); }

[data-layout="wide"] .book { max-width: 66rem; display: grid; grid-template-columns: 1fr 1fr; padding: 0; min-height: 100vh; background: var(--page); }
[data-layout="wide"] .leaf { background: var(--page); padding: 1.9rem 2.4rem 1.6rem; }
[data-layout="wide"] .verso { position: sticky; top: 0; height: 100vh; align-self: start; }
[data-layout="wide"] .toc { margin-top: 0; }
[data-layout="wide"] .runfoot { margin-top: auto; padding-top: 1.4rem; }
[data-layout="wide"] .titling { margin: clamp(2.5rem, 17vh, 10rem) 0 1.9rem; }
[data-layout="wide"] .intro { font-size: .9rem; line-height: 1.55; }

/* ------------------------------------------------ reader */
.runhead { display: flex; justify-content: space-between; gap: 1rem; font-family: var(--display); font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); padding-bottom: .9rem; border-bottom: 1px solid var(--rule); }
.runhead a { text-decoration: none; }
.runhead a.home { color: var(--berry); }
.runhead a.home:hover { color: var(--berry); text-decoration: none; }
.runhead span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* title block, gwern-style: centred small-caps title, a tiny grey line of metadata, the subtitle in italics */
.post-head { padding-block: 2.6rem 2rem; display: flex; flex-direction: column; align-items: center; gap: .7rem; text-align: center; }
.post-title { font-size: clamp(1.75rem, 7.4vw, 2.3rem); line-height: 1.14; font-weight: 600; letter-spacing: .005em; font-variant-caps: small-caps; text-wrap: balance; }
.post-head .meta { margin: 0; font-size: .74rem; letter-spacing: .02em; color: var(--muted); font-variant-numeric: lining-nums; }
.post-head .meta a { color: inherit; text-decoration-style: dotted; text-decoration-color: currentColor; }
.post-head .meta a:hover { color: var(--accent-ink); }
.dek { margin: .1rem 0 0; max-width: 30em; font-style: italic; color: var(--ink-soft); line-height: 1.5; text-wrap: balance; }

.flow { min-width: 0; hyphens: auto; overflow-wrap: break-word; }  /* long bare URLs wrap instead of running into the margin */
.flow > p { margin: 0; text-indent: 1.3em; text-align: justify; }
.flow > p:first-child, .flow > :is(blockquote, figure, h2, h3) + p { text-indent: 0; }
.flow blockquote { margin: 1.1em 1.3em; font-size: .92em; color: var(--ink-soft); font-style: italic; }
.flow blockquote p { margin: 0; }
.flow figure.plate, .post .cover { margin: 1.5em auto; width: 100%; display: flex; flex-direction: column; gap: .5em; }
.flow figure.plate .ph { max-width: 300px; margin: 0 auto; }
figure.plate img { display: block; width: 100%; height: auto; border: 1px solid var(--rule); }
.post .cover { margin: 1.3rem 0 0; }
.post .cover img { border: 0; }
.flow .bsky {
  margin: 0; padding: .8em 1em .75em; border: 1px solid var(--rule); border-radius: 10px; font-style: normal;
  background: color-mix(in srgb, var(--page) 86%, var(--lav) 14%); color: var(--ink);
  font-size: .86em; line-height: 1.45; display: flex; flex-direction: column; gap: .3em;
}
.bsky p { margin: 0; }
.bsky .name { font-weight: 500; }
.bsky .handle, .bsky .src { color: var(--muted); }
.bsky .src { font-size: .86em; text-decoration: none; }
.bsky .shots { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .35em; margin: .25em 0 .1em; }
.bsky .shots img { display: block; width: 100%; height: auto; border-radius: 6px; border: 0; }
.bsky .src:hover { color: var(--accent-ink); }
.toc .year { margin: 1rem 0 .35rem; font-size: .95rem; font-variant-caps: all-small-caps; letter-spacing: .12em; color: var(--muted); }
.toc section > .year:first-child { margin-top: 0; }
.flow figcaption { font-size: .78em; line-height: 1.4; color: var(--muted); font-style: italic; }

.fn-ref a { color: var(--accent-ink); font: 650 .76em/1 var(--sans); vertical-align: .55em; font-variant-numeric: lining-nums;
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
.fn-ref a[aria-expanded="true"], .fn-ref a.hot { color: var(--ink); text-decoration-thickness: 2px; }
.note-body { position: relative; margin: .5em 0 1em; padding: .1em 0 .1em 1.7em; font-size: .85em; line-height: 1.5; color: var(--ink-soft); }
.note-body p { margin: 0 0 .45em; }
.note-body p:last-child { margin: 0; }
.note-n { position: absolute; left: .2em; top: .15em; color: var(--accent-ink); font: 650 .9em/1.5 var(--sans); }
.note.hot .note-body { color: var(--ink); }

[data-layout="wide"] body.reader { font-size: 16.5px; }
[data-layout="wide"] .post {
  max-width: 66rem; display: grid; padding: 0; min-height: 100vh;
  grid-template-columns: 1fr 1fr; grid-template-rows: auto auto 1fr;
  background: linear-gradient(90deg, var(--page) 0 0) no-repeat; background-color: var(--page);
}
[data-layout="wide"] .runhead { grid-column: 1 / -1; grid-row: 1; padding: 1.3rem 2.4rem .8rem; }
[data-layout="wide"] .runhead span { text-align: right; max-width: 45%; }
[data-layout="wide"] .post-head { grid-column: 1; grid-row: 2; padding: 1.6rem 2.4rem 1.4rem; }
[data-layout="wide"] .flow { grid-column: 1; grid-row: 3; padding: 0 2.4rem 3rem; }
[data-layout="wide"] .rail { grid-column: 2; grid-row: 2 / 4; margin: 1.6rem 2.6rem 3rem; }
[data-layout="wide"] .note { --lift: 4px; }
[data-layout="wide"] .note-body { margin: 0; font-size: .82em; }
[data-layout="wide"] figure.plate { width: auto; }
[data-layout="wide"] figure.plate .ph { max-width: 260px; }
[data-layout="wide"] .post .cover img { border: 1px solid var(--rule); }
[data-layout="wide"] .flow > figure.plate + p { text-indent: 1.3em; }

/* "fig. 2 →" markers (made by wide.js) for figures and embeds that live in the margin.
   Hover one, or a footnote number, and its figure or note slides level with it (wide.js: summon). */
.fig-refs { display: none; }
[data-layout="wide"] .fig-refs { display: inline; margin-left: .4em; white-space: nowrap; }
[data-layout="wide"] .fig-ref + .fig-ref { margin-left: .6em; }
[data-layout="wide"] .fig-ref {
  padding: 0; background: none; border: 0; cursor: pointer;
  font: 650 .68em/1 var(--sans); letter-spacing: .02em; color: var(--accent-ink); vertical-align: .12em;
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 2px;
}
[data-layout="wide"] .fig-ref:hover, [data-layout="wide"] .fig-ref.hot { color: var(--ink); text-decoration-thickness: 2px; }

/* only the summoned note or figure moves; it slides over the others, which stay put and dim */
[data-layout="wide"] [data-wide-root] :is(.note, figure.plate) { transition: transform .38s cubic-bezier(.2, .8, .2, 1), opacity .25s ease; }
[data-layout="wide"] [data-wide-root].releasing :is(.note, figure.plate) { transition-duration: .2s; }
[data-layout="wide"] [data-wide-root].summoning :is(.note, figure.plate):not(.summoned) { opacity: .3; }
[data-layout="wide"] .summoned { z-index: 2; }
[data-layout="wide"] .note.summoned .note-body, [data-layout="wide"] figure.plate.summoned { background: var(--page); box-shadow: 0 0 0 10px var(--page); }
[data-layout="wide"] .note.summoned .note-body { color: var(--ink); }

/* the margin shows up all at once, already in place, instead of piece by piece */
[data-layout="wide"] [data-wide-root]:not(.ready) :is(.note, figure.plate) { visibility: hidden; }

/* your own earlier posts, embedded like Substack does: thumbnail, title, date, read link */
.own-card { display: flex; gap: .9em; align-items: center; text-decoration: none; color: var(--ink); }
.own-card:hover { color: var(--ink); }
.own-card:hover .own-title { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: .18em; }
figure.plate img.own-thumb, .note-body img.own-thumb { flex: none; width: 4.4em; height: 4.4em; object-fit: cover; display: block; border: 0 !important; }
.own-text { display: flex; flex-direction: column; gap: .15em; min-width: 0; }
.own-title { font-weight: 500; line-height: 1.25; }
.own-date { font-size: .74em; font-variant-caps: all-small-caps; letter-spacing: .1em; color: var(--muted); }
.own-read { font-size: .82em; color: var(--accent-ink); }
.flow figure.own { margin: 1.4em 0; }
.note-body .own-ref { margin: .7em 0; }
.note-body .own-card { font-size: 1.02em; }
.note-body img.own-thumb { width: 3.6em; height: 3.6em; }

/* theme switch: ○ light · ● dark · ◐ match the device (default) */
.switch { margin: .6rem 0 0; text-indent: 0 !important; font-size: .92em; color: var(--muted); }
.modes { display: inline-flex; gap: .15em; vertical-align: -.12em; margin-left: .2em; }
.modes button { width: 1.45em; height: 1.45em; display: grid; place-items: center; border-radius: 50%; color: var(--muted); transition: color .2s ease, background .2s ease; }
.modes button svg { width: .95em; height: .95em; display: block; }
.modes button:hover { color: var(--ink); }
.modes button[aria-pressed="true"] { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* drop caps: only when unfolded / on wide screens; folded and on phones the post just starts (like gwern.net).
   Sized with initial-letter so the letter sits exactly three lines deep, with no stray space
   (Safari and Chrome); other browsers get a floated letter. */
:root { --cap-face: "UnifrakturMaguntia", "Old English Text MT", serif; --cap-ink: var(--berry); }
[data-dropcap="poiret"] { --cap-face: "Poiret One", "Josefin Sans", sans-serif; --cap-ink: var(--lav); }
[data-dropcap="cover"] { --cap-face: "Abril Fatface", "Bodoni Moda", Didot, serif; --cap-ink: var(--accent-ink); }

[data-layout="wide"]:not([data-dropcap="none"]) .opening::first-letter {
  font-family: var(--cap-face); font-weight: 400; color: var(--cap-ink);
  -webkit-initial-letter: 3; initial-letter: 3; margin-right: .07em;
}
[data-layout="wide"][data-dropcap="cover"] .flow.has-cover .opening::first-letter {
  background-image: var(--cover); background-size: 180% auto; background-position: 30% 55%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
@supports not ((initial-letter: 3) or (-webkit-initial-letter: 3)) {
  [data-layout="wide"]:not([data-dropcap="none"]) .opening { display: flow-root; }
  [data-layout="wide"]:not([data-dropcap="none"]) .opening::first-letter {
    float: left; font-size: 4.3em; line-height: .8; margin: .04em .07em -.04em -.02em;
  }
}

/* ---- engine: shared by every direction (pairs with wide.js) ---- */
@view-transition { navigation: auto; }

/* notes are always shown: inline (smaller, indented) when narrow, in the margin when wide */
.note { display: block; view-transition-class: note; }
.fn-ref { line-height: 0; font-size: 1em; vertical-align: baseline; }
.fn-ref a { padding: .2em .18em; margin: -.2em -.02em; border-radius: 3px; }

.rail { display: none; }
[data-layout="wide"] [data-wide-root] { position: relative; }
[data-layout="wide"] .rail { display: block; min-height: 1px; }
[data-layout="wide"] .note { position: absolute; }
[data-layout="wide"] [data-plates="rail"] > figure.plate, [data-layout="wide"] [data-plates="rail"] .flow > figure.plate { position: absolute; margin: 0; }

.note.flash .note-body { animation: note-flash 1.1s ease; }
@keyframes note-flash { 0%, 30% { background: var(--flash) } 100% { background: transparent } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* placeholder for images the preview can't fetch */
.ph {
  display: grid; place-items: center; width: 100%; max-width: 100%;
  background:
    repeating-linear-gradient(135deg, transparent 0 11px, var(--ph-line) 11px 12px),
    var(--ph-bg);
  border: 1px solid var(--ph-line);
  color: var(--ph-ink);
  text-align: center; line-height: 1.35; font-size: .72em; letter-spacing: .04em;
}
.ph span { background: var(--ph-bg); padding: .45em .8em; }

/* ---- the unfold: View Transitions ---- */
[data-vt] { view-transition-class: text; }
::view-transition-group(*) { animation-duration: .62s; animation-timing-function: cubic-bezier(.22, .8, .2, 1); }
::view-transition-old(*.text), ::view-transition-new(*.text),
::view-transition-old(*.note), ::view-transition-new(*.note) { inline-size: auto; block-size: auto; }
::view-transition-old(*.text) { animation: vt-out .24s ease both; }
::view-transition-new(*.text) { animation: vt-in .46s .1s ease both; }
::view-transition-group(*.note) { animation-duration: .82s; }
::view-transition-old(*.note) { animation: vt-out .18s ease both; }
::view-transition-new(*.note) { animation: vt-in .5s .14s ease both; }
@keyframes vt-in { from { opacity: 0; } }
@keyframes vt-out { to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
