/* katebonner.ai — a physics figure drawn in burgundy ink on tan paper. */

:root {
  --paper: #F2ECE1;             /* off-white tan paper */
  --ink: #7A1E2C;               /* burgundy ink: every line and letter */
  --ink-2: #7A1E2C;             /* one ink for everything */
  --line: #7A1E2C;
  --red: #7A1E2C;               /* the same ink; hover thickens the underline instead */
  --lw-thin: 1px;
  --lw-med: 1px;               /* every line on the site is 1px */
  --lw-thick: 1px;

  --font-letter: "Be Vietnam Pro", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Be Vietnam Pro", "Helvetica Neue", Arial, sans-serif;
  --font-prose: "Be Vietnam Pro", "Helvetica Neue", Arial, sans-serif;

  --fs-0: 0.6875rem;   /* 11px: zone marks and title-block keys */
  --fs-1: 0.8125rem;   /* 13px: labels, readouts, captions */
  --fs-2: 1.0625rem;   /* 17px: prose */
  --fs-3: 1.375rem;    /* 22px: section titles */
  --fs-display: clamp(1.9rem, 1rem + 1.8vw, 2.4rem);

  --label-w: 360px;
  --bar-h: 56px;
  --sheet-pad: 24px;         /* page margin */
  --measure: 66ch;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  position: relative;
  padding: var(--sheet-pad);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-prose);
  font-size: var(--fs-2);
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100svh;   /* phones: the visible height, not the height behind the browser's bars */
  display: flex;
  flex-direction: column;
}
/* the sheet: paper and drawing move together frame to frame, about the viewport centre */
.paper {
  position: fixed; inset: -6%; z-index: -1;
  background: var(--paper) url('/assets/paper.jpg') center center / 880px auto repeat;
  will-change: transform;
  pointer-events: none;
}
::selection { background: var(--ink); color: var(--paper); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--ink); text-decoration-thickness: 2px; }

h1, h2, h3 { font-family: var(--font-letter); font-weight: 500; line-height: 1.12; margin: 0; letter-spacing: 0.01em; text-wrap: balance; }
h1 { font-size: var(--fs-display); }
h2 { font-size: var(--fs-3); text-transform: uppercase; letter-spacing: 0.08em; }
h3 { font-size: var(--fs-2); text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0; }
p + p { margin-top: 16px; }

.label {
  font-family: var(--font-letter);
  font-size: var(--fs-1);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}
.mono { font-family: var(--font-mono); font-size: var(--fs-1); font-variant-numeric: tabular-nums; }

/* ---------- header strip ---------- */
.topbar {
  height: var(--bar-h);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border-bottom: var(--lw-thin) solid var(--line);
  padding: 0 24px;
}
.topbar__mark {
  font-family: var(--font-letter);
  font-size: var(--fs-2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}
.topbar__nav { display: flex; gap: 28px; }
.topbar__nav a {
  font-family: var(--font-letter);
  font-size: var(--fs-1);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  padding: 6px 0;
  border-bottom: var(--lw-thin) solid transparent;
}
.topbar__nav a:hover { border-bottom-color: var(--line); }
.topbar__nav a[aria-current="page"] { border-bottom-color: var(--line); }
/* ---------- home: one sheet in three bands ---------- */
.sheet { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.band--figure { position: relative; flex: 1 1 auto; min-height: 0; border-bottom: var(--lw-thin) solid var(--line); }
.band--story {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: end;
  padding: 24px 24px 4px;
}
.story { max-width: 46ch; }
.story h1 { max-width: 14ch; }
.story .sub { margin-top: 12px; font-family: var(--font-prose); font-size: var(--fs-2); color: var(--ink-2); }

.state { position: absolute; inset: 0; margin: 0; display: grid; }
.state > * { grid-area: 1 / 1; }
.state .wp-frame { width: 100%; height: 100%; display: block; padding: 16px 24px; }
.state .wp-mount {
  width: 100%; height: 100%; position: relative; overflow: hidden;
  will-change: transform;
}
.state .wp-mount canvas { display: block; width: 100%; height: 100%; }
.state.is-live .wp-frame { visibility: hidden; }
.state:not(.is-live) .wp-mount { display: none; }

/* ---------- tiles: a row of square links under the figure ---------- */
.tiles {
  --tile: clamp(112px, 15vh, 168px);
  display: grid;
  grid-template-columns: repeat(3, var(--tile));
  gap: 16px;
}
.tile {
  aspect-ratio: 1;
  display: flex; align-items: flex-end;
  padding: 14px 16px;
  border: var(--lw-thin) solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-letter);
  font-size: var(--fs-1);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background 140ms ease-out, color 140ms ease-out;
}
.tile:hover, .tile:focus-visible { background: var(--ink); color: var(--paper); }

/* ---------- notes: hand-drawn figures lifted from the notebook ---------- */
.note { max-width: var(--measure); }
.note-layout { max-width: none; }
.note .katex { font-size: 1.02em; }
.note .katex-display { margin: 0; }
.note .meta { display: block; margin-bottom: 28px; }
.note .meta a { color: inherit; text-decoration: none; }
.note .meta a:hover { text-decoration: underline; }
.lede { font-family: var(--font-letter); font-size: 1.3125rem; font-weight: 500; line-height: 1.35; letter-spacing: -0.005em; margin: 0 0 14px; }
.epigraph { font-family: var(--font-letter); font-size: var(--fs-3); font-weight: 500; line-height: 1.3; letter-spacing: -0.005em; margin: 0 0 24px; max-width: 34ch; }
.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin: 24px 0 24px; }
.panels--wide { grid-template-columns: 1fr; }
.prose .ink-figure { margin: 0; }
.ink-figure img { display: block; width: 100%; height: auto; }
/* live panels: the brush draws into the mount; a lifted drawing, if present, is the no-script fallback */
.panels .ink-figure { aspect-ratio: 9 / 14; }
.ink-figure--live { position: relative; }
.ink-figure--live .ink-figure__fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center top; }
.ink-figure__sheet { position: absolute; inset: 0; }
.ink-figure__mount { position: absolute; inset: 0; display: none; }
.ink-figure--live.is-live .ink-figure__mount { display: block; }
.ink-figure--live.is-live .ink-figure__fallback { display: none; }
.ink-figure--live:not(.is-live) .ink-figure__fallback ~ .ink-figure__sheet { display: none; }
.ink-figure__title { position: absolute; top: 12px; left: 14px; z-index: 1; font-family: var(--font-letter); font-size: var(--fs-0); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink); white-space: nowrap; pointer-events: none; }
[data-sheet] { will-change: transform; }   /* paper.js writes the sheet's transform on these directly */
/* the stage: one state-space figure that sides with the text and follows the layer being read */
@media (max-width: 1320px) {
  /* with the stage beside the text there is no room for the title column: it folds above the text */
  .page.page--note { grid-template-columns: 1fr; }
  .page--note .page__label { border-right: 0; padding-bottom: 0; }
  .page--note .page__label h1 { position: static; }
  .page--note .page__body { padding-top: 16px; }
}
.note-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: start; }
.note-layout > .prose { grid-column: 1; grid-row: 1; }
.stage { grid-column: 2; grid-row: 1; position: sticky; top: max(24px, calc(50vh - 192px)); aspect-ratio: 5 / 6; margin: 0; align-self: start; }   /* the sphere's centre (47% down a 408px box) sits at the middle of the viewport */
.stage .ink-figure__title { top: auto; bottom: 5%; left: 0; right: 0; text-align: center; }
/* generators rest light; the one firing on the state space goes dark, in step with the drawing */
.gen__row { opacity: 0.5; transition: opacity 60ms linear; }
.gen__row.is-on { opacity: 1; }

.gen-panel { width: min(100%, 360px); margin: 12px 0 20px; }
.gen-panel--wide { width: 100%; }
.gen__grid { display: grid; grid-template-columns: repeat(2, auto); justify-content: center; gap: 14px 40px; }
.gen__sub { align-self: flex-start; margin: 10px 0 0; }
.gen-panel__title { font-family: var(--font-letter); font-size: var(--fs-0); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink); margin-bottom: 4px; }
.prose .still { margin: 16px 0 20px; max-width: 360px; }
.js .still { display: none; }
.js.no-stage .still { display: block; }
/* typeset generators inside the frame */
.gen { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 10px 0 2px; text-align: center; }
.gen .katex { font-size: 1.5em; }
.gen .katex-display { margin: 0; max-width: 100%; overflow: hidden; }
.gen .katex-display > .katex { white-space: normal; }
.gen__note { margin: 6px 0 0; font-size: var(--fs-1); color: var(--ink); line-height: 1.4; }
.trio { position: relative; }
.trio:not(.is-live) { aspect-ratio: 1400 / 644; }
.trio > .ink-figure__fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.trio__live { display: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.trio.is-live .trio__live { display: grid; }
.trio.is-live > .ink-figure__fallback { display: none; }
.trio .ink-figure--live { display: flex; flex-direction: column; min-width: 0; aspect-ratio: auto; }
.trio .ink-figure--live .ink-figure__sheet { position: relative; inset: auto; aspect-ratio: 1; }
.trio .ink-figure--live .ink-figure__mount { position: absolute; inset: 0; }
.trio figcaption { text-align: center; margin-top: 6px; padding: 0 4px; font-family: var(--font-letter); font-size: var(--fs-0); letter-spacing: 0.1em; line-height: 1.35; text-transform: uppercase; color: var(--ink); }
.notes { list-style: none; margin: 0 -14px; padding: 0; max-width: 788px; }
/* each entry is one link: an underlined title at rest, and the whole row inverts under the pointer */
.notes li { border-bottom: var(--lw-thin) solid var(--line); }
.notes li:first-child { border-top: var(--lw-thin) solid var(--line); }
.notes .entry { position: relative; display: block; padding: 18px 14px 20px; color: var(--ink); text-decoration: none; }
.notes .entry__title { position: relative; z-index: 1; display: block; font-family: var(--font-letter); font-size: var(--fs-2); font-weight: 500; }
.notes .entry__arrow { display: inline-block; margin-left: 0.15em; transition: transform 140ms ease-out; }
.notes .entry:hover .entry__arrow, .notes .entry:focus-visible .entry__arrow { transform: translateX(6px); }
.notes .entry__blurb { position: relative; z-index: 1; display: block; margin-top: 8px; font-size: var(--fs-1); line-height: 1.5; color: var(--ink-2); }
/* under the pointer the row is scribbled in with the pencil, behind the type (js/scribble.js) */
.notes .entry__scribble { position: absolute; inset: 4px 2px; z-index: 0; pointer-events: none; }
.notes .entry:focus-visible { outline: var(--lw-thin) solid var(--line); outline-offset: -1px; }
html:not(.js) .notes .entry:hover .entry__title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }

/* ---------- content pages ---------- */
.page { flex: 1; display: grid; grid-template-columns: var(--label-w) 1fr; }
.page__label { border-right: var(--lw-thin) solid var(--line); padding: 40px 24px; }
.page__label h1 { position: sticky; top: 40px; }
.page__body { padding: 40px 24px 64px; min-width: 0; }
.prose { max-width: var(--measure); min-width: 0; }
.prose p { margin: 0 0 16px; }
.prose h2 { margin: 40px 0 12px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-family: var(--font-letter); font-size: var(--fs-1); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; margin: 28px 0 10px; }
.prose h2 + h3 { margin-top: 14px; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 16px; }
.prose li + li { margin-top: 6px; }
.prose code, .prose pre { font-family: var(--font-mono); font-size: 0.92em; }
.prose pre { border: var(--lw-thin) solid var(--line); padding: 16px; overflow-x: auto; }
.prose figure { margin: 24px 0; }
.prose figcaption, .figcaption { font-family: var(--font-letter); font-size: var(--fs-1); letter-spacing: 0.04em; color: var(--ink-2); margin-top: 8px; line-height: 1.45; }
.meta { font-family: var(--font-mono); font-size: var(--fs-1); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- narrow ---------- */
@media (max-width: 1100px) {
  .topbar, .band--story, .state .wp-frame, .page__label, .page__body { padding-left: 20px; padding-right: 20px; }
}
@media (max-width: 860px) {
  .band--figure { flex: 1 1 auto; min-height: 320px; }   /* the drawing takes the screen, as on desktop */
  .band--story { grid-template-columns: 1fr; gap: 20px; padding: 20px 16px 8px; }
  .story h1 { max-width: none; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .tile { padding: 10px 12px; font-size: 0.75rem; letter-spacing: 0.1em; }
  :root { --label-w: 0px; --sheet-pad: 16px; }
  .page { grid-template-columns: 1fr; }
  .page__label { border-right: 0; }
  .panels { gap: 12px; }
  .ink-figure__title { top: 8px; left: 10px; font-size: 0.6875rem; letter-spacing: 0.1em; }
  .gen { gap: 12px; padding: 6px 0 0; font-size: 0.9rem; }
  .gen .katex { font-size: 1.4em; }
  .gen--wide .katex { font-size: 1.02em; }
  .gen__grid { gap: 10px 24px; }
  .gen__grid .katex { font-size: 1.25em; }
  .note-layout { display: block; }
  .stage { position: sticky; top: 0; z-index: 2; aspect-ratio: auto; height: 40vh; height: 40svh; min-height: 240px; margin: 0 -16px 20px; background: var(--paper) url('/assets/paper.jpg') center center / 880px auto repeat; border-bottom: var(--lw-thin) solid var(--line); }
  .stage .ink-figure__sheet { inset: 10px 16px; }
  .gen-panel { width: 100%; }
  .gen__note { font-size: 0.75rem; }
  .trio__live { gap: 8px; }
  .trio figcaption { font-size: 0.6875rem; letter-spacing: 0.08em; }
  .page__label, .page__body, .state .wp-frame { padding-left: 16px; padding-right: 16px; }
  .topbar { grid-template-columns: 1fr auto; gap: 12px; padding-left: 16px; padding-right: 16px; }
  .topbar__nav { justify-self: end; gap: 14px; }
  .page__label { padding-bottom: 0; }
  .page__label h1 { position: static; }
}

/* ---------- touch: every link is at least 44px tall ---------- */
@media (pointer: coarse) {
  .topbar__mark, .topbar__nav a { display: inline-flex; align-items: center; min-height: 44px; }
  .page__body .prose > p > a:only-child { display: inline-block; padding-block: 11px; }   /* a link standing alone on its line, as on Contact */
}
/* ---------- a phone on its side: the drawing sits beside the text instead of over it ---------- */
@media (max-width: 860px) and (orientation: landscape) and (max-height: 520px) {
  .note-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 20px; align-items: start; }
  .stage { position: sticky; top: 8px; height: calc(100vh - 16px); height: calc(100svh - 16px); min-height: 0; margin: 0; background: none; border-bottom: 0; }
  .stage .ink-figure__sheet { inset: 0; }
}
