/* Hallmark · genre: atmospheric · macrostructure: Marquee Hero · theme: custom (tuned) · tone: technical · enrichment: none · nav: N5 · footer: Ft5
 * contrast: pass (40–41) · slop: pass (42–45) · honest: pass (46) · chrome: pass (47) · tokens: pass (48) · responsive: pass (49) · mobile: pass (34, 49, 50–57)
 * Tokens live in /tokens.css — every colour and font below references a named token.
 */

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

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
  background: var(--color-paper);
  color-scheme: dark;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-4xl);
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; }
img { max-width: 100%; height: auto; }
::selection { background: var(--color-accent); color: var(--color-accent-ink); }

/* ── Links ───────────────────────────────────────────────────────────── */

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--color-rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
  transition: color var(--dur-base) var(--ease-out), text-decoration-color var(--dur-base) var(--ease-out);
}
a:hover, a.is-hover { color: var(--color-accent); text-decoration-color: var(--color-accent); }
a:active, a.is-active { opacity: 0.7; }
a:focus-visible, a.is-focus {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
  transition: none;
}

.skip {
  position: absolute;
  left: var(--page-gutter);
  top: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: var(--color-accent-ink);
  font-size: var(--text-sm);
  transform: translateY(-300%);
  z-index: 40;
}
.skip:focus-visible { transform: none; }

.wrap { width: 100%; max-width: var(--page-max); margin-inline: auto; padding-inline: var(--page-gutter); }

/* ── Nav · N5 floating pill ──────────────────────────────────────────── */

.nav-pill {
  position: fixed;
  top: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-xs) var(--space-lg);
  border: var(--rule-hair);
  border-radius: var(--radius-pill);
  background: color-mix(in oklch, var(--color-paper) 78%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
}
.nav-pill a { white-space: nowrap; font-size: var(--text-sm); text-decoration: none; }
.nav-pill .mark { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; font-size: var(--text-base); }
.nav-pill ul { display: flex; gap: var(--space-lg); margin: 0; padding: 0; list-style: none; }
.nav-pill a:not(.mark) { color: var(--color-muted); }
.nav-pill a:not(.mark):hover { color: var(--color-ink); }

/* ── Entrance: fade only; the atmosphere does the work ───────────────── */

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.fade { animation: fade var(--dur-slow) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 90ms); }
@media (prefers-reduced-motion: reduce) {
  .fade { animation-duration: var(--dur-fast); animation-delay: 0ms; }
  html { scroll-behavior: auto; }
  a, .card, .pill, .row { transition: none; }
}

/* ── Home · Marquee hero ─────────────────────────────────────────────── */

.marquee {
  position: relative;
  overflow: hidden;
  min-height: 80svh;
  display: flex;
  align-items: flex-end;
  padding: var(--space-3xl) var(--page-gutter) var(--space-4xl);
  background:
    radial-gradient(50rem 36rem at 92% 0%, var(--color-bloom), transparent 70%),
    var(--color-paper);
}

.thinking-orb-wrap {
  position: absolute;
  top: clamp(2.5rem, 10vh, 5.5rem);
  right: clamp(2rem, 9vw, 8rem);
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  pointer-events: auto;
  user-select: none;
  cursor: default;
}

#thinking-orb-canvas {
  display: block;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  pointer-events: auto;
}

@media (max-width: 640px) {
  .thinking-orb-wrap {
    top: 1.5rem;
    right: 1.25rem;
    width: 140px;
    height: 140px;
  }
  #thinking-orb-canvas {
    width: 140px;
    height: 140px;
  }
}
.marquee-title {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 300;
  font-size: var(--text-display);
  line-height: 0.92;
  letter-spacing: -0.05em;
}
.marquee-title span { display: block; }

/* Hard colour change below the fold; elevated surfaces instead of rules */
.below { --row-hover: var(--color-paper-3); background: var(--color-paper-2); padding-block: var(--space-3xl); }

.intro {
  max-width: 30ch;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: var(--text-xl);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.sect { margin-top: var(--space-3xl); }
.sect-title { margin: 0 0 var(--space-lg); color: var(--color-muted); font-family: var(--font-body); font-size: var(--text-sm); font-weight: 500; letter-spacing: 0.02em; }

/* Work cards: two equal tracks, aligned tops, equal heights */
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-lg); }
@media (min-width: 60rem) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-width: 0;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  background: var(--color-paper-3);
}
.card-name { margin: 0; font-family: var(--font-display); font-style: normal; font-weight: 300; font-size: var(--text-xl); line-height: 1.15; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.card-summary { margin: 0; max-width: 46ch; }
.card-meta { margin: 0; color: var(--color-muted); font-family: var(--font-mono); font-size: var(--text-sm); }
.card-links { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin: auto 0 0; padding-top: var(--space-md); }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 var(--space-lg);
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: var(--color-accent-ink);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity var(--dur-base) var(--ease-out);
}
.pill:hover, .pill.is-hover { color: var(--color-accent-ink); opacity: 0.88; }
.pill:active, .pill.is-active { opacity: 0.7; }

/* Post rows */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2xs);
  padding: var(--space-md);
  margin-inline: calc(var(--space-md) * -1);
  border-radius: var(--radius-sm);
  transition: background-color var(--dur-base) var(--ease-out);
}
@media (min-width: 44rem) { .row { grid-template-columns: minmax(0, 2fr) minmax(0, 8fr); gap: var(--space-xl); } }
.row:hover { background: var(--row-hover, var(--color-paper-2)); }
.row-date { color: var(--color-muted); font-family: var(--font-mono); font-size: var(--text-sm); font-variant-numeric: tabular-nums; line-height: 1.9; }
.row-body > * { margin: 0; }
.row-sub { color: var(--color-muted); font-size: var(--text-sm); }
.more { margin: var(--space-lg) 0 0; font-size: var(--text-sm); }
.more a { white-space: nowrap; }

/* ── Footer · Ft5 statement ──────────────────────────────────────────── */

.site-foot { background: var(--color-paper-2); margin-top: var(--space-3xl); padding-block: var(--space-3xl) var(--space-xl); }
main:has(.below) + .site-foot { margin-top: 0; padding-top: 0; }
.foot-stmt-line { max-width: 22ch; margin: 0; font-family: var(--font-display); font-weight: 300; font-size: var(--text-2xl); line-height: 1.05; letter-spacing: -0.03em; }
.foot-cta { margin: var(--space-lg) 0 0; }
.foot-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-sm) var(--space-xl);
  margin-top: var(--space-2xl);
  padding-top: var(--space-md);
  border-top: var(--rule-hair);
  color: var(--color-muted);
  font-size: var(--text-sm);
}
.foot-meta p { margin: 0; }
.foot-links { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-lg); margin: 0; padding: 0; list-style: none; }
.foot-links a { white-space: nowrap; }

/* ── Inner pages and posts ───────────────────────────────────────────── */

.page { padding-block: var(--space-4xl) 0; }
.page-head { max-width: var(--measure); margin-bottom: var(--space-2xl); }
.page-title {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 300;
  font-size: var(--text-2xl);
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.page-sub { margin: var(--space-md) 0 0; color: var(--color-muted); }
.page-meta { margin: var(--space-md) 0 0; display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-md); color: var(--color-muted); font-size: var(--text-sm); }
.page-meta time { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.page-meta a { white-space: nowrap; }

.prose { max-width: var(--measure); min-width: 0; }
.prose > * + * { margin-top: var(--space-md); }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2 {
  margin-top: var(--space-2xl);
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 300;
  font-size: var(--text-xl);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.prose h3, .prose h4 { margin-top: var(--space-xl); font-family: var(--font-display); font-style: normal; font-weight: 700; font-size: var(--text-base); line-height: 1.3; }
.prose h1 + *, .prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: var(--space-sm); }
.prose ul, .prose ol { padding-left: var(--space-lg); }
.prose li + li { margin-top: var(--space-2xs); }
.prose strong { font-weight: 500; }
.prose blockquote { margin-inline: var(--space-lg) 0; color: var(--color-muted); font-style: italic; }
.prose hr { border: 0; border-top: var(--rule-hair); margin-block: var(--space-xl); }
.prose img { display: block; }

.prose table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.prose th, .prose td { padding: var(--space-xs) var(--space-md) var(--space-xs) 0; text-align: left; vertical-align: top; border-bottom: var(--rule-hair); }
.prose th { font-weight: 500; border-bottom-color: var(--color-muted); }

.prose code { padding: 0 var(--space-2xs); border-radius: var(--radius-sm); background: var(--color-paper-3); font-family: var(--font-mono); font-size: 0.88em; overflow-wrap: anywhere; }
.prose pre, .prose pre[class*="language-"] { margin-inline: calc(var(--space-md) * -1); padding: var(--space-md); overflow-x: auto; border-radius: var(--radius-sm); background: var(--color-paper-2); font-size: var(--text-sm); line-height: 1.55; }
.prose pre code, .prose pre[class*="language-"] code { padding: 0; background: none; font-size: inherit; overflow-wrap: normal; }
.prose .highlight, .prose .highlighter-rouge { background: transparent; }

mjx-container { max-width: 100%; overflow-x: auto; overflow-y: hidden; }

/* Prism — four colours, tokens only */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--color-syn-comment); font-style: italic; }
.token.keyword, .token.selector, .token.important, .token.atrule, .token.builtin, .token.tag { color: var(--color-syn-keyword); }
.token.string, .token.char, .token.attr-value, .token.regex, .token.variable { color: var(--color-syn-string); }
.token.number, .token.boolean, .token.constant, .token.symbol { color: var(--color-syn-number); }

.pager { display: flex; justify-content: space-between; gap: var(--space-lg); max-width: var(--measure); margin-top: var(--space-2xl); padding-top: var(--space-lg); border-top: var(--rule-hair); font-size: var(--text-sm); }
.pager > * { min-width: 0; }
.pager-next { text-align: right; margin-left: auto; }

/* Tags page */
.tag-chips { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin: 0 0 var(--space-2xl); }
.tag-chip { padding: var(--space-2xs) var(--space-md); border: var(--rule-hair); border-radius: var(--radius-pill); font-size: var(--text-sm); text-decoration: none; white-space: nowrap; }
.tag-chip:hover { border-color: var(--color-accent); }
.tag-group { max-width: var(--measure); margin-bottom: var(--space-xl); }
.tag-group h2 { margin: 0 0 var(--space-sm); font-family: var(--font-display); font-weight: 700; font-size: var(--text-base); }
.tag-group ul { list-style: none; margin: 0; padding: 0; }
.tag-group li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2xs) var(--space-lg); padding-block: var(--space-xs); border-bottom: var(--rule-hair); }
.tag-group time { color: var(--color-muted); font-family: var(--font-mono); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }

/* 404 */
.lost { padding-block: var(--space-3xl); }
