html, body { overscroll-behavior: none; }
@property --accent { syntax: "<color>"; inherits: true; initial-value: #e3a35c; }
:root {
  --bg: #0e131b; --ink: #e9e4da; --muted: #8e97a6; --accent: #4043ff; --blue: #9a41ff;
  --line: rgba(233,228,218,.12); --pill: rgba(14,19,27,.62);
  --cellA: 64,67,255; --cellB: 154,65,255; --cellG: 138,143,153; --fieldA: .10; --chaos: 0;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
/* Crazy keeps the colours of the theme it was entered from (data-base); only the motion changes. */
:root[data-theme="light"], :root[data-theme="crazy"][data-base="light"] {
  --bg: #f5f1e8; --ink: #1c2330; --muted: #5d6573; --accent: #0003ca; --blue: #6200d2;
  --line: rgba(28,35,48,.14); --pill: rgba(245,241,232,.7);
  --cellA: 0,3,202; --cellB: 98,0,210; --cellG: 141,138,132; --fieldA: .08;
}
:root[data-theme="crazy"] { --chaos: 1; }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 200 800; font-display: block; src: url(/fonts/newsreader.woff2) format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 200 800; font-display: block; src: url(/fonts/newsreader-italic.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: block; src: url(/fonts/plex-mono-400.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: block; src: url(/fonts/plex-mono-500.woff2) format("woff2"); }
@font-face { font-family: "Newsreader Fallback"; src: local("Georgia"); size-adjust: 104%; ascent-override: 92%; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "Newsreader", "Newsreader Fallback", Georgia, serif; font-size: 20px; line-height: 1.6;
  transition: background .3s, color .3s;
}
body { position: relative; min-height: 100vh; }
/* One canvas: the agent field, the photo dots and the text particles, all in document coordinates with
   the scroll position as the camera (src/main.js). It lives in the document, taller than the viewport
   at each end (src/main.js sets the overhang), and is moved to the scroll position every frame, so a compositor scroll between
   frames moves world-anchored content by exactly the right amount. #bgw clips it to the page. */
#bgw { position: absolute; inset: 0; overflow: clip; pointer-events: none; z-index: 0; }
#bg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .6s cubic-bezier(.2,.7,.2,1); }
#bg.on { opacity: 1; }
.bgfb #bg { position: fixed; inset: 0; height: 100%; transform: none; }
/* Pixel intro: the text is hidden until its particles take over (the class is removed by src/main.js). */
.pxi :is(header nav a, .mail, h1, .intro p, section h2, .map-title, section > div > p, .end) { opacity: 0 !important; }
.pxi .photo img { opacity: 0; }
/* Particle text (html.ptx): the DOM text keeps the layout, links, selection and screen readers, and is
   painted with transparent ink; the canvas draws its pixels. Underlines stay DOM; they fade out in crazy
   mode (html.dis) while the letters break up. Hover shows the DOM link in the accent colour over its particles. */
html.ptx:not(.pxcap) :is(header nav a, nav a sup, .mail, .mail a, h1, .intro p, section h2, .map-title, section > div > p, section > div > p :is(a, code), .end, .end a) { color: transparent; transition: opacity .6s, color .2s, border-color .2s; }
html.ptx :is(nav a, .mail a):hover { color: var(--accent); }
html.ptx ::selection { color: var(--ink); }
html.ptx section h2::before { opacity: 0; }
.dis :is(header nav a, .mail, h1, .intro p, section h2, .map-title, section > div > p, .end) { opacity: 0 !important; transition-duration: 1.5s; }
.pxcap, .pxcap * { transition: none !important; animation: none !important; }
.mono { font-family: var(--mono); }

/* One centred column: name, email, intro beside the photo, then the sections. */
main { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 40px 24px 120px; }
header {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px 24px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 13px; letter-spacing: .02em;
}
nav { display: flex; gap: 22px; flex-wrap: wrap; }
nav a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 2px; transition: color .2s, border-color .2s; }
nav a:hover { color: var(--accent); border-color: var(--accent); }
nav a sup { font-size: 9px; color: var(--muted); margin-left: 2px; }
.theme { display: flex; gap: 4px; color: var(--muted); white-space: nowrap; }
.theme button {
  background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; letter-spacing: inherit;
}
.theme button::before { content: "["; } .theme button::after { content: "]"; }
.theme button::before, .theme button::after { visibility: hidden; color: var(--accent); }
.theme button[aria-pressed="true"] { color: var(--ink); }
.theme button[aria-pressed="true"]::before, .theme button[aria-pressed="true"]::after { visibility: visible; }
.theme button { transition: color .2s cubic-bezier(.2,.7,.2,1); }
.theme button:hover { color: var(--ink); }
/* One keyboard focus ring everywhere: accent, offset, never on mouse click. */
a:focus-visible, .theme button:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; border-radius: 2px; }
a, button { -webkit-tap-highlight-color: transparent; }
/* "crazy" shimmers faintly so it reads as the one to try. */
.theme button[data-t="crazy"] {
  background: linear-gradient(90deg, var(--muted) 0 30%, #ff7eb6, #ffb067, #ffe27a, #7cf0a4, #79d4ff, #c2a2ff, var(--muted) 70% 100%) 0 0 / 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 7s linear infinite; filter: drop-shadow(0 0 5px rgba(255, 170, 220, .22));
}
.theme button[data-t="crazy"]:hover { filter: drop-shadow(0 0 6px rgba(255, 170, 220, .45)); }
.theme button[data-t="crazy"][aria-pressed="true"] { background-image: none; color: var(--ink); filter: none; animation: none; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.name { margin-top: 120px; }
h1 {
  font-size: 96px; line-height: .92; font-weight: 600; margin: 0 0 22px -.04em; letter-spacing: -.035em;
}
.mail { font-family: var(--mono); font-size: 13px; margin: 0; }
.mail a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); transition: color .2s, border-color .2s; }
.mail a:hover { color: var(--accent); border-color: var(--accent); }
.lede { display: grid; grid-template-columns: minmax(0, 1fr) 236px; column-gap: 44px; align-items: center; margin-top: 56px; }
.intro { font-size: 23px; line-height: 1.5; }
p { margin: 0 0 22px; }
a.t { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* Photo: a square crop of /me.jpg around the face (680 px square at x 70, y 50 of the 800x1000 file;
   src/photo.js uses the same crop). While the WebGL particle photo runs (html.pgl) the image is
   hidden and the canvas draws it as dots; reduced motion and no-WebGL show this plain image. */
.photo { margin: 0; width: 236px; aspect-ratio: 1; position: relative; overflow: hidden; }
.photo img {
  position: absolute; display: block; max-width: none; width: 117.647%; height: auto; left: -10.294%; top: -7.353%;
  transition: opacity .6s;
}
.pgl .photo img { opacity: 0; }

section { margin-top: 44px; }
.lede + section { margin-top: 36px; }
section h2 {
  font-family: var(--mono); font-weight: 500; font-size: 11px; letter-spacing: .18em; color: var(--muted);
  margin: 0 0 12px; display: flex; align-items: center; gap: 10px;
}
section h2::before { content: ""; width: 5px; height: 5px; background: var(--accent); flex: none; }
section:nth-of-type(even) h2::before { background: var(--blue); }
.end { margin-top: 40px; font-style: italic; font-size: 23px; }
.end a { color: var(--accent); }

/* Word map page: the same column, with the map breaking out to a wider panel. */
code { font-family: var(--mono); font-size: .8em; }
.map {
  position: relative; margin: 40px 0 8px calc(50% - min(560px, 50vw - 16px)); width: min(1120px, calc(100vw - 32px));
  height: min(80vh, 760px); min-height: 480px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: radial-gradient(70% 60% at 50% 48%, color-mix(in srgb, var(--bg) 90%, var(--ink)) 0%, var(--bg) 75%);
  box-shadow: 0 30px 80px -50px rgba(0,0,0,.35);
  font-family: var(--mono); font-size: 12px; color: var(--muted); user-select: none;
}
:root[data-base="dark"] .map { box-shadow: inset 0 0 120px -20px rgba(0,0,0,.45), 0 30px 80px -40px rgba(0,0,0,.6); }
.map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
.map-canvas:active { cursor: grabbing; }
.map-top { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; pointer-events: none; }
.map-top > * { pointer-events: auto; }
.map-search { position: relative; width: min(260px, 100%); }
.map-search input {
  width: 100%; height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); outline: none;
  background: var(--pill); color: var(--ink); font: inherit; font-size: 13px; letter-spacing: .02em;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: border-color .2s;
}
.map-search input:focus { border-color: var(--muted); }
.map-search input::placeholder { color: var(--muted); }
.map-sugg {
  position: absolute; left: 0; right: 0; top: 44px; margin: 0; padding: 6px; list-style: none; border-radius: 12px; z-index: 3;
  background: color-mix(in srgb, var(--bg) 94%, transparent); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.map-sugg li { padding: 7px 10px; border-radius: 8px; color: var(--ink); cursor: pointer; font-size: 13px; }
.map-sugg li[aria-selected="true"], .map-sugg li:hover { background: var(--line); color: var(--accent); }
.map-sugg li.none { color: var(--muted); cursor: default; background: none; }
.map-try { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.map-try::before { content: "try"; color: var(--muted); margin-right: -4px; }
.map-try button { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; border-bottom: 1px solid var(--line); transition: color .2s, border-color .2s; }
.map-try button:hover { color: var(--accent); border-color: var(--accent); }
.map-info {
  position: absolute; top: 66px; right: 14px; width: 290px; padding: 20px 20px 16px; border-radius: 14px; z-index: 2;
  background: color-mix(in srgb, var(--bg) 78%, transparent); border: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 18px 50px -20px rgba(0,0,0,.55); animation: info-in .35s cubic-bezier(.2,.7,.2,1);
}
@keyframes info-in { from { opacity: 0; transform: translateY(-6px); } }
.map-info[hidden] { display: none; }
.map-word { font-family: "Newsreader", "Newsreader Fallback", Georgia, serif; font-size: 36px; font-weight: 600; line-height: 1; letter-spacing: -.025em; color: var(--ink); margin: 0 0 6px; overflow-wrap: anywhere; }
.map-rank { margin: 0 0 16px; font-size: 11px; color: var(--muted); }
.map-sub { display: flex; justify-content: space-between; margin: 0 0 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.map-sub span { letter-spacing: .08em; }
.map-nn { margin: 0; padding: 0; list-style: none; display: grid; gap: 1px; }
.map-nn button {
  display: grid; grid-template-columns: minmax(0, 1fr) 72px 34px; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; border-radius: 6px; padding: 3px 6px; margin: 0 -6px; width: calc(100% + 12px); font: inherit; color: var(--ink); cursor: pointer; text-align: left;
  animation: nn-in .4s cubic-bezier(.2,.7,.2,1) both; animation-delay: var(--d);
}
@keyframes nn-in { from { opacity: 0; transform: translateX(6px); } }
.map-nn .w { font-family: "Newsreader", "Newsreader Fallback", Georgia, serif; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-nn .bar { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.map-nn .bar i { display: block; height: 100%; width: calc(var(--s) * 100%); background: var(--accent); border-radius: 2px; transform-origin: left; animation: bar-in .7s cubic-bezier(.2,.7,.2,1) both; animation-delay: var(--d); }
@keyframes bar-in { from { transform: scaleX(0); } }
.map-nn .s { font-size: 11px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.map-nn button:hover { background: var(--line); }
.map-nn button:hover .w { color: var(--accent); }
.map-close { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 4px; }
.map-close:hover { color: var(--ink); }
.map-zoom { position: absolute; right: 14px; bottom: 14px; display: grid; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--pill); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.map-zoom button { width: 36px; height: 34px; background: none; border: 0; color: var(--ink); font: inherit; font-size: 16px; cursor: pointer; }
.map-zoom button + button { border-top: 1px solid var(--line); }
.map-zoom button:hover { color: var(--accent); }
.map-hint { position: absolute; left: 16px; bottom: 12px; margin: 0; font-size: 11px; letter-spacing: .04em; pointer-events: none; transition: opacity .8s; }
.map-hint.gone { opacity: 0; }
.map-load { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; }
.map-try button:focus-visible, .map-nn button:focus-visible, .map-zoom button:focus-visible, .map-close:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.wordmap { margin-top: 96px; }
.map-title { font-size: 38px; line-height: 1.02; font-weight: 600; letter-spacing: -.03em; margin: 0 0 18px -.02em; }
.map-cap { margin: 12px 0 0; font-family: var(--mono); font-size: 11px; letter-spacing: .03em; color: var(--muted); }
html.map-in #hud { opacity: 0; pointer-events: none; }
#hud { transition: opacity .4s; }

#hud {
  position: fixed; right: 20px; bottom: 18px; z-index: 2; font-family: var(--mono); font-size: 11px; line-height: 1.65;
  color: var(--muted); background: var(--pill); padding: 10px 12px; border: 1px solid var(--line);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); min-width: 190px; font-variant-numeric: tabular-nums;
}
#hud div { display: flex; justify-content: space-between; gap: 18px; }
#hud span { color: var(--ink); }
#hud i { display: block; height: 3px; margin: 6px 0 2px; background: linear-gradient(90deg, var(--accent) calc(var(--amber, .5) * 100%), var(--blue) 0); }

dialog {
  width: min(360px, calc(100vw - 32px)); padding: 28px; border: 1px solid var(--line); border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 96%, transparent); color: var(--ink);
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
}
dialog[open] { animation: d-in .18s cubic-bezier(.2,.7,.2,1); }
dialog.closing { animation: d-out .12s ease-in forwards; }
dialog.closing::backdrop { opacity: 0; transition: opacity .12s; }
dialog.shake { animation: d-shake .3s; }
dialog::backdrop { background: rgba(8,10,14,.32); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog h2 { font-size: 26px; font-weight: 600; line-height: 1.1; margin: 0 0 6px; }
dialog p { color: var(--muted); font-size: 16px; margin: 0 0 20px; }
dialog input, dialog button {
  display: block; width: 100%; height: 44px; border-radius: 999px; font: inherit; font-size: 17px;
}
dialog input {
  padding: 0 20px; color: var(--ink); background: var(--pill); border: 1px solid var(--line);
  outline: none; letter-spacing: .12em; transition: border-color .2s;
}
dialog input:focus { border-color: var(--muted); }
dialog input.bad { border-color: var(--accent); }
dialog button {
  margin-top: 12px; cursor: pointer; color: var(--accent); background: transparent;
  border: 1px solid var(--accent); transition: background .2s;
}
dialog button:hover, dialog button:focus-visible { background: color-mix(in srgb, var(--accent) 12%, transparent); outline: none; }
@keyframes d-in { from { opacity: 0; transform: scale(.98); } }
@keyframes d-out { to { opacity: 0; transform: scale(.98); } }
@keyframes d-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
/* Too narrow for the telemetry box beside the column: it joins the page flow under the text. */
@media (max-width: 1240px) {
  #hud { position: static; margin-top: 28px; max-width: 300px; backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (max-width: 700px) {
  main { padding: 24px 16px 48px; }
  header { flex-direction: column; align-items: flex-start; gap: 14px; }
  .theme { margin-left: -1ch; }
  .name { margin-top: 56px; }
  h1 { font-size: 52px; margin-bottom: 16px; }
  .lede { grid-template-columns: 1fr; margin-top: 32px; }
  .photo { order: -1; width: min(240px, 64vw); margin: 0 auto 28px; }
  .intro { font-size: 20px; }
  section { margin-top: 28px; }
  .lede + section { margin-top: 40px; }
  .end { font-size: 20px; }
  body { font-size: 18px; }
  #hud { max-width: none; }
  .map { height: 80vh; min-height: 520px; border-radius: 12px; }
  .map-title { font-size: 34px; }
  .wordmap { margin-top: 64px; }
  .map-info { top: auto; bottom: 10px; left: 10px; right: 58px; width: auto; padding: 12px 14px 10px; }
  .map-sub, .map-rank { display: none; }
  .map-nn { display: flex; flex-wrap: wrap; gap: 2px 14px; }
  .map-nn button { display: inline; width: auto; margin: 0; padding: 2px 0; }
  .map-nn .bar, .map-nn .s { display: none; }
  .map-nn .w { font-size: 14px; }
  .map-word { font-size: 24px; margin-bottom: 8px; }
  .map-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .theme button[data-t="crazy"] { animation: none; }
}
