/* Rethink Everything
   avi.nyc brand tokens (Midnight Terminal / Coastal Sprint), tuned for long reading.
   The one loud element is the struck-out old rule. Everything else stays quiet. */

@font-face {
  font-family: "Windsor";
  src: url("/fonts/WindsorBT-Light.woff") format("woff");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "Satoshi";
  src: url("/fonts/Satoshi-Variable.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}
@font-face {
  font-family: "Satoshi";
  src: url("/fonts/Satoshi-VariableItalic.woff2") format("woff2");
  font-weight: 300 900;
  font-style: italic;
  font-display: swap;
}

/* ── Tokens ── */

:root {
  --font-display: "Windsor", Georgia, "Times New Roman", serif;
  --font-body: "Satoshi", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-code: "Courier Prime", "Courier New", monospace;

  --measure: 40rem; /* about 64 characters of Satoshi at 20px */
  --gutter: clamp(1rem, 4vw, 2rem);

  /* Light: Coastal Sprint */
  --bg: #F7FAFC;
  --surface: #FFFFFF;
  --surface-2: #EEF5F7;
  --text: #0B1B2B;
  --text-2: #2C4157;
  --text-3: #5C7286;
  --rule: #D9E3EA;
  --strike: #8B2346;
  --link: #0E7C86;
  --link-hover: #8B2346;
  --selection: rgba(14, 124, 134, 0.18);
  color-scheme: light;
}

/* Dark: Midnight Terminal. Prose is brighter than the site's #A0A0A0 for long reads. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #080808;
    --surface-2: #0F0F0F;
    --text: #E8E8E8;
    --text-2: #A0A0A0;
    --text-3: #6E6E6E;
    --rule: #1F1F1F;
    --strike: #C74B7A;
    --link: #4ECDC4;
    --link-hover: #C74B7A;
    --selection: rgba(199, 75, 122, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #080808;
  --surface-2: #0F0F0F;
  --text: #E8E8E8;
  --text-2: #A0A0A0;
  --text-3: #6E6E6E;
  --rule: #1F1F1F;
  --strike: #C74B7A;
  --link: #4ECDC4;
  --link-hover: #C74B7A;
  --selection: rgba(199, 75, 122, 0.3);
  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(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.25rem;
  line-height: 1.7;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: normal;
  overflow-x: hidden;
}

::selection { background: var(--selection); }

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.15s ease;
}
a:hover { color: var(--link-hover); }

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  color: var(--text);
  z-index: 20;
  font-size: 0.9rem;
}
.skip:focus { top: 0.75rem; }

/* ── Reading progress ── */

.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 10;
  pointer-events: none;
}
.progress__bar {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--strike);
  transform: scaleX(var(--progress, 0));
  transform-origin: 0 50%;
}
.is-home .progress { display: none; }

/* ── Top bar ── */

.topbar {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 1.25rem var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
}
.topbar__trail { display: flex; gap: 0.6rem; align-items: baseline; min-width: 0; }
.topbar__trail a { color: var(--text-2); text-decoration: none; white-space: nowrap; }
.topbar__trail a:hover { color: var(--text); }
.topbar__sep { color: var(--text-3); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: -0.5rem;
  background: none;
  border: 0;
  border-radius: 2px;
  color: var(--text-2);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle__moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle__moon { display: block; }
}
:root[data-theme="dark"] .theme-toggle__sun { display: none; }
:root[data-theme="dark"] .theme-toggle__moon { display: block; }

/* ── Layout ── */

main, .footer {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ── The strike: the site's signature ── */

.strike {
  text-decoration: none;
  color: var(--text-3);
  /* A background line instead of text-decoration so it can be drawn, and so every wrapped line gets its own strike. */
  background-image: linear-gradient(var(--strike), var(--strike));
  background-repeat: no-repeat;
  background-position: 0 58%;
  background-size: 100% max(2px, 0.09em);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding: 0 0.06em;
  margin: 0 -0.06em;
}
.js .strike { background-size: 0% max(2px, 0.09em); }
.js .strike.is-drawn {
  background-size: 100% max(2px, 0.09em);
  transition: background-size 0.7s cubic-bezier(0.65, 0, 0.35, 1);
  transition-delay: var(--delay, 0s);
}

/* ── Masthead ── */

.masthead {
  padding: clamp(3rem, 10vh, 7rem) 0 clamp(2.5rem, 6vh, 4rem);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 3rem;
}
.masthead--post { padding-top: clamp(2rem, 6vh, 4rem); }

.masthead__old {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.masthead__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.75rem, 8vw, 5.25rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.masthead--post .masthead__title { font-size: clamp(2.4rem, 6.5vw, 4.25rem); }

.masthead__dek {
  margin: 1.5rem 0 0;
  max-width: 34em;
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--text-2);
  text-wrap: pretty;
}

.meta {
  margin: 2rem 0 0;
  font-size: 0.95rem;
  color: var(--text-3);
}
.masthead--post .meta { margin: 0 0 1.5rem; }
.meta span { margin: 0 0.35rem; }

/* ── Prose ── */

.prose { font-size: 1.25rem; }

.prose > * { margin: 0 0 1.35em; }
.prose > :last-child { margin-bottom: 0; }

.prose p { text-wrap: pretty; }

.prose h2 {
  margin: 2.6em 0 0.7em;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(1.9rem, 4vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.prose h3 {
  margin: 2em 0 0.5em;
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.3;
}
.prose h2 + *, .prose h3 + * { margin-top: 0; }

.prose strong { font-weight: 650; }
.prose em { font-style: italic; }

.prose ul, .prose ol:not(.ledger) { padding-left: 1.3em; }
.prose li { margin-bottom: 0.45em; }
.prose li::marker { color: var(--text-3); }

.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--strike);
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.5rem;
  line-height: 1.4;
}
.prose blockquote p { margin: 0 0 0.6em; }
.prose blockquote a {
  color: inherit;
  text-decoration-color: var(--strike);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}
.prose blockquote a:hover { color: var(--link); }
.prose blockquote p:last-child { margin: 0; }

.prose hr {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 3em 0;
}

.prose :not(pre) > code {
  font-family: var(--font-code);
  font-size: 0.9em;
  padding: 0.08em 0.3em;
  background: var(--surface-2);
  border-radius: 2px;
}

/* Code and tables break out a little on wide screens. */
@media (min-width: 900px) {
  .prose > .code, .prose > .table {
    margin-left: -3rem;
    margin-right: -3rem;
  }
}

/* ── Code ── */

.code {
  position: relative;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
}
.code pre {
  margin: 0;
  padding: 1.5rem 1.5rem 1.35rem;
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 0.95rem;
  line-height: 1.6;
  background: transparent !important;
  tab-size: 2;
}
.code code { font-family: inherit; }

.code__lang {
  position: absolute;
  top: 0.55rem;
  left: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-3);
}
.code:has(.code__lang) pre { padding-top: 2.1rem; }

.code__copy {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  padding: 0.25rem 0.6rem;
  font: 500 0.78rem/1.4 var(--font-body);
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 2px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.code:hover .code__copy, .code__copy:focus-visible { opacity: 1; }
.code__copy:hover { color: var(--text); }
.code__copy.is-copied { color: var(--link); opacity: 1; }
@media (hover: none) { .code__copy { opacity: 1; } }

/* Shiki dual themes: light by default, dark tokens when dark is active. */
.shiki, .shiki span { color: var(--shiki-light); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shiki,
  :root:not([data-theme="light"]) .shiki span { color: var(--shiki-dark); }
}
:root[data-theme="dark"] .shiki,
:root[data-theme="dark"] .shiki span { color: var(--shiki-dark); }

/* ── Tables ── */

.table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: 1rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
.table th, .table td {
  padding: 0.8rem 1rem 0.8rem 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}
.table th {
  font-weight: 600;
  color: var(--text);
  border-bottom-color: var(--text-3);
}
.table td { color: var(--text-2); }
.table td:first-child { color: var(--text); font-weight: 500; }

/* ── Ledger (homepage series list) ── */

.prose .ledger {
  list-style: none;
  padding: 0;
  margin: 2rem 0 3rem;
  border-top: 1px solid var(--rule);
}
.ledger__item {
  margin: 0;
  padding: 1.6rem 0 1.7rem;
  border-bottom: 1px solid var(--rule);
}
.ledger__link {
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  column-gap: 0.5rem;
  color: inherit;
  text-decoration: none;
}
.ledger__num {
  grid-row: 1 / span 2;
  padding-top: 0.2rem;
  font-size: 0.95rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.ledger__old {
  grid-column: 2;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.2rem;
  line-height: 1.3;
  justify-self: start;
}
.ledger__new {
  grid-column: 2;
  margin-top: 0.15rem;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(1.6rem, 3.6vw, 2.05rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--text);
  transition: color 0.15s ease;
}
.ledger__link:hover .ledger__new { color: var(--link); }
.ledger__summary {
  margin: 0.7rem 0 0 3rem;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-2);
}

/* ── Pager ── */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 4.5rem 0 0;
  padding: 2rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.pager__link { display: flex; flex-direction: column; gap: 0.3rem; text-decoration: none; color: var(--text); }
.pager__link--next { text-align: right; }
.pager__label { font-size: 0.9rem; color: var(--text-3); }
.pager__title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.5rem;
  line-height: 1.2;
  transition: color 0.15s ease;
}
.pager__link:hover .pager__title { color: var(--link); }

/* ── Series list (post pages) ── */

.series { margin: 3.5rem 0 0; }
.series__heading {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.75rem;
}
.series__list { list-style: none; margin: 0; padding: 0; }
.series__list li { border-bottom: 1px solid var(--rule); }
.series__list a {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.5rem;
  padding: 0.85rem 0;
  color: var(--text-2);
  text-decoration: none;
  line-height: 1.35;
}
.series__num { font-size: 0.9rem; color: var(--text-3); padding-top: 0.15rem; font-variant-numeric: tabular-nums; }
.series__text { display: flex; flex-direction: column; gap: 0.15rem; }
.series__old {
  font-size: 0.9rem;
  color: var(--text-3);
  text-decoration-color: var(--strike);
  text-decoration-thickness: 1px;
}
.series__new { font-size: 1.05rem; color: var(--text); transition: color 0.15s ease; }
.series__list a:hover .series__new { color: var(--link); }
.series__list [aria-current="page"] .series__new { color: var(--strike); }
.series__list [aria-current="page"] .series__num { color: var(--strike); }

/* ── Footer ── */

.footer {
  margin-top: 5rem;
  padding-top: 2rem;
  padding-bottom: 3rem;
  font-size: 0.95rem;
  color: var(--text-3);
}
.footer p { margin: 0; }
.footer a { color: var(--text-2); }

/* ── Small screens ── */

@media (max-width: 640px) {
  body, .prose { font-size: 1.125rem; }
  .masthead__dek { font-size: 1.15rem; }
  .prose blockquote { font-size: 1.3rem; }
  .code pre { font-size: 0.85rem; padding-left: 1rem; padding-right: 1rem; }
  .code__lang { left: 1rem; }
  .code { margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); border-left: 0; border-right: 0; border-radius: 0; }
  .ledger__link { grid-template-columns: 1.75rem 1fr; }
  .ledger__summary { margin-left: 2.25rem; font-size: 1rem; }
  .pager { grid-template-columns: 1fr; }
  .pager__link--next { text-align: left; }
  .pager__title { font-size: 1.3rem; }
}

/* ── Motion preferences ── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .js .strike { background-size: 100% max(2px, 0.09em); }
}

@media print {
  .topbar, .progress, .pager, .series, .code__copy, .footer { display: none; }
  body { background: #fff; color: #000; font-size: 12pt; }
}
