/* Shared inner-page system. The home page keeps its own layout. */
:root {
  --shell-bg: #f4f5f4;
  --shell-card: #dce1e2;
  --shell-card-muted: #edf0f0;
  --shell-ink: #1d2020;
  --shell-soft: #5c6262;
  --shell-line: #c7cdce;
  /* Cards are lifted off the page as white sheets with a hairline edge, and
     the page itself is a dot grid — a measuring surface rather than flat grey. */
  --shell-surface: #ffffff;
  --shell-dot: rgba(29, 32, 32, .3);
  /* One teal accent site-wide — the same hue as the "Values & Personality"
     keyword tag (--kw-amber) and the home page's nav hover. It clears WCAG AA
     for normal text on --shell-bg (4.6:1), so headlines and small text share it;
     dark mode lifts only the text variant (see below). */
  --shell-accent: #067b85;
  --shell-accent-text: #067b85;
  /* Same reasoning for the research keyword tags: their brighter hues only clear
     4.5:1 against the dark theme's near-black background, so light mode gets a
     darkened variant and dark mode keeps the original saturated hue. */
  --kw-amber: #067b85;
  --kw-red: #637730;
  --kw-violet: #c04a1d;
  --shell-mono: 'JetBrains Mono', ui-monospace, monospace;
  --shell-body: 'DM Sans', 'Noto Sans SC', -apple-system, sans-serif;
  --shell-gutter: clamp(.5rem, .8vw, 1rem);
  --shell-edge: var(--shell-gutter);
  /* Fixed, not vw-fluid: matches the home page's .nav-symbol at 84px so the
     Mm mark is the same physical size (and same particle density) whether
     it's floating over the nav grid or pinned to the corner of an inner page. */
  --shell-mark-width: 84px;
  --shell-top-width: 46px;
  /* Content sits in one centred column with air on both sides, so every block
     keeps a fixed, deliberate size instead of stretching with the window. */
  --shell-col: 58rem;
  /* Extra side air between the browser edge and the column on narrow screens. */
  --shell-inset: .5rem;
  --shell-radius: clamp(.85rem, 1.2vw, 1.15rem);
  --shell-gap: clamp(.65rem, 1.2vw, 1rem);
  /* Room below the last card — sized to clear the *top* of the fixed arrow
     (bottom offset + its own height, mirroring .shell-top's formula below),
     plus a bit of breathing room, so the reserved strip always extends past
     it rather than just tucking under its bottom edge. .site-footer sits
     inside this strip, absolutely positioned to its bottom edge. */
  --shell-pad-bottom: calc(var(--shell-edge) + var(--shell-mark-width) * .27 + var(--shell-top-width) * .86 + var(--shell-gap));
  --symbol-particle-density: .7;
  --shell-rail-center: calc((var(--shell-edge) + var(--shell-mark-width) + var(--shell-gutter)) / 2);

  /* Short aliases the inner pages' own stylesheets are written against. Declared
     once here rather than repeated in every page's <style>: custom properties
     resolve at use time, so rules earlier in the document still pick these up. */
  --bg: var(--shell-bg);
  --surface: var(--shell-card);
  --surface-2: var(--shell-card-muted);
  --text: var(--shell-ink);
  --text-muted: var(--shell-soft);
  --border: var(--shell-line);
  --accent: var(--shell-accent);
  --font-display: var(--shell-mono);
  --font-body: var(--shell-body);
}

html {
  background: var(--shell-bg) !important;
  scroll-behavior: smooth;
  /* Reserve the scrollbar's width on every page, long or short, so the
     centred column and the Mm mark never shift between pages. */
  scrollbar-gutter: stable;
}
html, body {
  background-image: radial-gradient(var(--shell-dot) 1.2px, transparent 1.5px) !important;
  background-size: 24px 24px !important;
  background-position: 12px 12px !important;
}

/* Kill the default mobile WebKit/Chrome tap-highlight rectangle — our own
   hover/active/focus states already give feedback, and the browser default
   is a plain gray box that clashes with pill and particle shapes. */
* { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 2px solid var(--shell-accent-text);
  outline-offset: 3px;
  border-radius: 2px;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  /* Containing block for .site-footer, which is absolutely positioned to the
     bottom of this box — including the reserved padding below, not past it. */
  position: relative;
  /* A compact right rail lets the MM mark sit outside the content blocks. */
  /* Explicit margin: 0 — not every page resets the browser's default 8px body
     margin, and the inset below is the only side spacing pages should get. */
  margin: 0 !important;
  padding: clamp(1rem, 2.5vw, 2rem) calc(var(--shell-edge) + var(--shell-mark-width) + var(--shell-gutter) + var(--shell-inset)) var(--shell-pad-bottom) calc(var(--shell-gutter) + var(--shell-inset)) !important;
  background-color: var(--shell-bg) !important;
  color: var(--shell-ink) !important;
  font-family: var(--shell-body) !important;
}
body > nav, body > footer { display: none !important; }

.page-header, body > section, body > main {
  max-width: var(--shell-col) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* The title sits directly on the page. Content, rather than every element,
   receives the quiet grey block treatment. */
.pub-section, .works-section {
  width: 100% !important;
  margin-top: 0 !important;
  margin-bottom: var(--shell-gap) !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.page-header::before { display: none !important; }
.page-header > *, body > main > * { position: relative; z-index: 1; }

.page-header {
  width: 100% !important;
  min-height: 0 !important;
  margin-top: 0 !important;
  margin-bottom: var(--shell-gap) !important;
  padding: clamp(5rem, 12vh, 9rem) 0 clamp(2.5rem, 5vh, 4rem) !important;
  display: flex !important;
  flex-direction: column;
  justify-content: flex-start;
  overflow: visible !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.page-header h1 {
  color: var(--shell-accent-text) !important;
  font-family: var(--shell-body) !important;
  font-weight: 600 !important;
  letter-spacing: -.035em !important;
  text-shadow: none !important;
}
.page-header h1 { font-size: clamp(4rem, 9vw, 8.5rem) !important; line-height: .85 !important; margin: 0 0 .9rem !important; letter-spacing: -.05em !important; text-wrap: balance; }
.page-header > p.research-intro, .page-header > p.page-intro { text-wrap: pretty; }
.page-header p:not(.section-label) {
  color: var(--shell-soft) !important;
  font-family: var(--shell-body) !important;
}
.page-header > p:not(.section-label) { max-width: 39rem !important; font-size: clamp(.95rem, 1.4vw, 1.08rem) !important; line-height: 1.65 !important; }
.section-label {
  margin-bottom: 1.2rem !important;
  color: var(--shell-accent-text) !important;
  font: 500 .6rem/1 var(--shell-mono) !important;
  letter-spacing: .16em !important;
  text-transform: uppercase !important;
}
.page-header .section-label::before { content: none !important; display: none !important; }

/* Shared inner-page title pattern: category → title → concise summary. Only
   the title is large; everything around it stays small so it reads as one
   precise mark rather than a wall of headline. */
.page-header h1 + p:not(.section-label) { margin-top: 0 !important; }
.page-header > p.research-intro,
.page-header > p.page-intro {
  max-width: 28rem !important;
  color: var(--shell-ink) !important;
  font: 400 clamp(1.05rem, 1.5vw, 1.35rem)/1.35 var(--shell-body) !important;
  letter-spacing: -.01em !important;
}
.page-header.research-header { padding-bottom: clamp(.75rem, 1.5vw, 1.25rem) !important; }

/* Research keywords — also double as a publication filter bar on the header. */
.kw-list { display: flex !important; align-items: center; flex-wrap: wrap; gap: .65rem !important; margin-top: 1.6rem !important; }
.kw-heading { flex-basis: 100%; margin-bottom: .3rem; color: var(--shell-ink); font: 600 .67rem/1.2 var(--shell-mono); letter-spacing: .04em; }
.kw-list > .kw-tag, .pub-tags .kw-tag {
  display: inline-flex !important; flex-direction: row !important; align-items: center;
  width: auto !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important;
  background: transparent !important; font: 700 .74rem/1.25 var(--shell-body) !important;
  letter-spacing: .035em !important;
}
.pub-tags .kw-tag::before {
  display: inline-block !important; order: initial !important; width: auto !important; height: auto !important;
  margin: 0 .45rem 0 0 !important; background: none !important; font-weight: 700;
}
.kw-tag.amber, .kw-tag.amber::before { color: var(--kw-amber) !important; }
.kw-tag.red, .kw-tag.red::before { color: var(--kw-red) !important; }
.kw-tag.violet, .kw-tag.violet::before { color: var(--kw-violet) !important; }
.pub-tags .kw-tag.amber::before { content: '+' !important; background: none !important; }
.pub-tags .kw-tag.red::before { content: '▲' !important; background: none !important; font-size: .8em; }
.pub-tags .kw-tag.violet::before { content: '●' !important; background: none !important; font-size: .78em; }
.page-header .kw-list > .kw-tag {
  font-family: var(--shell-body) !important;
  font-size: .78rem !important;
  line-height: 1.5 !important;
}
.page-header .kw-heading {
  color: var(--shell-soft) !important;
  font: 500 .6rem/1 var(--shell-mono) !important;
  letter-spacing: .16em !important;
  text-transform: uppercase;
}
.page-header .kw-list > .kw-tag {
  font-weight: 700 !important;
  cursor: pointer;
  padding: .3rem .8rem .3rem .55rem !important;
  border-radius: 999px !important;
  /* White chips with a hairline edge: they read cleanly over the dot grid and
     look like the buttons they are. */
  background: var(--shell-surface) !important;
  box-shadow: inset 0 0 0 1px var(--shell-line);
  transition: background-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.kw-badge { display: block; width: 22px; height: 22px; margin-right: .35rem; }
.page-header .kw-list > .kw-tag:hover { box-shadow: inset 0 0 0 1px currentColor; }
.page-header .kw-list > .kw-tag[aria-pressed="true"] {
  color: var(--shell-bg) !important;
  box-shadow: none;
}
.page-header .kw-list > .kw-tag.amber[aria-pressed="true"] { background: var(--kw-amber) !important; }
.page-header .kw-list > .kw-tag.red[aria-pressed="true"] { background: var(--kw-red) !important; }
.page-header .kw-list > .kw-tag.violet[aria-pressed="true"] { background: var(--kw-violet) !important; }
.pub-count:empty { display: none; }
.pub-count { flex-basis: 100%; margin-top: .2rem; color: var(--shell-soft); font: 500 .72rem/1 var(--shell-mono); letter-spacing: .08em; text-transform: uppercase; }
.pub-self { font-weight: 700; }
.pub-item[hidden] { display: none !important; }
.pub-entry[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) {
  .pub-item:not([hidden]) { animation: pub-item-in .32s ease both; }
}
@keyframes pub-item-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
/* Long-form reading sits on the same white sheet as the cards, so the dot grid
   frames the list instead of running behind the citations. The edge is an
   inset shadow rather than a border so the rail script's offsets stay exact. */
.pub-section {
  --pub-pad: clamp(1rem, 2.5vw, 1.75rem);
  padding: var(--pub-pad) !important;
  background: var(--shell-surface) !important;
  border-radius: .7rem !important;
  box-shadow: inset 0 0 0 1px var(--shell-line) !important;
}
.pub-rail { left: calc(var(--pub-pad) + 3px) !important; background: var(--shell-line) !important; }
.pub-dot { background: var(--shell-accent-text) !important; }
.pub-year { color: var(--shell-accent-text) !important; font-size: .6rem !important; }
.pub-text { color: var(--shell-ink) !important; font-size: .86rem !important; line-height: 1.6 !important; }
.pub-text a { color: var(--shell-accent-text) !important; overflow-wrap: anywhere; }
.pub-tags { width: 100% !important; margin: .35rem 0 0 !important; }
.pub-tags .kw-tag { font-size: .64rem !important; }

/* Card grid shared by Craft and Connect: fixed-width cards that never stretch
   to fill the row, each a white sheet with a 4:3 preview on top. A card with
   somewhere to go is an <a class="work-card">; one without stays a static
   <div>. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(0, 13.5rem));
  /* Every row as tall as the tallest card, so cards with and without a link
     or status line stay one uniform size even when they wrap to a new row. */
  grid-auto-rows: 1fr;
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
:where(.work-card p, .work-card h2, .work-card h3) { margin: 0; }
.work-card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  height: 100%;
  padding: .75rem .75rem 1rem;
  border: 1px solid var(--shell-line);
  border-radius: .7rem;
  background: var(--shell-surface);
  color: inherit;
  text-decoration: none;
  transition: border-color .2s ease;
}
.work-preview {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  margin-bottom: .35rem;
  color: var(--shell-ink);
  /* The SVG marks punch holes with --shell-card-muted; point it at the card. */
  --shell-card-muted: var(--shell-surface);
}
.work-preview svg { width: 38%; height: auto; display: block; }
.work-preview .accent { color: var(--shell-accent); }
.work-kind {
  color: var(--shell-accent-text);
  font: 500 .58rem/1 var(--shell-mono);
  letter-spacing: .16em;
  text-transform: uppercase;
}
.work-title {
  color: var(--shell-ink);
  font: 600 .95rem/1.2 var(--shell-body);
  letter-spacing: -.01em;
}
.work-status {
  margin-top: auto;
  padding-top: .6rem;
  color: var(--shell-soft);
  font: 500 .6rem/1 var(--shell-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
}
a.work-card .work-status { color: var(--shell-accent-text); }
a.work-card:hover { border-color: var(--shell-accent); }
a.work-card:hover .work-status { color: var(--shell-accent); }

/* About receives an enclosed work-surface. */
body > main {
  width: 100% !important;
  margin-top: 0 !important;
  margin-bottom: var(--shell-gap) !important;
  padding: clamp(1.5rem, 3.5vw, 3rem) !important;
  min-height: min(620px, calc(100vh - 4rem)) !important;
  display: block !important;
  background: var(--shell-card) !important;
  border: 0 !important;
  border-radius: var(--shell-radius) !important;
  box-shadow: none !important;
}

/* Fixed right rail: Mm returns home; the arrow only appears after scrolling. */
.shell-card {
  position: fixed; right: var(--shell-rail-center); top: var(--shell-edge); z-index: 10000;
  width: var(--shell-mark-width); padding: 0; border: 0; background: transparent; text-decoration: none;
  line-height: 0; cursor: pointer; overflow: visible; isolation: isolate; transform: translateX(50%);
}
.shell-card-symbol { display: block; width: 100%; height: auto; }
.shell-top {
  position: fixed; right: var(--shell-rail-center);
  /* Align visible particle edges, not their transparent canvas boxes. */
  bottom: calc(var(--shell-edge) + var(--shell-mark-width) * .27 - var(--shell-top-width) * .14);
  z-index: 10000; width: var(--shell-top-width); padding: 0; border: 0;
  background: transparent; line-height: 0; cursor: pointer; transform: translate(50%, .5rem);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.shell-top.is-visible { opacity: 1; pointer-events: auto; transform: translateX(50%); }
.shell-top-symbol { display: block; width: 100%; height: auto; }

/* Sits at the true end of the page — reachable only by scrolling past all
   content, not pinned over it. Anchored to body's own bottom edge (padding
   included), not appended after it, so it sits inside the reserved strip
   below the last card rather than adding to it. left/right are relative to
   body's padding box (its full outer width, ignoring body's own asymmetric
   left/right padding), so this centers on the true viewport, not the
   lopsided content column the Mm-mark rail leaves on the right. */
.site-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--shell-edge);
  text-align: center;
  color: var(--shell-soft);
  font-family: var(--shell-body);
  font-size: 0.7rem;
  font-weight: 300;
}
/* Only "max" is bold in the name; "minimalism" keeps the footer's weight. */
.site-footer b { font-weight: 700; }

@media (max-width: 720px) {
  :root { --shell-edge: var(--shell-gutter); --shell-mark-width: 68px; --shell-top-width: 2.3rem; --shell-gutter: .5rem; --shell-radius: 1rem; --shell-gap: .65rem; --symbol-particle-density: .45; }
  body { padding: .8rem calc(var(--shell-edge) + var(--shell-mark-width) + var(--shell-gutter) + var(--shell-inset)) var(--shell-pad-bottom) calc(var(--shell-gutter) + var(--shell-inset)) !important; }
  .page-header, .pub-section, .works-section, body > main { margin-bottom: 1rem !important; }
  .page-header { min-height: 0 !important; padding: 3.5rem 0 2rem !important; }
  .page-header h1 { font-size: clamp(3rem, 16vw, 4.5rem) !important; }
  /* Rows size to their own content on phones: one tall card would otherwise
     stretch every row (cards in the same row still match each other). */
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: auto; }
}

/* One dark palette, keyed off the attribute only. The <head> boot script sets
   data-theme before first paint — from localStorage if the reader has chosen,
   otherwise from the OS preference — and shell.js keeps it in sync when the OS
   flips, so a parallel prefers-color-scheme block would only restate this. */
html[data-theme="dark"] {
  --shell-bg: #111211;
  --shell-card: #1c1d1c;
  --shell-card-muted: #161716;
  --shell-ink: #e2e3e2;
  --shell-soft: #7a7e7e;
  --shell-line: #2e3232;
  --shell-surface: #1a1b1a;
  --shell-dot: rgba(226, 227, 226, .12);
  --shell-accent-text: #0799a5;
  --kw-amber: #0799a5;
  --kw-red: #758d39;
  --kw-violet: #de5723;
}
