:root {
  --bg: #04060b;
  --surface: #0b0f18;
  --line: rgba(160, 180, 220, .16);
  --text: #e7eaf1;
  --muted: #98a3b8;
  --accent: #9fb4d8;
  --serif: "Newsreader", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--sans); -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: inherit; }
[hidden] { display: none !important; }

/* ─── universe ─── */
#universe {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; transition: opacity .45s ease;
}
.labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.star-label {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  background: none; border: 0; color: var(--text); cursor: pointer; text-align: center;
  font: 500 15px/1.2 var(--sans); letter-spacing: .01em; padding: 6px 10px; white-space: nowrap;
  text-shadow: 0 0 12px #04060b, 0 0 4px #04060b;
  transition: opacity .25s;
}
.star-label small {
  display: block; margin-top: 3px; font: italic 400 12.5px var(--serif); color: var(--accent);
  opacity: 0; transform: translateY(-3px); transition: opacity .2s, transform .2s;
}
.star-label.active span, .star-label:focus-visible span { color: var(--accent); }
.star-label.active small, .star-label:focus-visible small { opacity: 1; transform: none; }
.star-label:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.node-tip {
  position: fixed; left: 0; top: 0; z-index: 3; pointer-events: none;
  font: 500 12.5px var(--sans); color: var(--text); white-space: nowrap; max-width: 60vw; overflow: hidden; text-overflow: ellipsis;
  background: rgba(11, 15, 24, .92); border: 1px solid var(--accent); border-radius: 6px; padding: 5px 9px;
}

/* section menu */
.section-menu { display: flex; flex-wrap: wrap; gap: 4px; }
.section-menu a {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  font: 500 13.5px var(--sans); color: #b9c6dd; padding: 7px 11px; border-radius: 999px; transition: background .15s, color .15s;
}
.section-menu a i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.section-menu a:hover { background: rgba(160, 180, 220, .1); color: #fff; }
.section-menu a.selected { background: rgba(160, 180, 220, .13); color: #fff; }
.fallback-menu { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.fallback-menu:focus-within, body.no-webgl .fallback-menu {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: auto; height: auto; clip-path: none; z-index: 6;
  flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px;
}
body.no-webgl .fallback-menu a { font-size: 17px; padding: 10px 16px; }

/* ─── pages ─── */
.page {
  position: fixed; inset: 0; z-index: 10; overflow-y: auto; overscroll-behavior: contain;
  background: linear-gradient(rgba(4, 6, 11, .9), rgba(4, 6, 11, .96));
  animation: fade-in .35s ease both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.page-inner { max-width: 780px; margin: 0 auto; padding: 0 24px 120px; }
.back { font: 500 13.5px var(--sans); text-decoration: none; color: #b9c6dd; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; }
.back:hover { border-color: var(--accent); color: #fff; }

#content { font-family: var(--serif); font-size: 19px; line-height: 1.7; color: #dfe3ec; animation: rise .4s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
#content a { color: var(--accent); text-underline-offset: 3px; }
.page-head { margin-bottom: 34px; padding-bottom: 26px; border-bottom: 1px solid var(--line); position: relative; }
.kicker { font: 500 12px var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
.kicker::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); margin-right: 10px; }
#content h1 { font: 500 clamp(34px, 6vw, 52px)/1.08 var(--serif); letter-spacing: -.01em; color: #fff; }
.lead { margin-top: 12px; font-style: italic; color: var(--muted); font-size: 20px; }
.page-head .logo { position: absolute; right: 0; top: 0; max-width: 110px; max-height: 54px; object-fit: contain; background: #f4f1e8; border-radius: 8px; padding: 6px 8px; }
.crumb { font: 500 13.5px var(--sans); margin-bottom: 18px; }
.crumb a { text-decoration: none; color: var(--muted) !important; }
.crumb a:hover { color: var(--accent) !important; }
#content h2 { font: 500 26px/1.2 var(--serif); color: #fff; margin: 40px 0 12px; }
#content h3 { font: 600 16px/1.3 var(--sans); color: #fff; }
#content p + p { margin-top: 14px; }
.large { font-size: 21px; }
.sub { font: 400 14px/1.5 var(--sans); color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }
.badge { display: inline-block; vertical-align: middle; font: 600 10.5px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: #04060b; background: var(--accent); border-radius: 4px; padding: 3px 7px; margin-left: 6px; }

.prose ul, .prose ol { margin: 12px 0 12px 24px; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--accent); }
.prose blockquote { margin: 22px 0; padding: 4px 0 4px 20px; border-left: 2px solid var(--accent); font-style: italic; color: #c5cbd8; }
.prose code { font: 14.5px ui-monospace, Consolas, monospace; background: rgba(160, 180, 220, .1); border-radius: 4px; padding: 2px 6px; }
.prose pre { margin: 16px 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose img { max-width: 100%; border-radius: 8px; margin: 18px 0; }
.prose img.small { display: block; width: min(340px, 100%); margin-top: 28px; }
.prose strong { color: #fff; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip { font: 500 12.5px var(--sans); text-decoration: none; color: #b9c6dd !important; border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; transition: border-color .15s, color .15s; }
.chip:hover, .chip.selected { border-color: var(--accent); color: #fff !important; }
.chip.selected { background: rgba(160, 180, 220, .12); }
.chip i { font-style: normal; color: #6f7b91; margin-left: 3px; }

.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 6px; }
.button { font: 500 14px var(--sans); text-decoration: none; color: #04060b !important; background: var(--accent); border-radius: 999px; padding: 9px 18px; }
.button:hover { filter: brightness(1.12); }

.timeline { list-style: none; }
.timeline li { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.timeline h3 a { color: #fff !important; text-decoration-color: var(--accent); }
.timeline time { font: 400 13.5px var(--sans); color: var(--muted); white-space: nowrap; padding-top: 2px; }
.skills { display: grid; grid-template-columns: auto 1fr; gap: 10px 22px; font: 400 15.5px/1.55 var(--sans); }
.skills dt { color: var(--accent); font-weight: 500; }
.links { list-style: none; font: 400 15.5px var(--sans); }
.links li { display: flex; gap: 16px; padding: 8px 0; }
.links span { min-width: 80px; color: var(--muted); }

.posts { list-style: none; }
.posts li { padding: 24px 0; border-bottom: 1px solid var(--line); }
.posts a { text-decoration: none; display: block; }
.posts time { font: 400 13px var(--sans); color: var(--muted) ; }
.posts h2 { margin: 6px 0 6px !important; transition: color .15s; }
.posts a:hover h2 { color: var(--accent) !important; }
.posts p { color: #c5cbd8; font-size: 17.5px; }

.cards { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.cards li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; transition: border-color .15s, transform .15s; }
.cards li:hover { border-color: var(--accent); transform: translateY(-2px); }
.cards a { text-decoration: none; display: block; position: relative; }
.cards small { font: 400 12.5px var(--sans); color: var(--muted); }
.cards h2 { font-size: 22px !important; margin: 6px 0 4px !important; padding-right: 70px; }
.cards p { font-size: 16px; line-height: 1.55; color: #c5cbd8; }
.cards .sub { margin-bottom: 8px; }
.cards .logo { position: absolute; right: 0; top: 0; width: 56px; height: 36px; object-fit: contain; background: #f4f1e8; border-radius: 6px; padding: 4px; }

.series-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.series-list a { display: block; text-decoration: none; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); transition: border-color .15s; }
.series-list a:hover { border-color: var(--accent); }
.series-list img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; }
.series-list div { padding: 14px 16px 16px; }
.series-list h2 { font-size: 20px !important; margin: 0 0 4px !important; }
.series-list small { font: 400 13px var(--sans); color: var(--muted); }
/* city essay: the photos sit inside the text, floated right and left in turn */
.city-essay { display: flow-root; }
/* photos that do not fit in the essay: an equal-height strip that scrolls sideways */
.strip { display: flex; gap: 10px; margin-top: 34px; padding-bottom: 10px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.strip figure { flex: none; margin: 0; scroll-snap-align: start; }
.strip button { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 8px; overflow: hidden; }
.strip img { display: block; height: 150px; width: auto; transition: transform .3s; }
.strip button:hover img { transform: scale(1.04); }
.strip button:focus-visible, .strip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.city-essay figure.inline { width: 46%; margin: 6px 0 16px; }
.city-essay figure.right { float: right; clear: right; margin-left: 26px; }
.city-essay figure.left { float: left; clear: left; margin-right: 26px; }
.city-essay figure.inline + p { margin-top: 0 !important; }
.city-essay figure.inline img { margin: 0; border-radius: 0; }
.city-essay h2 { clear: both; }
@media (max-width: 640px) { .city-essay figure.inline { float: none; width: 100%; margin: 20px 0; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 28px 22px; align-items: start; }
.grid figure { margin: 0; }
:is(.grid, .city-essay) figcaption { margin-top: 9px; padding-left: 12px; border-left: 2px solid var(--accent); font: italic 400 16.5px/1.5 var(--serif); color: #c5cbd8; white-space: pre-line; }
:is(.grid, .city-essay) button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 8px; overflow: hidden; }
:is(.grid, .city-essay) img { width: 100%; height: auto; display: block; transition: transform .3s; }
:is(.grid, .city-essay) button:hover img { transform: scale(1.03); }
:is(.grid, .city-essay) button:focus-visible { outline: 2px solid var(--accent); }

.lightbox { position: fixed; inset: 0; z-index: 30; background: rgba(2, 3, 6, .96); display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; }
.lightbox figure { grid-column: 2; display: grid; justify-items: center; gap: 12px; max-height: 100vh; padding: 24px 0; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 6px; }
.lightbox figcaption { font: 400 14px var(--sans); color: #b9c6dd; text-align: center; white-space: pre-wrap; }
.lightbox button { background: none; border: 0; color: #dfe3ec; font-size: 38px; cursor: pointer; height: 100%; }
.lightbox button:hover { color: #fff; }
.lightbox .close { position: absolute; right: 14px; top: 8px; height: auto; font-size: 34px; z-index: 2; }

.search-box input {
  width: 100%; font: 400 19px var(--sans); color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.tag-cloud { margin: 16px 0 26px; }
.results { list-style: none; }
.results a { display: block; text-decoration: none; padding: 16px 0 16px 18px; border-left: 2px solid var(--accent); margin-bottom: 14px; transition: background .15s; }
.results a:hover { background: rgba(160, 180, 220, .06); }
.results .kind { font: 600 11px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.results h3 { font: 500 21px/1.25 var(--serif) !important; margin: 3px 0; }
.results p { font-size: 16px; color: #c5cbd8; line-height: 1.5; }

.neighbors { display: flex; justify-content: space-between; gap: 16px; margin-top: 50px; padding-top: 22px; border-top: 1px solid var(--line); font: 500 15px var(--sans); }
.neighbors a { text-decoration: none; max-width: 48%; color: #fff !important; }
.neighbors a:hover { color: var(--accent) !important; }
.neighbors small { display: block; font-weight: 400; color: var(--muted); margin-bottom: 3px; }
.neighbors .right { text-align: right; margin-left: auto; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 720px) {
  .star-label { font-size: 13.5px; }
  #content { font-size: 17.5px; }
  .page-inner { padding: 0 18px 90px; }
  .section-menu a { padding: 6px 8px; font-size: 12.5px; }
  .timeline li { flex-direction: column; gap: 2px; }
  .lightbox { grid-template-columns: 40px 1fr 40px; }
  .page-head .logo { position: static; margin-top: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .page, #content { animation: none; }
  #universe { transition: none; }
}

/* ─── top bar + EEG trace ─── */
.bar {
  position: fixed; inset: 0 0 auto 0; height: 46px; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 11, .78);   /* no backdrop blur: re-blurring the animated canvas behind it every frame is costly */
  border-bottom: 1px solid var(--line);
}
.bar .section-menu { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; padding: 0 10px; }
.bar .section-menu::-webkit-scrollbar { display: none; }
.bar .section-menu a { white-space: nowrap; padding: 6px 12px; }
.bar .section-menu a.home-link { margin: 0 6px; border: 1px solid var(--line); color: #fff; letter-spacing: .04em; }
.bar .section-menu a.home-link:hover { border-color: #9fb4d8; }
.bar .back { position: absolute; left: 14px; display: none; padding: 5px 11px; font-size: 13px; }
body.on-page .bar .back { display: block; }
.eeg { position: fixed; left: 0; top: 46px; width: 100%; height: 20px; z-index: 20; pointer-events: none; }
/* the page window starts below the EEG trace: scrolling content never passes under the line */
.page { top: 66px; }
body.on-page .bar { background: rgba(4, 6, 11, .94); border-bottom-color: transparent; }
body.on-page .eeg { background: rgba(4, 6, 11, .94); }
.page-inner { padding-top: 34px; }
.fallback-menu:focus-within, body.no-webgl .fallback-menu { top: 55%; }
@media (max-width: 720px) {
  .bar { justify-content: flex-start; }
  body.on-page .bar .section-menu { margin-left: 86px; }
  .bar .section-menu a { padding: 6px 9px; }
}
.page-head:has(.logo) .kicker { padding-right: 130px; line-height: 1.5; }
@media (max-width: 720px) { .page-head:has(.logo) .kicker { padding-right: 0; } }

/* ─── language buttons ─── */
.lang { position: absolute; right: 12px; display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 999px; }
.lang button { font: 600 11.5px var(--sans); letter-spacing: .06em; color: #8f9bb2; background: none; border: 0; border-radius: 999px; padding: 4px 9px; cursor: pointer; }
.lang button[aria-pressed="true"] { background: rgba(160, 180, 220, .18); color: #fff; }
.lang button:hover { color: #fff; }

/* ─── phone and touch ─── */
html, body { height: 100dvh; overscroll-behavior: none; }
body { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
.bar { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.page-inner { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
#content { overflow-wrap: anywhere; }
.prose pre { max-width: 100%; }
@media (pointer: coarse) {
  .bar .section-menu a, .chip, .back, .button { min-height: 34px; }
  .chip { padding: 7px 13px; }
  .grid button { cursor: pointer; }
}
@media (max-width: 720px) {
  .bar { justify-content: flex-start; padding-right: calc(82px + env(safe-area-inset-right)); }
  .bar .section-menu { padding: 0 6px; -webkit-overflow-scrolling: touch; mask-image: linear-gradient(90deg, #000 88%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); }
  body.on-page .bar .section-menu { margin-left: 84px; }
  .bar .back { left: 8px; }
  .lang { right: 8px; }
  #content h1 { font-size: clamp(30px, 8.6vw, 40px); }
  #content h2 { font-size: 23px; margin-top: 32px; }
  .large { font-size: 18.5px; }
  .lead { font-size: 18px; }
  .cards, .series-list { grid-template-columns: 1fr; }
  .cards h2 { padding-right: 64px; }
  .skills { grid-template-columns: 1fr; gap: 2px 0; }
  .skills dd { margin-bottom: 10px; }
  .links li { flex-direction: column; gap: 0; }
  .grid { columns: 2 140px; }
  .lightbox { grid-template-columns: 34px 1fr 34px; }
  .lightbox img { max-height: calc(100dvh - 130px); }
  .search-box input { font-size: 16px; }     /* keep iOS from zooming in on focus */
  .neighbors { flex-direction: column; }
  .neighbors a { max-width: 100%; }
  .neighbors .right { text-align: left; margin-left: 0; }
  .node-tip { max-width: 80vw; }
}

/* ─── narrow screens: the bar becomes two rows (back + language on top, the whole section menu below) ─── */
@media (max-width: 720px) {
  .bar { height: 78px; align-items: flex-end; justify-content: center; padding-right: env(safe-area-inset-right); }
  .bar .section-menu, body.on-page .bar .section-menu { width: 100%; margin-left: 0; padding: 0 4px 6px; gap: 0; justify-content: space-between; mask-image: none; -webkit-mask-image: none; }
  .bar .section-menu a { padding: 5px 5px; font-size: 11.5px; min-height: 0; }
  .bar .section-menu a i { display: none; }
  .bar .section-menu a.home-link { margin: 0 2px; padding: 4px 9px; }
  .bar .back, .lang { top: 7px; }
  .eeg { top: 78px; }
  .page { top: 98px; }
}

/* ─── touch targets: the menu, the lightbox buttons and the notch in landscape ─── */
.page-inner { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
.lightbox .close { width: 44px; height: 44px; right: 6px; top: 6px; line-height: 1; }
@media (max-width: 720px) {
  .page-inner { padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
  .bar { height: 88px; }
  .bar .section-menu a { padding: 11px 5px; }
  .bar .section-menu a.home-link { padding: 8px 9px; }
  .eeg { top: 88px; }
  .page { top: 108px; }
  .lightbox { background: rgba(2, 3, 6, .985); }
}
@media (max-width: 370px) {
  .bar .section-menu a { font-size: 10.5px; padding: 11px 3px; }
}
