/* =============================================================
   Matteo Filosa — personal site
   Dark-first "lab" theme. Tokens in :root, light theme overrides.
   ============================================================= */

/* ---------- Tokens ---------------------------------------------------- */
:root {
  color-scheme: dark;

  --bg:        #0a0c10;
  --bg-soft:   #0f1218;
  --surface:   #12161d;
  --surface-2: #171c25;
  --border:    #232a35;
  --border-soft: #1b212a;

  --text:      #e7ebf2;
  --text-dim:  #a2adbe;
  --text-faint:#6c7787;

  --accent:      #5ad1ff;
  --accent-ink:  #04121a;
  --accent-soft: rgba(90, 209, 255, 0.12);
  --accent-line: rgba(90, 209, 255, 0.35);
  --violet:      #b39dff;
  --amber:       #ffc46b;
  --green:       #6ee7a8;

  --grid-line: rgba(255, 255, 255, 0.035);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.4), 0 32px 64px -24px rgba(0,0,0,.75);

  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Space Grotesk', var(--font-sans);
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --maxw: 1120px;
  --gutter: clamp(1.15rem, 4vw, 2.5rem);
  --radius: 14px;
  --radius-sm: 9px;
  --nav-h: 60px;

  --ease: cubic-bezier(.22, .68, 0, 1);
}

html[data-theme='light'] {
  color-scheme: light;

  --bg:        #fbfcfe;
  --bg-soft:   #f4f6fa;
  --surface:   #ffffff;
  --surface-2: #f6f8fc;
  --border:    #dfe4ee;
  --border-soft: #eaeef5;

  --text:      #10141b;
  --text-dim:  #4e5a6b;
  --text-faint:#8894a5;

  --accent:      #0b6fd0;
  --accent-ink:  #ffffff;
  --accent-soft: rgba(11, 111, 208, 0.09);
  --accent-line: rgba(11, 111, 208, 0.28);
  --violet:      #6d4df0;
  --amber:       #b3701a;
  --green:       #12855b;

  --grid-line: rgba(10, 16, 30, 0.045);
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 10px 28px -14px rgba(16,24,40,.22);
  --shadow-lg: 0 1px 3px rgba(16,24,40,.06), 0 28px 56px -28px rgba(16,24,40,.28);
}

/* ---------- Reset ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 20px);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
ul, ol { list-style: none; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

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

::selection { background: var(--accent); color: var(--accent-ink); }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--accent); color: var(--accent-ink);
  padding: .6rem 1rem; border-radius: 8px; font-weight: 600;
  transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; text-decoration: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Typography ------------------------------------------------ */
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.2rem); }
h3 { font-size: 1.12rem; letter-spacing: -0.01em; }
p { text-wrap: pretty; }

.mono {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
}

/* ---------- Layout ---------------------------------------------------- */
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); width: 100%; }

.section { padding-block: clamp(3.5rem, 8vw, 6rem); position: relative; }
.section + .section { border-top: 1px solid var(--border-soft); }
.section--tint { background: var(--bg-soft); }

.section-head {
  display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 2.25rem;
}
.section-head .idx {
  font-family: var(--font-mono); font-size: .75rem; color: var(--accent);
  border: 1px solid var(--accent-line); background: var(--accent-soft);
  padding: .15rem .5rem; border-radius: 6px; letter-spacing: .06em;
}
.section-head .note { margin-left: auto; color: var(--text-faint); font-size: .86rem; }

/* ---------- Top bar --------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--nav-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid transparent;
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
.topbar.is-stuck { border-bottom-color: var(--border); }
.topbar .wrap { display: flex; align-items: center; gap: 1rem; }

.brand {
  display: inline-flex; align-items: center; gap: .6rem;
  font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em;
  color: var(--text); text-decoration: none; flex: none;
}
.brand:hover { text-decoration: none; }
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.nav { display: flex; gap: .15rem; margin-inline: auto; }
.nav a {
  color: var(--text-dim); font-size: .875rem; font-weight: 500;
  padding: .4rem .7rem; border-radius: 8px; text-decoration: none;
  transition: color .18s var(--ease), background .18s var(--ease);
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a[aria-current='true'] { color: var(--accent); background: var(--accent-soft); }

.topbar-actions { display: flex; align-items: center; gap: .5rem; flex: none; }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text-dim);
  transition: all .18s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--accent-line); background: var(--surface-2); }
.icon-btn svg { width: 16px; height: 16px; }

.kbd-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text-faint);
  padding: .35rem .6rem; font-size: .8rem;
  transition: all .18s var(--ease);
}
.kbd-btn:hover { color: var(--text); border-color: var(--accent-line); }
kbd {
  font-family: var(--font-mono); font-size: .68rem;
  border: 1px solid var(--border); border-radius: 5px;
  padding: .05rem .3rem; background: var(--surface-2); color: var(--text-dim);
}

/* ---------- Hero ------------------------------------------------------ */
.hero {
  position: relative;
  min-height: calc(100svh - var(--nav-h));
  display: flex; align-items: center;
  padding-block: clamp(2rem, 5vw, 3.5rem) clamp(3rem, 7vw, 5rem);
  overflow: hidden;
}
#hero-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 0; opacity: .85;
}
.hero::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(120% 80% at 15% 0%, transparent 30%, var(--bg) 92%),
    linear-gradient(to bottom, transparent 55%, var(--bg) 100%);
}
.hero .wrap { position: relative; z-index: 2; }

.hero-grid {
  display: grid; gap: clamp(2rem, 5vw, 3.5rem);
  grid-template-columns: 1fr;
  align-items: center;
}
@media (min-width: 880px) {
  .hero-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, .85fr); }
}

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-dim);
  border: 1px solid var(--border); background: var(--surface);
  padding: .3rem .7rem; border-radius: 100px; margin-bottom: 1.4rem;
}
.hero-eyebrow .pulse {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent);
  animation: pulse 2.6s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 55%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.hero h1 {
  font-size: clamp(2.7rem, 8vw, 4.6rem);
  font-weight: 700; letter-spacing: -.04em; line-height: 1.02;
  margin-bottom: 1rem;
}
.hero h1 .surname {
  background: linear-gradient(100deg, var(--text) 20%, var(--accent) 90%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero-role {
  font-family: var(--font-mono); font-size: clamp(.8rem, 1.6vw, .92rem);
  color: var(--text-dim); margin-bottom: 1.5rem; letter-spacing: .02em;
}
.hero-role .sep { color: var(--accent); margin-inline: .5rem; }
.hero-tagline {
  font-size: clamp(1.02rem, 2vw, 1.2rem); color: var(--text-dim);
  max-width: 56ch; margin-bottom: 2rem;
}

.hero-cta { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: 2.5rem; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1.05rem; border-radius: 10px; font-size: .9rem; font-weight: 550;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: all .18s var(--ease); text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--accent-line); background: var(--surface-2); transform: translateY(-1px); }
.btn svg { width: 15px; height: 15px; }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn--primary:hover { background: var(--accent); filter: brightness(1.08); border-color: transparent; }
.btn--ghost { background: transparent; }

.hero-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 1px; background: var(--border-soft);
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  overflow: hidden; max-width: 520px;
}
.hero-stats .stat { background: var(--bg); padding: .85rem 1rem; }
.hero-stats .stat b {
  display: block; font-family: var(--font-display); font-size: 1.5rem;
  font-weight: 700; letter-spacing: -.03em; line-height: 1.1;
}
.hero-stats .stat span {
  font-family: var(--font-mono); font-size: .64rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint);
}

.hero-portrait { position: relative; justify-self: center; }
.hero-portrait img {
  width: min(300px, 62vw); aspect-ratio: 1; object-fit: cover;
  border-radius: 20px; border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  filter: saturate(1.02);
}
.hero-portrait::before {
  content: ''; position: absolute; inset: -1px; border-radius: 21px;
  background: linear-gradient(150deg, var(--accent-line), transparent 45%);
  z-index: -1;
}

.scroll-hint {
  position: absolute; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
  z-index: 3; color: var(--text-faint); font-family: var(--font-mono);
  font-size: .64rem; letter-spacing: .16em; text-transform: uppercase;
  display: flex; flex-direction: column; align-items: center; gap: .45rem;
}
.scroll-hint .line {
  width: 1px; height: 28px;
  background: linear-gradient(to bottom, var(--accent), transparent);
  animation: drop 2.2s var(--ease) infinite;
}
@keyframes drop { 0%,100% { opacity: .25; transform: scaleY(.5); transform-origin: top; } 50% { opacity: 1; transform: scaleY(1); } }

/* ---------- News ------------------------------------------------------ */
.news-list { display: grid; gap: 0; border-top: 1px solid var(--border-soft); }
.news-item {
  display: grid; grid-template-columns: 92px 1fr; gap: 1.25rem;
  padding: 1rem 0; border-bottom: 1px solid var(--border-soft);
  align-items: baseline;
}
.news-item time {
  font-family: var(--font-mono); font-size: .74rem; color: var(--accent);
  letter-spacing: .04em; white-space: nowrap;
}
.news-item p { color: var(--text-dim); font-size: .95rem; }
.news-item em { color: var(--text); font-style: normal; font-weight: 550; }
@media (max-width: 600px) {
  .news-item { grid-template-columns: 1fr; gap: .3rem; }
}

/* ---------- About ----------------------------------------------------- */
.about-grid { display: grid; gap: clamp(2rem, 5vw, 3.5rem); grid-template-columns: 1fr; }
@media (min-width: 860px) { .about-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.about-body p { color: var(--text-dim); margin-bottom: 1rem; max-width: 66ch; }
.about-body p:first-child { color: var(--text); font-size: 1.06rem; }

.facts { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.facts dl { display: grid; }
.facts .row {
  display: grid; grid-template-columns: 96px 1fr; gap: .75rem;
  padding: .8rem 1.1rem; border-bottom: 1px solid var(--border-soft);
  font-size: .88rem;
}
.facts .row:last-child { border-bottom: 0; }
.facts dt { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); padding-top: .2rem; }
.facts dd { color: var(--text-dim); }

/* ---------- Cards ----------------------------------------------------- */
.cards { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); }

.card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.35rem;
  transition: transform .25s var(--ease), border-color .25s var(--ease), box-shadow .25s var(--ease);
  overflow: hidden;
}
.card::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), var(--accent-soft), transparent 42%);
  opacity: 0; transition: opacity .3s var(--ease);
}
.card:hover { transform: translateY(-3px); border-color: var(--accent-line); box-shadow: var(--shadow); }
.card:hover::before { opacity: 1; }
.card > * { position: relative; }
.card h3 { margin-bottom: .5rem; }
.card p { color: var(--text-dim); font-size: .92rem; }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .9rem; }
.chip {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .05em;
  padding: .18rem .5rem; border-radius: 100px;
  border: 1px solid var(--border); color: var(--text-faint); background: var(--surface-2);
  white-space: nowrap;
}
.chip[data-group='1'] { color: var(--accent); border-color: var(--accent-line); }
.chip[data-group='2'] { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 35%, transparent); }
.chip[data-group='3'] { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }

/* ---------- Knowledge graph ------------------------------------------- */
.graph-panel {
  margin-top: 2.5rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.graph-bar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .7rem 1rem; border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.graph-bar .legend { display: flex; gap: .9rem; flex-wrap: wrap; margin-right: auto; }
.graph-bar .legend span {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--font-mono); font-size: .68rem; color: var(--text-faint);
}
.graph-bar .legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.graph-wrap { position: relative; height: clamp(360px, 52vh, 520px); }
#graph-canvas { width: 100%; height: 100%; cursor: grab; touch-action: none; }
#graph-canvas.dragging { cursor: grabbing; }
.graph-tip {
  position: absolute; pointer-events: none; z-index: 5; max-width: 260px;
  background: var(--bg); border: 1px solid var(--accent-line); border-radius: 9px;
  padding: .5rem .7rem; font-size: .8rem; color: var(--text);
  box-shadow: var(--shadow); opacity: 0; transform: translateY(4px);
  transition: opacity .14s var(--ease), transform .14s var(--ease);
}
.graph-tip.show { opacity: 1; transform: translateY(0); }
.graph-tip .k { font-family: var(--font-mono); font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); display: block; }

/* ---------- Publications ---------------------------------------------- */
.pub-dash {
  display: grid; gap: 1px; background: var(--border-soft);
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 1.75rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.pub-dash > div { background: var(--bg); padding: 1rem 1.15rem; }
.pub-dash .k { font-family: var(--font-mono); font-size: .64rem; letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint); display: block; margin-bottom: .5rem; }
.pub-dash .v { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; letter-spacing: -.03em; }
.pub-dash .v small { font-size: .8rem; font-weight: 400; color: var(--text-faint); font-family: var(--font-sans); letter-spacing: 0; }

.year-bars { display: flex; align-items: flex-end; gap: 5px; height: 46px; }
.year-bars button {
  flex: 1; min-width: 8px; display: flex; flex-direction: column;
  justify-content: flex-end; height: 100%; gap: 4px; border-radius: 3px;
}
.year-bars .bar {
  width: 100%; background: var(--accent); border-radius: 3px 3px 0 0;
  opacity: .55; transition: opacity .2s var(--ease), transform .2s var(--ease);
  min-height: 3px;
}
.year-bars button:hover .bar, .year-bars button[aria-pressed='true'] .bar { opacity: 1; }
.year-bars button[aria-pressed='true'] .bar { box-shadow: 0 0 12px var(--accent-line); }
.year-bars .yl { font-family: var(--font-mono); font-size: .58rem; color: var(--text-faint); }

.pub-toolbar {
  display: flex; gap: .6rem; flex-wrap: wrap; align-items: center;
  margin-bottom: 1.25rem;
}
.search-box {
  display: flex; align-items: center; gap: .5rem; flex: 1 1 220px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  padding: .45rem .75rem;
}
.search-box svg { width: 15px; height: 15px; color: var(--text-faint); flex: none; }
.search-box input { border: 0; background: none; outline: none; width: 100%; font-size: .9rem; }
.search-box input::placeholder { color: var(--text-faint); }

.filter-pills { display: flex; gap: .35rem; flex-wrap: wrap; }
.pill {
  font-size: .78rem; padding: .38rem .75rem; border-radius: 100px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  transition: all .18s var(--ease); white-space: nowrap;
}
.pill:hover { color: var(--text); border-color: var(--accent-line); }
.pill[aria-pressed='true'] { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 550; }

.pub-list { display: grid; gap: 0; border-top: 1px solid var(--border-soft); }
.pub {
  display: grid; grid-template-columns: 78px 1fr; gap: 1.25rem;
  padding: 1.35rem 0; border-bottom: 1px solid var(--border-soft);
  transition: opacity .2s var(--ease);
}
.pub.dim { display: none; }
.pub-year { font-family: var(--font-mono); font-size: .78rem; color: var(--text-faint); padding-top: .2rem; }
.pub-year .type {
  display: block; margin-top: .35rem; font-size: .6rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint);
}
.pub h3 { font-size: 1.02rem; font-weight: 600; line-height: 1.4; margin-bottom: .4rem; font-family: var(--font-sans); letter-spacing: -.005em; }
.pub h3 a { color: var(--text); }
.pub h3 a:hover { color: var(--accent); text-decoration: none; }
.pub .authors { font-size: .86rem; color: var(--text-dim); margin-bottom: .3rem; }
.pub .authors .me { color: var(--text); font-weight: 650; }
.pub .venue { font-size: .84rem; color: var(--text-faint); font-style: italic; margin-bottom: .7rem; }
.pub .venue b { font-style: normal; color: var(--text-dim); font-weight: 550; }
.pub-links { display: flex; flex-wrap: wrap; gap: .4rem; }
.pub-links a, .pub-links button {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .05em;
  padding: .22rem .55rem; border-radius: 6px; border: 1px solid var(--border);
  color: var(--text-dim); background: var(--surface); transition: all .16s var(--ease);
  text-decoration: none;
}
.pub-links a:hover, .pub-links button:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); text-decoration: none; }
.badge-new {
  font-family: var(--font-mono); font-size: .6rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 40%, transparent);
  background: color-mix(in srgb, var(--green) 12%, transparent);
  padding: .1rem .4rem; border-radius: 5px; margin-left: .4rem; vertical-align: middle;
}
.bib {
  margin-top: .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-soft); overflow: hidden;
}
.bib pre {
  font-family: var(--font-mono); font-size: .72rem; line-height: 1.6;
  padding: .8rem 1rem; overflow-x: auto; color: var(--text-dim);
}
.bib .bib-bar { display: flex; justify-content: flex-end; padding: .35rem .5rem; border-top: 1px solid var(--border-soft); }
.empty-state { padding: 2rem 0; color: var(--text-faint); font-size: .9rem; }
@media (max-width: 600px) {
  .pub { grid-template-columns: 1fr; gap: .4rem; }
  .pub-year { display: flex; gap: .6rem; align-items: baseline; }
  .pub-year .type { margin-top: 0; }
}

/* ---------- Project cards --------------------------------------------- */
.project { display: flex; flex-direction: column; padding: 0; }
.project .thumb {
  aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden;
  border-bottom: 1px solid var(--border-soft); position: relative;
}
.project .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.project:hover .thumb img { transform: scale(1.04); }
.project .thumb.placeholder { display: grid; place-items: center; color: var(--text-faint); font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; }
.project .body { padding: 1.25rem; display: flex; flex-direction: column; flex: 1; }
.project .status {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: .5rem; display: flex; gap: .5rem; align-items: center;
}
.project .status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }
.project .status[data-status='released'] .dot { background: var(--green); }
.project .status[data-status='in progress'] .dot { background: var(--amber); }
.project .status[data-status='research prototype'] .dot { background: var(--violet); }
.project .sub { color: var(--text-faint); font-size: .82rem; margin-bottom: .6rem; }
.project .links { margin-top: auto; padding-top: 1rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.project .links a {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .05em;
  padding: .25rem .6rem; border-radius: 6px; border: 1px solid var(--border);
  color: var(--text-dim); background: var(--surface-2);
}
.project .links a:hover { color: var(--accent); border-color: var(--accent-line); text-decoration: none; }

/* ---------- Two-column list sections ---------------------------------- */
.split { display: grid; gap: clamp(2rem, 5vw, 3rem); grid-template-columns: 1fr; }
@media (min-width: 820px) { .split { grid-template-columns: 1fr 1fr; } }

.mini-head {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 1rem;
  padding-bottom: .5rem; border-bottom: 1px solid var(--border);
}
.entry-list { display: grid; }
.entry {
  padding: .9rem 0; border-bottom: 1px solid var(--border-soft);
  display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; align-items: baseline;
}
.entry .t { font-size: .93rem; font-weight: 550; }
.entry .m { font-family: var(--font-mono); font-size: .72rem; color: var(--text-faint); white-space: nowrap; }
.entry .d { grid-column: 1 / -1; font-size: .85rem; color: var(--text-dim); }

/* ---------- Timeline -------------------------------------------------- */
.timeline { position: relative; padding-left: 1.7rem; }
.timeline::before {
  content: ''; position: absolute; left: 5px; top: .5rem; bottom: .5rem; width: 1px;
  background: linear-gradient(to bottom, var(--accent-line), var(--border-soft));
}
.tl-item { position: relative; padding-bottom: 1.7rem; }
.tl-item::before {
  content: ''; position: absolute; left: -1.7rem; top: .5rem;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.tl-item .when { font-family: var(--font-mono); font-size: .72rem; color: var(--accent); }
.tl-item .what { font-weight: 600; font-size: 1rem; margin-top: .2rem; }
.tl-item .where { color: var(--text-dim); font-size: .88rem; }
.tl-item .detail { color: var(--text-faint); font-size: .86rem; margin-top: .3rem; }

/* ---------- Trace mirror ---------------------------------------------- */
.trace-panel {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.trace-head {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .75rem 1.1rem; border-bottom: 1px solid var(--border-soft); background: var(--surface-2);
}
.trace-head .rec { display: inline-flex; align-items: center; gap: .45rem; font-family: var(--font-mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }
.trace-head .rec .dot { width: 7px; height: 7px; border-radius: 50%; background: #ff5f56; animation: pulse-rec 1.6s infinite; }
.trace-head.off .rec .dot { background: var(--text-faint); animation: none; }
@keyframes pulse-rec { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.trace-head .spacer { margin-left: auto; }

.trace-body { display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .trace-body { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); } }
.trace-canvas-wrap { position: relative; aspect-ratio: 16 / 10; background: var(--bg-soft); border-bottom: 1px solid var(--border-soft); }
@media (min-width: 900px) { .trace-canvas-wrap { border-bottom: 0; border-right: 1px solid var(--border-soft); } }
#trace-canvas { width: 100%; height: 100%; }
.trace-side { padding: 1.1rem; display: grid; gap: 1.1rem; align-content: start; }

.trace-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
.trace-stats .s { border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: .6rem .75rem; background: var(--bg-soft); }
.trace-stats .s b { display: block; font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.trace-stats .s span { font-family: var(--font-mono); font-size: .6rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); }

.dwell { display: grid; gap: .45rem; }
.dwell .row { display: grid; grid-template-columns: 92px 1fr 40px; gap: .6rem; align-items: center; font-size: .78rem; }
.dwell .row .name { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dwell .row .track { height: 6px; border-radius: 100px; background: var(--surface-2); overflow: hidden; }
.dwell .row .fill { height: 100%; border-radius: 100px; background: linear-gradient(90deg, var(--accent), var(--violet)); transition: width .4s var(--ease); }
.dwell .row .val { font-family: var(--font-mono); font-size: .68rem; color: var(--text-faint); text-align: right; }

.privacy-note {
  font-size: .8rem; color: var(--text-faint); padding: .75rem 1.1rem;
  border-top: 1px solid var(--border-soft); background: var(--bg-soft);
  display: flex; gap: .6rem; align-items: flex-start;
}
.privacy-note svg { width: 15px; height: 15px; flex: none; margin-top: .2rem; color: var(--green); }

/* ---------- Contact --------------------------------------------------- */
.contact-grid { display: grid; gap: clamp(2rem, 5vw, 3rem); grid-template-columns: 1fr; }
@media (min-width: 820px) { .contact-grid { grid-template-columns: 1fr 1fr; } }
.contact-mail {
  font-family: var(--font-display); font-size: clamp(1.15rem, 3vw, 1.7rem);
  font-weight: 600; letter-spacing: -.02em; word-break: break-word;
}
.link-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-top: 1.5rem; }
.link-grid a {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  border: 1px solid var(--border); border-radius: 10px; padding: .7rem .9rem;
  color: var(--text); background: var(--surface); font-size: .88rem; font-weight: 500;
  transition: all .18s var(--ease);
}
.link-grid a:hover { border-color: var(--accent-line); background: var(--surface-2); text-decoration: none; transform: translateY(-1px); }
.link-grid a span { color: var(--text-faint); font-family: var(--font-mono); font-size: .8rem; }

/* ---------- Footer ---------------------------------------------------- */
footer.site {
  border-top: 1px solid var(--border); padding-block: 2rem;
  background: var(--bg-soft);
}
footer.site .wrap { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
footer.site p { font-size: .82rem; color: var(--text-faint); }
footer.site a { color: var(--text-dim); }

/* ---------- Command palette ------------------------------------------- */
.cmdk-backdrop {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: clamp(1rem, 10vh, 7rem) 1rem 1rem;
}
.cmdk-backdrop.open { display: block; animation: fade .16s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.cmdk {
  max-width: 620px; margin-inline: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: rise .2s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(-10px) scale(.985); } to { opacity: 1; transform: none; } }
.cmdk-input { display: flex; align-items: center; gap: .7rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border-soft); }
.cmdk-input svg { width: 17px; height: 17px; color: var(--text-faint); flex: none; }
.cmdk-input input { border: 0; background: none; outline: none; width: 100%; font-size: 1rem; }
.cmdk-list { max-height: min(52vh, 420px); overflow-y: auto; padding: .4rem; }
.cmdk-group { font-family: var(--font-mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); padding: .6rem .7rem .3rem; }
.cmdk-item {
  display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left;
  padding: .55rem .7rem; border-radius: 9px; color: var(--text-dim); font-size: .9rem;
}
.cmdk-item .ttl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item .hint { font-family: var(--font-mono); font-size: .66rem; color: var(--text-faint); }
.cmdk-item .ico { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border-soft); flex: none; font-size: .7rem; }
.cmdk-item[aria-selected='true'] { background: var(--accent-soft); color: var(--text); }
.cmdk-item[aria-selected='true'] .ico { border-color: var(--accent-line); color: var(--accent); }
.cmdk-foot {
  display: flex; gap: 1rem; padding: .55rem 1rem; border-top: 1px solid var(--border-soft);
  background: var(--surface-2); font-size: .72rem; color: var(--text-faint);
}
.cmdk-foot span { display: inline-flex; align-items: center; gap: .3rem; }
.cmdk-empty { padding: 1.75rem 1rem; text-align: center; color: var(--text-faint); font-size: .88rem; }

/* ---------- Toast ------------------------------------------------------ */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translate(-50%, 14px);
  z-index: 120; background: var(--surface); border: 1px solid var(--accent-line);
  color: var(--text); padding: .6rem 1rem; border-radius: 10px; font-size: .86rem;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Scroll progress ------------------------------------------- */
.progress {
  position: fixed; top: 0; left: 0; height: 2px; z-index: 70;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  width: 0%;
}

/* ---------- Reveal on scroll ------------------------------------------ */
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in { opacity: 1; transform: none; transition: opacity .6s var(--ease), transform .6s var(--ease); }

/* ---------- Mobile nav -------------------------------------------------
   No hamburger: the nav becomes a horizontally scrollable strip and the
   wordmark collapses to the initials, so every section stays reachable. */
.brand-short { display: none; }

@media (max-width: 900px) {
  .brand-full { display: none; }
  .brand-short { display: inline; }
  .kbd-btn .kbd-label { display: none; }

  .topbar .wrap { gap: .6rem; padding-inline: .9rem; }
  .nav {
    margin-inline: 0; flex: 1 1 auto; min-width: 0;
    overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: none; -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 14px), transparent);
            mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 14px), transparent);
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: .4rem .55rem; font-size: .82rem; }
}

@media (max-width: 520px) {
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .trace-stats { grid-template-columns: repeat(2, 1fr); }
  .dwell .row { grid-template-columns: 74px 1fr 38px; }
}

/* ---------- Reduced motion -------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- Print ------------------------------------------------------ */
@media print {
  .topbar, .cmdk-backdrop, .progress, #hero-canvas, .scroll-hint,
  #trace, .graph-panel, .pub-toolbar, .pub-dash { display: none !important; }
  body { background: #fff; color: #000; }
  .section { padding-block: 1rem; break-inside: avoid; }
}
