/* =============================================
   FONTS (self-hosted, preloaded in each page's <head>)
   ============================================= */
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/ibm-plex-sans.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/ibm-plex-mono.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
/* Arial resized to Plex Sans metrics, so a late swap doesn't reflow the page */
@font-face {
  font-family: 'Plex Fallback';
  src: local('Arial'), local('ArialMT'), local('Helvetica');
  size-adjust: 100.88%;
  ascent-override: 101.61%;
  descent-override: 27.26%;
  line-gap-override: 0%;
}

/* =============================================
   TOKENS
   ============================================= */
:root {
  --bg: #080b10;
  --surface: #0d1117;
  --card: #111823;
  --line: #222c3a;
  --line-strong: #344256;
  --primary: #3CB9FF;
  --primary-soft: rgba(60, 185, 255, 0.1);
  --good: #4ade80;
  --text: #e6edf3;
  --muted: #9aa5b1;

  --sans: 'IBM Plex Sans', 'Plex Fallback', Arial, sans-serif;
  --mono: 'IBM Plex Mono', Consolas, monospace;

  --wrap: 1080px;
  --gutter: 32px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  background: var(--bg);
  color: var(--text);
}

img, svg { display: block; max-width: 100%; }

a { color: var(--primary); text-underline-offset: 3px; }

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

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

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

/* =============================================
   NAVBAR
   ============================================= */
.navbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1000;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}

.navbar.scrolled {
  background: rgba(8, 11, 16, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: var(--line);
}

.nav-logo {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  padding: 4px 0;
}
.nav-logo:hover { color: var(--primary); }

.nav-links { display: flex; align-items: center; gap: 4px; }

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.93rem;
  font-weight: 500;
  padding: 6px 12px;
}
.nav-link:hover, .nav-link[aria-current="page"] { color: var(--text); }

.nav-cta {
  margin-left: 12px;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 16px;
  border: 1px solid var(--primary);
  border-radius: 6px;
}
.nav-cta:hover { background: var(--primary-soft); }

.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 6px;
}
.nav-hamburger span { display: block; width: 24px; height: 2px; background: var(--text); border-radius: 2px; transition: transform 0.2s, opacity 0.2s; }
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-menu {
  position: fixed;
  top: 64px;
  left: 0;
  width: 100%;
  z-index: 999;
  display: flex;
  flex-direction: column;
  padding: 8px 20px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  transform: translateY(-110%);
  visibility: hidden;
  transition: transform 0.2s, visibility 0s linear 0.2s;
}
.mobile-menu.open { transform: none; visibility: visible; transition: transform 0.2s, visibility 0s; }

.mobile-link {
  color: var(--text);
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 500;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.mobile-link:last-child { border-bottom: none; }

/* =============================================
   HERO
   ============================================= */
.hero {
  padding: 152px 0 80px;
}

.hero-name {
  font-size: clamp(2.9rem, 7vw, 4.5rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
}

.hero-role {
  color: var(--primary);
  font-weight: 500;
  font-size: clamp(1.1rem, 2.4vw, 1.3rem);
  margin-bottom: 6px;
}

.hero-lede {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 40em;
  margin-bottom: 32px;
}

.hero-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.error-page .hero-btns { justify-content: center; }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.97rem;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--primary);
}
.btn-primary { background: var(--primary); color: #061018; }
.btn-primary:hover { background: #74cfff; border-color: #74cfff; }
.btn-outline { color: var(--primary); background: transparent; }
.btn-outline:hover { background: var(--primary-soft); }
.btn-sm { padding: 7px 16px; font-size: 0.9rem; }
.btn svg { width: 16px; height: 16px; fill: currentColor; }

/* =============================================
   SECTIONS
   ============================================= */
.section { padding: 96px 0; border-top: 1px solid var(--line); }
.section.alt { background: var(--surface); }

.section-title {
  font-size: clamp(1.75rem, 3.6vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 40px;
}

/* =============================================
   ABOUT
   ============================================= */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 64px;
  align-items: center;
}
.about-text .section-title { margin-bottom: 24px; }
.about-text p { color: var(--muted); max-width: 36em; }
.about-text p + p { margin-top: 16px; }
.about-text strong { color: var(--text); font-weight: 600; }

.photo-frame {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--line-strong);
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; object-position: top; }

/* =============================================
   EXPERIENCE
   ============================================= */
.jobs { list-style: none; }
.job + .job { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--line); }

.job-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 24px;
  flex-wrap: wrap;
}
.job-role { font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
.job-dates { color: var(--muted); font-size: 0.95rem; white-space: nowrap; }
.job-company { color: var(--primary); font-weight: 500; margin: 2px 0 12px; }

.points { list-style: disc; padding-left: 1.15em; max-width: 44em; }
.points li { color: var(--muted); padding-left: 0.2em; }
.points li + li { margin-top: 6px; }
.points li::marker { color: var(--primary); }
.points strong { color: var(--text); font-weight: 600; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.tag {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 4px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

/* =============================================
   PROJECTS
   ============================================= */
.project {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
}
.project + .project { margin-top: 28px; }

.project.has-media {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

.project-media img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line-strong); }
.project-media a { display: block; }

.project-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }

.project-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}
.project-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }

.project-desc { color: var(--muted); font-size: 0.98rem; max-width: 40em; }
.project .points { margin-top: 16px; font-size: 0.95rem; }
.project .points li { color: var(--text); }

.project-links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

.project:not(.has-media) .project-body { max-width: 760px; }

/* Piper architecture diagram */
.diagram {
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 14px;
}
.diagram svg { width: 100%; height: auto; display: block; }
.project-body + .diagram { max-width: 760px; margin-top: 28px; }
.diagram .diagram-narrow { display: none; }
@media (max-width: 560px) {
  .diagram svg { display: none; }
  .diagram .diagram-narrow { display: block; max-width: 400px; margin: 0 auto; }
}

.d-cluster { fill: none; stroke: var(--line-strong); stroke-width: 1.5; stroke-dasharray: 6 5; }
.d-label { fill: var(--muted); font: 500 13px var(--sans); }
.d-box { fill: var(--card); stroke: var(--line-strong); stroke-width: 1.5; }
.d-accent { fill: #0f2536; stroke: var(--primary); }
.d-dashed { stroke-dasharray: 5 4; }
.d-text { fill: var(--text); font: 600 15px var(--sans); text-anchor: middle; }
.d-sub { fill: var(--muted); font: 400 12.5px var(--sans); text-anchor: middle; }
.d-line { stroke: var(--primary); stroke-width: 1.75; fill: none; }
.d-dashed-line { stroke-dasharray: 5 4; }
.d-arrow { fill: var(--primary); }
.d-metric { fill: var(--muted); font: 600 22px var(--sans); }
.d-metric.d-good { fill: var(--good); }
.d-note { fill: var(--muted); font: 400 13px var(--sans); }

/* =============================================
   SKILLS
   ============================================= */
.skills { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 14px 32px; max-width: 900px; }
.skills dt { font-weight: 600; }
.skills dd { color: var(--muted); }

/* =============================================
   WRITING
   ============================================= */
.post-link {
  display: block;
  max-width: 760px;
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  text-decoration: none;
  color: inherit;
}
.post-link:hover { border-color: var(--line-strong); }
.post-link:hover .post-link-title { text-decoration: underline; }
.post-link + .post-link { margin-top: 16px; }
.post-link-date { color: var(--muted); font-size: 0.9rem; }
.post-link-title { color: var(--primary); font-size: 1.2rem; font-weight: 600; line-height: 1.35; margin: 2px 0 8px; text-underline-offset: 4px; }
.post-link-excerpt { color: var(--muted); }

.more-link { display: inline-block; margin-top: 24px; font-weight: 600; }

/* =============================================
   CONTACT
   ============================================= */
.contact-desc { color: var(--muted); font-size: 1.1rem; margin-bottom: 28px; }

.contact-links { display: flex; flex-wrap: wrap; gap: 12px; }
.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}
.contact-link:hover { border-color: var(--primary); }
.contact-link svg { width: 20px; height: 20px; color: var(--primary); flex-shrink: 0; }

/* =============================================
   FOOTER
   ============================================= */
.footer { border-top: 1px solid var(--line); padding: 28px 0 36px; color: var(--muted); font-size: 0.9rem; }

/* =============================================
   BLOG PAGES
   ============================================= */
.page-head { padding: 136px 0 40px; border-bottom: 1px solid var(--line); background: var(--surface); }
.page-head .wrap { max-width: 800px; }
.page-head h1 { font-size: clamp(2rem, 5vw, 2.9rem); font-weight: 700; letter-spacing: -0.025em; line-height: 1.15; margin-bottom: 12px; }
.page-head p { color: var(--muted); font-size: 1.1rem; }
.page-head .post-date { font-size: 0.95rem; margin-bottom: 10px; }

.blog-list { max-width: 800px; margin: 0 auto; padding: 48px var(--gutter) 96px; }

.post-body { max-width: 800px; margin: 0 auto; padding: 40px var(--gutter) 96px; color: #c9d1d9; font-size: 1.05rem; line-height: 1.8; }
.post-body > * { max-width: 42em; }
.post-body h2 { color: var(--text); font-size: 1.5rem; font-weight: 700; letter-spacing: -0.015em; line-height: 1.3; margin: 2em 0 0.6em; }
.post-body h3 { color: var(--text); font-size: 1.15rem; font-weight: 600; margin: 1.6em 0 0.5em; }
.post-body p { margin-bottom: 1.1em; }
.post-body ul, .post-body ol { padding-left: 1.4em; margin-bottom: 1.1em; }
.post-body li { margin-bottom: 0.4em; }
.post-body strong { color: var(--text); font-weight: 600; }
.post-body code { font-family: var(--mono); font-size: 0.88em; background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; color: var(--text); }
.post-body pre { max-width: none; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; overflow-x: auto; margin: 1.5em 0; line-height: 1.55; }
.post-body pre code { background: none; border: none; padding: 0; font-size: 0.9rem; }
.post-back { display: inline-block; margin-bottom: 28px; font-weight: 500; }

/* =============================================
   404
   ============================================= */
.error-page { padding: 168px 0 128px; text-align: center; }
.error-code {
  font-size: clamp(6rem, 22vw, 11rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--line-strong);
  margin-bottom: 20px;
}
.error-title { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 700; letter-spacing: -0.02em; margin-bottom: 12px; }
.error-path {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
}
.error-path:empty { display: none; }
.error-page .hero-btns { margin-top: 36px; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
  .about-grid { grid-template-columns: 1fr; gap: 32px; }
  .about-photo { order: -1; }
  .photo-frame { width: 160px; height: 160px; }
  .project.has-media { grid-template-columns: 1fr; gap: 28px; }
  .skills { grid-template-columns: 1fr; gap: 0; }
  .skills dd + dt { margin-top: 16px; }
}

@media (max-width: 760px) {
  .navbar { padding: 0 20px; }
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }
}

@media (max-width: 560px) {
  :root { --gutter: 20px; }
  .hero { padding: 120px 0 64px; }
  .section { padding: 72px 0; }
  .section-title { margin-bottom: 28px; }
  .project { padding: 22px 18px; }
  .diagram { padding: 6px; }
  .contact-link { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
