/* Bala in Production. Colours come from /theme.css (set in the admin); everything else is here. */

@font-face { font-family: "Trace Text"; src: url(../fonts/trace-text.woff) format("woff"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Trace Slab"; src: url(../fonts/trace-slab.woff) format("woff"); font-weight: 500 800; font-stretch: 100% 125%; font-display: swap; }
@font-face { font-family: "Trace Hand"; src: url(../fonts/trace-hand.woff) format("woff"); font-weight: 400 600; font-display: swap; }

:root {
  --text: "Trace Text", ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --slab: "Trace Slab", "Trace Text", ui-monospace, Menlo, Consolas, monospace;
  --hand: "Trace Hand", "Segoe Print", "Bradley Hand", cursive;
  --edge: clamp(1.25rem, 5vw, 4.5rem);
  --bar: 2.75rem;
  color-scheme: light;
}
:root[data-theme="night"] { color-scheme: dark; }
html.js3d { scroll-padding-top: 4.5rem; }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; font-size: clamp(100%, calc(100% + (100vw - 1440px) * 0.006), 120%); }
body { margin: 0; font: 400 .94rem/1.62 var(--text); padding-bottom: var(--bar); }
h1, h2, h3, p, ul, ol, dl, dd, pre, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .22em; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
mark { background: var(--marker); color: var(--on-marker); padding: .08em .4em; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999rem; }
.skip:focus { left: 1rem; top: 1rem; z-index: 20; background: var(--paper); padding: .5rem .75rem; }

/* ---------- top bar ---------- */
.top { position: fixed; inset: 0 0 auto 0; z-index: 6; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem var(--edge); }
.top::before { content: ""; position: absolute; inset: 0 0 -1.2rem 0; z-index: -1; pointer-events: none; background: linear-gradient(var(--paper) 58%, transparent); }
.wordmark { font: 800 1rem/1 var(--slab); font-stretch: 125%; letter-spacing: -.01em; text-decoration: none; white-space: nowrap; }
.wordmark { flex: none; }
.tools { display: flex; align-items: center; gap: clamp(.7rem, 2vw, 1.5rem); font-size: .8rem; min-width: 0; }
.tools-strip { display: flex; align-items: center; gap: inherit; min-width: 0; }
.tools a, .tools button { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .22em; white-space: nowrap; }
/* Profile links as the official marks: the [in] bug as LinkedIn ships it, GitHub's mark in their black (white
   at night). The envelope is drawn here. The marks never get the page's own colours, by the brands' rules. */
.brand { display: inline-block; vertical-align: middle; flex: none; }
.brand.github { width: 1.15rem; height: 1.15rem; fill: #000; }
:root[data-theme="night"] .brand.github { fill: #fff; }
.brand.linkedin { width: auto; height: 1.15rem; }
.brand.linkedin.night, :root[data-theme="night"] .brand.linkedin.day { display: none; }
:root[data-theme="night"] .brand.linkedin.night { display: inline-block; }
.brand.mail { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.tools a.icon { text-decoration: none; display: inline-flex; align-items: center; padding: .1rem 0; }
.tools a.icon:hover .brand, .tools a.icon:focus-visible .brand { outline: 2px solid var(--marker); outline-offset: 3px; }
.tools .short { display: none; }
.ask-button { background: var(--marker); color: var(--on-marker); font-weight: 700; padding: .4rem .85rem; text-decoration: none !important; }
.ask-button:hover { outline: 2px solid var(--ink); }

/* ---------- type ---------- */
h1 { font: 800 clamp(1.95rem, 3.5vw, 3.2rem)/1.05 var(--slab); font-stretch: 116%; letter-spacing: -.028em; word-spacing: -.22em; text-wrap: balance; }
h2 { font: 700 clamp(1.5rem, 2.6vw, 2.25rem)/1.12 var(--slab); font-stretch: 112%; letter-spacing: -.018em; word-spacing: -.18em; text-wrap: balance; }
h3 { font: 700 1.05rem/1.35 var(--text); }
.who { font-weight: 500; }
.lede { font-size: 1.04rem; }
.role, .hint, .stack { color: var(--graphite); }
.hint { font-size: .8rem; }

/* ---------- the story, as a plain page (no script, text mode, or no WebGL) ---------- */
main { position: relative; z-index: 3; }
.span { padding: 5.5rem var(--edge) 1.5rem; scroll-margin-top: 0; }
.span + .span { padding-top: 3rem; }
.panel { max-width: 44rem; margin: 0 0 3.2rem; }
.panel > * + * { margin-top: 1rem; }
.plain li { position: relative; padding-left: 1.5rem; }
.plain li + li { margin-top: .65rem; }
.plain li::before { content: ""; position: absolute; left: 0; top: .78em; width: .8rem; height: 1px; background: var(--ink); }

#scene, #labels { display: none; }

/* ---------- the story, with the 3D floor behind it ---------- */
.js3d #scene { display: block; position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
.js3d #labels { display: block; position: fixed; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
.js3d body.home::before { content: ""; position: fixed; inset: 0 auto 0 0; width: 64vw; z-index: 2; pointer-events: none; background: linear-gradient(90deg, var(--paper) 0, var(--paper) 62%, transparent); }
.js3d .span { min-height: 100vh; padding-top: 26vh; padding-bottom: 0; }
.js3d .span + .span { padding-top: 26vh; }
.js3d .panel { max-width: min(33rem, 39vw); margin-bottom: 64vh; }
.js3d #arrival { padding-top: 15vh; }
.js3d #arrival .panel { max-width: min(40rem, 44vw); margin-bottom: 30vh; }
.js3d #response .panel:last-of-type { margin-bottom: 8vh; }

/* names pinned to things in the scene: a solid chip on a short stem */
.tag { position: absolute; left: 0; top: 0; visibility: hidden; transform: translate3d(-999px, -999px, 0); white-space: nowrap; font: 700 .8rem/1 var(--text); color: var(--paper); background: var(--ink); padding: .36rem .62rem .38rem; margin: -2.5rem 0 0 -.56rem; }
.tag::after { content: ""; position: absolute; left: .5rem; top: 100%; width: 2px; height: .8rem; background: var(--ink); }
.tag.you { font: 500 1.1rem/1 var(--hand); color: var(--ink); background: color-mix(in srgb, var(--paper) 82%, transparent); padding: .12rem .35rem .2rem; margin: -1.5rem 0 0 -1rem; }
.tag.you::after { display: none; }

/* ---------- arrival ---------- */
.readout { margin-top: 2.2rem !important; max-width: 31rem; border-top: 1px solid var(--ink); padding-top: .9rem; }
.readout-title { display: flex; flex-wrap: wrap; gap: .7rem; align-items: baseline; font-size: .82rem; }
.timings { margin-top: .75rem; display: grid; gap: .3rem; font-size: .78rem; }
.timings li { display: grid; grid-template-columns: 5.6rem 1fr 4.4rem; align-items: center; gap: .7rem; }
.timings .bar { border-bottom: 1px solid var(--rule); height: .55rem; }
.timings .bar i { display: block; height: 100%; min-width: 2px; background: var(--ink); }
.timings .v { text-align: right; font-variant-numeric: tabular-nums; }
.timings .note { display: block; margin-top: .5rem; color: var(--graphite); }
.readout .hint { margin-top: .8rem; }

/* ---------- the floor ---------- */
.count { font: 800 clamp(2.3rem, 5.4vw, 4.4rem)/1 var(--slab); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.counter > * + * { margin-top: .6rem; }

/* ---------- the incident ---------- */
.console { margin-top: 1.5rem !important; border: 1px solid var(--ink); background: var(--paper); padding: 1rem 1.1rem 1.1rem; }
.ticket strong { background: var(--alert); color: var(--paper); font-weight: 700; padding: .08em .45em; margin-right: .45rem; }
.steps { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .95rem; }
.steps button { border: 1px solid var(--ink); padding: .42rem .7rem; font-size: .8rem; text-align: left; }
.steps button:not(:disabled):hover { background: var(--marker); color: var(--on-marker); }
.steps button:disabled { color: var(--graphite); border: 1px dashed var(--rule); cursor: default; }
.steps button.done { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.out-block { margin-top: 1rem; border-top: 1px solid var(--rule); padding-top: .85rem; }
.out pre { font: 400 .72rem/1.6 var(--text); white-space: pre; overflow-x: auto; padding-bottom: .2rem; }
.out p { margin-top: .65rem; font-size: .88rem; }
.resolved { color: var(--ok); font-weight: 700; }

/* ---------- shipped ---------- */
.status { display: flex; align-items: center; gap: .55rem; font-size: .8rem; margin-top: .45rem !important; }
.status::before { content: ""; width: .62rem; height: .62rem; border: 1px solid var(--ink); flex: none; }
.status.live::before { background: var(--ok); }
.status.pre::before { background: var(--marker); }
.stack { font-size: .84rem; }

/* ---------- the response ---------- */
.headers, .skills { margin-top: 1.3rem !important; font-size: .88rem; }
.headers > div, .skills > div { display: grid; grid-template-columns: 6.6rem 1fr; gap: 1rem; border-top: 1px solid var(--rule); padding: .55rem 0; }
.headers dt { color: var(--graphite); }
.skills > div { grid-template-columns: 1fr; gap: .15rem; }
.skills dt { font-weight: 700; }
.headers dd, .skills dd { overflow-wrap: anywhere; }
.reach { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; font-size: .88rem; }
.reach a { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; }
.reach a span { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .22em; overflow-wrap: anywhere; }
.reach .brand.github { width: 1.3rem; height: 1.3rem; }
.reach .brand.linkedin { height: 1.3rem; }
.reach .brand.mail { width: 1.35rem; height: 1.35rem; }
.visit .timings li { grid-template-columns: 6.2rem 1fr 4.4rem; }
.colophon { max-width: 44rem; padding: 2rem 0 3rem; color: var(--graphite); font-size: .78rem; }
.colophon p + p { margin-top: .5rem; }

/* ---------- trace bar ---------- */
.tracebar { position: fixed; inset: auto 0 0 0; z-index: 6; height: var(--bar); display: flex; align-items: stretch; padding-right: 5.6rem; background: var(--paper); border-top: 1px solid var(--ink); font-size: .74rem; }
.tracebar a { flex: 1 0 auto; min-width: max-content; display: flex; align-items: center; padding: 0 .65rem; overflow: hidden; white-space: nowrap; text-decoration: none; color: var(--graphite); border-right: 1px solid var(--rule); }
.tracebar { touch-action: none; -webkit-user-select: none; user-select: none; cursor: ew-resize; }   /* it can be dragged */
.tracebar.scrubbing, .tracebar.scrubbing a { cursor: grabbing; }
.tracebar a { -webkit-user-drag: none; }
.tracebar a:hover { color: var(--ink); }
.tracebar a[aria-current] { color: var(--ink); font-weight: 700; }
.playhead { position: absolute; top: -1px; left: 0; width: 2px; height: .5rem; background: var(--ink); pointer-events: none; }
.playhead::before { content: ""; position: absolute; top: -.5rem; left: -.44rem; width: 1rem; height: .62rem; background: var(--marker); border: 1px solid var(--ink); }
.tracebar.scrubbing .playhead::before { transform: scale(1.25); transform-origin: 50% 100%; }
.clock { position: absolute; right: .9rem; top: 50%; transform: translateY(-50%); font-variant-numeric: tabular-nums; }

/* ---------- assistant ---------- */
.ask { position: fixed; z-index: 8; top: 0; right: 0; bottom: 0; width: min(27rem, 100vw); display: flex; flex-direction: column; gap: .9rem; padding: 1.1rem 1.2rem 1rem; background: var(--paper); border-left: 1px solid var(--ink); }
.ask-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.ask-head h2 { font-size: 1.35rem; }
.ask-head button { text-decoration: underline; font-size: .8rem; }
.ask-note { font-size: .76rem; color: var(--graphite); }
.ask-chips { display: flex; flex-wrap: wrap; gap: .4rem; max-height: 9.5rem; overflow-y: auto; }
.ask-chips button { border: 1px solid var(--rule); padding: .28rem .55rem; font-size: .76rem; text-align: left; }
.ask-chips button:hover { border-color: var(--ink); background: var(--marker); color: var(--on-marker); }
.ask-log { flex: 1; min-height: 4rem; overflow-y: auto; border-top: 1px solid var(--rule); padding-top: .8rem; font-size: .88rem; }
.ask-log p + p { margin-top: .7rem; }
.ask-log .q { font-weight: 700; }
.ask-log .q::before { content: "Q  "; color: var(--graphite); font-weight: 400; }
.ask-log .a { white-space: pre-wrap; }
.ask-log .pending { color: var(--graphite); }
.ask-log .failed { color: var(--alert); }
.ask-form label { display: block; font-size: .76rem; color: var(--graphite); margin-bottom: .3rem; }
.ask-row { display: flex; gap: .5rem; }
.ask-row input { flex: 1; min-width: 0; font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--ink); border-radius: 0; padding: .5rem .6rem; }
.ask-row button { background: var(--ink); color: var(--paper); padding: .5rem .95rem; font-weight: 700; }
.ask-row .ask-mic { background: var(--paper); color: var(--ink); border: 1px solid var(--ink); padding: .35rem .6rem; display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-size: .8rem; }
.ask-row .ask-mic svg { fill: currentColor; stroke: none; flex: none; }
.ask-row .ask-mic .mic-icon { width: .95rem; height: 1.7rem; }
.ask-row .ask-mic .stop-icon { display: none; width: 1rem; height: 1rem; }
.ask-row .ask-mic[aria-pressed="true"] { background: var(--marker); color: var(--on-marker); border-color: var(--ink); }
.ask-row .ask-mic[aria-pressed="true"] .mic-icon { display: none; }
.ask-row .ask-mic[aria-pressed="true"] .stop-icon { display: block; }
.ask-voice { margin-top: .45rem; font-size: .76rem; }
.ask-voice.listening::before { content: ""; display: inline-block; width: .55em; height: .55em; margin-right: .5em; background: var(--alert); border-radius: 50%; animation: mic-pulse 1s ease-in-out infinite; }
@keyframes mic-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .ask-voice.listening::before { animation: none; } }
.ask-left { margin-top: .45rem; font-size: .74rem; color: var(--graphite); min-height: 1.2em; }

/* ---------- articles and other plain pages ---------- */
.doc .top { position: static; }
.doc .top::before { display: none; }
.doc-main { max-width: 46rem; margin: 0 auto; padding: 3rem var(--edge) 5rem; }
.doc-main > * + * { margin-top: 1.2rem; }
.doc-main h1 { font-size: clamp(1.9rem, 4vw, 3rem); }
.article > * + * { margin-top: .9rem; }
.meta, .back { font-size: .8rem; color: var(--graphite); }
.meta a { margin-left: .9rem; }
.preview-note { border: 1px dashed var(--ink); padding: .5rem .8rem; font-size: .8rem; }
.articles { margin-top: 2rem !important; }
.articles li { border-top: 1px solid var(--rule); padding: 1.1rem 0; display: grid; gap: .3rem; }
.articles a { font: 700 1.2rem/1.25 var(--slab); font-stretch: 108%; text-decoration: none; }
.articles a:hover { text-decoration: underline; }
.articles time { font-size: .76rem; color: var(--graphite); }
.latest .articles { margin-top: .6rem !important; }
.latest .articles a { font-size: 1rem; }
.prose { margin-top: 2rem; }
.prose > * + * { margin-top: 1.15rem; }
.prose h2 { font-size: 1.45rem; margin-top: 2.4rem; }
.prose h3 { font: 700 1.15rem/1.3 var(--slab); margin-top: 2rem; }
.prose h4 { font: 700 1rem/1.3 var(--text); margin: 1.6rem 0 0; }
.prose ul { list-style: disc; padding-left: 1.4rem; }
.prose ol { list-style: decimal; padding-left: 1.8rem; }
.prose li + li { margin-top: .35rem; }
.prose code { background: color-mix(in srgb, var(--ink) 9%, var(--paper)); padding: .08em .3em; font-size: .92em; }
.prose pre { border: 1px solid var(--rule); padding: .9rem 1rem; overflow-x: auto; font: 400 .8rem/1.6 var(--text); }
.prose pre code { background: none; padding: 0; }
.prose blockquote { border-left: 3px solid var(--marker); padding-left: 1rem; color: var(--graphite); }
.prose img { max-width: 100%; height: auto; display: block; }
.prose hr { border: 0; border-top: 1px solid var(--rule); }

/* ---------- small screens ---------- */
@media (max-width: 899px) {
  /* The header links become one strip that slides sideways under a finger; Ask stays put on the right.
     The last link fades at the edge so it is clear there is more. */
  .tools { gap: .8rem; flex: 1 1 auto; justify-content: flex-end; }
  .tools-strip { gap: .9rem; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; padding-right: 1.4rem;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.6rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 1.6rem), transparent); }
  .tools-strip::-webkit-scrollbar { display: none; }
  .tools-strip > * { flex: none; scroll-snap-align: start; }
  .tools-strip > #theme-toggle { order: 1; }
  .tools-strip > #mode-toggle { order: 2; }
  .tools-strip > a.icon { order: 3; }
  .tools-strip > a[href="/articles"] { order: 4; }
  .tracebar { padding-right: 4.6rem; }
  .tracebar a { flex: 1 1 0; min-width: 0; padding: 0 .3rem; justify-content: center; }
  .tracebar a span { display: none; }
  .tracebar a[aria-current] { flex-basis: 6.5rem; }
  .tracebar a[aria-current] span { display: inline; }
  .headers > div { grid-template-columns: 5.2rem 1fr; gap: .7rem; }
  .ask { width: 100vw; border-left: 0; }
}
/* Phones held upright: the scene gets its own strip at the top and the text scrolls beneath it,
   so neither covers the other. */
@media (max-width: 899px) and (orientation: portrait) {
  html.js3d { scroll-padding-top: calc(46vh + 1rem); scroll-padding-top: calc(46svh + 1rem); }
  .js3d .top { height: 3.2rem; padding-block: 0; background: var(--paper); }
  .js3d .top::before { display: none; }
  .js3d #scene { inset: 3.2rem 0 auto 0; height: calc(46vh - 3.2rem); height: calc(46svh - 3.2rem); z-index: 4; border-bottom: 1px solid var(--ink); }
  .js3d #labels { inset: 3.2rem 0 auto 0; height: calc(46vh - 3.2rem); height: calc(46svh - 3.2rem); z-index: 5; }
  .js3d body.home::before { display: none; }
  .js3d main { padding-top: 46vh; padding-top: 46svh; }
  .js3d .span, .js3d .span + .span { min-height: 0; padding-top: 2rem; padding-bottom: 0; scroll-margin-top: 0; }   /* the page's own scroll padding already clears the strip */
  .js3d #arrival { padding-top: 1.5rem; }
  .js3d .panel, .js3d #arrival .panel { max-width: none; margin-bottom: 20vh; }
  .js3d #response .panel:last-of-type { margin-bottom: 2.5rem; }
  .tag { font-size: .72rem; padding: .3rem .5rem .32rem; margin-top: -2.2rem; }
}
@media (max-width: 520px) {
  .wordmark { font-size: .84rem; }
  .tools { font-size: .76rem; gap: .8rem; }
  .tools .long { display: none; }
  .tools .short { display: inline; }
  .tools a[href="/articles"] { display: none; }
  .doc .tools a[href="/articles"] { display: inline; }
}
@media (max-height: 760px) and (min-width: 900px) {
  .js3d #arrival { padding-top: 11vh; }
  .readout { margin-top: 1.3rem !important; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print {
  #scene, #labels, .tracebar, .top .tools, .ask { display: none !important; }
  .span, .js3d .span { min-height: 0; padding: 1rem 0; }
  .panel, .js3d .panel { max-width: none; margin-bottom: 1.5rem; }
}
