/* ---------------------------------------------------------------------------
   Reading typography for /writing/.

   Loaded alongside tokens.css and NOTHING else. No styles.css, no app.js, no
   three.js. The whole point of these pages is that someone tapping a link on
   a phone gets text in under a second.

   The surface is the same paper as the .u-note stack on the main site, so an
   article reads as one of those notes opened up rather than a different site.
--------------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--paper-ink);
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Night reading. Articles get opened from a phone at 11pm far more often than
   the main site does, so this is worth the few extra lines. Kept warm — it is
   still paper, just paper in a dark room. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16150f;
    --paper-deep: #1e1c15;
    --paper-ink: #e8e3d6;
    --paper-ink-soft: #b3ad9c;
    --paper-ink-faint: #7d7768;
    --paper-rule: rgba(232, 227, 214, 0.16);
    --paper-accent: #9dc45f;
  }
}

.wrap {
  /* ~68ch. Long-form measure, not app-layout width. */
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

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

.masthead {
  padding: 1.75rem 0 0;
}

.masthead a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-ink-faint);
  text-decoration: none;
  transition: color 160ms ease;
}

.masthead a:hover { color: var(--paper-ink); }
.masthead img { width: 20px; height: 20px; opacity: 0.75; }

/* --- article head -------------------------------------------------------- */

.article-head {
  padding: 3.5rem 0 0;
  border-bottom: 1px solid var(--paper-rule);
  margin-bottom: 2.75rem;
  padding-bottom: 2rem;
}

.kicker {
  margin: 0 0 1rem;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper-accent);
}

.article-head h1 {
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 2.9rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.byline {
  margin: 1.4rem 0 0;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--paper-ink-faint);
}

/* --- body ---------------------------------------------------------------- */

/* Flow spacing. The reset and the rhythm rule have equal specificity, so the
   later one wins — do NOT reset margins with a type selector like `.body p`
   instead, because (0,1,1) would outrank (0,1,0) and silently collapse every
   gap in the article. */
.body > * { margin: 0; }
.body > * + * { margin-top: 1.45em; }

.body h2 {
  margin: 2.9rem 0 0;
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.body h3 {
  margin: 2.2rem 0 0;
  font-family: var(--font-body);
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.body a {
  color: inherit;
  text-decoration-color: var(--paper-accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1.5px;
}

.body a:hover { color: var(--paper-accent); }

.body strong { font-weight: 650; }

.body blockquote {
  margin: 2.2rem 0;
  padding: 0 0 0 1.4rem;
  border-left: 2px solid var(--paper-accent);
  color: var(--paper-ink-soft);
  font-style: italic;
}

.body blockquote p + p { margin-top: 1em; }

/* padding only — margins are left to the flow rule above, for the same
   specificity reason. */
.body ul, .body ol { padding-left: 1.3rem; }
.body li + li { margin-top: 0.55em; }
.body li > ul, .body li > ol { margin-top: 0.55em; }
.body li::marker { color: var(--paper-ink-faint); }

.body hr {
  margin: 3rem auto;
  width: 60px;
  border: 0;
  border-top: 1px solid var(--paper-rule);
}

.body code {
  padding: 0.12em 0.38em;
  border-radius: 3px;
  background: var(--paper-deep);
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.body pre {
  margin: 2rem 0;
  padding: 1.1rem 1.25rem;
  border-radius: 6px;
  background: var(--paper-deep);
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.6;
}

.body pre code { padding: 0; background: none; font-size: inherit; }

/* --- images and diagrams -------------------------------------------------- */

/* Safety net: any image that ends up outside a <figure> — inline in a
   sentence, or in hand-written HTML — still respects the measure instead of
   forcing the whole page to scroll sideways. */
.body img {
  max-width: 100%;
  height: auto;
}

/* Diagrams are the point of this series, so they break the measure and run
   wider than the text. On mobile they go full-bleed and scroll horizontally
   rather than shrinking into illegibility. */
.body figure {
  margin: 2.8rem 0;
  width: 100%;
}

@media (min-width: 56rem) {
  .body figure {
    width: calc(100% + 9rem);
    margin-left: -4.5rem;
  }
}

.body figure img,
.body figure svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: var(--paper-deep);
}

.body figcaption {
  margin-top: 0.85rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--paper-ink-faint);
  text-align: center;
}

/* --- end card ------------------------------------------------------------ */

/* Someone who reached this point just gave you eight minutes. This is the
   warmest visitor the site ever gets, and the only place the main site is
   pitched to them. */
.endcard {
  margin: 4.5rem 0 0;
  padding: 2rem 1.75rem;
  border-radius: 10px;
  background: var(--paper-deep);
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.endcard img {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
}

.endcard p {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--paper-ink-soft);
}

.endcard strong { color: var(--paper-ink); font-weight: 650; }

.endcard a {
  color: var(--paper-accent);
  text-underline-offset: 0.16em;
}

footer.foot {
  margin: 3rem 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--paper-rule);
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--paper-ink-faint);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

footer.foot a { color: inherit; }

/* --- index page ---------------------------------------------------------- */

.index-head { padding: 4rem 0 2.5rem; }

.index-head h1 {
  margin: 0 0 0.9rem;
  font-size: clamp(2rem, 6vw, 2.6rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.index-head p {
  margin: 0;
  max-width: 30rem;
  color: var(--paper-ink-soft);
}

.post-list { list-style: none; margin: 0; padding: 0; }

.post-list li { border-top: 1px solid var(--paper-rule); }

.post-list a {
  display: block;
  padding: 1.75rem 0;
  color: inherit;
  text-decoration: none;
}

.post-list a:hover h2 { color: var(--paper-accent); }

.post-list h2 {
  margin: 0.5rem 0 0.45rem;
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.2;
  transition: color 160ms ease;
}

.post-list p {
  margin: 0;
  font-size: 0.98rem;
  color: var(--paper-ink-soft);
}

@media (max-width: 30rem) {
  body { font-size: 18px; }
  .endcard { flex-direction: column; align-items: flex-start; }
}
