/* ---------- Tokens ---------- */
:root {
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px; --s10: 128px;
  --radius: 6px;
  --radius-lg: 14px;
  --bar-h: 64px;
  --gutter: clamp(20px, 4vw, 40px);
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: light dark;
  --bg: light-dark(#fafafa, #0a0a0b);
  --surface: light-dark(#ffffff, #131316);
  --surface-2: light-dark(#f4f4f5, #1b1b1f);
  --ink: light-dark(#09090b, #fafafa);
  --ink-2: light-dark(#3f3f46, #d4d4d8);
  --muted: light-dark(#52525b, #a1a1aa);
  --line: light-dark(#e4e4e7, #27272a);
  --line-strong: light-dark(#18181b, #e4e4e7);
  --accent: light-dark(#2563eb, #7aa2ff);
  --accent-ink: light-dark(#ffffff, #0a0a0b);
  --accent-soft: light-dark(#eef3ff, #151d33);
  --focus: light-dark(#2563eb, #9db9ff);
  --shadow-a: light-dark(rgba(9, 9, 11, .04), rgba(255, 255, 255, .03));
  --shadow-b: light-dark(rgba(9, 9, 11, .18), rgba(0, 0, 0, .7));
  --shadow: 0 1px 0 var(--shadow-a), 0 12px 32px -12px var(--shadow-b); /* light-dark() takes colors only */

  /* Toggle override lives in <meta name="color-scheme">; map it to the property. */
  &:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }
  &:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--bar-h) + var(--s5)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--font-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; line-height: 1.05; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--accent); color: var(--accent-ink); }

.wrap { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter); }
.skip { position: absolute; left: var(--s4); top: -100px; z-index: 100; padding: var(--s2) var(--s4); background: var(--ink); color: var(--bg); border-radius: var(--radius); }
.skip:focus { top: var(--s3); }

/* ---------- Top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.bar__in { height: var(--bar-h); display: flex; align-items: center; gap: var(--s4); }
.brand { font: 700 1.125rem/1 var(--font-display); letter-spacing: -.02em; text-decoration: none; margin-right: auto; padding-block: var(--s3); }

.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu ul { display: flex; gap: var(--s1); }
.menu a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--s3);
  font-size: .9375rem; color: var(--ink-2); text-decoration: none; border-radius: var(--radius);
  transition: color .15s, background-color .15s;
}
.menu a:hover { color: var(--ink); background: var(--surface-2); }
.menu ul { scroll-target-group: auto; }
.menu a:is([aria-current="true"], :target-current) { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }

/* Desktop: script.js keeps the details open; summary hidden only when JS runs */
@media (min-width: 900px) {
  .js .menu summary { display: none; }
}
/* Mobile: dropdown */
@media (max-width: 899px) {
  .menu summary {
    display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4);
    border: 1px solid var(--line); border-radius: var(--radius); font-weight: 500; font-size: .9375rem;
  }
  .menu summary::after { content: ""; width: 8px; height: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .2s var(--ease); }
  .menu[open] summary::after { transform: translateY(2px) rotate(-135deg); }
  .menu > ul {
    position: absolute; left: var(--gutter); right: var(--gutter); top: calc(var(--bar-h) - 4px);
    flex-direction: column; padding: var(--s2);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  }
  .menu a { display: flex; min-height: 48px; font-size: 1rem; }
}

.theme {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4);
  font: 500 .9375rem/1 var(--font-body); color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.theme:hover { border-color: var(--line-strong); }
.theme:active { transform: scale(.97); }
.i-sun { display: none; }
@media (prefers-color-scheme: dark) { .i-moon { display: none; } .i-sun { display: inline; } }
:root:has(> head > meta[name="color-scheme"][content="dark"]) { .i-moon { display: none; } .i-sun { display: inline; } }
:root:has(> head > meta[name="color-scheme"][content="light"]) { .i-moon { display: inline; } .i-sun { display: none; } }
@media (max-width: 480px) { .theme__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } .theme { padding: 0 var(--s3); } }

/* ---------- Shared bits ---------- */
.eyebrow, .index, .app__for, .flow__label, .job__when, .metric, .repo__meta, .agents figcaption {
  font-family: var(--font-mono); font-size: .8125rem; letter-spacing: .02em;
}
.index { color: var(--accent); text-transform: uppercase; margin-bottom: var(--s4); }
.btn {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 48px; padding: 0 var(--s5);
  font-weight: 600; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: transform .15s var(--ease), background-color .15s, color .15s;
}
.btn:hover { color: var(--ink); background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }

/* ---------- Hero ---------- */
.hero {
  display: grid; gap: var(--s8); align-items: center;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr);
  padding-block: var(--s9) var(--s10);
}
.hero h1 { font-size: clamp(3rem, 8vw, 6.5rem); line-height: .95; letter-spacing: -.035em; margin-block: var(--s4) var(--s5); }
.eyebrow { color: var(--muted); display: inline-flex; align-items: center; gap: var(--s2); }
.eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.lead { font-size: clamp(1.125rem, 1.6vw, 1.375rem); color: var(--ink-2); max-width: 32ch; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s6); }
.hero__photo { margin: 0; }
.hero__photo img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--surface-2);
  box-shadow: var(--shadow);
}
.hero__photo figcaption { margin-top: var(--s3); font-size: .875rem; color: var(--muted); }
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: var(--s7); padding-block: var(--s7) var(--s8); }
  .hero__photo { max-width: 360px; }
}

/* ---------- Sections ---------- */
.section { padding-block: var(--s9); border-top: 1px solid var(--line); }
.section__head { max-width: 760px; margin-bottom: var(--s7); }
.section__head h2 { font-size: clamp(2.25rem, 5vw, 3.75rem); }
.section__lead { margin-top: var(--s5); font-size: 1.125rem; color: var(--ink-2); max-width: 60ch; }
.section__head--row { max-width: none; display: flex; justify-content: space-between; align-items: end; gap: var(--s5); flex-wrap: wrap; }
@media (max-width: 640px) { .section { padding-block: var(--s8); } }

/* ---------- Work ---------- */
.jump { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s8); }
.jump a {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: var(--s1) var(--s4) var(--s1) var(--s1);
  font-weight: 500; font-size: .9375rem; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  transition: border-color .15s, transform .15s var(--ease);
}
.jump a:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-1px); }
.jump img { width: 32px; height: 32px; border-radius: 999px; }

.apps { display: grid; gap: var(--s6); }
.app {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s7); align-items: center;
  padding: var(--s7); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.app:nth-child(even) .app__info { order: 2; }
.app__name { display: flex; align-items: center; gap: var(--s3); font-size: clamp(1.75rem, 3vw, 2.25rem); }
.app__name img { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); }
.app__for { color: var(--muted); margin: var(--s2) 0 var(--s4); }
.app__info > p:not([class]) { color: var(--ink-2); max-width: 56ch; }
.metric {
  display: inline-block; margin-top: var(--s4); padding: var(--s1) var(--s3);
  color: var(--accent); background: var(--accent-soft); border-radius: var(--radius);
}

.flow { margin-top: var(--s5); padding: var(--s4); border: 1px dashed var(--line); border-radius: var(--radius); }
.flow__label { color: var(--muted); margin-bottom: var(--s3); }
.flow ol { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) 22px; }
.flow li {
  position: relative;
  font-size: .875rem; padding: var(--s1) var(--s3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.flow li:first-child { border-color: var(--accent); color: var(--accent); }
.flow li + li::before { content: "→"; position: absolute; left: -17px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.stores { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); }
.store {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 48px; padding: var(--s1) var(--s4);
  color: var(--bg); background: var(--ink); border-radius: var(--radius); text-decoration: none; line-height: 1.1;
  font-weight: 600; font-size: .9375rem; transition: transform .15s var(--ease), opacity .15s;
}
.store small { display: block; font-size: .6875rem; font-weight: 400; opacity: .8; }
.store:hover { color: var(--bg); opacity: .88; }
.store:active { transform: scale(.98); }

.shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); align-items: center; }
.shots img {
  width: 100%; aspect-ratio: 300 / 533; object-fit: cover;
  border-radius: 18px; border: 1px solid var(--line); background: var(--surface-2); box-shadow: var(--shadow);
}
.shots img:nth-child(2) { transform: translateY(-16px) scale(1.06); z-index: 1; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; padding: var(--s5); gap: var(--s6); }
  .app:nth-child(even) .app__info { order: 0; }
  .shots { max-width: 480px; }
  .shots img { border-radius: 12px; }
  .shots img:nth-child(2) { transform: translateY(-8px) scale(1.04); }
}

/* ---------- Experience ---------- */
.timeline { border-left: 1px solid var(--line); margin-left: 6px; }
.job { position: relative; display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: var(--s5); padding: 0 0 var(--s7) var(--s6); }
.job:last-child { padding-bottom: 0; }
.job::before { content: ""; position: absolute; left: -7px; top: 6px; width: 13px; height: 13px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent); }
.job:first-child::before { background: var(--accent); }
.job__when { color: var(--muted); padding-top: 4px; }
.job h3 { font-size: 1.5rem; }
.job__org { margin: var(--s1) 0 var(--s3); color: var(--muted); }
.job ul { display: grid; gap: var(--s2); max-width: 64ch; color: var(--ink-2); }
.job ul li { padding-left: var(--s5); position: relative; }
.job ul li::before { content: ""; position: absolute; left: 4px; top: .7em; width: 8px; height: 1px; background: var(--muted); }
@media (max-width: 640px) { .job { grid-template-columns: 1fr; gap: var(--s2); padding-left: var(--s5); } }

/* ---------- Workflow ---------- */
.agents {
  margin: 0 0 var(--s7); padding: var(--s6); display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s5) var(--s6); align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 20px 20px;
}
.agents__route { display: flex; align-items: center; }
.node { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 600; background: var(--surface); }
.node--you { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.node--orch { padding: var(--s3) var(--s5); border: 1px solid var(--line-strong); border-radius: var(--radius); font-family: var(--font-display); font-size: 1.125rem; }
.node--orch small { font: 400 .75rem var(--font-mono); color: var(--muted); }
.wire { width: 40px; height: 1px; background: var(--line-strong); }
.agents__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--s2); }
.ag {
  position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: var(--s2) var(--s3);
  font: 500 .875rem var(--font-mono); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.ag b { display: inline-grid; place-items: center; min-width: 22px; height: 22px; font-size: .75rem; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); }
.ag b:empty { background: transparent; }
.ag em { margin-left: auto; font-style: normal; font-size: .75rem; color: var(--muted); }
.ag--opus { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ag--opus em, .ag--opus b { color: var(--accent-ink); background: transparent; }
.ag--haiku { border-style: dashed; }
.ag__note { position: absolute; right: var(--s3); bottom: -9px; padding: 0 var(--s1); font-size: .6875rem; color: var(--accent); background: var(--surface); }
.agents figcaption { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); align-items: center; color: var(--muted); }
.key { display: inline-flex; align-items: center; gap: var(--s2); }
.key::before { content: ""; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line-strong); }
.key--opus::before { background: var(--accent); border-color: var(--accent); }
.key--haiku::before { border-style: dashed; }
@media (max-width: 900px) {
  .agents { grid-template-columns: 1fr; padding: var(--s5); }
  .agents__route { justify-content: flex-start; }
}

.owners { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.owners th, .owners td { text-align: left; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); vertical-align: top; }
.owners thead th { font: 500 .75rem var(--font-mono); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom-color: var(--line-strong); }
.owners tbody th { font: 500 .875rem var(--font-mono); white-space: nowrap; }
.owners td:nth-child(2) { color: var(--muted); white-space: nowrap; }
.owners tbody tr:hover { background: var(--surface); }
@media (max-width: 640px) {
  .owners thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .owners, .owners tbody, .owners tr, .owners th, .owners td { display: block; }
  .owners tr { padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
  .owners th, .owners td { padding: 2px 0; border: 0; }
  .owners td:nth-child(2) { font: .8125rem var(--font-mono); }
}

/* ---------- Stack ---------- */
.stack { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
.group { padding: var(--s5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.group h3 { font-size: 1.25rem; padding-bottom: var(--s3); margin-bottom: var(--s4); border-bottom: 1px solid var(--line-strong); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chips li { font-size: .875rem; padding: var(--s1) var(--s3); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
@media (max-width: 1000px) { .stack { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stack { grid-template-columns: 1fr; } }

/* ---------- Open source ---------- */
.more { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; font-weight: 600; color: var(--accent); }
.repos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.repo {
  display: flex; flex-direction: column; height: 100%; padding: var(--s5); gap: var(--s2);
  text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  transition: border-color .15s, transform .2s var(--ease), box-shadow .2s;
}
.repo:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.repo h3 { font: 600 1.0625rem var(--font-mono); letter-spacing: 0; overflow-wrap: anywhere; }
.repo p { color: var(--ink-2); font-size: .9375rem; }
.repo__meta { margin-top: auto; padding-top: var(--s3); display: flex; gap: var(--s4); color: var(--muted) !important; }
.lang::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: var(--s2); border-radius: 50%; background: var(--lang); }
.lang--dart { --lang: #00b4ab; } .lang--kotlin { --lang: #a97bff; } .lang--js { --lang: #e5c100; }
.stars { display: inline-flex; align-items: center; gap: var(--s1); }
@media (max-width: 900px) { .repos { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .repos { grid-template-columns: 1fr; } }

/* ---------- Contact ---------- */
.mail {
  display: inline-block; margin-bottom: var(--s7);
  font: 700 clamp(1.125rem, 5.4vw, 4.25rem)/1.1 var(--font-display); letter-spacing: -.03em; overflow-wrap: anywhere;
  text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: .15em;
}
.socials { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.socials a {
  display: flex; align-items: center; gap: var(--s4); min-height: 72px; padding: var(--s3) var(--s4);
  text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  transition: border-color .15s, transform .2s var(--ease);
}
.socials a:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-2px); }
.socials a > span:last-child { display: grid; font-size: .875rem; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.socials b { font-weight: 600; font-size: 1rem; color: var(--ink); }
.tile { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
@media (max-width: 900px) { .socials { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .socials { grid-template-columns: 1fr; } }

/* ---------- Footer ---------- */
.foot { border-top: 1px solid var(--line); padding-block: var(--s7); font-size: .875rem; color: var(--muted); }
.foot__in { display: flex; justify-content: space-between; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.foot p { max-width: 70ch; }
.foot a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 600; }

/* ---------- Reveal (JS only, skipped for reduced motion) ---------- */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
@media print { .bar, .theme, .skip { display: none; } .js .reveal { opacity: 1; transform: none; } }
