/* K Visuals site. Every value is a token from tokens.css or a step on the 4px grid. Rules: DESIGN.md. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
/* Smooth scrolling only when motion is allowed (halftone.js sets data-motion; localhost always moves). */
:root[data-motion="on"] { scroll-behavior: smooth; }
body {
  background: var(--ground);
  color: var(--text);
  font: var(--weight-ui) var(--text-reading) / var(--leading-reading) var(--font-sans);
  letter-spacing: var(--tracking-ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-weight: var(--weight-ui); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; letter-spacing: inherit; background: none; border: 0; cursor: pointer; }
ul, ol { list-style: none; }
svg, canvas { display: block; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 2px; }
.icon { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.skip {
  position: absolute; z-index: 60; left: var(--page-x); top: -100px;
  height: var(--control-h); padding: 0 14px; display: inline-flex; align-items: center;
  border-radius: var(--radius-control); background: var(--surface); box-shadow: var(--shadow-button);
  font-size: var(--text-body); line-height: var(--leading-body);
}
.skip:focus { top: var(--space-4); }

/* ---------- Header: signature, section toggle, link pills. No border, no background of its own. ---------- */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: var(--space-6) var(--page-x) var(--space-8);
  /* a fade in the ground colour, so content scrolling under the header softens instead of colliding */
  background: linear-gradient(to bottom, var(--ground) 55%, transparent);
  pointer-events: none; /* the cursor still reaches the halftone through the fade */
}
.site-header > * { pointer-events: auto; }

.signature { justify-self: start; display: inline-flex; align-items: center; color: var(--text); }
.signature svg { width: 66px; height: 27px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.signature path { stroke-dasharray: 1; stroke-dashoffset: 0; }
:root[data-motion="on"] .signature.draw path { animation: sign 900ms var(--ease-out) 150ms both; }
@keyframes sign { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

/* The section toggle: a well with one raised white pill that slides to the section in view. */
.toggle {
  position: relative; justify-self: center;
  display: flex; gap: var(--space-1); padding: var(--space-1);
  border-radius: var(--radius-full); background: var(--well);
}
.toggle a {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; justify-content: center;
  height: var(--control-h-pill); padding: 0 11px; border-radius: var(--radius-full);
  font-size: var(--text-body); line-height: var(--leading-body); white-space: nowrap;
  color: var(--text-secondary);
  transition: color var(--dur-hover) var(--ease-out);
}
@media (hover: hover) { .toggle a:hover { color: var(--text); } }
.toggle a[aria-current="true"] { color: var(--text); }
.toggle-pill {
  position: absolute; z-index: 0; top: var(--space-1); left: 0;
  width: 0; height: var(--control-h-pill);
  border-radius: var(--radius-full); background: var(--surface); box-shadow: var(--shadow-toggle);
}
.toggle.ready .toggle-pill { transition: transform var(--dur-move) var(--ease-spring), width var(--dur-move) var(--ease-spring); }
:root[data-motion="off"] .toggle.ready .toggle-pill { transition: none; }
/* Without JavaScript the current link carries the pill itself. */
.toggle:not(.ready) a[aria-current="true"] { background: var(--surface); box-shadow: var(--shadow-toggle); }

.link-pills { justify-self: end; display: flex; gap: var(--space-2); }
.pill {
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: var(--control-h-pill); padding: 0 var(--space-2) 0 10px; border-radius: var(--radius-full);
  background: var(--surface); box-shadow: var(--shadow-button);
  font-size: var(--text-body); line-height: var(--leading-body); white-space: nowrap;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-hover) var(--ease-out), transform var(--dur-hover) var(--ease-out);
}
.pill .icon { color: var(--text-faint); transition: color var(--dur-hover) var(--ease-out); }
@media (hover: hover) {
  .pill:hover { background: var(--ground); }
  .pill:hover .icon { color: var(--text); }
}
.pill:active { transform: scale(.97); }
/* Brand hover (from Wonder: DS Navigation, Link pills - Colours): at rest the pills are white like every control;
   on hover (and keyboard focus) a pill takes the colour of where it goes. */
.pill-github { --pill-bg: var(--primary-bg); }
.pill-linkedin { --pill-bg: var(--brand-linkedin); }
.pill-brand { transition: background-color var(--dur-hover) var(--ease-out), color var(--dur-hover) var(--ease-out), transform var(--dur-hover) var(--ease-out); }
@media (hover: hover) {
  .pill-brand:hover { background: var(--pill-bg); color: var(--primary-fg); }
  .pill-brand:hover .icon { color: currentColor; }
}
.pill-brand:focus-visible { background: var(--pill-bg); color: var(--primary-fg); }
.pill-brand:focus-visible .icon { color: currentColor; }

/* ---------- Home: the halftone fills the window; the introduction sits bottom-left. ---------- */
.hero { position: relative; height: 100svh; min-height: 640px; overflow: hidden; }
.stage { position: absolute; inset: 0; }
.stage canvas { width: 100%; height: 100%; }

.intro { position: absolute; z-index: 2; left: var(--page-x); bottom: var(--space-6); max-width: 30rem; }
.intro-name, .intro-role { font-size: var(--text-body); line-height: var(--leading-body); }
.intro-role { color: var(--text-secondary); }
.intro-text { margin-top: var(--space-3); max-width: 28rem; line-height: 28px; }

/* A hover word: the only serif in a sentence. Dotted gray-9 underline, solid gray-12 while its card is open. */
.word {
  font-family: var(--font-serif); font-style: italic; font-weight: 400;
  font-size: var(--word-size); line-height: 1; letter-spacing: 0;
  color: var(--text);
  text-decoration: underline dotted var(--text-faint);
  text-decoration-thickness: 1px; text-underline-offset: 4px;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.word:hover, .word[data-open] { text-decoration-style: solid; text-decoration-color: var(--text); }

/* The card a hover word opens. Fixed, so it can sit over the halftone; placed by site.js. */
.pop {
  position: fixed; z-index: 50; left: 0; top: 0;
  width: 264px; padding: var(--space-3);
  border-radius: var(--radius-container); background: var(--surface); box-shadow: var(--shadow-popover);
  font-size: var(--text-body); line-height: var(--leading-body);
  opacity: 0; transform: scale(.97); visibility: hidden; pointer-events: none;
  transition: opacity var(--dur-pop-out) var(--ease-out), transform var(--dur-pop-out) var(--ease-out), visibility 0s var(--dur-pop-out);
}
.pop.open {
  opacity: 1; transform: none; visibility: visible;
  transition: opacity var(--dur-pop-in) var(--ease-out), transform var(--dur-pop-in) var(--ease-out), visibility 0s;
}
:root[data-motion="off"] .pop { transform: none; }
.pop-shot {
  display: grid; place-items: center; height: 100px; margin-bottom: var(--space-3);
  border-radius: var(--radius-control); background: var(--well);
  color: var(--text-secondary); font-size: var(--text-meta); line-height: var(--leading-meta);
}
.pop-meta { font-size: var(--text-meta); line-height: var(--leading-meta); color: var(--text-secondary); }
.pop-place { width: 232px; display: grid; gap: var(--space-1); }
.pop-time { font: 400 24px / 32px var(--font-mono); letter-spacing: 0; }
.pop-link { display: flex; align-items: center; gap: var(--space-3); }
.pop-link > span:nth-child(2) { flex: 1; }
.pop-link .icon { color: var(--text-faint); }
.pop-icon { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: var(--radius-control); background: var(--well); }
.pop-icon .icon { width: 16px; height: 16px; stroke-width: 2; color: var(--text); }
.pop-handle { display: block; font: 400 var(--text-meta) / var(--leading-meta) var(--font-mono); letter-spacing: 0; color: var(--text-secondary); }
.num { margin-right: var(--space-2); font: 400 var(--text-meta) / var(--leading-meta) var(--font-mono); letter-spacing: 0; color: var(--text-faint); }

/* ---------- Sections: a reading column on the ground ---------- */
main { position: relative; z-index: 1; }
.section { max-width: calc(var(--column-max) + 2 * var(--page-x)); margin: 0 auto; padding: var(--space-24) var(--page-x) 0; scroll-margin-top: 64px; }
.section-title { font-size: var(--text-section); line-height: var(--leading-section); margin-bottom: var(--space-6); }

/* A case study is one raised white card. */
.case {
  --shadow-primary: 0 0 0 1px var(--surface);
  padding: var(--space-6); border-radius: var(--radius-container);
  background: var(--surface); box-shadow: var(--shadow-card);
}
.case + .case { margin-top: var(--space-6); }
.case-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); }
.case-kind { font-size: var(--text-body); line-height: var(--leading-body); color: var(--text-secondary); text-align: right; }
.case-title {
  font-size: var(--text-display); line-height: var(--leading-display); letter-spacing: var(--tracking-display);
  margin: var(--space-2) 0 var(--space-6);
}
/* Empty slot for a screenshot: swap the div for an <img> with the same class. */
.shot {
  display: grid; place-items: center; aspect-ratio: 2 / 1; width: 100%; object-fit: cover;
  margin-bottom: var(--space-6); border-radius: var(--radius-control); background: var(--well);
  color: var(--text-secondary); font-size: var(--text-meta); line-height: var(--leading-meta);
}
.case-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 240px; gap: var(--space-8) var(--space-12); }
.col-label { font-size: var(--text-body); line-height: var(--leading-body); margin-bottom: var(--space-1); }
.col-label.built { margin-top: var(--space-6); }
.col-text { color: var(--text-secondary); max-width: 52ch; }
.decision { font-size: var(--text-title); line-height: var(--leading-title); max-width: 30ch; }
.stack { margin-bottom: var(--space-6); }
.project-links { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-4); }

/* Buttons: one black primary per surface; white secondary; dotted text link. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-h); padding: 0 14px; border-radius: var(--radius-control);
  font-size: var(--text-body); line-height: var(--leading-body); white-space: nowrap;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-hover) var(--ease-out), background-color var(--dur-hover) var(--ease-out);
}
.btn:active { transform: scale(.97); }
:root[data-motion="off"] .btn:active, :root[data-motion="off"] .pill:active { transform: none; }
.btn-primary { background: var(--primary-bg); color: var(--primary-fg); box-shadow: var(--shadow-primary); }
.btn-secondary { background: var(--surface); box-shadow: var(--shadow-button); }
.btn-secondary .icon { color: var(--text-faint); }
@media (hover: hover) {
  .btn-primary:hover { background: var(--primary-hover); }
  .btn-secondary:hover { background: var(--ground); }
}
.text-link {
  font-size: var(--text-body); line-height: var(--leading-body);
  text-decoration: underline dotted var(--text-faint); text-decoration-thickness: 1px; text-underline-offset: 4px;
}
.text-link:hover { text-decoration-style: solid; text-decoration-color: var(--text); }

/* How I work */
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-8) var(--space-6); }
.steps li { padding-top: var(--space-4); border-top: var(--hairline) solid var(--line); }
.step-title { font-size: var(--text-title); line-height: var(--leading-title); margin: var(--space-2) 0 var(--space-1); }
.step-text { color: var(--text-secondary); }

/* About */
.about-text { max-width: 60ch; }

/* ---------- Footer: identity, contact rows, K Visuals in dots ---------- */
.site-footer { margin-top: 128px; padding: var(--space-24) var(--page-x) var(--space-6); }
.footer-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-12); }
.footer-id p { font-size: var(--text-body); line-height: var(--leading-body); }
.footer-id .secondary { color: var(--text-secondary); }
.link-rows { width: min(520px, 100%); border-top: var(--hairline) solid var(--line); }
.link-rows li { border-bottom: var(--hairline) solid var(--line); }
.link-rows a, .link-rows .row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  min-height: 44px; font-size: var(--text-body); line-height: var(--leading-body);
}
.link-rows .value { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--text-secondary); transition: color var(--dur-hover) var(--ease-out); }
.link-rows .value .icon { color: var(--text-faint); }
@media (hover: hover) { .link-rows a:hover .value { color: var(--text); } }

/* The wordmark box keeps the word's proportions; wordmark.js draws the dots into the canvas.
   The fallback is the same word filled with a CSS dot grid, shown until the canvas has drawn (or if it can't). */
.wordmark { position: relative; container-type: inline-size; aspect-ratio: 100 / 30; margin: var(--space-16) 0 var(--space-6); }
.wordmark canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.wordmark-fallback {
  display: block; white-space: nowrap;
  font: 400 36cqw / 0.82 var(--font-serif); letter-spacing: -0.03em;
  color: transparent;
  background: radial-gradient(circle, var(--gray-12) 1.4px, transparent 1.6px) 0 0 / 5px 5px;
  -webkit-background-clip: text; background-clip: text;
}
.wordmark.is-drawn .wordmark-fallback { visibility: hidden; }
.footer-bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2) var(--space-4);
  padding-top: var(--space-4); border-top: var(--hairline) solid var(--line);
  font-size: var(--text-meta); line-height: var(--leading-meta); color: var(--text-secondary);
}

/* ---------- Tablet ---------- */
/* Icon sprite (no inline style, for the CSP), and the 404 page */
.sprite { position: absolute; }
.notfound {
  min-height: 100svh; max-width: calc(30rem + 2 * var(--page-x)); margin: 0 auto;
  padding: var(--space-12) var(--page-x);
  display: grid; align-content: center; justify-items: start; gap: var(--space-2);
}
.notfound-title { font-size: var(--text-display); line-height: var(--leading-display); letter-spacing: var(--tracking-display); font-weight: var(--weight-ui); }
.notfound-text { color: var(--text-secondary); margin-bottom: var(--space-4); }

@media (max-width: 1100px) {
  .case-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .case-cols > :last-child { grid-column: 1 / -1; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Phone ---------- */
@media (max-width: 767px) {
  /* The header scrolls away with the Home screen: signature on top, the toggle full width under it. */
  .site-header { position: absolute; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); padding: var(--space-4) var(--page-x) 0; background: none; }
  .signature { height: 44px; }
  .signature svg { width: 56px; height: 23px; }
  .toggle { justify-self: stretch; }
  .toggle a { flex: 1 1 auto; padding: 0 var(--space-2); font-size: 14px; }
  .link-pills { display: none; } /* GitHub and LinkedIn live in the footer on a phone */
  .intro { right: var(--page-x); }
  .intro-name, .intro-role { font-size: var(--text-reading); line-height: var(--leading-reading); }
  .section { padding-top: var(--space-16); scroll-margin-top: var(--space-4); }
  .case { padding: var(--space-4); }
  .case-title { font-size: 24px; line-height: 32px; }
  .case-cols { grid-template-columns: minmax(0, 1fr); }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .footer-top { flex-direction: column; }
  .link-rows { width: 100%; }
}
