/* Portfolio: strict monochrome, see docs/SPEC.md "Visual rules" and the Figma file. */
:root {
  --bg: #0E0E0E;
  --surface: #161616;
  --line: #2A2A2A;
  --text: #EDEAE4;
  --muted: #A8A49C;
  --faint: #85827C;
  --soft: rgba(237, 234, 228, 0.06);
  --hard: rgba(237, 234, 228, 0.13);
  --hl-keyword: #C4A7E7;
  --hl-func: #9CCFD8;
  --hl-type: #EBBCBA;
  --hl-string: #F6C177;
  --hl-number: #EA9A97;
  --sans: "Inter Tight", Inter, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --gutter: clamp(16px, 6vw, 200px);
  /* nav/footer inset: the gutter, plus the margin .wrap gains once it hits its 2400px cap */
  --edge: max(var(--gutter), calc((100% - 2400px) / 2 + var(--gutter)));
  --nav-h: 81px; /* sticky nav height: anchors and sticky elements sit below it */
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 24px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 clamp(18px, 0.45vw + 11.5px, 21px)/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--muted); }
:focus-visible { outline: 1px solid var(--text); outline-offset: 3px; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
p { margin: 0; }

/* content scales with the screen, capped for ultrawides; nav/footer rules stay full bleed */
.wrap { width: 100%; max-width: 2400px; margin-inline: auto; padding-inline: var(--gutter); }
.mono { font-family: var(--mono); font-size: clamp(14px, 0.25vw + 10.5px, 16px); line-height: 1.5; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.eyebrow, .label { font: 500 12px/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.display { font-weight: 700; font-size: clamp(56px, 11vw, 240px); line-height: 0.9; letter-spacing: -0.05em; }
.lede { font-size: clamp(20px, 0.55vw + 12px, 26px); line-height: 1.55; max-width: 36em; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; background: var(--bg); padding: 8px; z-index: 10; }

/* ---------- nav / footer ---------- */
.nav {
  position: sticky; top: 0; z-index: 20; height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 0 var(--edge); border-bottom: 1px solid var(--line);
  background: rgba(14, 14, 14, 0.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.nav-name { font-weight: 600; font-size: clamp(16px, 0.3vw + 11.5px, 19px); text-decoration: none; }
.nav-links { display: flex; gap: clamp(32px, 2vw, 48px); font: clamp(14px, 0.25vw + 10.5px, 16px)/1.5 var(--mono); }
.nav-links a { color: var(--muted); text-decoration: none; }
.nav-links a:hover, .nav-links a[aria-current] { color: var(--text); text-decoration: underline; }
.nav-toggle { display: none; background: none; border: 0; color: var(--text); font: 14px var(--mono); cursor: pointer; padding: 4px 0; }

.footer {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap;
  padding: 40px var(--edge) 48px; border-top: 1px solid var(--line);
}
.footer-name { font-weight: 600; font-size: 16px; margin-bottom: 6px; }
.footer-links { display: flex; gap: 28px; flex-wrap: wrap; }

/* ---------- buttons, links rows ---------- */
.button {
  display: inline-block; font: 14px/1 var(--mono); padding: 14px 22px;
  border: 1px solid var(--text); text-decoration: none;
}
.button:hover { text-decoration: underline; }
.cta, .contact-links { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }

/* ---------- ascii art + evidence-tag frame ---------- */
pre.ascii {
  margin: 0; font-family: var(--mono); font-size: var(--ascii-size, 5px); line-height: 1;
  white-space: pre; color: var(--text); overflow: hidden; user-select: none; max-width: 100%;
  /* JetBrains Mono ligatures would merge art characters (!= -> one glyph, === -> a bar) */
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0;
}
/* every piece ships one size denser; large screens draw it bigger, so they get the denser one */
pre.ascii-dense { display: none; }
@media (min-width: 1600px) {
  pre.ascii.has-dense { display: none; }
  pre.ascii-dense { display: block; }
}
/* One standard art format everywhere: a 4:3 box. The art is scaled (site.js) to fit the stage
   inside it, so wide subjects (marlin) and tall ones (crane, portrait) sit in identical frames. */
.art-frame {
  --c: var(--text);
  position: relative; margin: 0; min-width: 0; aspect-ratio: 4 / 3; overflow: hidden; padding: 32px 32px 20px;
  display: flex; flex-direction: column; gap: 16px;
  background:
    linear-gradient(var(--c), var(--c)) top left / 20px 1px,
    linear-gradient(var(--c), var(--c)) top left / 1px 20px,
    linear-gradient(var(--c), var(--c)) top right / 20px 1px,
    linear-gradient(var(--c), var(--c)) top right / 1px 20px,
    linear-gradient(var(--c), var(--c)) bottom left / 20px 1px,
    linear-gradient(var(--c), var(--c)) bottom left / 1px 20px,
    linear-gradient(var(--c), var(--c)) bottom right / 20px 1px,
    linear-gradient(var(--c), var(--c)) bottom right / 1px 20px;
  background-repeat: no-repeat;
}
.art-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.art-caption { display: flex; justify-content: space-between; gap: 16px; font: 500 12px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, clamp(520px, 40vw, 1000px)); gap: clamp(64px, 5vw, 160px); align-items: end; padding-block: 112px; }
.hero-intro { min-width: 0; display: flex; flex-direction: column; gap: 32px; }
.hero h1 { width: min-content; }
.hero-tags { list-style: none; margin: 0; padding: 0; }

.section { padding-top: 96px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; padding-bottom: 24px; }
.section-head h2 { font-size: clamp(40px, 2.8vw, 64px); }

.cases { list-style: none; margin: 0; padding: 0; }
.case { display: grid; grid-template-columns: 48px minmax(0, 1fr) clamp(400px, 30vw, 760px); gap: clamp(48px, 4vw, 120px); padding-block: 48px; border-top: 1px solid var(--line); }
.case-body { display: flex; flex-direction: column; gap: 16px; }
.case-body h3 { font-size: clamp(40px, 2.8vw, 64px); }
.case-body h3 a { text-decoration: none; }
.case-body h3 a:hover { text-decoration: underline; }
.case-body > p:first-of-type { color: var(--muted); max-width: 34em; font-size: clamp(18px, 0.5vw + 11px, 23px); }
.case-art { min-width: 0; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; overflow: hidden; text-decoration: none; }

.compact { list-style: none; margin: 0; padding: 0; }
.compact li { display: grid; grid-template-columns: 220px minmax(0, 1fr) 240px 110px; gap: 32px; align-items: baseline; padding-block: 20px; border-top: 1px solid var(--line); }
.case-links { display: flex; flex-wrap: wrap; gap: 6px 24px; }
.compact-body { display: flex; flex-direction: column; gap: 6px; }
.compact-body .case-links { font-size: 13px; }
.compact-name { font-weight: 600; text-decoration: none; }
.compact-name:hover { text-decoration: underline; }
.compact p { font-size: 16px; }
.compact-year { text-align: right; }

.posts { list-style: none; margin: 0; padding: 0; }
.post-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) 200px; gap: 32px; align-items: baseline; padding-block: 14px; }
.post-title { text-decoration: none; }
.post-title:hover { text-decoration: underline; }
.post-projects { text-align: right; }

.contact { padding-block: 120px; display: flex; flex-direction: column; gap: 32px; }
.contact-heading { font-size: clamp(40px, 6.7vw, 96px); line-height: 0.95; max-width: 12em; }

/* ---------- page heads, articles ---------- */
.page-head { padding-top: 72px; padding-bottom: 48px; display: flex; flex-direction: column; gap: 24px; }
.page-head .display { font-size: clamp(52px, 10vw, 144px); }
.title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 48px; flex-wrap: wrap; }
.title-row .lede { max-width: 460px; }
.crumb a { color: var(--muted); }
/* project / post heroes reuse the home hero grid, a little tighter */
.page-hero { padding-block: 72px 64px; }
.page-hero:not(:has(.art-frame)) { grid-template-columns: minmax(0, 1fr); } /* no art: the title spans the row */
.page-hero h1 { width: auto; font-size: clamp(52px, 7vw, 150px); overflow-wrap: anywhere; }
.cover img { display: block; width: 100%; height: 100%; object-fit: cover; }

.article-grid { display: grid; grid-template-columns: minmax(0, clamp(720px, 46vw, 900px)) clamp(300px, 17vw, 400px); justify-content: space-between; gap: clamp(64px, 8vw, 240px); padding-bottom: 96px; }
.rule-top { border-top: 1px solid var(--line); padding-top: 56px; }
.sidebar { display: flex; flex-direction: column; gap: 40px; align-self: start; position: sticky; top: calc(var(--nav-h) + 32px); }
.toc { display: flex; flex-direction: column; gap: 10px; font: 13px/1.5 var(--mono); }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--text); text-decoration: underline; }
/* scroll spy (site.js): every section on screen is lit, the topmost one is the current one */
.toc a.is-visible { color: var(--text); }
.toc a.is-current { color: var(--text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }

.metablock { margin: 0; border: 1px solid var(--line); font: 14px/1.5 var(--mono); }
.metablock div { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 16px; padding: 5px 20px; }
.metablock div:first-child { padding-top: 20px; }
.metablock div:nth-last-child(2) { padding-bottom: 20px; }
.metablock dt { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.metablock dd { margin: 0; }
.metablock-links { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 14px 20px; border-top: 1px solid var(--line); }

/* ---------- prose ---------- */
.prose > * + * { margin-top: 1.2em; }
.prose h2 { font-size: 32px; margin-top: 2em; }
.prose h3 { font-size: 22px; margin-top: 1.8em; }
.prose ul, .prose ol { padding-left: 0; list-style: none; }
.prose ul > li { padding-left: 1.4em; position: relative; }
.prose ul > li::before { content: "-"; position: absolute; left: 0; color: var(--muted); }
.prose ol { counter-reset: n; }
.prose ol > li { counter-increment: n; padding-left: 2em; position: relative; }
.prose ol > li::before { content: counter(n) "."; position: absolute; left: 0; font-family: var(--mono); font-size: 14px; color: var(--muted); }
.prose li + li { margin-top: 0.4em; }
.prose code:not(pre code) { font: 0.85em var(--mono); background: var(--surface); padding: 0.1em 0.35em; }
.prose em { font-style: italic; }
/* <u>: heavier and dimmer than a link's underline, and never changes on hover, so it doesn't read as one */
.prose u { text-decoration-line: underline; text-decoration-thickness: 2px; text-decoration-color: var(--faint); text-underline-offset: 4px; }
.prose blockquote { margin-inline: 0; padding-left: 20px; border-left: 2px solid var(--line); color: var(--muted); }
.prose blockquote > * + * { margin-top: 0.8em; }
.prose blockquote strong, .prose blockquote a { color: var(--text); }
/* tables scroll sideways on their own when wider than the column, instead of the page */
.prose table { display: block; width: max-content; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 16px; font-variant-numeric: tabular-nums; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 10px 24px 10px 0; border-bottom: 1px solid var(--line); }
.prose th:last-child, .prose td:last-child { padding-right: 0; }
.prose th { font: 500 12px/1.5 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-bottom-color: var(--muted); }
.prose td code { white-space: nowrap; }

/* mermaid diagrams: rendered to SVG at build time (internal/site/mermaid.go) and inlined */
.prose .diagram { margin-block: 2em; }
.diagram { margin: 0; }
/* page background, not surface: the theme's edge labels and clusters are drawn in --bg */
.diagram-body { overflow-x: auto; padding: 24px; border: 1px solid var(--line); }
.diagram-body svg { display: block; margin-inline: auto; max-width: 100%; height: auto; }
.diagram figcaption { margin-top: 10px; font: 12px/1.5 var(--mono); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--line); }
.broken-link { text-decoration: underline dotted; color: var(--muted); }
.footnote-ref { font: 11px var(--mono); text-decoration-style: dotted; margin-left: 2px; }
.footnotes { font-size: 15px; color: var(--muted); margin-top: 56px; }
.footnotes hr { margin-bottom: 16px; }
.footnote-backref { text-decoration: none; margin-left: 4px; }

/* case study sections: h2 becomes "01 / overview" */
.prose-case h2 {
  font: 500 12px/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-top: 56px;
}
.prose-case h2 + * { margin-top: 16px; }

/* about: full width; every section (the build wraps each h2 + its content) is a ruled row with the
   heading in the left quarter and the content across the rest */
.prose-about { padding-bottom: 96px; }
.prose-about > .doc-section {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: clamp(32px, 4vw, 120px);
  margin-top: 72px; padding-top: 24px; border-top: 1px solid var(--line);
}
.prose-about > .doc-section:first-child { margin-top: 0; }
.prose-about .doc-section > h2 { font-size: clamp(24px, 1.6vw, 34px); margin: 0; }
.doc-section-body > * + * { margin-top: 1.2em; }
.doc-section-body > p { max-width: 75ch; }
.doc-section-body > ul { columns: 2 28em; column-gap: clamp(32px, 4vw, 96px); }
.doc-section-body > ul > li { break-inside: avoid; }
.prose .tl-role { margin-top: 0; }
.doc-section-body > .timeline > li:first-child { border-top: 0; padding-top: 0; } /* the section rule is enough */

/* ---------- code blocks + references ---------- */
.code { margin: 0; background: var(--surface); border: 1px solid var(--line); }
.prose .code { margin-top: 1.6em; }
.code-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--line); font: 13px var(--mono); color: var(--muted); }
.code-actions { display: flex; gap: 20px; align-items: center; }
.code-copy { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }
.code pre { margin: 0; padding: 14px 0; overflow-x: auto; }
.code code { display: inline-block; min-width: 100%; font: 14px/1.65 var(--mono); tab-size: 4; }
.code .line { display: block; padding: 0 18px; transition: background-color 0.4s, box-shadow 0.4s; }
.code .ln { display: inline-block; width: 2.5ch; margin-right: 20px; text-align: right; color: var(--faint); user-select: none; }
/* Syntax colours: the one exception to the monochrome rule, kept muted to sit with the warm greys. */
.code .k { color: var(--hl-keyword); }
.code .f { color: var(--hl-func); }
.code .t { color: var(--hl-type); }
.code .s { color: var(--hl-string); }
.code .n { color: var(--hl-number); }
.code .c { color: var(--faint); font-style: italic; }
.code .line.is-soft { background: var(--soft); }
.code .line.is-hard { background: var(--hard); box-shadow: inset 2px 0 0 var(--text); }
.code .line.is-hard .ln { color: var(--text); }

.coderef {
  text-decoration-line: underline; text-decoration-style: double; text-decoration-thickness: 1px;
  text-decoration-color: var(--muted); text-underline-offset: 5px; cursor: pointer;
}
.coderef:hover, .coderef:focus-visible, .coderef.is-active { text-decoration-color: var(--text); }
.coderef-lines { font: 11px var(--mono); color: var(--faint); vertical-align: super; margin-left: 3px; text-decoration: none; display: inline-block; }
.coderef:hover .coderef-lines, .coderef.is-active .coderef-lines { color: var(--text); }
.coderef.is-broken { text-decoration-style: dotted; cursor: help; }

/* images: one on its own line = a figure at its natural shape; several on one line or in a
   > [!gallery] callout = a grid of identical 4:3 cells. Click any to see it full size (site.js). */
.prose .figure, .prose .gallery-block { margin-block: 2em; }
.prose > .gallery { margin-block: 2em; }
.figure { margin: 0; }
.figure img, .figure video { display: block; max-width: 100%; max-height: 80vh; height: auto; border: 1px solid var(--line); }
.figure video { width: 100%; background: var(--surface); } /* full width before its size is known */
.gallery { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 12px; }
.gallery-block { margin: 0; }
.gallery-item { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.gallery-item img, .gallery-item video { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border: 1px solid var(--line); }
.figure figcaption, .gallery-item figcaption, .gallery-caption { font: 12px/1.5 var(--mono); color: var(--muted); }
.figure figcaption, .gallery-caption { margin-top: 10px; }
.prose .figure img, .prose .gallery img, .prose .aside-media img { cursor: zoom-in; }
/* > [!aside|right] Caption: the leading image(s) in a column beside the rest of the callout */
.prose .aside { margin-block: 2em; }
.aside { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: clamp(20px, 3vw, 40px); align-items: start; }
.aside-left { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.aside-right .aside-media { order: 2; }
.aside-media { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.aside-media img, .aside-media video { display: block; max-width: 100%; max-height: 60vh; width: auto; height: auto; border: 1px solid var(--line); } /* a tall photo can't dwarf its text */
.aside-media .gallery-caption { margin-top: 0; }
.aside-text > * + * { margin-top: 1.2em; } /* the same rhythm as .prose, which only spaces its direct children */
.aside-text > :first-child { margin-top: 0; }
.lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh; }
.lightbox::backdrop { background: rgba(14, 14, 14, 0.94); }
.lightbox img { display: block; max-width: 96vw; max-height: 92vh; cursor: zoom-out; }
.lightbox p { font: 12px var(--mono); color: var(--muted); margin-top: 8px; }

.callout { border-left: 2px solid var(--text); padding: 4px 0 4px 20px; }
.callout > * + * { margin-top: 0.6em; }
.callout-label { font: 500 12px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.callout-title { font-weight: 600; }

.timeline { list-style: none; padding: 0; margin: 0; }
.prose .timeline > li { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 32px; padding: 24px 0 0; margin: 0; border-top: 1px solid var(--line); }
.prose .timeline > li::before { content: none; }
.prose .timeline > li + li { margin-top: 24px; }
.tl-years { font: 14px var(--mono); color: var(--muted); }
.tl-role { font-size: 20px; }
.tl-org { font: 14px var(--mono); color: var(--muted); margin-top: 6px; }
.tl-desc { color: var(--muted); font-size: 16px; margin-top: 6px; }

.byline a { white-space: nowrap; }
.byline { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-top: 56px; padding-top: 32px; border-top: 1px solid var(--line); font-size: 16px; }

/* ---------- writing index ---------- */
.year { display: grid; grid-template-columns: 200px minmax(0, 1fr); padding-bottom: 64px; }
.year-label { font-size: 40px; color: var(--faint); }
.year .posts { border-top: 1px solid var(--line); padding-top: 8px; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  body { font-size: 16px; }
  :root { --nav-h: 64px; }
  .nav { padding: 0 16px; }
  .nav-toggle { display: block; }
  .nav-links { display: none; }
  .nav-open .nav-links {
    display: flex; flex-direction: column; gap: 12px; position: fixed; inset: var(--nav-h) 0 0; padding: 96px 16px 32px;
    background: var(--bg); z-index: 5; font: 500 48px/1.1 var(--sans); letter-spacing: -0.02em;
  }
  .nav-open .nav-links a { color: var(--text); text-decoration: none; }
  .nav-open { overflow: hidden; }
  /* backdrop-filter would make the nav the containing block for the fixed menu overlay */
  .nav-open .nav { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }

  .hero { grid-template-columns: minmax(0, 1fr); gap: 32px; padding-block: 48px 24px; }
  .hero .art-frame { padding: 24px 20px 16px; order: 2; }
  .lede { font-size: 17px; }
  .section { padding-top: 56px; }
  .section-head h2 { font-size: 28px; }
  .case { grid-template-columns: minmax(0, 1fr); gap: 14px; padding-block: 32px; }
  .case-art { order: -1; }
  .case-index { display: none; }
  .case-body h3 { font-size: 28px; }
  .compact li { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; }
  .compact li .compact-body, .compact li > .faint { grid-column: 1 / -1; }
  .compact-year { grid-row: 1; grid-column: 2; }
  .post-row { grid-template-columns: minmax(0, 1fr); gap: 4px; padding-block: 16px; border-top: 1px solid var(--line); }
  .post-projects { text-align: left; order: -1; }
  .post-row time { order: -2; }
  .contact { padding-block: 72px; }
  .page-head { padding-top: 32px; }
  .article-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .sidebar { position: static; order: -1; }
  .post .sidebar { order: 1; }
  .year { grid-template-columns: minmax(0, 1fr); }
  .prose-about > .doc-section { grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 48px; }
  .prose .timeline > li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .footer { padding: 32px 16px 40px; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } /* at most 2 across on phones */
  .aside { grid-template-columns: minmax(0, 1fr); } /* stacked, image first */
  .aside-right .aside-media { order: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .code .line { transition: none; }
  html { scroll-behavior: auto; }
}
