/* ============================================================
   confusedbutinspired.com
   Dark, single column, one sans-serif. That's the whole design.
   Edit the tokens below to change the feel of everything.
   ============================================================ */

:root {
  --bg:      #0a0a0a;
  --bg-soft: #131313;
  --fg:      #ededed;
  --muted:   #9b9b9b;   /* 8.4:1 on --bg */
  --faint:   #808080;   /* 5.0:1 */
  --line:    #242424;
  --line-lit:#3a3a3a;
  --accent:  #78a9ff;

  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --col:  46rem;   /* page column */
  --text: 38rem;   /* reading measure */
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.011em;
  margin: 0;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

strong { font-weight: 600; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--line-lit);
    text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

code, pre { font-family: var(--mono); font-size: 0.875em; }
code { background: var(--bg-soft); border: 1px solid var(--line);
       border-radius: 3px; padding: 0.05em 0.35em; }

hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--bg-soft);
              border: 1px solid var(--line-lit); padding: 0.5rem 0.75rem; z-index: 10; }

/* ---------- shell ---------- */

.wrap {
  width: 100%;
  max-width: var(--col);
  margin-inline: auto;
  padding-inline: 1.5rem;
}

header.site {
  padding-block: 2rem 0;
}
header.site .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
}
.site-name { font-size: 0.9375rem; font-weight: 500; text-decoration: none; color: var(--fg); }
.site-name:hover { color: var(--accent); }

nav.site { display: flex; gap: 1.1rem; flex-wrap: wrap; }
nav.site a {
  font-size: 0.9375rem;
  color: var(--muted);
  text-decoration: none;
}
nav.site a:hover { color: var(--fg); }
nav.site a[aria-current="page"] { color: var(--fg); }

main { flex: 1 0 auto; padding-block: 2.5rem 0; }

footer.site {
  flex: none;
  margin-top: 5rem;
  padding-block: 1.5rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.875rem;
}
footer.site .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
footer.site a { color: var(--faint); text-decoration: none; }
footer.site a:hover { color: var(--fg); }

/* ---------- text ---------- */

.page-title { margin-bottom: 1rem; }

.intro { max-width: var(--text); }
.intro p { color: var(--muted); }

.prose { max-width: var(--text); }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin: 2rem 0 0.6rem; }
.prose h3 { margin: 1.5rem 0 0.4rem; }
.prose ul { padding-left: 1.1rem; margin: 0 0 1rem; }
.prose li { margin-bottom: 0.3rem; }
.prose blockquote {
  margin: 1.25rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--line-lit);
  color: var(--muted);
}
.prose ol { padding-left: 1.1rem; margin: 0 0 1rem; }

/* Chain headings: "A -> B -> C". The arrow is connective, so it stays faint. */
.prose h2 .arrow, .item-desc .arrow { color: var(--faint); font-weight: 400; padding-inline: 0.15em; }

/* Nested and longer lists need a little more air than the default. */
.prose ol > li { margin-bottom: 0.65rem; }
.prose li > ul { margin: 0.35rem 0 0; }

/* Named quantities set as real fractions: label = numerator over denominator. */
/* Named quantities set as real fractions. Stacked by default; on a wide
   enough column both rows share one grid so the "=" and fractions align. */
.defs { margin: 1.75rem 0; }
.def {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.85rem;
  margin-bottom: 1.5rem;
}
.def:last-child { margin-bottom: 0; }
.def__name { flex-basis: 100%; font-weight: 500; }
.def__scope { font-weight: 400; }
.def__eq { color: var(--muted); }

.frac { display: inline-flex; flex-direction: column; text-align: center; vertical-align: middle; }
.frac__num { border-bottom: 1px solid var(--line-lit); padding: 0 0.25rem 0.2rem; }
.frac__den { padding: 0.2rem 0.25rem 0; }

@media (min-width: 760px) {
  .defs {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    column-gap: 0.85rem;
    row-gap: 1.5rem;
  }
  .def { display: contents; }
  .def__name { flex-basis: auto; }
}

/* A wide table scrolls on its own rather than widening the page. */
.scroll-x { overflow-x: auto; }
.scroll-x table { min-width: 22rem; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}
.prose th, .prose td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 1rem 0.5rem 0;
  border-top: 1px solid var(--line);
}
.prose th { font-weight: 500; color: var(--muted); border-top: 0; padding-top: 0; }
.prose th:last-child, .prose td:last-child { padding-right: 0; }
.prose .num { text-align: right; white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 1px solid var(--line); }

/* Every block of content on every page is a .section, so the vertical
   rhythm is identical whether or not the page has an intro. */
.section { margin-top: 2.75rem; }
.section > h2 { margin-bottom: 0.75rem; }

/* ---------- lists of things ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding-block: 0.7rem; border-top: 1px solid var(--line); }
.list li:has(.shot) { padding-block: 1.1rem 1.6rem; }
.list li:first-child { border-top: 0; padding-top: 0; }
.list li[id] { scroll-margin-top: 1.5rem; }

.item { display: flex; gap: 1rem; align-items: baseline; justify-content: space-between; }
.item a { text-decoration: none; }
.item a:hover { color: var(--accent); }
.item .when { color: var(--faint); font-size: 0.875rem; flex: none; font-variant-numeric: tabular-nums; }
.item-desc { color: var(--muted); font-size: 0.9375rem; margin: 0.15rem 0 0; max-width: var(--text); }

.empty { color: var(--faint); font-size: 0.9375rem; max-width: var(--text); }

/* Project shots. Kept to the reading measure so text and images share one edge. */
.shot { margin: 1.1rem 0 0; max-width: var(--text); }
.shot img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-soft);
}
.shot__zoom { display: block; text-decoration: none; }
.shot__zoom:hover img { border-color: var(--line-lit); }
.shot figcaption { margin-top: 0.5rem; color: var(--faint); font-size: 0.875rem; }

/* A moving preview drawn by previews.js. The frame holds its space before the
   script runs, and the canvas is laid over it. A poster image in the frame shows
   until the canvas draws, and is what a reader without scripting sees; a live
   figure with no poster (marked shot--bare) goes entirely then, as there is
   nothing to show. Caption on the left, the pause button on the right. */
.shot--live { display: grid; grid-template-columns: 1fr auto; align-items: baseline; }
.shot--live .shot__zoom { grid-column: 1 / -1; }
.shot--live figcaption { grid-row: 2; grid-column: 1; }
/* The button's place, held from the first paint so the caption does not rewrap
   when the script adds the button: as wide as the button and its gap. */
.shot--live::after { content: ""; grid-row: 2; grid-column: 2; align-self: start; width: 2.625rem; margin-left: 1rem; }
.shot__frame {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-soft);
  overflow: hidden;
}
.shot__frame canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
/* Pinned to the top: under cover the poster is a hair taller than the frame, and
   previews.js lays its canvas over it from the top-left corner too. */
.shot__frame img { height: 100%; border: 0; border-radius: 0; object-fit: cover; object-position: 50% 0%; }
.shot__zoom:hover .shot__frame { border-color: var(--line-lit); }
/* The button keeps one width for Pause and Play so the caption never reflows,
   and carries the gap itself so a hidden button gives the caption full width. */
.shot__toggle {
  grid-row: 2;
  grid-column: 2;
  min-width: 3em;
  margin: 0.5rem 0 0 1rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.875rem;
  text-align: right;
  color: var(--faint);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line-lit);
  text-underline-offset: 3px;
}
.shot__toggle:hover { color: var(--accent); text-decoration-color: var(--accent); }
.shot__toggle[hidden] { display: none; }
@media (scripting: none) { .shot--bare { display: none; } .shot--live::after { content: none; } }
@media (prefers-reduced-motion: reduce) { .shot--live::after { content: none; } }

.meta { margin: 0.35rem 0 0; color: var(--faint); font-size: 0.875rem; max-width: var(--text); }
.meta a { color: var(--faint); text-decoration-color: var(--line); }
.meta a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ---------- themes ---------- */

.group { margin-top: 1.9rem; scroll-margin-top: 1.5rem; }
.group:first-of-type { margin-top: 0; }
.group > h3 { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; margin-bottom: 0.35rem; }
.group .gloss { font-size: 0.875rem; font-weight: 400; color: var(--faint); }
.group .empty { margin: 0; }

/* ---------- notes: sticky cards ---------- */

.tag { font-size: 0.8125rem; color: var(--faint); }

.stickies {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.stickies > li { display: flex; }
.sticky {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 9rem;
  padding: 0.9rem 1.05rem 0.85rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--fg);
  text-decoration: none;
  transition: border-color 140ms, background-color 140ms;
}
.sticky:hover { color: var(--fg); border-color: var(--line-lit); background: #171717; }
.sticky:hover .sticky__title { color: var(--accent); }
.sticky__title { margin: 0.45rem 0 0.4rem; font-weight: 500; line-height: 1.35; transition: color 140ms; }
.sticky__text { margin: 0; font-size: 0.9375rem; color: var(--muted); }
.sticky__when { margin-top: auto; padding-top: 0.75rem; font-size: 0.8125rem; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------- map ---------- */

.map__canvas { margin-top: 0.5rem; }

.map__canvas { display: none; }
.map__canvas svg { display: block; width: 100%; height: auto; overflow: visible; }

.map__edge { fill: none; stroke: var(--line); stroke-width: 1; }
.map__node circle, .map__node rect { fill: var(--bg); stroke: var(--faint); stroke-width: 1; }
/* A halo in the page colour keeps edges from striking through labels. */
.map__node text { font-family: var(--sans); font-size: 12px; fill: var(--muted);
                  paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.map__node--root circle { fill: var(--fg); stroke: var(--fg); }
.map__node--root text { fill: var(--fg); font-size: 13px; }
.map__node--branch text { fill: var(--fg); font-size: 12.5px; }
.map__node--leaf text { font-size: 11.5px; fill: var(--faint); }
.map__node--essay circle { fill: var(--fg); stroke: var(--fg); }
.map__node--essay text { font-size: 12px; fill: var(--fg); }
.map__node--project rect { fill: var(--fg); stroke: var(--fg); }
.map__node--project text { font-size: 12px; fill: var(--fg); }

.map__node a { text-decoration: none; }
.map__node a:hover circle, .map__node a:hover rect { fill: var(--accent); stroke: var(--accent); }
.map__node a:hover text { fill: var(--accent); }
.map__node a:focus-visible circle, .map__node a:focus-visible rect { stroke: var(--accent); stroke-width: 2.5; }

.map__edge, .map__node circle, .map__node rect, .map__node text { transition: stroke 140ms, fill 140ms, opacity 140ms; }
/* While one branch is lit, the others step back: their marks fade and their
   labels drop to the faint grey, which still reads at 5:1 against the page. */
.map.is-lit .map__node:not(.map__node--root):not(.map__node--lit) :is(circle, rect) { opacity: 0.45; }
.map.is-lit .map__node:not(.map__node--root):not(.map__node--lit) text { fill: var(--faint); }
.map.is-lit .map__edge--lit { stroke: var(--line-lit); }

/* Outline fallback: no JS, or narrow screens. */
.map__list { list-style: none; margin: 0; padding: 0; max-width: var(--text); }
.map__list > li { padding-block: 0.7rem; border-top: 1px solid var(--line); }
.map__list > li:first-child { border-top: 0; padding-top: 0; }
.map__list > li > a { text-decoration: none; }
.map__list ul { list-style: none; margin: 0.2rem 0 0; padding: 0; }
.map__list ul li { display: inline; color: var(--faint); font-size: 0.9375rem; }
.map__list ul li + li::before { content: " · "; }

@media (min-width: 800px) {
  .map.is-drawn .map__canvas { display: block; }
  .map.is-drawn .map__list { display: none; }
}

/* ---------- small screens ---------- */

@media (max-width: 560px) {
  body { font-size: 16px; }
  h1 { font-size: 1.4rem; }
  .wrap { padding-inline: 1.25rem; }
  header.site { padding-block: 1.5rem 0; }
  .item { flex-direction: column; gap: 0.15rem; }
  .item .when { font-size: 0.8125rem; }
  .frac { font-size: 0.875rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
