/* ==========================================================================
   NOTES | the reading section (/notes/, /de/notes/, /fr/notes/)

   Self-contained by design. The main site's css/styles.css turns <main> into
   a mandatory scroll-snap deck of 100vh sections with html/body set to
   overflow:hidden | a presentation, not a document. Long-form prose needs
   ordinary document scroll, so this file does not build on styles.css; it
   carries its own copy of the Bradford @font-face pair and the type/motion
   tokens, exactly as salient/site.css and 404.html already do.

   What it keeps from the main site: the typeface, the motion tokens
   (--beat / --dur-beat / --ease-settle), the tracked-caps micro-type idiom,
   and the guillemet-as-mark convention with its French narrow no-break
   spaces. What it adds: an actual prose system. The repository contained no
   <ul>, <ol>, <blockquote>, <figure>, <time>, <hr> or <code> before this
   section existed, so every element rule below is new ground.
   ========================================================================== */

/* Bradford Font | same pair as css/styles.css:1-18, root-relative paths */
@font-face {
  font-family: 'Bradford';
  src: url('/fonts/BradfordLLSub-Book.woff2') format('woff2'),
       url('/fonts/BradfordLLSub-Book.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Bradford';
  src: url('/fonts/BradfordLLWeb-Book.woff2') format('woff2'),
       url('/fonts/BradfordLLWeb-Book.woff') format('woff');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

:root {
  /* The fuller serif fallback from print.css:85 | styles.css falls back to
     sans-serif, which is wrong for a serif face and worst on a reading page. */
  --font-serif: 'Bradford', Palatino, 'Palatino Linotype', Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Motion tokens | values from css/styles.css:36-45, so /notes/ moves at the
     same tempo as the rest of the site. */
  --beat: 0.4s;
  --dur-beat: 0.7s;
  --ease-fade: ease;
  --ease-settle: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-reveal: 0.65s;
  --reveal-rise: 14px;

  /* Measure. A serif at 1.18rem wants a shorter line than salient's 68ch
     Helvetica column; 34rem lands around 68-72 characters in Bradford. */
  --measure: 34rem;
  --pad: clamp(1.25rem, 5vw, 3rem);

  /* Light (default). Warm off-white rather than pure #fff | long reading on
     pure white is harsh, and the site's print document already sits at #111
     rather than #000. */
  --paper: #fbfaf8;
  --ink: #14130f;
  --ink-soft: #55524a;
  --ink-faint: #6f6a5f;
  --hair: #e2ded4;
  --accent: #3a6b6e;   /* the section-dot green from styles.css:1097 */
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111110;
    --ink: #eceae4;
    --ink-soft: #a8a49a;
    --ink-faint: #858178;
    --hair: #2b2a26;
    --accent: #7aacb0; /* the dark-background dot green, styles.css:1105 */
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html {
  font-size: 16px;
  scroll-behavior: auto;
  /* Not the homepage: this document scrolls normally. */
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: clamp(1.05rem, 0.99rem + 0.3vw, 1.1875rem);
  line-height: 1.6;
  font-kerning: normal;
  font-feature-settings: 'kern' 1, 'liga' 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  padding: 0 var(--pad);
}

/* Cross-document view transitions | same progressive enhancement the main
   site opts into (css/styles.css:93-95), so moving between the homepage and
   /notes/ cross-fades where supported. */
@view-transition {
  navigation: auto;
}

/* Page exit/enter fade for browsers without view transitions. Same names and
   same timings as css/write-link.css:120-131, restated here because notes
   pages do not load that stylesheet. */
body.page-exit {
  opacity: 0 !important;
  transition: opacity 0.18s ease-out !important;
}

body.page-enter {
  opacity: 0;
}

body.page-enter.page-enter-active {
  opacity: 1;
  transition: opacity 0.22s ease-in;
}

/* Nothing may push the page sideways. */
:where(p, h1, h2, h3, li, blockquote, figcaption, td, th, dd, dt) {
  overflow-wrap: break-word;
  min-inline-size: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  inset: 0.75rem auto auto 0.75rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

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

/* The site's tracked-caps micro-type. The padding-left compensates for the
   trailing letter-space so the text still reads as optically flush | the same
   trick as .hero-content p in css/styles.css:313-326. */
.kicker {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1;
  letter-spacing: 0.32em;
  padding-left: 0.32em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ==========================================================================
   Paper shader background (js/notes-paper.js)
   Fixed behind everything; the body keeps its plain --paper colour, so a
   missing canvas | no JS, no WebGL, prefers-contrast | costs nothing.
   z-index -1 paints above the body background but below all in-flow content.
   ========================================================================== */

#paper-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

#paper-bg canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1.4s var(--ease-fade);
}

#paper-bg canvas.on {
  opacity: 1;
}

/* ==========================================================================
   Header | language switcher + back link
   ========================================================================== */

.notes-header {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vh, 2.5rem) 0 clamp(2.5rem, 8vh, 5rem);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.back-link {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-faint);
  transition: color 0.3s var(--ease-fade);
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--ink);
}

.language-switcher {
  display: flex;
  align-items: baseline;
  gap: 0.125rem;
}

.lang-btn {
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-decoration: none;
  color: var(--ink-faint);
  padding: 0.25rem 0.4rem;
  transition: color 0.3s var(--ease-fade);
}

.lang-btn:hover,
.lang-btn:focus-visible {
  color: var(--ink);
}

.lang-btn.active {
  color: var(--ink);
}

/* ==========================================================================
   Index | the masthead and the post list
   ========================================================================== */

.notes-masthead {
  max-width: var(--measure);
  margin: 0 auto clamp(3rem, 9vh, 5.5rem);
}

.notes-masthead h1 {
  font-size: clamp(2rem, 1.6rem + 1.8vw, 3rem);
  font-weight: normal;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 0.6rem;
}

.notes-masthead .standfirst {
  color: var(--ink-soft);
  text-wrap: pretty;
}

.notes-list {
  max-width: var(--measure);
  margin: 0 auto;
  list-style: none;
}

.notes-list > li + li {
  margin-top: clamp(2rem, 5vh, 3rem);
  padding-top: clamp(2rem, 5vh, 3rem);
  border-top: 1px solid var(--hair);
}

/* The whole entry is one link, so every child is a span | the pattern from
   salient/index.html:146-174, plus the date slot those cards lack. */
.note-entry {
  display: block;
  text-decoration: none;
  color: inherit;
}

.note-entry .date {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.32em;
  padding-left: 0.32em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.75rem;
  transition: color 0.3s var(--ease-fade);
}

.note-entry .t {
  display: block;
  font-size: clamp(1.4rem, 1.2rem + 0.9vw, 1.9rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin-bottom: 0.5rem;
}

.note-entry .d {
  display: block;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.note-entry .go {
  display: inline-block;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-faint);
  transition: color 0.3s var(--ease-fade);
}

.note-entry:hover .t,
.note-entry:focus-visible .t {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.note-entry:hover .go,
.note-entry:focus-visible .go,
.note-entry:hover .date,
.note-entry:focus-visible .date {
  color: var(--ink);
}

/* ==========================================================================
   Post | title block and prose
   ========================================================================== */

.note {
  max-width: var(--measure);
  margin: 0 auto;
}

.note-title {
  margin-bottom: clamp(2rem, 6vh, 3.5rem);
}

.note-title .date {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.32em;
  padding-left: 0.32em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 1rem;
}

.note-title h1 {
  font-size: clamp(1.9rem, 1.5rem + 1.7vw, 2.75rem);
  font-weight: normal;
  line-height: 1.18;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.note-title .standfirst {
  margin-top: 1.1rem;
  color: var(--ink-soft);
  font-size: 1.0625rem;
  line-height: 1.55;
  text-wrap: pretty;
}

/* --- prose ---------------------------------------------------------------
   Values lifted from css/print.css:197-215, the only real long-form
   typography in the repo (it is print-only there because everything in that
   file is namespaced under #print-document). Left-aligned rather than
   justified: justification without a hyphenation dictionary you control
   produces rivers on a narrow screen. */

.prose {
  orphans: 3;
  widows: 3;
}

.prose > * + * {
  margin-top: 1.25em;
}

.prose p {
  text-wrap: pretty;
  hyphens: none;
  -webkit-hyphens: none;
}

html:lang(de) .prose p {
  hyphens: auto;
  -webkit-hyphens: auto;
  hyphenate-limit-chars: 6 3 3;
}

.prose h2 {
  font-size: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  font-weight: normal;
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin-top: 2.5em;
  text-wrap: balance;
}

.prose h3 {
  font-size: 1.0625rem;
  font-weight: bold;
  line-height: 1.35;
  margin-top: 2em;
}

.prose h2 + *,
.prose h3 + * {
  margin-top: 0.6em;
}

/* --hair is the rule colour and disappears under text | an inline link has to
   be findable while reading, so the underline sits at --ink-faint and goes to
   full ink on hover. */
.prose a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  text-decoration-color: var(--ink-faint);
  transition: text-decoration-color 0.3s var(--ease-fade);
}

.prose a:hover,
.prose a:focus-visible {
  text-decoration-color: currentColor;
}

.prose strong {
  font-weight: bold;
}

.prose em {
  font-style: italic;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li + li {
  margin-top: 0.5em;
}

.prose ul {
  list-style: none;
}

/* A hanging en dash rather than a bullet | the site sets its lists in prose,
   and a dash keeps the left edge quieter than a disc. */
.prose ul > li {
  position: relative;
}

.prose ul > li::before {
  content: '\2013';
  position: absolute;
  left: -1.4em;
  color: var(--ink-faint);
}

.prose ol {
  list-style: decimal;
}

.prose ol > li::marker {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* Quotations. Guillemets are set as marks in CSS, never typed into the copy |
   the house rule from css/styles.css:432-453 and css/print.css:227-243. Each
   language gets its own pair, and French its narrow no-break spaces. */
.prose blockquote {
  position: relative;
  margin-left: 0;
  padding-left: 1.4em;
  border-left: 1px solid var(--hair);
  color: var(--ink-soft);
}

.prose blockquote p:first-child::before {
  content: '\201C';
  position: absolute;
  left: 0.45em;
  color: var(--ink-faint);
}

.prose blockquote p:last-child::after {
  content: '\201D';
  color: var(--ink-faint);
}

/* Swiss German takes guillemets pointing outward, without the French inner
   spaces | not the German „…" pair. This matches the philosophy epigraph,
   which is set in « » in every language (css/print.css:227-243). */
.prose blockquote:lang(de) p:first-child::before {
  content: '\AB';
  left: 0.3em;
}

.prose blockquote:lang(de) p:last-child::after {
  content: '\BB';
}

.prose blockquote:lang(fr) p:first-child::before {
  content: '\AB\202F';
  left: 0.2em;
}

.prose blockquote:lang(fr) p:last-child::after {
  content: '\202F\BB';
}

.prose blockquote cite {
  display: block;
  margin-top: 0.8em;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.prose figure {
  margin-left: 0;
  margin-right: 0;
}

.prose figure img {
  display: block;
  width: 100%;
  height: auto;
}

.prose figcaption {
  margin-top: 0.6em;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-faint);
  text-wrap: pretty;
}

.prose hr {
  border: 0;
  height: 1px;
  background: var(--hair);
  margin-top: 2.5em;
  margin-bottom: 2.5em;
}

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

/* Footnotes. Referenced with <sup><a href="#fn-1" id="fnref-1">1</a></sup>
   and collected in <ol class="footnotes"> at the end of the article. */
.prose sup a {
  text-decoration: none;
  font-size: 0.75em;
  padding: 0 0.1em;
  color: var(--accent);
}

.footnotes {
  max-width: var(--measure);
  margin: clamp(3rem, 8vh, 4.5rem) auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--hair);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.footnotes ol {
  padding-left: 1.4em;
}

.footnotes li + li {
  margin-top: 0.6em;
}

.footnotes li:target {
  color: var(--ink);
}

.footnotes a[href^="#fnref"] {
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.notes-footer {
  max-width: var(--measure);
  margin: clamp(4rem, 12vh, 7rem) auto 0;
  padding: clamp(1.5rem, 4vh, 2.5rem) 0 clamp(3rem, 8vh, 5rem);
  border-top: 1px solid var(--hair);
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--ink-faint);
}

.notes-footer a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--hair);
  transition: color 0.3s var(--ease-fade), border-color 0.3s var(--ease-fade);
}

.notes-footer a:hover,
.notes-footer a:focus-visible {
  color: var(--ink);
  border-bottom-color: currentColor;
}

.notes-footer address {
  font-style: normal;
  line-height: 1.7;
}

.notes-footer .footer-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  text-align: right;
  margin-left: auto;
}

.notes-footer .footer-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

/* align-items:flex-end above keeps each link only as wide as its own text |
   as column flex items they would otherwise stretch, and the border-bottom
   would run the full width of the column instead of underlining the word. */

/* ==========================================================================
   Reading content is visible without JavaScript
   ========================================================================== */

.r {
  opacity: 1;
  transform: none;
}

.r.in {
  opacity: 1;
  transform: none;
}

/* ==========================================================================
   Preferences
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  body {
    opacity: 1 !important;
    transition: none !important;
  }

  /* the shader renders a single static frame; show it without a fade */
  #paper-bg canvas {
    transition: none;
    opacity: 1;
  }

  .r {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  @view-transition {
    navigation: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --ink: #000;
    --ink-soft: #1a1a1a;
    --ink-faint: #3d3d3d;
    --hair: #767676;
    --paper: #fff;
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --ink: #fff;
      --ink-soft: #f0f0f0;
      --ink-faint: #cfcfcf;
      --hair: #8a8a8a;
      --paper: #000;
    }
  }

  .prose a {
    text-decoration-color: currentColor;
  }
}

/* ==========================================================================
   Print | a plain reading copy. The homepage has a dedicated print document
   (css/print.css); a note only needs to get out of its own way.
   ========================================================================== */

@media print {
  @page {
    size: A4 portrait;
    margin: 22mm 22mm 25mm 22mm;
  }

  #paper-bg {
    display: none !important;
  }

  body {
    background: #fff;
    color: #111;
    opacity: 1 !important;
    padding: 0;
    font-size: 10.5pt;
    line-height: 14pt;
  }

  .notes-header,
  .notes-footer .footer-nav,
  .note-entry .go {
    display: none;
  }

  .note,
  .notes-list,
  .notes-masthead,
  .footnotes,
  .notes-footer {
    max-width: none;
  }

  .r {
    opacity: 1 !important;
    transform: none !important;
  }

  .prose p {
    orphans: 3;
    widows: 3;
  }

  .prose h2,
  .prose h3,
  .note-title h1 {
    break-after: avoid;
    page-break-after: avoid;
  }

  .prose blockquote,
  .prose figure {
    break-inside: avoid;
  }

  /* Spell out link targets, since a printed underline points nowhere. */
  .prose a::after {
    content: ' (' attr(href) ')';
    font-size: 8.5pt;
    color: #555;
    word-break: break-all;
  }

  .prose a[href^='#']::after {
    content: '';
  }
}
