/* benleikin.me — instrument-panel portfolio
   Fonts: Archivo (display), IBM Plex Sans (body), IBM Plex Mono (data) — SIL OFL 1.1 */

@font-face {
  font-family: "Archivo";
  src: url("/assets/fonts/archivo-var.woff2") format("woff2-variations");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Sans";
  src: url("/assets/fonts/plexsans-var.woff2") format("woff2-variations");
  font-weight: 300 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/assets/fonts/plexmono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/assets/fonts/plexmono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0c1318;
  --bg-2: #101a21;
  --panel: #14212a;
  --line: #22343f;
  --line-soft: #1a2932;
  --text: #dde7ec;
  --muted: #8699a5;
  --amber: #f2a83c;
  --amber-dim: #7a5316;
  --ok: #5bc99a;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset;

  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Plex Sans", system-ui, -apple-system, Segoe UI, sans-serif;
  --f-mono: "Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --wrap: 74rem;
  --gut: clamp(1.25rem, 4vw, 3rem);
  --rhythm: clamp(4rem, 9vw, 7.5rem);
}

html[data-theme="light"],
html[data-theme="light"] body {
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
  }
}

/* Light palette: warm instrument paper, ink, darker amber for contrast */
:root:not([data-theme="dark"]) {
  --lt-bg: #e9e6df;
  --lt-bg-2: #f2f0eb;
  --lt-panel: #f6f4f0;
  --lt-line: #cdc7bb;
  --lt-line-soft: #ddd8ce;
  --lt-text: #16212a;
  --lt-muted: #5d6b74;
  --lt-amber: #9c6300;
  --lt-amber-dim: #d9bc86;
  --lt-ok: #16755a;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: var(--lt-bg);
    --bg-2: var(--lt-bg-2);
    --panel: var(--lt-panel);
    --line: var(--lt-line);
    --line-soft: var(--lt-line-soft);
    --text: var(--lt-text);
    --muted: var(--lt-muted);
    --amber: var(--lt-amber);
    --amber-dim: var(--lt-amber-dim);
    --ok: var(--lt-ok);
    --shadow: 0 1px 0 rgba(0, 0, 0, .02) inset;
  }
}

html[data-theme="light"] {
  --bg: var(--lt-bg);
  --bg-2: var(--lt-bg-2);
  --panel: var(--lt-panel);
  --line: var(--lt-line);
  --line-soft: var(--lt-line-soft);
  --text: var(--lt-text);
  --muted: var(--lt-muted);
  --amber: var(--lt-amber);
  --amber-dim: var(--lt-amber-dim);
  --ok: var(--lt-ok);
  --shadow: 0 1px 0 rgba(0, 0, 0, .02) inset;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  padding-bottom: 3.5rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: clamp(1rem, .96rem + .2vw, 1.075rem);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--text); text-decoration-color: var(--amber-dim); text-underline-offset: .18em; }
a:hover { text-decoration-color: var(--amber); }

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--panel);
  color: var(--text);
  padding: .75rem 1rem;
  z-index: 60;
}
.skip:focus { left: .5rem; top: .5rem; }

.sep { color: var(--amber); padding: 0 .35em; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem var(--gut);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  font-family: var(--f-mono);
  font-size: .8rem;
  letter-spacing: .04em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
}

.brand-dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent);
}

.topnav { display: flex; gap: clamp(.9rem, 2.5vw, 1.75rem); }

.topnav a {
  font-family: var(--f-mono);
  font-size: .78rem;
  letter-spacing: .05em;
  text-transform: lowercase;
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}
.topnav a:hover,
.topnav a.is-current { color: var(--text); border-bottom-color: var(--amber); }

/* ---------- hero ---------- */

.hero {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6.5rem) var(--gut) var(--rhythm);
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, .85fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}

.eyebrow {
  font-family: var(--f-mono);
  font-size: .76rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.4rem;
}

h1 {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(3.6rem, 13vw, 8.5rem);
  line-height: .84;
  letter-spacing: -.035em;
  margin: 0 0 1.6rem;
  text-wrap: balance;
}

/* ASCII wordmark. Two stacked layers with identical metrics: solid blocks in
   the text color, the drop-shadow strokes in amber. 40 columns wide; IBM Plex
   Mono advances 0.6em per cell, so one line is exactly 24em. Sizing off the
   container width keeps it flush to the column at every viewport. */
.hero-text { container-type: inline-size; }

.wordmark {
  position: relative;
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 3.4vw;
  font-size: min(calc(100cqw / 23.6), 2.15rem);
  line-height: 1;
  /* A hair of overlap. Cell boundaries land on fractional pixels at most
     sizes, and without this the antialiasing leaves vertical seams between
     adjacent full-block glyphs. Both layers get it, so they stay aligned. */
  letter-spacing: -.015em;
  margin: 0 0 1.9rem;
  color: var(--text);
}

.wm-fill,
.wm-edge {
  display: block;
  white-space: pre;
  font: inherit;
  margin: 0;
}

.wm-edge {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--amber);
  pointer-events: none;
}

.lede {
  font-size: clamp(1.15rem, 1rem + .7vw, 1.5rem);
  line-height: 1.4;
  font-weight: 400;
  margin: 0 0 1.1rem;
  max-width: 34ch;
  text-wrap: pretty;
}

.sub {
  color: var(--muted);
  margin: 0 0 2.25rem;
  max-width: 46ch;
  text-wrap: pretty;
}

.actions {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin: 0;
  padding: 0;
}

.btn {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: .82rem;
  letter-spacing: .02em;
  text-decoration: none;
  padding: .6rem 1.05rem;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: border-color .18s ease, color .18s ease, transform .18s ease;
}
.btn:hover { border-color: var(--amber); transform: translateY(-1px); }

.btn-primary {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--panel);
  background: color-mix(in srgb, var(--amber) 8%, var(--panel));
}

.portrait { margin: 0; }

.portrait img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border: 1px solid var(--line);
  filter: saturate(.9) contrast(1.02);
}

.portrait figcaption {
  font-family: var(--f-mono);
  font-size: .72rem;
  color: var(--muted);
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .1rem 0;
  border-top: 1px solid var(--line-soft);
  margin-top: .6rem;
  text-wrap: pretty;
}

.dot {
  flex: none;
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: var(--muted);
}
.dot-ok { background: var(--ok); }

/* ---------- sections ---------- */

main section[id] { scroll-margin-top: 4.75rem; }

.section {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gut) var(--rhythm);
}

.section-head {
  border-top: 1px solid var(--line);
  padding-top: 1.1rem;
  margin-bottom: clamp(1.75rem, 4vw, 3rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem clamp(2rem, 5vw, 4rem);
  align-items: baseline;
}

.section-head h2 {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.9rem, 1.2rem + 2.4vw, 3.1rem);
  line-height: 1;
  letter-spacing: -.025em;
  margin: 0;
}

.section-note {
  margin: 0;
  color: var(--muted);
  font-size: .95rem;
  max-width: 44ch;
  text-wrap: pretty;
}

/* ---------- service board ---------- */

.board { list-style: none; margin: 0; padding: 0; }

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1.1rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--line-soft);
}
.row:first-child { border-top: 0; padding-top: 0; }

.row > .dot { margin-top: .62rem; }

.row h3 {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 1.22rem;
  letter-spacing: -.008em;
  margin: 0 0 .4rem;
}

.row-body p { margin: 0 0 .6rem; max-width: 68ch; text-wrap: pretty; }
.row-body p:last-child { margin-bottom: 0; }

.tags { display: flex; flex-wrap: wrap; gap: .4rem; }

.tags span {
  font-family: var(--f-mono);
  font-size: .7rem;
  letter-spacing: .04em;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: .16rem .5rem;
  white-space: nowrap;
}

/* ---------- project cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
}

.card {
  background: var(--bg-2);
  padding: clamp(1.35rem, 3vw, 2.1rem);
}

.card-kicker {
  font-family: var(--f-mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .9rem;
}

.card h3 {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem);
  letter-spacing: -.02em;
  margin: 0 0 .7rem;
}

.card h3 a { text-decoration: none; }
.card h3 a::after { content: " \2192"; color: var(--amber); font-size: .8em; }
.card h3 a:hover { color: var(--amber); }

.card p { margin: 0 0 .7rem; text-wrap: pretty; }
.card p:last-child { margin-bottom: 0; }

.card-note {
  font-family: var(--f-mono);
  font-size: .78rem;
  color: var(--muted);
  border-left: 2px solid var(--amber-dim);
  padding-left: .8rem;
}

/* ---------- toolbox ---------- */

.toolbox {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 1.75rem clamp(2rem, 5vw, 4rem);
}

.tool-group dt {
  font-family: var(--f-mono);
  font-size: .74rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--amber);
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: .7rem;
}

.tool-group dd { margin: 0; color: var(--muted); line-height: 1.75; }
.tool-group dd span { color: var(--line); padding: 0 .15em; }

/* ---------- contact ---------- */

.contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line-soft);
}

.contact-list li {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 1rem;
  align-items: baseline;
  padding: .95rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.c-label {
  font-family: var(--f-mono);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.contact-list a {
  font-family: var(--f-mono);
  font-size: .95rem;
  word-break: break-word;
}

/* ---------- footer ---------- */

.foot {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 1.5rem var(--gut) 2.5rem;
  border-top: 1px solid var(--line-soft);
}

.foot p {
  margin: 0;
  font-family: var(--f-mono);
  font-size: .72rem;
  color: var(--muted);
  letter-spacing: .02em;
}

/* ---------- status line (signature) ---------- */

.statusline {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: .4rem var(--gut);
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-family: var(--f-mono);
  font-size: .72rem;
  letter-spacing: .04em;
  color: var(--muted);
}

.sl-mode {
  background: var(--amber);
  color: #0c1318;
  font-weight: 500;
  padding: .1rem .5rem;
  margin-right: .6rem;
}

html[data-theme="light"] .sl-mode { color: #fff; }
html[data-theme="dark"] .sl-mode { color: #0c1318; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .sl-mode { color: #fff; }
}

.sl-right {
  cursor: pointer;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  letter-spacing: inherit;
}
.sl-right:hover { color: var(--text); }

.sl-mid { color: var(--text); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-mid::before { content: "\2014 "; color: var(--muted); }

kbd {
  font-family: var(--f-mono);
  font-size: .95em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  padding: 0 .3em;
  margin: 0 .1em;
  color: var(--text);
}

/* ---------- command palette ---------- */

.palette {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  padding: 0;
  width: min(38rem, calc(100vw - 2rem));
  margin: 12vh auto auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.palette::backdrop { background: rgba(4, 8, 11, .62); backdrop-filter: blur(2px); }

.palette-input {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--line);
}

.palette-prompt { font-family: var(--f-mono); color: var(--amber); }

.palette-input input {
  flex: 1;
  border: 0;
  background: none;
  color: var(--text);
  font-family: var(--f-mono);
  font-size: .95rem;
  padding: 0;
}
.palette-input input:focus { outline: none; }
.palette-input input::placeholder { color: var(--muted); }

.palette-list {
  list-style: none;
  margin: 0;
  padding: .35rem 0;
  max-height: 46vh;
  overflow-y: auto;
}

.palette-list li {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  padding: .5rem 1rem;
  font-family: var(--f-mono);
  font-size: .85rem;
  cursor: pointer;
}

.palette-list li[aria-selected="true"] {
  background: var(--panel);
  background: color-mix(in srgb, var(--amber) 14%, transparent);
  box-shadow: inset 2px 0 0 var(--amber);
}

.pl-kind {
  color: var(--muted);
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  min-width: 4.5rem;
}

.pl-hint-text {
  margin-left: auto;
  color: var(--muted);
  font-size: .72rem;
  text-align: right;
}

.pl-empty { color: var(--muted); cursor: default; }

.palette-hint {
  margin: 0;
  padding: .6rem 1rem;
  border-top: 1px solid var(--line);
  font-family: var(--f-mono);
  font-size: .7rem;
  color: var(--muted);
}

/* ---------- topology card ---------- */

.card-topo .topo {
  display: block;
  width: 100%;
  height: auto;
  margin: .3rem 0 1.1rem;
  overflow: visible;
}

.topo-wire path {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}

.topo-node circle,
.topo-node rect {
  fill: var(--bg-2);
  stroke: var(--muted);
  stroke-width: 1;
}

.topo-label text {
  fill: var(--muted);
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: .04em;
}

.topo-pulse .p {
  fill: var(--amber);
  offset-rotate: 0deg;
  animation: topo-run 2.8s linear infinite;
}

/* Responses. Same wires, same keyframes, run backwards and tinted with the
   healthy-status color so the pair reads as request out, answer back. */
.topo-pulse .back {
  fill: var(--ok);
  animation-direction: reverse;
}

/* offset-path carries each pulse along its own wire. Browsers without it
   simply leave the dots parked at the origin, which reads as a static
   diagram rather than a broken one. */
.topo-pulse .p0 { offset-path: path("M 46 98 H 130"); animation-duration: .9s; }
.topo-pulse .pa { offset-path: path("M 170 98 C 212 98, 224 34, 272 34"); }
.topo-pulse .pb { offset-path: path("M 170 98 C 212 98, 224 66, 272 66"); }
.topo-pulse .pc { offset-path: path("M 170 98 H 272"); }
.topo-pulse .pd { offset-path: path("M 170 98 C 212 98, 224 130, 272 130"); }
.topo-pulse .pe { offset-path: path("M 170 98 C 212 98, 224 162, 272 162"); }

/* Outbound staggered down the fan, returns offset by half a cycle so the two
   directions interleave instead of colliding at the proxy. */
.topo-pulse .pa { animation-delay: .0s; }
.topo-pulse .pb { animation-delay: .5s; }
.topo-pulse .pc { animation-delay: 1.0s; }
.topo-pulse .pd { animation-delay: 1.5s; }
.topo-pulse .pe { animation-delay: 2.0s; }

.topo-pulse .back.p0 { animation-delay: .45s; }
.topo-pulse .back.pa { animation-delay: 1.4s; }
.topo-pulse .back.pb { animation-delay: 1.9s; }
.topo-pulse .back.pc { animation-delay: 2.4s; }
.topo-pulse .back.pd { animation-delay: 2.9s; }
.topo-pulse .back.pe { animation-delay: 3.4s; }

@keyframes topo-run {
  0%   { offset-distance: 0%;   opacity: 0; }
  12%  { opacity: 1; }
  82%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* ---------- public endpoints card ---------- */

.endpoints {
  list-style: none;
  margin: 0;
  padding: 0;
}

.endpoints li {
  padding: .7rem 0;
  border-top: 1px solid var(--line-soft);
}
.endpoints li:first-child { border-top: 0; padding-top: 0; }

.endpoints a {
  font-family: var(--f-mono);
  font-size: .9rem;
  display: inline-block;
  margin-bottom: .15rem;
}

.endpoints p {
  margin: 0;
  color: var(--muted);
  font-size: .92rem;
}

/* ---------- motion ---------- */

.reveal { opacity: 0; transform: translateY(14px); }
.reveal.is-in { opacity: 1; transform: none; transition: opacity .5s ease, transform .5s ease; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .topo-pulse { display: none; }
  .reveal,
  .reveal.is-in { opacity: 1; transform: none; transition: none; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- responsive ---------- */

@media (max-width: 60rem) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .wordmark { font-size: min(calc(100cqw / 23.6), 2.6rem); }
  .portrait { max-width: 24rem; }
  .section-head { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 40rem) {
  .topnav a { font-size: .72rem; }
  .statusline { grid-template-columns: auto minmax(0, 1fr); font-size: .68rem; }
  .sl-right { display: none; }
  .contact-list li { grid-template-columns: minmax(0, 1fr); gap: .2rem; }
  .row { grid-template-columns: minmax(0, 1fr); }
  .row > .dot { display: none; }
}

@media print {
  .topbar, .statusline, .palette, .skip { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
}
