/* ===========================================================
   Khoi Space — dark-mono design system
   Shared by home, projects listing, and project detail pages
   =========================================================== */

:root, html[data-theme="dark"] {
  --bg:        #070b0c;
  --bg-soft:   #0d1416;
  --surface:   #101a1d;
  --line:      #1d2a2d;
  --text:      #e8f1f2;
  --text-soft: #c5d2d4;
  --muted:     #6f8186;
  --faint:     #46565a;
  --accent:    #2de2c9;
  --accent-dim:#1a9d8c;
  --nav-bg:    rgba(7,11,12,0.72);
  --code-bg:   #0a1113;
  --code-text: #8be9d4;
  --glow:      rgba(45,226,201,0.10);
  --on-accent: #04201c;
}

html[data-theme="light"] {
  --bg:        #f6f8f8;
  --bg-soft:   #ffffff;
  --surface:   #eef3f3;
  --line:      #dbe4e4;
  --text:      #0c1518;
  --text-soft: #38474a;
  --muted:     #5d6f73;
  --faint:     #9aaaac;
  --accent:    #0c8b7b;
  --accent-dim:#13a594;
  --nav-bg:    rgba(246,248,248,0.78);
  --code-bg:   #0f1719;
  --code-text: #0c8b7b;
  --glow:      rgba(12,139,123,0.10);
  --on-accent: #ffffff;
}

:root {
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sans: "Sora", system-ui, sans-serif;
}

html { background: var(--bg); }

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
}

/* blueprint grid + radial glow atmosphere */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.18;
  mask-image: radial-gradient(ellipse 90% 70% at 70% 0%, #000 25%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 70% 0%, #000 25%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: "";
  position: fixed;
  top: -20%; right: -10%;
  width: 60vw; height: 60vw;
  background: radial-gradient(circle, var(--glow) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ---- nav ---- */
nav.top {
  position: sticky; top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
}
nav.top .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
}
.brand .dot { color: var(--accent); }
.navlinks { display: flex; gap: 26px; list-style: none; }
.navlinks a {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
  position: relative;
}
.navlinks a:hover { color: var(--accent); }
.navlinks a.is-active { color: var(--accent); }
.navlinks a::before { content: "/ "; color: var(--faint); }
@media (max-width: 620px) { .navlinks { display: none; } }

.nav-right { display: flex; align-items: center; }
.theme-toggle {
  margin-left: 24px;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.theme-toggle .i-moon { display: none; }
.theme-toggle .i-sun  { display: inline; }
html[data-theme="light"] .theme-toggle .i-sun  { display: none; }
html[data-theme="light"] .theme-toggle .i-moon { display: inline; }

/* ---- hero ---- */
.hero { padding: 92px 0 64px; }
.eyebrow {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 26px;
}
.eyebrow::before {
  content: "";
  width: 28px; height: 1px;
  background: var(--accent);
}

.hero h1 {
  font-family: var(--mono);
  font-weight: 800;
  font-size: clamp(2.6rem, 8vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
  margin-bottom: 22px;
}
.hero h1 .light { color: var(--muted); font-weight: 500; }

.role {
  font-family: var(--mono);
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  color: var(--text);
  margin-bottom: 8px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px;
}
.role .at { color: var(--accent); }
.cursor {
  display: inline-block;
  width: 0.55em; height: 1.05em;
  background: var(--accent);
  translate: 0 0.12em;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.loc {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 22px;
}
.loc .pin { color: var(--accent-dim); }

/* "currently building" pill */
.building {
  display: inline-flex; align-items: center; gap: 11px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 8px 16px;
  margin-bottom: 34px;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.building:hover { border-color: var(--accent); color: var(--text); transform: translateY(-2px); }
.building strong { color: var(--accent); font-weight: 600; }
.building .pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  flex: none;
  animation: pulse 1.9s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(45,226,201,0.55); }
  70%  { box-shadow: 0 0 0 9px rgba(45,226,201,0); }
  100% { box-shadow: 0 0 0 0 rgba(45,226,201,0); }
}

.summary {
  max-width: 62ch;
  font-size: 1.06rem;
  color: var(--text-soft);
  margin-bottom: 38px;
}

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--text);
  background: var(--surface);
  transition: all 0.2s ease;
  display: inline-flex; align-items: center; gap: 9px;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}
.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  font-weight: 500;
}
.btn.primary:hover { background: var(--accent-dim); color: var(--on-accent); }

/* ---- section frame ---- */
section.block { padding: 30px 0; }
.sec-head {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 34px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}
.sec-no {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--accent);
  letter-spacing: 0.1em;
}
.sec-head h2 {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

/* ---- timeline ---- */
.timeline { border-left: 1px solid var(--line); margin-left: 6px; }
.job {
  position: relative;
  padding: 0 0 34px 30px;
}
.job:last-child { padding-bottom: 4px; }
.job::before {
  content: "";
  position: absolute;
  left: -5px; top: 6px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--faint);
  transition: all 0.25s ease;
}
.job.current::before {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(45,226,201,0.15);
}
.job:hover::before { border-color: var(--accent); }
.job .when {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.job .what {
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--text);
}
.job .what .co { color: var(--accent); }
.job .where {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--faint);
  margin-top: 3px;
}
.badge-now {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--on-accent);
  background: var(--accent);
  padding: 2px 7px;
  border-radius: 2px;
  margin-left: 8px;
  translate: 0 -2px;
  display: inline-block;
}

/* ---- grid lists (edu / awards) ---- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .cards { grid-template-columns: 1fr; } }
.card {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 3px;
  padding: 20px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
.card .k {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.card .t { font-size: 1.02rem; font-weight: 600; }
.card .s { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); margin-top: 4px; }

/* ---- repo / project cards ---- */
.repos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .repos { grid-template-columns: 1fr; } }
.repo {
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 3px;
  padding: 20px;
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}
.repo:hover { border-color: var(--accent); transform: translateY(-3px); background: var(--surface); }
.repo-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.repo-name {
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.repo-name::before { content: "~/ "; color: var(--faint); }
.repo-arr { font-family: var(--mono); color: var(--faint); transition: color 0.2s ease; }
.repo:hover .repo-arr { color: var(--accent); }
.repo-desc { color: var(--text-soft); font-size: 0.95rem; margin: 12px 0 16px; flex: 1; }
.repo-meta { display: flex; gap: 16px; flex-wrap: wrap; }
.repo-meta span {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.repo-meta span .lang-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent-dim);
  margin-right: 6px; translate: 0 0;
}
.all-repos {
  display: inline-block;
  margin-top: 22px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.all-repos:hover { color: var(--accent); border-color: var(--accent); }

/* ---- tags ---- */
.tags { display: flex; flex-wrap: wrap; gap: 9px; }
.tag {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 7px 12px;
  background: var(--bg-soft);
  transition: all 0.2s ease;
}
.tag:hover { color: var(--accent); border-color: var(--accent-dim); }
.tag::before { content: "# "; color: var(--faint); }

/* ---- inner-page header (projects listing / detail) ---- */
.page-head { padding: 80px 0 12px; }
.page-head .kicker {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 22px;
}
.page-head .kicker::before { content: ""; width: 28px; height: 1px; background: var(--accent); }
.page-head h1 {
  font-family: var(--mono);
  font-weight: 800;
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  letter-spacing: -0.03em;
  line-height: 1.02;
}
.page-head .lede { color: var(--text-soft); max-width: 60ch; margin-top: 18px; font-size: 1.05rem; }
.page-body { padding: 28px 0 10px; }

/* back link */
.backlink {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 8px;
  transition: color 0.2s ease, gap 0.2s ease;
}
.backlink:hover { color: var(--accent); gap: 12px; }

/* meta line under detail title */
.detail-meta {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 16px;
  display: flex; gap: 18px; flex-wrap: wrap;
}
.detail-meta .dot-sep { color: var(--accent-dim); }

/* ---- prose (markdown article body) ---- */
.prose { color: var(--text-soft); font-size: 1.0rem; max-width: 760px; }
.prose > * + * { margin-top: 1.1em; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--mono);
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-top: 2em;
}
.prose h1 { font-size: 1.7rem; }
.prose h2 {
  font-size: 1.3rem;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--line);
}
.prose h3 { font-size: 1.08rem; color: var(--accent); }
.prose h4 { font-size: 0.95rem; }
.prose p { line-height: 1.75; }
.prose a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(45,226,201,0.35); }
.prose a:hover { border-color: var(--accent); }
.prose strong { color: var(--text); font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: 0.4em 0; }
.prose li::marker { color: var(--accent-dim); }
.prose img {
  max-width: 100%; height: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  margin: 1.4em 0;
  display: block;
}
.prose blockquote {
  border-left: 2px solid var(--accent-dim);
  padding-left: 1em;
  color: var(--muted);
  font-style: italic;
}
.prose code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.12em 0.4em;
  color: var(--code-text);
}
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}
.prose pre code {
  background: none; border: none; padding: 0; color: #c8d4d6;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}
.prose th { font-family: var(--mono); color: var(--accent); font-weight: 500; background: var(--bg-soft); }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }

/* ---- footer ---- */
footer.site {
  border-top: 1px solid var(--line);
  margin-top: 56px;
  padding: 38px 0 60px;
}
footer.site .wrap {
  display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: space-between; align-items: center;
}
footer.site .copy {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--faint);
}
footer.site .social { display: flex; gap: 18px; list-style: none; }
footer.site .social a {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}
footer.site .social a:hover { color: var(--accent); }

/* ---- reveal on load ---- */
.reveal { opacity: 0; transform: translateY(18px); animation: rise 0.7s cubic-bezier(.2,.7,.2,1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
.d1 { animation-delay: 0.05s; }
.d2 { animation-delay: 0.13s; }
.d3 { animation-delay: 0.21s; }
.d4 { animation-delay: 0.29s; }
.d5 { animation-delay: 0.37s; }
.d6 { animation-delay: 0.45s; }
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
  .cursor, .building .pulse { animation: none; }
}
