:root {
  --paper: #F3F6F9;
  --paper-dim: #E7ECF1;
  --ink: #141C26;
  --ink-soft: #3B4753;
  --muted: #7C8896;
  --cobalt: #2453D9;
  --cobalt-dark: #16307D;
  --amber: #F2A93B;
  --line: rgba(20, 28, 38, 0.14);
  --line-strong: rgba(20, 28, 38, 0.28);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --max: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

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

/* faint architectural grid, purely atmospheric */
.grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
          linear-gradient(var(--line) 1px, transparent 1px),
          linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.35;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent 70%);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cobalt);
  margin: 0 0 0.9rem;
}

.eyebrow-invert { color: var(--amber); }

.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  line-height: 1.15;
  margin: 0 0 2.5rem;
  max-width: 20ch;
}

.section-title-invert { color: var(--paper); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 3rem;
  background: rgba(243, 246, 249, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
}

.logo-mark {
  font-family: var(--font-mono);
  color: var(--cobalt);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 2.2rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  transition: color 0.15s ease;
}

.site-nav a:hover, .site-nav a:focus-visible { color: var(--cobalt); }

.nav-cta {
  color: var(--paper) !important;
  background: var(--ink);
  padding: 0.5rem 1.1rem;
  border-radius: 3px;
}

.nav-cta:hover { background: var(--cobalt); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
}
.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--ink);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 3rem;
  align-items: center;
  max-width: var(--max);
  margin: 0 auto;
  padding: 5.5rem 3rem 6rem;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 5.2vw, 4.4rem);
  line-height: 1.02;
  margin: 0 0 1.4rem;
  letter-spacing: -0.01em;
}

.hero-sub {
  max-width: 46ch;
  color: var(--ink-soft);
  font-size: 1.08rem;
  margin: 0 0 2.2rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 3rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  padding: 0.85rem 1.6rem;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: var(--cobalt); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-ghost:hover { border-color: var(--cobalt); color: var(--cobalt); }

.btn:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}

.hero-stats {
  display: flex;
  gap: 2.2rem;
  list-style: none;
  padding: 1.6rem 0 0;
  margin: 0;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.hero-stats li { display: flex; flex-direction: column; gap: 0.2rem; }
.stat-num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--cobalt);
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 16ch;
}

/* ---------- Code panel (signature element) ---------- */
.code-panel {
  background: var(--ink);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 30px 60px -20px rgba(20, 28, 38, 0.35);
  border: 1px solid rgba(255,255,255,0.06);
}

.code-panel-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.code-panel-bar .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255,255,255,0.18);
}
.code-panel-title {
  margin-left: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: rgba(255,255,255,0.45);
}

.code-panel-body {
  position: relative;
  padding: 1.6rem 1.7rem;
  height: 400px;
  overflow: hidden;
}

.code-panel-body pre {
  position: absolute;
  inset: 1.6rem 1.7rem;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.65;
  white-space: pre-wrap;
  background: var(--ink);
}

.code-messy {
  color: rgba(255,255,255,0.28);
}

.code-clean {
  color: rgba(255,255,255,0.92);
  z-index: 2;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 1.6s cubic-bezier(0.65, 0, 0.35, 1);
}

.code-panel-body.revealed .code-clean {
  clip-path: inset(0 0 0 0);
}

.tok-kw { color: #7FA8FF; }
.tok-fn { color: var(--amber); }
.tok-type { color: #6FD6C8; }
.tok-str { color: #F2A93B; }
.tok-punc { color: rgba(255,255,255,0.5); }

.reveal-line {
  position: absolute;
  top: 0; bottom: 0;
  left: 0;
  width: 2px;
  z-index: 3;
  background: var(--amber);
  box-shadow: 0 0 12px var(--amber);
  transition: left 1.6s cubic-bezier(0.65, 0, 0.35, 1);
  opacity: 0.9;
}
.code-panel-body.revealed .reveal-line { left: 100%; }

.lucid-badge {
  position: absolute;
  top: 0.9rem;
  right: 1.1rem;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.7s ease 1.5s;
  pointer-events: none;
}
.code-panel-body.revealed .lucid-badge { opacity: 1; }

.lucid-badge span {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  color: var(--amber);
  border: 1px solid rgba(242, 169, 59, 0.4);
  border-radius: 3px;
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
}

/* ---------- Services ---------- */
.services {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: 5rem 3rem;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.service-card {
  background: var(--paper);
  padding: 2.2rem 1.8rem;
}

.service-tag {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

.service-card h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 0.7rem;
}

.service-card p {
  color: var(--ink-soft);
  font-size: 0.94rem;
  margin: 0;
}

/* ---------- Work ---------- */
.work {
  position: relative;
  z-index: 1;
  background: var(--ink);
  color: var(--paper);
  padding: 5.5rem 3rem;
}

.work .section-title { color: var(--paper); }

.plate-list {
  max-width: var(--max);
  margin: 0 auto;
  display: grid;
  gap: 1.4rem;
}

.plate {
  border: 1px solid rgba(243, 246, 249, 0.15);
  border-left: 3px solid var(--amber);
  padding: 1.8rem 2rem;
  background: rgba(243, 246, 249, 0.03);
}

.plate-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--amber);
  flex-wrap: wrap;
  gap: 0.4rem;
}

.plate-tags { color: rgba(243, 246, 249, 0.45); }

.plate h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0 0 0.6rem;
}

.plate p {
  color: rgba(243, 246, 249, 0.7);
  max-width: 70ch;
  margin: 0;
}

/* ---------- About ---------- */
.about {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: 5.5rem 3rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
}

.about-bio {
  color: var(--ink-soft);
  max-width: 52ch;
  font-size: 1.02rem;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line-strong);
}

.timeline li {
  position: relative;
  padding: 0 0 2.4rem 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.timeline li::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 0.3rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cobalt);
}

.timeline-year {
  font-family: var(--font-mono);
  color: var(--cobalt);
  font-size: 0.85rem;
}

.timeline-role {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
}

.timeline-detail {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Contact ---------- */
.contact {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 5.5rem 3rem 7rem;
  text-align: left;
}

.contact-sub {
  color: var(--ink-soft);
  margin: -1.5rem 0 2.2rem;
}

.contact-form {
  display: grid;
  gap: 1.3rem;
}

.form-row {
  display: grid;
  gap: 0.5rem;
}

.form-row label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.form-row input,
.form-row textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  resize: vertical;
}

.form-row input:focus-visible,
.form-row textarea:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 1px;
}

.contact-form .btn { justify-self: start; margin-top: 0.4rem; }

.contact-alt {
  margin-top: 1.8rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.contact-alt a { color: var(--cobalt); text-decoration: none; }
.contact-alt a:hover { text-decoration: underline; }

/* ---------- Footer ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.6rem 3rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 0.8rem;
}

.footer-left { display: flex; align-items: center; gap: 0.5rem; }

.footer-right { display: flex; gap: 1.4rem; }
.footer-right a { text-decoration: none; color: var(--muted); }
.footer-right a:hover { color: var(--cobalt); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; padding: 3.5rem 1.5rem 4rem; }
  .service-grid { grid-template-columns: repeat(2, 1fr); }
  .about { grid-template-columns: 1fr; padding: 4rem 1.5rem; }
  .site-header { padding: 1rem 1.5rem; }
  .services, .work, .contact { padding-left: 1.5rem; padding-right: 1.5rem; }
}

@media (max-width: 680px) {
  .site-nav { position: fixed; top: 64px; left: 0; right: 0; background: var(--paper); flex-direction: column; align-items: flex-start; padding: 1.5rem; gap: 1.2rem; border-bottom: 1px solid var(--line); transform: translateY(-140%); transition: transform 0.25s ease; }
  .site-nav.open { transform: translateY(0); }
  .nav-toggle { display: flex; }
  .service-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 1.4rem; }
  .plate-head { flex-direction: column; align-items: flex-start; }
  .code-panel-body { height: 480px; }
  .code-panel-body pre { font-size: 0.76rem; }
}