/* Design A — clean terminal. System fonts only: no external requests, fast and private. */
:root {
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  --maxw: 1080px;
}

:root[data-theme="dark"] {
  --bg: #0b0f10;
  --bg-elev: #11171a;
  --fg: #e7edf0;
  --muted: #93a1a8;
  --line: #1f2a2f;
  --accent: #3ddc97;
  --accent-fg: #06130d;
  --accent-soft: rgba(61, 220, 151, 0.1);
  --grid: rgba(255, 255, 255, 0.035);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fafaf7;
  --bg-elev: #ffffff;
  --fg: #14191c;
  --muted: #566269;
  --line: #e1e5e0;
  --accent: #0a7d5a;
  --accent-fg: #ffffff;
  --accent-soft: rgba(10, 125, 90, 0.08);
  --grid: rgba(20, 25, 28, 0.05);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
a { color: inherit; }
.mono { font-family: var(--mono); }
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 24px; }

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

.skip {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--accent); color: var(--accent-fg);
  padding: 8px 14px; border-radius: 6px; font-weight: 600; text-decoration: none;
}
.skip:focus { top: 12px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.bar { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand { font-family: var(--mono); font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.brand-path { color: var(--muted); }
.cursor { color: var(--accent); animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.nav { display: flex; gap: 4px; margin-left: auto; font-size: 0.95rem; }
.nav a {
  text-decoration: none; color: var(--muted);
  padding: 6px 12px; border-radius: 6px;
}
.nav a:hover { color: var(--fg); background: var(--accent-soft); }
.controls { display: flex; gap: 8px; align-items: center; }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; height: 36px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--fg);
  font: 600 0.8rem var(--mono); text-decoration: none; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
:root[data-theme="dark"] .i-moon, :root[data-theme="light"] .i-sun { display: none; }

/* Hero */
.hero { position: relative; padding: 88px 0 64px; }
/* The grid lives on a pseudo-element so its fade-out mask never dims the text */
.hero::before {
  content: "";
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 36px 36px;
  background-position: center top;
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 40%, transparent 100%);
}
.hero .wrap { position: relative; z-index: 1; }
.kicker { color: var(--accent); margin: 0 0 12px; font-size: 0.95rem; }
h1 {
  margin: 0; font-size: clamp(2.8rem, 8vw, 5rem);
  line-height: 1.02; letter-spacing: -0.035em; font-weight: 700;
}
.role { margin: 14px 0 0; color: var(--accent); font-size: clamp(1rem, 2.2vw, 1.25rem); }
.lead {
  margin: 28px 0 0; max-width: 30ch;
  font-size: clamp(1.4rem, 3.2vw, 2rem); line-height: 1.25; letter-spacing: -0.015em; font-weight: 500;
}
.sub { margin: 18px 0 0; max-width: 62ch; color: var(--muted); }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.btn {
  display: inline-flex; align-items: center; padding: 11px 20px;
  border: 1px solid var(--line); border-radius: 8px;
  font-weight: 600; text-decoration: none; background: var(--bg-elev);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.status { margin: 22px 0 0; color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 2.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 48px; }
.stat { border-left: 2px solid var(--accent); padding: 2px 0 2px 16px; }
.stat strong { display: block; font: 700 clamp(1.8rem, 4vw, 2.4rem) var(--mono); letter-spacing: -0.03em; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 0.92rem; line-height: 1.35; display: block; margin-top: 4px; }

/* Hero layout: copy on the left, illustration on the right */
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); gap: 48px; align-items: center; }
.hero-art { min-width: 0; }
.hero-copy > * { animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.hero-copy > :nth-child(2) { animation-delay: 0.05s; }
.hero-copy > :nth-child(3) { animation-delay: 0.1s; }
.hero-copy > :nth-child(4) { animation-delay: 0.15s; }
.hero-copy > :nth-child(5) { animation-delay: 0.2s; }
.hero-copy > :nth-child(6) { animation-delay: 0.25s; }
.hero-copy > :nth-child(7) { animation-delay: 0.3s; }
.hero-art { animation: rise 0.8s 0.2s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Hero art: a tiny ortholinear keyboard whose keys tap in a diagonal wave over a PCB */
.art { min-width: 0; }
.board {
  position: relative; padding: 16px; background: var(--bg-elev); overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent), 0 24px 60px -30px color-mix(in srgb, var(--accent) 35%, transparent);
}
.traces { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.traces path {
  fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: 0.35; stroke-dasharray: 6 10;
  animation: flow 2.2s linear infinite; vector-effect: non-scaling-stroke;
}
.traces path:nth-child(even) { animation-direction: reverse; animation-duration: 3s; }
@keyframes flow { to { stroke-dashoffset: -64; } }
.keys { position: relative; display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.k {
  aspect-ratio: 1; display: grid; place-items: center; min-width: 0;
  font: 700 clamp(0.6rem, 1.3vw, 0.85rem) var(--mono); color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-bottom-width: 5px; border-radius: 7px;
  animation: tap 3.4s ease-in-out infinite; animation-delay: calc(var(--d) * 85ms);
}
.k.hot { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }
@keyframes tap {
  0%, 16%, 100% { transform: none; border-bottom-width: 5px; }
  5%, 11% { transform: translateY(4px); border-bottom-width: 1px; background: color-mix(in srgb, var(--accent) 12%, var(--bg)); color: var(--accent); border-color: var(--accent); }
}
.art-cap { margin: 14px 0 0; font-size: 0.74rem; color: var(--muted); }
/* Easter egg: type 6 then 0 and every key lights up */
.art.party .k { animation: party 0.5s ease-in-out 3; background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
@keyframes party { 50% { transform: translateY(4px); border-bottom-width: 1px; } }

/* Keyboard collection */
.collection { margin-top: 20px; gap: 14px; }
.collection h3 { font-size: 0.95rem; font-weight: 500; color: var(--muted); }
.collection h3 .p-cmd { color: var(--accent); }
.kb-list { list-style: none; margin: 0; padding: 0; display: grid; }
.kb-list li { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 6px 20px; padding: 12px 0; border-top: 1px solid var(--line); }
.kb-name { font-weight: 600; }
.kb-name a { color: var(--accent); text-decoration: none; }
.kb-name a:hover { text-decoration: underline; text-underline-offset: 3px; }
.kb-note { color: var(--muted); }

/* Toast (easter egg) */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 90; max-width: min(520px, calc(100vw - 32px));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--accent); color: var(--accent-fg); padding: 12px 18px; border-radius: 10px;
  font: 600 0.9rem/1.4 var(--mono); box-shadow: 0 12px 40px -10px rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Lessons */
.lessons { grid-template-columns: repeat(2, 1fr); }
.lesson { position: relative; gap: 14px; }
.lesson-num { position: absolute; top: 14px; right: 20px; margin: 0; font-size: 2.6rem; font-weight: 700; line-height: 1; color: var(--accent); opacity: 0.18; user-select: none; }
.lesson h3 { font-size: 1.3rem; max-width: 30ch; padding-right: 56px; }
.lesson .story { color: var(--muted); }
.rules-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-top: 6px !important; }
.proof {
  margin: auto 0 0; padding: 12px 14px; font-size: 0.8rem; line-height: 1.5; overflow-x: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere;
}
.proof .p-cmd { color: var(--fg); }
.proof .p-note { color: var(--accent); }

/* Scroll reveal: only applied once JS has tagged the elements, so nothing is hidden without JS */
[data-reveal] { opacity: 0; transform: translateY(14px); transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1); }
[data-reveal].in { opacity: 1; transform: none; }

/* Sections */
.section { padding: 72px 0; border-top: 1px solid var(--line); }
.section-head { margin-bottom: 32px; }
.label { color: var(--accent); font-size: 0.9rem; margin: 0 0 8px; }
h2 { margin: 0; font-size: clamp(1.75rem, 3.6vw, 2.4rem); letter-spacing: -0.025em; line-height: 1.15; }
.intro { margin: 12px 0 0; color: var(--muted); max-width: 60ch; }
h3 { margin: 0; font-size: 1.15rem; letter-spacing: -0.01em; line-height: 1.3; }

.grid { display: grid; gap: 20px; }
.cases { grid-template-columns: repeat(2, 1fr); }
.projects { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.three { grid-template-columns: repeat(3, 1fr); }

.card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.card p { margin: 0; }
.meta { color: var(--muted); font-size: 0.8rem; margin: 4px 0 0; }

.case dl { margin: 4px 0 0; display: grid; gap: 4px; }
.case dt { font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-top: 10px; }
.case dt:first-child { margin-top: 0; }
.case dd { margin: 0; }
.results { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.results li { position: relative; padding-left: 20px; }
.results li::before { content: "›"; position: absolute; left: 4px; color: var(--accent); font-family: var(--mono); font-weight: 700; }
.case .chips { margin-top: auto; padding-top: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chips li {
  font: 500 0.75rem var(--mono); color: var(--accent);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  padding: 3px 9px; border-radius: 6px;
}
.chips.certs li { color: var(--fg); background: transparent; border-color: var(--line); }
.chips.certs a { text-decoration: none; color: inherit; }
.chips.certs li:hover { border-color: var(--accent); }
.chips.certs li:hover a { color: var(--accent); }
.certs-col { display: grid; gap: 10px; }
.certs-col .links { margin: 0; padding: 0; }

.project p:not(.note):not(.links) { color: var(--muted); font-size: 0.97rem; }
.note { font-size: 0.78rem; color: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: auto; padding-top: 4px; font-size: 0.85rem; }
.links a { color: var(--accent); text-decoration: none; }
.links a:hover { text-decoration: underline; text-underline-offset: 3px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.filters[hidden] { display: none; }
.filter {
  font: 500 0.82rem var(--mono); color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer;
}
.filter:hover { color: var(--fg); border-color: var(--accent); }
.filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.project[hidden] { display: none; }

/* Keyboards */
.kb { flex-direction: row; gap: 40px; align-items: center; padding: 28px; }
.kb-text { flex: 1 1 56%; display: grid; gap: 14px; }
.kb-text p { color: var(--muted); }
.kb-text .links, .kb-text .note { margin-top: 0; }
.kb-keys { flex: 1 1 36%; display: grid; justify-items: center; gap: 14px; }
.keycaps { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 292px; }
.keycap {
  width: 44px; height: 44px; display: grid; place-items: center;
  font: 700 1rem var(--mono); color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-bottom-width: 5px; border-radius: 8px;
  user-select: none; cursor: pointer; transition: transform 0.05s ease, border-bottom-width 0.05s ease;
}
.keycap.pressed {
  transform: translateY(4px); border-bottom-width: 1px;
  background: var(--accent-soft); color: var(--accent); border-color: var(--accent);
}
.hint { color: var(--muted); font-size: 0.78rem; margin: 0; }

/* Stack */
.stack { display: grid; gap: 4px; }
.stack-row { display: grid; grid-template-columns: 170px 1fr; gap: 16px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.stack-row:last-child { border-bottom: 0; }
.stack-row h3 { font-size: 0.85rem; color: var(--muted); font-weight: 500; padding-top: 4px; }

/* Contact */
.contact-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; max-width: 560px; }
.contact-list li { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.contact-list span { color: var(--muted); }
.contact-list a { color: var(--accent); text-decoration: none; word-break: break-all; }
.contact-list a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 32px 0 48px; color: var(--muted); font-size: 0.9rem; }
.site-footer p { margin: 0 0 6px; }

/* 404 */
.page-404 .wrap { padding-block: 72px; }
.page-404 h1 { font-size: clamp(2rem, 6vw, 3.2rem); }
.page-404 .lead { max-width: 40ch; font-size: 1.2rem; font-weight: 400; color: var(--muted); }
.sep { border: 0; border-top: 1px solid var(--line); margin: 56px 0; }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 36px; }
  .hero-art { max-width: 460px; }
  .cases, .three, .lessons { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .kb { flex-direction: column; align-items: stretch; gap: 28px; }
}
@media (max-width: 760px) {
  .bar { gap: 10px 16px; padding-block: 10px; }
  .controls { margin-left: auto; }
  .nav { order: 3; width: 100%; margin-left: -12px; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .hero { padding-top: 56px; }
  .section { padding: 56px 0; }
  .stack-row { grid-template-columns: 1fr; gap: 8px; }
  .kb-list li { grid-template-columns: 1fr; gap: 2px; }
  .contact-list li { grid-template-columns: 90px 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  [data-reveal] { opacity: 1; transform: none; }
}
