/* Page CSS: only what the kit lacks. Tokens, grid, buttons and cards come from /assets. */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.logo { width: 24px; height: 24px; color: var(--accent); flex: none; margin-right: 8px; }
.nav__logo { display: inline-flex; align-items: center; }
.numbers { background: none; border: 0; padding: 0 var(--s-2); min-height: 44px; color: var(--muted); font: 400 var(--t-small)/1 var(--font-mono); cursor: pointer; }
.numbers:hover { color: var(--ink); }
.numbers__note { font-size: var(--t-small); color: var(--muted); }
.footer--page { margin-top: var(--s-8); }
main#top > .wrap { padding-bottom: var(--s-6); }

/* ---- hero: the foxfire constellation is the full-bleed layer, the words sit on the left */
.hero--sky > .wrap { pointer-events: none; }
.hero--sky .hero__text, .hero--sky .hero__facts { pointer-events: auto; }
.hero--sky .hero__text { display: grid; gap: var(--s-5); justify-items: start; }
.hero--sky h1 { max-width: 12ch; font-size: clamp(44px, 6.2vw, 92px); line-height: 1.02; }
.hero--sky .hero__lead { max-width: 30ch; margin: 0; }
.hero--sky .btn-row { margin: 0; }
.hero--sky .hero__facts { gap: var(--s-6); }
.portrait { display: block; width: 112px; height: 112px; border-radius: 50%; padding: 3px; background: var(--bg); box-shadow: 0 0 0 2px var(--accent), 0 0 26px 3px rgb(217 174 85 / .4); animation: foxfire-glow 3.6s ease-in-out infinite; }
.portrait img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
@keyframes foxfire-glow { 50% { box-shadow: 0 0 0 2px var(--accent), 0 0 40px 8px rgb(217 174 85 / .62); } }
@media (prefers-reduced-motion: reduce) { .portrait { animation: none; } }
@media (max-width: 639px) { .portrait { width: 72px; height: 72px; } }
.sky { position: absolute; inset: 0; z-index: 0; container-type: size; overflow: hidden; touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none; }
.sky.is-drag { cursor: grabbing; }
.sky__canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .5s var(--ease, ease); display: block; }
.sky.is-live .sky__canvas { opacity: 1; }
.sky__still, .sky__stars, .sky__labels {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; margin: 0; padding: 0; list-style: none;
  aspect-ratio: 1440 / 900; width: min(100%, calc(100cqh * 1.6));
}
.sky__still { pointer-events: none; transition: opacity .4s var(--ease, ease); }
.sky.is-live .sky__still { opacity: 0; }
.sky.is-live .sky__stars, .sky.is-live .sky__labels { inset: 0; left: 0; top: 0; translate: none; width: 100%; height: 100%; aspect-ratio: auto; }
.sky__svg { width: 100%; height: 100%; display: block; }
.sky__svg--tall { display: none; }
@media (max-width: 639px) {
  .sky__still, .sky__stars, .sky__labels { aspect-ratio: 390 / 355; width: min(100%, calc(100cqh * 1.0986)); }
  .sky__svg--wide { display: none; } .sky__svg--tall { display: block; }
}
.sky__ring { stroke: var(--steel); stroke-opacity: .5; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.sky__ticks { stroke: var(--steel); stroke-opacity: .6; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.sky__tail { stroke: var(--accent); stroke-opacity: .4; stroke-width: 1.2; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.sky__tail--main { stroke-opacity: .9; stroke-width: 2; }
.sky__fox { stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sky__core { fill: #f6e6b8; }
.sky__ember { fill: var(--accent); fill-opacity: .6; }
.sky__li { position: absolute; left: var(--xd); top: var(--yd); width: 0; height: 0; }
.sky.is-live .sky__li { left: 0; top: 0; }
.sky__star { position: absolute; left: -20px; top: -20px; width: 40px; height: 40px; border-radius: 50%; display: block; cursor: pointer; }
.sky__star:focus-visible { outline: 2px solid var(--action); outline-offset: 0; }
.sky__tip {
  position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%); width: max-content; max-width: 250px; z-index: 3;
  display: grid; gap: 2px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: var(--t-small); line-height: 1.35; opacity: 0; visibility: hidden; pointer-events: none; text-align: left;
  transition: opacity .15s var(--ease, ease), visibility 0s linear .15s;
}
.sky__tip b { font-weight: 500; color: var(--ink); }
.sky__tip span { color: var(--ink); }
.sky__tip em { font-style: normal; color: var(--accent); font-size: var(--t-label); }
.sky__li.is-left .sky__tip { left: auto; right: -14px; transform: none; }
.sky__li.is-right .sky__tip { left: -14px; transform: none; }
.sky__li.is-low .sky__tip { bottom: auto; top: calc(100% + 4px); }
.sky__star:hover .sky__tip, .sky__star:focus-visible .sky__tip { opacity: 1; visibility: visible; transition-delay: 0s; }
.sky__label { position: absolute; left: var(--xd); top: var(--yd); translate: -50% -40px; font: 500 var(--t-label)/1.2 var(--font-text); color: var(--steel); white-space: nowrap; pointer-events: none; }
.sky.is-live .sky__label { left: 0; top: 0; }
@media (max-width: 639px) { .sky__li, .sky__label { left: var(--xt); top: var(--yt); } .sky.is-live .sky__li, .sky.is-live .sky__label { left: 0; top: 0; } }
/* on a phone the saturn tip sits just under the jupiter label and near the right edge, so its label hangs left of the tip on a dark panel, because the tails run behind it */
@media (max-width: 639px) { .sky__label[data-body="saturn"] { translate: -85% -34px; background: rgb(20 18 15 / .9); padding: 1px 5px; border-radius: 3px; } }
.sky__pause { position: absolute; right: var(--gut, var(--s-5)); bottom: var(--s-5); z-index: 4; height: 44px; padding: 0 var(--s-4); border: 1px solid var(--line-strong); border-radius: var(--r-btn); background: color-mix(in oklab, var(--bg) 78%, transparent); color: var(--ink); font: 500 var(--t-small)/1 var(--font-text); cursor: pointer; transition: border-color .15s, color .15s; }
.sky__pause:hover { border-color: var(--accent); color: var(--accent); }
.sky__pause:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

/* ---- featured cards */
#featured .panel { --p-h: auto; height: auto; min-height: 0; flex: 1 1 0; position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); transition: box-shadow .25s var(--ease, ease), border-color .25s var(--ease, ease); }
#featured .panel > a { position: absolute; inset: 0; display: block; }
#featured .panel .frame__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#featured .frame__img[src*="esp32"] { object-fit: cover; }
#featured .panel--gif { background: #0c0b09; }
#featured .panel--gif .frame__img { position: absolute; inset: auto; left: 50%; top: 50%; width: 160px; height: 160px; transform: translate(-50%, -50%); object-fit: contain; }
#featured .card:hover .panel, #featured .card:focus-within .panel { border-color: var(--accent); box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 60%, transparent), 0 14px 48px -10px rgb(217 174 85 / .38); }
#featured .card h3 a { text-decoration: none; }
@media (max-width: 639px) { #featured .panel { min-height: 120px; } #featured .card:nth-of-type(4), #featured .card:nth-of-type(6) { display: none; } #featured .panel[data-live] { min-height: 170px; } .portrait { width: 56px; height: 56px; } .hero--sky .hero__text { gap: var(--s-4); } }

/* ---- lab bench */
.bench__link { display: inline-flex; align-items: center; min-height: 44px; }
.rows .rows__name a:not(.link) { text-decoration: none; }
.tabs { gap: var(--s-2); }

/* ---- tools, drawn traces, bench rows */
.toolrow { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-5); }
.toolrow .ic-chip { background: var(--surface); }
@keyframes row-in { from { opacity: 0; translate: 0 10px; } }
.bench:not([hidden]) .rows > li { animation: row-in .45s var(--ease, ease) both; }
.bench:not([hidden]) .rows > li:nth-child(2) { animation-delay: .06s; } .bench:not([hidden]) .rows > li:nth-child(3) { animation-delay: .12s; }
.bench:not([hidden]) .rows > li:nth-child(4) { animation-delay: .18s; } .bench:not([hidden]) .rows > li:nth-child(n+5) { animation-delay: .24s; }
@media (prefers-reduced-motion: reduce) { .bench:not([hidden]) .rows > li { animation: none; } }
.about-portrait { width: min(100%, 360px); aspect-ratio: 1; border-radius: 50%; padding: 4px; background: var(--bg); box-shadow: 0 0 0 2px var(--accent), 0 0 48px 6px rgb(217 174 85 / .4); animation: foxfire-glow 3.6s ease-in-out infinite; margin-bottom: var(--s-6); }
.about-portrait img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }

/* ---- inner pages */
.page { padding-top: calc(var(--nav) + var(--s-8)); }
.page__head { display: grid; gap: var(--s-4); max-width: 820px; margin-bottom: var(--s-8); }
.page__head h1 { font-size: clamp(36px, 5.2vw, 64px); line-height: 1.04; letter-spacing: var(--display-tracking-xl); }
.page__head .t-lead { max-width: 60ch; }
.crumbs { font-size: var(--t-small); color: var(--muted); }
.crumbs a { color: var(--muted); }
.prose { max-width: 62ch; display: grid; gap: var(--s-4); }
.prose h2 { font-size: var(--t-h3); margin-top: var(--s-6); }
.prose p { color: var(--ink); }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-5); margin-bottom: var(--s-8); }
.metrics > div { border-top: 1px solid var(--line-strong); padding-top: var(--s-4); display: grid; gap: var(--s-2); align-content: start; }
.metrics dt { color: var(--muted); font-size: var(--t-small); }
.metrics dd { margin: 0; font: 500 var(--t-card)/1.3 var(--font-text); letter-spacing: -0.01em; }
@media (max-width: 719px) { .metrics { grid-template-columns: minmax(0, 1fr); } }
.demo { margin-bottom: var(--s-8); display: grid; gap: var(--s-4); }
.demo__frame { position: relative; aspect-ratio: 16 / 10; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); overflow: hidden; display: grid; place-items: center; }
.demo__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.demo__links { display: flex; flex-wrap: wrap; gap: var(--s-4) var(--s-6); align-items: center; }
.cover { margin-bottom: var(--s-8); border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.cover img { display: block; width: 100%; height: auto; max-height: 520px; object-fit: contain; }
.group-title { margin: var(--s-7) 0 var(--s-5); font-size: var(--t-h3); }
.plist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s-6); }
@media (max-width: 719px) { .plist { grid-template-columns: minmax(0, 1fr); } }
.pnav { display: flex; justify-content: space-between; gap: var(--s-5); flex-wrap: wrap; margin-top: var(--s-9); }

/* about: the dial */
.about { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-8); align-items: start; }
@media (max-width: 899px) { .about { grid-template-columns: minmax(0, 1fr); } }
.dial { width: 100%; max-width: 560px; justify-self: start; }
.dial svg { width: 100%; height: auto; display: block; overflow: visible; }
.dial__ring { transform-origin: 250px 250px; animation: dial-turn 240s linear infinite; }
@keyframes dial-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dial__ring { animation: none; } }
.dial__ring.is-paused { animation-play-state: paused; }
.dial__cell { fill: transparent; stroke: none; cursor: pointer; pointer-events: all; }
.dial__sign { fill: none; stroke: var(--steel); stroke-opacity: .5; }
.dial__a { outline: none; }
.dial__a:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
.dial__a:hover .dial__cell, .dial__a:focus-visible .dial__cell, .dial__a.is-on .dial__cell { fill: color-mix(in oklab, var(--accent) 30%, transparent); stroke: var(--accent); stroke-opacity: 1; filter: drop-shadow(0 0 8px rgb(217 174 85 / .6)); }
.dial__a:focus-visible .dial__cell { stroke: var(--action); stroke-width: 2; }
.dial__read { min-height: 5.5em; margin-top: var(--s-4); font-size: var(--t-body); }
.dial__read b { color: var(--accent); font-weight: 500; }
.fine { color: color-mix(in oklab, var(--ink) 75%, var(--muted)); font-size: var(--t-small); }
.cv-links { display: flex; gap: var(--s-4); flex-wrap: wrap; }

/* quick CV */
.cv { max-width: 860px; }
.cv h2 { font-size: var(--t-h3); margin: var(--s-5) 0 var(--s-3); }
.cv ul { display: grid; gap: var(--s-2); }
.cv li { display: grid; grid-template-columns: minmax(0, 16rem) minmax(0, 1fr); gap: var(--s-4); }
.cv li > b { font-weight: 500; }
@media (max-width: 639px) { .cv li { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.cv__bar .btn.btn--secondary, .cv-links .btn.btn--secondary { padding-inline: 0; }
.cv__bar { display: flex; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-6); }

/* 404 */
.lost { min-height: 100svh; display: grid; align-content: center; justify-items: start; gap: var(--s-5); padding-top: var(--nav); }
.lost svg { width: min(100%, 720px); height: auto; overflow: visible; }
.lost__trace { fill: none; stroke: var(--steel); stroke-opacity: .5; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lost__tail { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 520; stroke-dashoffset: 520; animation: lost-draw 2.4s ease-out forwards; }
.lost__fox { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
@keyframes lost-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .lost__tail { animation: none; stroke-dashoffset: 0; } }

@media print {
  html, body { background: #fff !important; color: #000 !important; }
  .nav, .footer, .no-print, .skip-link, .nav__toggle { display: none !important; }
  .page { padding-top: 0; }
  .cv, .cv * { color: #000 !important; }
  .cv a { text-decoration: none; }
  .cv h1 { font-size: 26pt; }
  .cv h2 { font-size: 12pt; margin: 8pt 0 3pt; border-bottom: .5pt solid #000; }
  .cv li { font-size: 9.5pt; line-height: 1.3; gap: 8pt; grid-template-columns: 11rem 1fr; }
  .cv p { font-size: 10pt; }
  @page { size: A4; margin: 14mm; }
}


/* the two overlay lists must not swallow the pointer; only the star links take it */
.sky__stars, .sky__labels { pointer-events: none; }
.sky__star { pointer-events: auto; }

/* in-page demos size themselves; only iframe demos use the fixed 16:10 frame */
.demo__frame--live { aspect-ratio: auto; display: block; overflow: visible; border: 0; background: none; border-radius: 0; min-height: 120px; }
.demo__frame--live .dm { width: 100%; }

/* ---- starter cards: lift, gold glow, slow zoom on the picture; the live card holds a turning board */
#featured .card { transition: transform .3s var(--ease, ease); }
#featured .card:hover, #featured .card:focus-within { transform: translateY(-6px); }
#featured .panel .frame__img { transition: transform .8s var(--ease, ease); }
#featured .card:hover .panel .frame__img { transform: scale(1.06); }
#featured .panel--gif .card:hover .frame__img, #featured .card:hover .panel--gif .frame__img { transform: translate(-50%, -50%) scale(1.12); }
#featured .panel[data-live] .frame__img { opacity: .5; }
#featured .panel[data-live]:has(canvas) .frame__img { opacity: 0; }
#featured .panel[data-live] { cursor: grab; }

/* ---- lab bench: filter chips and a grid of cards with a picture each */
.bgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: var(--s-5); margin-top: var(--s-5); padding: 0; list-style: none; }
.bcard--wide { grid-column: span 2; }
.bcard { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: transform .3s var(--ease, ease), border-color .25s, box-shadow .25s; }
.bcard:hover, .bcard:focus-within { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 14px 40px -12px rgb(217 174 85 / .4); }
.bcard__thumb { display: block; min-height: 0; overflow: hidden; background: #0c0b09; position: relative; }
.bcard__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .7s var(--ease, ease); }
.bcard:hover .bcard__thumb img { transform: scale(1.07); }
.bcard__tile { position: absolute; inset: 0; display: grid; align-content: center; justify-items: start; gap: var(--s-2); padding: var(--s-5); background:
  linear-gradient(135deg, transparent 49%, color-mix(in oklab, var(--accent) 22%, transparent) 49.5% 50.5%, transparent 51%) 0 0 / 38px 38px, #14120f; }
.bcard__tile b { font: 500 clamp(22px, 2.4vw, 30px)/1.1 var(--font-mono); color: var(--accent); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.bcard__tile i { font-style: normal; font-size: var(--t-small); color: var(--muted); }
.bcard__body { display: grid; gap: var(--s-2); padding: var(--s-4); align-content: start; }
.bcard__body h3 { font-size: var(--t-body); font-weight: 500; line-height: 1.3; }
.bcard__body h3 a { text-decoration: none; }
.bcard__body p { color: var(--ink); font-size: var(--t-small); }
.bcard__body b { color: var(--ink); font-weight: 500; }
@media (prefers-reduced-motion: reduce) { .bcard, #featured .card, .bcard__thumb img, #featured .panel .frame__img { transition: none; } }
.grid--cards { row-gap: var(--s-7); margin-top: var(--s-6); }

.dial__list { margin: var(--s-2) 0 0; padding: 0; list-style: none; display: grid; gap: 0; }
.dial__list .link { display: inline-flex; min-height: 32px; align-items: center; }
.dial__read { min-height: 11em; }


/* ---- about: large portrait and the three lenses */
.about-photo { margin: 0 0 var(--s-6); max-width: 520px; border: 1px solid var(--line-strong); position: relative; overflow: hidden; background: #0c0b09; box-shadow: 0 24px 60px -24px rgb(217 174 85 / .35); }
.about-photo::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 1px rgb(217 174 85 / .35), inset 0 -80px 80px -40px rgb(20 18 15 / .6); pointer-events: none; }
.about-photo img { display: block; width: 100%; height: auto; }
.lenses { display: grid; gap: var(--s-4); align-content: start; }
.lenses__title { font-size: var(--t-h3); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-btn); padding: 3px; gap: 3px; width: max-content; max-width: 100%; }
.seg__b { min-height: 44px; padding: 0 var(--s-4); border: 0; border-radius: calc(var(--r-btn) - 2px); background: transparent; color: var(--ink); font: 500 var(--t-small)/1 var(--font-text); cursor: pointer; transition: background .25s var(--ease, ease), color .25s var(--ease, ease); }
.seg__b[aria-selected="true"] { background: var(--accent); color: var(--accent-ink, #14120f); }
.seg__b:focus-visible, .palace__b:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
@keyframes lens-in { from { opacity: 0; translate: 0 12px; } }
.lens:not([hidden]) { animation: lens-in .45s var(--ease, ease) both; }
.reads { display: grid; gap: 0; margin: var(--s-4) 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.read { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); gap: var(--s-1) var(--s-4); padding: var(--s-3) 0; border-bottom: 1px solid var(--line); font-size: var(--t-small); }
.read__n { color: var(--accent); font-weight: 500; }
.read__n span { color: var(--muted); font-weight: 400; }
.read__t { color: var(--ink); }
.read__l { grid-column: 2; font-size: var(--t-label); }
@media (max-width: 539px) { .read { grid-template-columns: minmax(0, 1fr); } .read__l { grid-column: 1; } }
.palaces { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-2); margin: var(--s-4) 0 0; padding: 0; list-style: none; }
@media (max-width: 479px) { .palaces { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.palace__b { display: grid; align-content: space-between; width: 100%; min-height: 64px; padding: var(--s-2); border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; transition: border-color .25s var(--ease, ease), background .25s var(--ease, ease), translate .25s var(--ease, ease); }
.palace__b b { font: 500 var(--t-small)/1.2 var(--font-text); overflow-wrap: anywhere; }
.palace__b i { font-style: normal; font-size: var(--t-label); color: var(--muted); overflow-wrap: anywhere; }
.palace__b:hover { border-color: var(--accent); translate: 0 -2px; }
.palace__b[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 16%, var(--surface)); }
.palace__b[aria-pressed="true"] b { color: var(--accent); }
@keyframes pal-in { from { opacity: 0; translate: 0 8px; } }
.palace__read { min-height: 9em; margin-top: var(--s-3); font-size: var(--t-small); }
.palace__read.is-in { animation: pal-in .35s var(--ease, ease) both; }
.palace__read b { color: var(--accent); font-weight: 500; }
.palace__read em { font-style: normal; color: var(--steel); }
.nums { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); margin: var(--s-4) 0; padding: 0; list-style: none; }
.num { display: grid; gap: var(--s-1); padding: var(--s-4); border: 1px solid var(--line-strong); background: var(--surface); }
.num__v { font: 500 56px/1 var(--font-mono); color: var(--accent); font-variant-numeric: tabular-nums; }
.num__n { font-weight: 500; }
.num__h { color: var(--muted); font-size: var(--t-small); }
@media (prefers-reduced-motion: reduce) { .lens:not([hidden]) { animation: none; } .palace__b, .palace__read.is-in { transition: none; animation: none; } }

/* the three hero figures span the container, first on its left line and last on its right line */
@media (min-width: 1024px) { .hero--sky .hero__facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; } }
@media (max-width: 639px) {
  .bgrid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; gap: var(--s-1); margin-top: var(--s-4); }
  .bcard--wide { grid-column: auto; }
  .bcard { grid-template-rows: none; grid-template-columns: 128px minmax(0, 1fr); min-height: 80px; }
  .bcard__body { padding: 4px var(--s-3); gap: 2px; align-content: center; }
  .bcard__body h3 { font-size: 14px; line-height: 1.25; }
  .bcard__body p { font-size: 12.5px; line-height: 1.3; }
  .bench__link { display: none; }
  .bcard__thumb img { width: calc(100% - var(--s-2)); margin-left: var(--s-2); }
  .bcard__tile { padding: var(--s-2); } .bcard__tile b { font-size: 16px; background: #14120f; } .bcard__tile i { display: none; }
}

.bcard__thumb img[src$=".gif"] { width: 160px; height: 160px; object-fit: contain; position: absolute; inset: 0; margin: auto; }
.toolrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.hero--sky .hero__facts dt { color: var(--ink); }

/* the three hero figures sit in the normal flow under the buttons (the kit pins them to the section floor, over the words) */
.hero--photo.hero--sky[data-calm] .hero__facts { position: static; margin: var(--s-6) 0 0; }
.hero--sky .hero-text { gap: var(--s-2); }
@media (max-height: 820px) and (min-width: 640px) { .portrait { width: 72px; height: 72px; } .hero--sky .hero__text { gap: var(--s-4); } .hero--photo.hero--sky[data-calm] .hero__facts { margin-top: var(--s-5); } .hero--sky h1 { font-size: clamp(40px, 5.2vw, 76px); } }
/* demos never push a phone sideways */
.dm, .dm select, .dm label { min-width: 0; max-width: 100%; }
.dm .dm-row { min-width: 0; }
@media (min-width: 640px) { .hero--photo.hero--sky[data-calm] .hero__facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-6); width: 100%; } }
@media (min-width: 640px) { .hero--photo.hero--sky[data-calm] .hero__facts > * { grid-column: auto; } }
.demo { grid-template-columns: minmax(0, 1fr); } .demo > * { min-width: 0; }
@media (max-width: 639px) { .footer__lede { display: none; } .closing__links .footer__col ul { gap: 0; } }

/* ---- a statement section of its own (word-highlight), featured cards in three layouts, two bench sections of two screens each */
main > .statement > .wrap { justify-content: flex-start; padding-top: var(--s-7); }
.fill.grid--cards { grid-auto-rows: 1fr; row-gap: var(--card-gap, 24px); margin-top: var(--s-5); min-height: 0; }
.fill.grid--cards > .card { display: flex; flex-direction: column; gap: var(--s-2); min-height: 0; }
.card--wide { display: grid !important; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); grid-template-rows: auto 1fr; column-gap: var(--s-6); align-content: stretch; }
.card--wide > h3, .card--wide > p { grid-column: 1; }
.card--wide > .panel { grid-column: 2; grid-row: 1 / span 2; }
.card--tile > .panel { order: -1; }
@media (max-width: 639px) { .card--wide { display: flex !important; flex-direction: column; } .card--wide > .panel { order: -1; } }
.benchsec .bench__all { margin: 0; }
.bgrid.fill, .grid.fill { flex: 1 1 0; }
@media (max-width: 639px) { .closing__links .footer__legal { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; } .closing__links .footer__legal .fine { order: 3; flex-basis: 100%; font-size: 12px; line-height: 1.35; } }
.bcard--wide .bcard__thumb img { object-fit: contain; }
@media (max-width: 639px) { footer.closing { --padb: 24px; } .bcard--wide .bcard__thumb img { object-fit: cover; } }
@media (max-width: 639px) { .fill.grid--cards { grid-auto-rows: auto; } .fill.grid--cards > .card { min-height: auto; } }
@media (max-width: 1279px) { main > .section > .wrap > .fill { flex: 1 0 auto; } }

/* ---- the toolbox: the heading on the left and a diagram card from column 7; below, four ruled rows, each one a single row of equal cells from the left line to the right */
.toolhead { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); align-items: start; }
.toolhead > .section-head { grid-column: 1 / span 6; }
main .toolhead__visual.panel { background-color: var(--surface) !important; background-image: none; }
.toolhead__visual { --p-h: clamp(150px, calc(100svh - 650px), 330px); grid-column: 7 / -1; align-self: start; }
.toolgrid { display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(min-content, 1fr); min-width: 0; margin-top: var(--s-5); min-height: 0; border-bottom: 1px solid var(--line); }
.toolgroup { display: grid; align-content: center; min-width: 0; min-height: 0; padding: var(--s-4) 0; border-top: 1px solid var(--line); }
.toolgroup__body { display: grid; gap: var(--s-3); min-width: 0; }
.toolgroup__n { color: var(--accent); font: 500 var(--t-small)/1.2 var(--font-mono); letter-spacing: .02em; }
.tools .toolrow { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
.tools .toolrow .ic-chip { display: flex; width: 100%; max-width: 100%; height: 48px; padding: 0 var(--s-3); border-radius: var(--r-sm); white-space: normal; line-height: 1.2; font-size: var(--t-small); }
.tools .toolrow .ic-chip > img.ic { flex: none; }
.tools .ic-name { min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.bench__all { margin-top: var(--s-5); }
main > .tools > .wrap > .toolgrid.fill { flex: 1 0 auto; }
@media (min-width: 1280px) and (max-height: 820px) { .toolgrid { margin-top: var(--s-3); } .toolgroup { padding: var(--s-2) 0; } .toolgroup__body { gap: var(--s-2); } .tools .toolrow .ic-chip { height: 44px; } }
@media (max-width: 1279px) {
  .tools .toolrow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .toolgrid { grid-auto-rows: auto; }
}
@media (max-width: 899px) {
  .toolhead { display: block; }
  .toolhead__visual { --p-h: 264px; max-width: 460px; margin-top: var(--s-4); }
  main > .tools > .wrap > .toolgrid.fill { flex: 0 0 auto; }
}
}
@media (max-width: 639px) { .tools .ic-chip--lg > .ic { --ic-s: 18px; } .tools .ic-dark .ic-chip > img.ic { padding: 1px; } .toolgroup { padding: var(--s-3) 0; } .toolgrid { margin-top: var(--s-4); } }
@media (max-width: 479px) {
  .tools .toolrow { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
  .tools .toolrow .ic-chip { height: auto; min-height: 40px; padding: 0 var(--s-2); }
  main > .tools > .wrap { display: flex; flex-direction: column; }
  main > .tools > .wrap > .toolgrid.fill { flex: 1 0 auto; grid-auto-rows: minmax(min-content, 1fr); }
  .toolgrid { margin-top: var(--s-3); }
  .toolgroup { padding: var(--s-2) 0; }
  .toolgroup__body { gap: var(--s-2); }
}

/* ---- view transitions between pages: the project title morphs from the clicked flame or card (names are set in Base.astro) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-group(proj-title) { animation-duration: .5s; animation-timing-function: var(--ease, ease); }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; }
}

/* ---- phone: a fixed contact bar for people hiring (CV, Upwork, GitHub); hidden while the menu sheet is open and in print */
.quickbar { display: none; }
@media (max-width: 768px) {
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .quickbar {
    position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; gap: var(--s-2); align-items: center;
    padding: 6px; border: 1px solid var(--line-strong); border-radius: calc(var(--r-btn, 8px) + 6px); background: color-mix(in oklab, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  }
  .quickbar .btn { flex: 1 1 0; min-height: 44px; height: 44px; justify-content: center; padding: 0 var(--s-3); }
  body:has(.nav.is-open) .quickbar, body.at-foot .quickbar { display: none; }
}
@media print { .quickbar { display: none !important; } }

/* the fox's nose reaches the second headline line from 1281px up: a smaller headline keeps ~60px clear of it */
@media (min-width: 1281px) and (min-height: 821px) { .hero--sky h1 { font-size: clamp(44px, 5.3vw, 76px); } }

/* phone: a card's title link is a full-height touch target, not a 23px line */
@media (max-width: 639px) { #featured .card h3 a { display: inline-flex; align-items: center; min-height: 44px; } }

.tools img.ic-sq { border-radius: 8px; }

/* the toolbox diagram holds still: a node changes colour at once when its pulse reaches it, with no fade that starts on scroll */
.toolhead__visual .dg-node, .toolhead__visual .dg-node * { transition: none !important; }
