/* ---------- Tokens ---------- */
:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --text: #15161a;
  --muted: #5b5e68;
  --faint: #8b8e98;
  --rule: #e6e5e0;
  --rule-strong: #d6d5cf;
  --accent: #1f4fd1;
  --accent-hover: #163ca3;
  --ok: #1f8a4c;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Inter Tight", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --wrap: 1080px;
  --gutter: 28px;
  --radius: 10px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -0.02em; color: var(--text); }
ul { margin: 0; padding: 0; list-style: none; }
::selection { background: #dbe4fb; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

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

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(250, 250, 248, 0.86);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease;
}
.site-header.scrolled { border-bottom-color: var(--rule); }
.site-header .wrap { display: flex; align-items: center; gap: 28px; height: 64px; }
.brand { font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; margin-right: auto; }
.nav { display: flex; align-items: center; gap: 26px; font-size: 14px; color: var(--muted); }
.nav a:hover { color: var(--text); }
.nav .nav-cta { color: var(--text); font-weight: 500; }

/* ---------- Buttons & links ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: 8px; border: 1px solid var(--text);
  font-size: 14px; font-weight: 500;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.btn-primary { background: var(--text); color: #fff; }
.btn-primary:hover { background: #2c2e35; border-color: #2c2e35; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--rule-strong); }
.btn-secondary:hover { border-color: var(--text); }

.link { color: var(--accent); font-weight: 500; font-size: 14px; }
.link:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
.links { display: flex; flex-wrap: wrap; gap: 8px 22px; }

/* ---------- Shared type ---------- */
.label { font-size: 13px; font-weight: 500; color: var(--faint); }
.meta { font-size: 13px; color: var(--faint); }
.stack { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); line-height: 1.7; }

/* ---------- Hero ---------- */
.hero { padding: 72px 0 88px; }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); gap: 64px; align-items: center; }
.status { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); margin-bottom: 28px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(31, 138, 76, 0.14); }
.hero h1 { font-size: clamp(36px, 4.6vw, 54px); line-height: 1.08; letter-spacing: -0.032em; margin-bottom: 24px; max-width: 18ch; text-wrap: balance; }
.hero h1 .soft { color: var(--faint); }
.hero .lede { font-size: 18px; line-height: 1.65; color: var(--muted); max-width: 54ch; margin-bottom: 34px; text-wrap: pretty; }
.hero .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.hero .social { display: flex; gap: 20px; margin-top: 28px; font-size: 14px; color: var(--muted); }
.hero .social a:hover { color: var(--text); }
.portrait { border-radius: 14px; overflow: hidden; aspect-ratio: 4 / 5; background: #e9e8e3; }
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }

/* ---------- Sections ---------- */
.section { padding: 88px 0; border-top: 1px solid var(--rule); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 48px; }
.section-head h2 { font-size: 30px; letter-spacing: -0.025em; }
.section-head p { color: var(--muted); font-size: 15px; }

/* Two-column section: label on the left, content on the right */
.split { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; }
.split > h2 { font-size: 30px; letter-spacing: -0.025em; }

/* ---------- Screenshots ---------- */
.shot {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 12px 32px -12px rgba(20, 20, 30, 0.12);
}
.shot img { width: 100%; }
.shot.crop { aspect-ratio: 16 / 10; }
.shot.crop img { height: 100%; object-fit: cover; object-position: top center; }

/* ---------- Featured projects ---------- */
.project { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 48px; align-items: center; padding: 48px 0; border-top: 1px solid var(--rule); }
.project:first-of-type { border-top: 0; padding-top: 0; }
.project .shot { transition: transform 220ms ease, box-shadow 220ms ease; }
.project a.shot-link:hover .shot { transform: translateY(-3px); box-shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 18px 40px -14px rgba(20, 20, 30, 0.2); }
.project .meta { margin-bottom: 10px; }
.project h3 { font-size: 26px; letter-spacing: -0.022em; margin-bottom: 12px; }
.project h3 a:hover { color: var(--accent); }
.project .summary { color: var(--muted); margin-bottom: 20px; text-wrap: pretty; }
.points { display: grid; gap: 8px; margin-bottom: 20px; font-size: 15px; }
.points li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; text-wrap: pretty; }
.points li::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--rule-strong); margin-top: 10px; }
.project .stack { margin-bottom: 22px; }

/* ---------- Other projects ---------- */
.subhead { font-size: 18px; letter-spacing: -0.015em; margin: 64px 0 22px; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.card { display: flex; flex-direction: column; gap: 10px; padding: 26px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); transition: border-color 160ms ease; }
.card:hover { border-color: var(--rule-strong); }
.card h4 { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.card p { color: var(--muted); font-size: 15px; text-wrap: pretty; }
.card .links { margin-top: auto; padding-top: 6px; }

.archive { border-top: 1px solid var(--rule); }
.archive li { border-bottom: 1px solid var(--rule); }
.archive a { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr) auto; gap: 24px; align-items: baseline; padding: 16px 0; font-size: 15px; }
.archive a:hover .name { color: var(--accent); }
.archive .name { font-weight: 500; }
.archive .desc { color: var(--muted); }
.archive .go { color: var(--faint); font-size: 13px; }

/* ---------- Skills ---------- */
.skills { display: grid; border-top: 1px solid var(--rule); }
.skills > div { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.skills dt { font-weight: 500; }
.skills dd { margin: 0; color: var(--muted); }

/* ---------- About ---------- */
.about p + p { margin-top: 16px; }
.about .prose { font-size: 17px; color: #33353c; max-width: 62ch; text-wrap: pretty; }
.timeline { margin-top: 44px; border-top: 1px solid var(--rule); }
.timeline li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 24px; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.timeline .what { font-weight: 500; }
.timeline .where { color: var(--muted); font-size: 15px; grid-column: 1; }
.timeline .when { color: var(--faint); font-size: 14px; grid-column: 2; grid-row: 1; text-align: right; white-space: nowrap; }
.timeline .note { color: var(--faint); font-size: 14px; grid-column: 1 / -1; }
.languages { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 18px; font-size: 15px; }
.languages span { color: var(--faint); margin-left: 6px; }

/* ---------- Contact ---------- */
.contact h2 { font-size: clamp(30px, 3.6vw, 42px); letter-spacing: -0.03em; margin-bottom: 14px; max-width: 20ch; }
.contact .lede { color: var(--muted); font-size: 17px; margin-bottom: 34px; }
.contact .big { font-family: var(--font-display); font-size: clamp(20px, 2.6vw, 28px); font-weight: 500; letter-spacing: -0.02em; border-bottom: 1px solid var(--rule-strong); padding-bottom: 2px; transition: color 150ms ease, border-color 150ms ease; }
.contact .big:hover { color: var(--accent); border-color: var(--accent); }
.contact-list { display: flex; flex-wrap: wrap; gap: 12px 36px; margin-top: 40px; font-size: 15px; color: var(--muted); }
.contact-list a:hover { color: var(--text); }

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

/* ---------- Case study pages ---------- */
.case-hero { padding: 56px 0 40px; }
.back { display: inline-block; font-size: 14px; color: var(--muted); margin-bottom: 36px; }
.back:hover { color: var(--text); }
.case-hero h1 { font-size: clamp(36px, 4.8vw, 52px); letter-spacing: -0.032em; line-height: 1.06; margin-bottom: 18px; }
.case-hero .lede { font-size: 19px; line-height: 1.6; color: var(--muted); max-width: 60ch; text-wrap: pretty; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin-top: 44px; padding: 22px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.facts dt { font-size: 13px; color: var(--faint); margin-bottom: 4px; }
.facts dd { margin: 0; font-size: 15px; }
.facts dd a { color: var(--accent); }
.facts dd a:hover { text-decoration: underline; text-underline-offset: 3px; }
.case-figure { margin: 0 0 16px; }
.case-figure figcaption { font-size: 14px; color: var(--faint); margin-top: 12px; max-width: 70ch; text-wrap: pretty; }
.case-body { padding: 24px 0 40px; }
.case-section { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; padding: 40px 0; border-top: 1px solid var(--rule); }
.case-section h2 { font-size: 20px; letter-spacing: -0.015em; }
.case-section .points { font-size: 16px; gap: 12px; margin: 0; max-width: 68ch; color: #33353c; }
.case-section .points li::before { margin-top: 11px; }
.case-section .stack-list { display: flex; flex-wrap: wrap; gap: 8px; }
.case-section .stack-list li { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); padding: 4px 10px; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); }
.gallery { display: grid; gap: 40px; padding: 8px 0 24px; }
.next { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 36px 0 72px; border-top: 1px solid var(--rule); }
.next .label { display: block; margin-bottom: 4px; }
.next a.title { font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.next a.title:hover { color: var(--accent); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .rise { animation: rise 600ms cubic-bezier(0.22, 0.61, 0.36, 1) both; }
  .rise.d1 { animation-delay: 80ms; }
  .rise.d2 { animation-delay: 160ms; }
  @keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { padding: 40px 0 64px; }
  .hero .wrap { grid-template-columns: 1fr; gap: 40px; }
  .portrait { max-width: 360px; order: -1; aspect-ratio: 1 / 1; }
  .project { grid-template-columns: 1fr; gap: 28px; }
  .split, .case-section { grid-template-columns: 1fr; gap: 20px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .section { padding: 64px 0; }
  .nav { gap: 16px; font-size: 13px; }
  .nav .hide-sm { display: none; }
  .cards { grid-template-columns: 1fr; }
  .skills > div { grid-template-columns: 1fr; gap: 4px; }
  .archive a { grid-template-columns: 1fr; gap: 2px; }
  .archive .go { display: none; }
  .next { flex-direction: column; align-items: flex-start; }
}

code { font-family: var(--font-mono); font-size: 0.88em; padding: 1px 5px; border-radius: 4px; background: #efeee9; }
