/* =========================================================
   Tokens
   ========================================================= */
:root {
  --bg: #101114;
  --surface: #17181c;
  --surface-2: #1c1e24;
  --line: #2a2c33;
  --text: #ece9e1;
  --text-dim: #92949c;
  --text-faint: #55575f;
  --accent: #7c83ff;
  --accent-dim: #4b4fb0;
  --warm: #e8a33d;

  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --max-w: 1120px;
  --pad: clamp(20px, 5vw, 64px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

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

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

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

::selection { background: var(--accent); color: #0b0b0d; }

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

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.01em;
}

.wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.mono {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* =========================================================
   Nav
   ========================================================= */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(16, 17, 20, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-nav .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.nav-mark {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-mark .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.nav-links {
  display: flex;
  gap: clamp(16px, 3vw, 32px);
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 13px;
}

.nav-links a {
  color: var(--text-dim);
  padding: 6px 2px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--text);
  border-color: var(--accent);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

@media (max-width: 640px) {
  .nav-links {
    position: fixed;
    inset: 68px 0 auto 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 20px var(--pad) 28px;
    gap: 18px;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .nav-toggle { display: flex; }
}

/* =========================================================
   Buttons / links
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 12px 20px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  cursor: pointer;
  background: transparent;
}

.btn:hover { border-color: var(--accent); transform: translateY(-1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0b0d;
  font-weight: 600;
}

.btn-primary:hover { background: #8d93ff; border-color: #8d93ff; }

.text-link {
  border-bottom: 1px solid var(--line);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.text-link:hover { border-color: var(--accent); color: var(--accent); }

/* =========================================================
   Hero (home)
   ========================================================= */
.hero {
  padding: clamp(64px, 12vh, 120px) 0 clamp(40px, 8vh, 80px);
  border-bottom: 1px solid var(--line);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: clamp(32px, 6vw, 64px);
  align-items: center;
}

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
}

.hero h1 {
  font-size: clamp(2.4rem, 5.2vw, 4rem);
  line-height: 1.05;
  margin-top: 14px;
}

.hero h1 .accent { color: var(--accent); }

.hero p.lede {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 46ch;
  margin-top: 20px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.hero-canvas-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.hero-canvas-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 10px;
}

#loss-canvas {
  width: 100%;
  height: 220px;
  display: block;
}

/* =========================================================
   Sections
   ========================================================= */
section { padding: clamp(48px, 9vh, 96px) 0; }
section + section { border-top: 1px solid var(--line); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.section-head h2 { font-size: clamp(1.5rem, 3vw, 2rem); }

/* Stats row */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-top: 40px;
}

.stat {
  background: var(--bg);
  padding: 20px;
}

.stat .num {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  color: var(--accent);
}

.stat .label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* =========================================================
   Cards: projects
   ========================================================= */
.project-list { display: flex; flex-direction: column; }

.project-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 24px;
  align-items: start;
  padding: 28px 0;
  border-top: 1px solid var(--line);
  transition: background 0.15s ease;
}

.project-row:last-child { border-bottom: 1px solid var(--line); }

.project-row:hover { background: var(--surface); }

.project-index {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 13px;
  padding-top: 4px;
}

.project-body h3 { font-size: 1.25rem; }

.project-body p {
  color: var(--text-dim);
  margin: 10px 0 0;
  max-width: 60ch;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 3px 8px;
}

.project-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  font-family: var(--font-mono);
  font-size: 12px;
  padding-top: 6px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .project-row { grid-template-columns: 40px 1fr; }
  .project-links { grid-column: 2; flex-direction: row; align-items: center; margin-top: 12px; }
}

/* =========================================================
   Skills
   ========================================================= */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.skill-group { background: var(--bg); padding: 24px; }

.skill-group h3 {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--warm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.skill-group ul {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  color: var(--text-dim);
  font-size: 14px;
}

.skill-group li { padding: 5px 0; }

/* =========================================================
   Timeline (about)
   ========================================================= */
.timeline { border-top: 1px solid var(--line); }

.tl-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.tl-row .when {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  padding-top: 2px;
}

.tl-row h3 { font-size: 1.05rem; }
.tl-row p { color: var(--text-dim); margin: 8px 0 0; }

@media (max-width: 560px) {
  .tl-row { grid-template-columns: 1fr; gap: 6px; }
}

/* =========================================================
   Contact form
   ========================================================= */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
}

@media (max-width: 800px) {
  .contact-grid { grid-template-columns: 1fr; }
}

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.field input,
.field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px 14px;
  transition: border-color 0.15s ease;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.field textarea { resize: vertical; min-height: 140px; }

.form-status {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  min-height: 18px;
}

.form-status.ok { color: #7fd99a; }
.form-status.err { color: #e26b6b; }

.contact-info dt {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 24px;
}

.contact-info dt:first-child { margin-top: 0; }

.contact-info dd {
  margin: 8px 0 0;
  font-size: 1.05rem;
}

/* =========================================================
   Footer
   ========================================================= */
footer {
  border-top: 1px solid var(--line);
  padding: 32px 0;
}

footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}

footer .socials { display: flex; gap: 18px; }
footer .socials a { color: var(--text-dim); }
footer .socials a:hover { color: var(--accent); }

/* =========================================================
   Page header (non-home pages)
   ========================================================= */
.page-header {
  padding: clamp(56px, 10vh, 96px) 0 clamp(32px, 6vh, 56px);
  border-bottom: 1px solid var(--line);
}

.page-header h1 {
  font-size: clamp(2rem, 4.5vw, 3rem);
  margin-top: 14px;
}

.page-header p {
  color: var(--text-dim);
  max-width: 60ch;
  margin-top: 18px;
}
