:root {
  --bg: #F4F4F1;
  --ink: #111111;
  --muted: #55554F;
  --line: rgba(17, 17, 17, 0.18);
  --hover: #EAEAE4;
  --field: #FFFFFF;
  --field-border: #8A8A84;
  --accent: #C2380F;
  --sans: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --gutter: clamp(16px, 4vw, 64px);
  --shadow: 0 24px 80px rgba(17, 17, 17, 0.22);
  color-scheme: light;
}

/* Dark theme: OS preference unless data-theme="light" */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211;
    --ink: #EDEDE8;
    --muted: #A3A39B;
    --line: rgba(237, 237, 232, 0.16);
    --hover: #22221F;
    --field: #1A1A18;
    --field-border: #6E6E68;
    --accent: #FF7A4D;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211;
  --ink: #EDEDE8;
  --muted: #A3A39B;
  --line: rgba(237, 237, 232, 0.16);
  --hover: #22221F;
  --field: #1A1A18;
  --field-border: #6E6E68;
  --accent: #FF7A4D;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-underline-offset: 4px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3, p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }

.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }

.skip {
  position: absolute; left: 16px; top: -48px;
  padding: 8px 12px; background: var(--ink); color: var(--bg);
  z-index: 10;
}
.skip:focus { top: 16px; color: var(--bg); }

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Header */
.site-header {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 16px; padding: 28px 0;
  border-bottom: 1px solid var(--line);
}
.site-header .brand { font-weight: 500; text-decoration: none; }
.site-header nav { display: flex; flex-wrap: wrap; align-items: center; gap: 28px; }
.site-header nav a { text-decoration: none; }

.cmdk-btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 36px; padding: 0 6px 0 12px;
  font: inherit; color: inherit; cursor: pointer;
  background: transparent;
  border: 1px solid var(--line); border-radius: 8px;
  transition: border-color 0.2s ease;
}
.cmdk-btn:hover { border-color: var(--ink); }
.cmdk-btn kbd {
  font: inherit; font-size: 11px; color: var(--muted);
  padding: 3px 6px; border-radius: 4px; background: var(--hover);
}
@media (pointer: coarse) {
  .cmdk-btn { min-height: 44px; padding: 0 14px; }
  .cmdk-btn kbd { display: none; }
}

/* Phones: header on one row, palette button hidden */
@media (max-width: 640px) {
  .site-header { flex-wrap: nowrap; padding: 18px 0; }
  .site-header .brand { white-space: nowrap; }
  .site-header nav { flex-wrap: nowrap; gap: 18px; }
  /* Larger tap area, offset with negative margin */
  .site-header nav a { padding: 12px 0; margin: -12px 0; }
  .cmdk-btn { display: none; }
}
@media (max-width: 359px) {
  .site-header { font-size: 12px; }
  .site-header nav { gap: 12px; }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Hero */
.hero { padding: clamp(64px, 10vw, 144px) 0 64px; }
.eyebrow { color: var(--muted); margin-bottom: 28px; }
.hero h1 {
  font-size: clamp(56px, 11vw, 168px);
  line-height: 0.92;
  letter-spacing: -0.045em;
  font-weight: 600;
}
/* Name decode (main.js). The animation reveals the name if the script fails. */
.hero h1 .word { white-space: nowrap; }
.hero h1 .ch { display: inline-block; }
.hero h1 .ch.scrambling {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.62em;
  color: var(--muted);
  text-align: center;
  overflow: visible;
}
@media (prefers-reduced-motion: no-preference) {
  .js .hero h1:not(.decoded) { opacity: 0; animation: reveal 0s linear 1.5s forwards; }
}
@keyframes reveal { to { opacity: 1; } }

.lede {
  max-width: 780px;
  margin-top: 44px;
  font-size: clamp(20px, 2.2vw, 28px);
  line-height: 1.35;
}

/* Facts row */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 24px;
  margin: 0;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  line-height: 1.6;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

/* Sections */
.section { padding: 96px 0; border-top: 1px solid var(--line); }
#work { border-top: 0; padding-top: 112px; }
.section-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
}
.section-head h2, .label {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Projects */
.projects { margin-top: 24px; border-top: 1px solid var(--ink); }
.project {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 200px;
  gap: clamp(12px, 3vw, 32px);
  align-items: baseline;
  padding: 32px 8px;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.2s ease;
}
.project:has(a):hover { background: var(--hover); }
.project .num { color: var(--muted); }
.project h3 {
  font-size: clamp(26px, 3.6vw, 44px);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.05;
}
.project h3 a { text-decoration: none; display: inline-flex; align-items: center; gap: 12px; }
/* Make the whole row clickable */
.project h3 a::after { content: ''; position: absolute; inset: 0; }
.arrow {
  width: 0.5em; height: 0.5em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  transition: transform 0.2s ease;
}
.project:hover .arrow { transform: translate(4px, -4px); }
.project:hover h3 a { color: var(--accent); }
.desc { max-width: 680px; margin-top: 12px; color: var(--muted); }
.result { margin-top: 14px; color: var(--accent); }
.result::before { content: '→ '; }
.count { font-variant-numeric: tabular-nums; }

/* Highlight after the palette jumps to a project */
.project.flash { animation: flash 1.4s ease; }
@keyframes flash { 0%, 30% { background: var(--hover); } 100% { background: transparent; } }

/* Hover screenshot preview (main.js) */
.preview {
  position: fixed; left: 0; top: 0; z-index: 20;
  width: clamp(260px, 26vw, 380px);
  pointer-events: none;
}
.preview img {
  display: block; width: 100%;
  aspect-ratio: 16 / 10; object-fit: cover; object-position: top;
  border-radius: 6px;
  box-shadow: var(--shadow);
  opacity: 0; transform: scale(0.94);
  transition: opacity 0.2s ease, transform 0.25s ease;
}
.preview.show img { opacity: 1; transform: scale(1); }
.stack { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: flex-end; color: var(--muted); }

@media (max-width: 720px) {
  .project { grid-template-columns: 32px minmax(0, 1fr); padding: 28px 0; }
  .project .stack { grid-column: 2; justify-content: flex-start; }
}

/* About + experience */
.split { display: flex; flex-wrap: wrap; gap: 48px; }
.split > .label { flex: 1 1 240px; }
.split > :not(.label) { flex: 999 1 560px; min-width: 0; }
.about-lede {
  font-size: clamp(21px, 2.3vw, 30px);
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 24px;
  margin-top: 56px;
  font-size: 15px;
  line-height: 1.7;
}
.columns .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }

.timeline { border-top: 1px solid var(--line); }
.timeline li {
  display: flex; flex-wrap: wrap; gap: 4px 32px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.timeline .when { flex: 0 0 180px; color: var(--muted); padding-top: 3px; }
.timeline .what { flex: 1 1 280px; font-size: 18px; color: var(--muted); }
.timeline strong { font-weight: 500; margin-right: 10px; color: var(--ink); }

/* Contact */
.contact { border-top: 1px solid var(--ink); padding-top: 112px; }
.contact-grid { display: flex; flex-wrap: wrap; gap: clamp(48px, 7vw, 112px); }
.contact-intro { flex: 1 1 360px; min-width: 0; }
.contact-title {
  font-size: clamp(40px, 6vw, 88px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}
.contact-note { margin-top: 24px; max-width: 440px; font-size: 19px; color: var(--muted); }
.contact-alt { margin-top: 40px; color: var(--muted); overflow-wrap: anywhere; }
.contact-alt a { color: var(--ink); }
.contact-alt a:hover { color: var(--accent); }
.links { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 20px; }

.contact-form { flex: 1 1 420px; min-width: 0; display: grid; gap: 22px; align-content: start; }
.field label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--mono); font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.field input,
.field textarea {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 13px 16px;
  font: inherit; font-size: 17px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
.field input:hover,
.field textarea:hover { border-color: var(--ink); }
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; }
.submit {
  display: inline-flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 0 26px;
  font: inherit; font-size: 17px; font-weight: 500;
  color: var(--bg); background: var(--ink);
  border: 0; border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.submit:hover { background: var(--accent); }
.submit:disabled { opacity: 0.6; cursor: progress; }
.submit svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; transition: transform 0.2s ease; }
.submit:hover svg { transform: translateX(3px); }
.form-status { color: var(--muted); }
.form-status[data-state="ok"] { color: var(--ink); }
.form-status[data-state="error"] { color: var(--accent); }
.hp { display: none; }

/* Footer */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px;
  padding: 28px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

/* Footer cats: ears above the line, full cat on hover */
.site-footer { position: relative; }
.cats {
  position: absolute;
  right: clamp(0px, 2vw, 24px);
  bottom: 100%;
  display: flex;
  gap: 2px;
  height: 70px;
  overflow: hidden;
}
.cat {
  position: relative;
  width: 60px; height: 70px;
  padding: 0; border: 0; border-radius: 6px;
  background: none;
  cursor: pointer;
}
.cat:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cat svg {
  position: absolute; left: 0; top: 0;
  width: 60px; height: auto;
  overflow: visible;
  transform: translateY(54px);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cat.nyx svg { transition-delay: 0.07s; }
.site-footer:hover .cat svg,
.cat:focus-visible svg,
.cat.up svg { transform: translateY(4px); }

/* Hide seated cats until their run ends (must follow the hover rule) */
.cats-away .cat:not(.arrived) svg { transform: translateY(80px); }

.cat .w, .runner .w { fill: #F7F7F4; }
.cat .k, .runner .k { fill: #1C1C1B; }
.cat .o, .runner .o { stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }

/* Side-view runners */
.runners { position: absolute; left: 0; bottom: 100%; width: 0; height: 0; pointer-events: none; }
.runner { position: absolute; left: 0; bottom: -1px; width: 56px; opacity: 0; will-change: transform; }
.runner svg { display: block; width: 56px; height: auto; overflow: visible; }
.runner .leg, .runner .leg-o, .runner .tail, .runner .tail-o { fill: none; stroke-linecap: round; }
.runner .leg-o { stroke: var(--ink); stroke-width: 5.6; }
.runner .leg { stroke-width: 4; }
.runner .tail-o { stroke: var(--ink); stroke-width: 6.6; }
.runner .tail { stroke: #1C1C1B; stroke-width: 5; }
.runner.scooter .leg { stroke: #F7F7F4; }
.runner.nyx .leg { stroke: #1C1C1B; }
.runner .leg-b { opacity: 0; }
.runner.go .gait { animation: bob 0.34s ease-in-out infinite; }
.runner.go .leg-a { animation: gait-a 0.34s linear infinite; }
.runner.go .leg-b { animation: gait-b 0.34s linear infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2.5px); } }
@keyframes gait-a { 0%, 49.9% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes gait-b { 0%, 49.9% { opacity: 0; } 50%, 100% { opacity: 1; } }
.cat .pupil { fill: #111111; }
.cat .mouth, .cat .whisker { fill: none; stroke-width: 1; stroke-linecap: round; }
.runner .nose { fill: #E4A3A3; }
.runner.nyx .nose { fill: #55534F; }
.scooter .ear-in { fill: #D99A9A; }
.scooter .iris { fill: #EDC53F; }
.scooter .nose { fill: #E4A3A3; }
.scooter .mouth { stroke: #3A3A38; }
.scooter .whisker { stroke: #8A8A84; }
.nyx .ear-in { fill: #46443F; }
.nyx .iris { fill: #8CC152; }
.nyx .nose { fill: #55534F; }
.nyx .mouth { stroke: #8A8A84; }
.nyx .whisker { stroke: #C9C9C3; }

.cat .eye { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
.cat.nyx .eye { animation-delay: 1.7s; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
@media (prefers-reduced-motion: reduce) { .cat .eye { animation: none; } }

/* Command palette */
.palette {
  width: min(600px, calc(100vw - 32px));
  max-height: 80vh;
  margin: 12vh auto auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.palette::backdrop { background: rgba(17, 17, 17, 0.4); backdrop-filter: blur(2px); }
.palette[open] { animation: pop 0.16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(0.985); } }
.palette-input {
  width: 100%;
  padding: 18px 20px;
  border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: inherit;
  font: inherit; font-size: 18px;
}
.palette-input:focus { outline: none; }
.palette.sql .palette-input,
.palette.sql .cmd-label { font-family: var(--mono); font-size: 15px; }
.palette-list { max-height: min(50vh, 400px); overflow-y: auto; padding: 8px; }
.palette-list:empty { display: none; }
.palette-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 11px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.palette-list li[aria-selected="true"] { background: var(--hover); }
.palette-list li[aria-selected="true"] .cmd-label { color: var(--accent); }
.cmd-hint {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.palette-foot {
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
}
.palette-list:empty + .palette-foot { border-top: 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 30;
  padding: 10px 16px; border-radius: 8px;
  background: var(--ink); color: var(--bg);
  opacity: 0; transform: translate(-50%, 8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
