/* ==========================================================================
   Second Brain — showcase site
   Design system (via ui-ux-pro-max): code-dark slate + run-green accent
   Archivo (headings) · Space Grotesk (body) · JetBrains Mono (terminal)
   ========================================================================== */

:root {
  --bg: #0F172A;
  --bg-deep: #0B1120;
  --surface: #1E293B;
  --surface-hover: #24334A;
  --border: #334155;
  --text: #F8FAFC;
  --body: #CBD5E1;
  --muted: #94A3B8;
  --dim: #64748B;
  --accent: #22C55E;
  --accent-bright: #4ADE80;
  --accent-ink: #052E16;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --warn: #FBBF24;
  --red: #F87171;
  --font-head: "Archivo", system-ui, sans-serif;
  --font-body: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px -24px rgba(2, 6, 23, 0.9);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --nav-h: 76px;
  color-scheme: dark;
}

/* ---------- reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 24px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ambient glow + dot grid, kept cheap: two fixed pseudo-layers */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(900px 500px at 78% -10%, rgba(34, 197, 94, 0.09), transparent 65%),
    radial-gradient(700px 420px at 8% 108%, rgba(34, 197, 94, 0.05), transparent 60%);
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(148, 163, 184, 0.10) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), rgba(0,0,0,.12) 40%, rgba(0,0,0,.35));
  pointer-events: none;
}

h1, h2, h3, h4 {
  font-family: var(--font-head);
  color: var(--text);
  line-height: 1.15;
  margin: 0 0 0.6em;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent-bright); text-decoration: none; transition: color 200ms var(--ease); }
a:hover { color: var(--text); }

img, svg { max-width: 100%; }
button { font: inherit; cursor: pointer; }

.mono { font-family: var(--font-mono); font-size: 0.92em; color: var(--text); }
.accent { color: var(--accent); }

::selection { background: rgba(34, 197, 94, 0.35); color: var(--text); }

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

.skip-link {
  position: absolute;
  top: -48px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  border-radius: 8px;
  transition: top 200ms var(--ease);
}
.skip-link:focus { top: 12px; color: var(--accent-ink); }

/* ---------- nav ---------- */
.nav {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 50;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.nav-inner {
  pointer-events: auto;
  width: min(1120px, 100%);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 18px;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--text); }
.brand:hover .brand-mark { color: var(--accent-bright); }
.brand-mark { width: 26px; height: 26px; color: var(--accent); flex: none; transition: color 200ms var(--ease); }
.brand-dash { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.nav-links a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 200ms var(--ease), background-color 200ms var(--ease);
}
.nav-links a:hover { color: var(--text); background: rgba(148, 163, 184, 0.10); }
.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.88rem !important;
}
.nav-cta svg { width: 14px; height: 14px; }
.nav-links .nav-cta:hover { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-soft); }

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  transition: border-color 200ms var(--ease);
}
.nav-toggle:hover { border-color: var(--accent); }
.nav-toggle svg { width: 20px; height: 20px; }

/* ---------- layout primitives ---------- */
main { width: min(1120px, 100% - 48px); margin: 0 auto; }

.section { padding: clamp(72px, 10vw, 128px) 0 0; }
main > .section:last-of-type { padding-bottom: clamp(72px, 10vw, 120px); }

.section-head { max-width: 720px; margin-bottom: clamp(36px, 5vw, 56px); }
.kicker {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}
.section-title { font-size: clamp(1.75rem, 3.6vw, 2.6rem); font-weight: 700; }
.section-sub { color: var(--muted); font-size: 1.1rem; max-width: 64ch; }
.section-sub.left { margin-bottom: 1em; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: border-color 250ms var(--ease), background-color 250ms var(--ease), box-shadow 250ms var(--ease);
}
.card:hover {
  border-color: rgba(34, 197, 94, 0.45);
  background: var(--surface-hover);
  box-shadow: 0 18px 44px -22px rgba(2, 6, 23, 0.8);
}
.card h3 { font-size: 1.2rem; margin-bottom: 10px; }
.card p { color: var(--muted); font-size: 0.99rem; }

.card-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.card-icon svg { width: 22px; height: 22px; }

.step .step-num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 14px;
}
.step { position: relative; overflow: hidden; }
.step::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
  opacity: 0;
  transition: opacity 250ms var(--ease);
}
.step:hover::after { opacity: 1; }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(32px, 5vw, 64px);
  padding-top: calc(var(--nav-h) + clamp(48px, 8vw, 96px));
  min-height: 88vh;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.6);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 26px;
}
.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  flex: none;
}
.hero-title {
  font-size: clamp(2.35rem, 5.4vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 22px;
}
.hero-sub { font-size: 1.15rem; color: var(--muted); max-width: 54ch; margin-bottom: 34px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 22px; }
.hero-meta { font-family: var(--font-mono); font-size: 0.82rem; color: var(--dim); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  transition: background-color 200ms var(--ease), border-color 200ms var(--ease), color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: var(--accent-bright);
  color: var(--accent-ink);
  box-shadow: 0 8px 28px -8px rgba(34, 197, 94, 0.55);
}
.btn-ghost {
  border-color: var(--border);
  color: var(--text);
  background: rgba(30, 41, 59, 0.5);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-soft); }

/* ---------- terminal ---------- */
.terminal, .tree-card {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.45);
}
.t-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.t-red { background: #F87171; }
.t-amber { background: #FBBF24; }
.t-green { background: #34D399; }
.terminal-title {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--dim);
}
.terminal-replay {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  transition: color 200ms var(--ease), border-color 200ms var(--ease);
}
.terminal-replay:hover { color: var(--accent-bright); border-color: var(--accent); }
.terminal-replay svg { width: 12px; height: 12px; }

.terminal-body, .tree-body {
  margin: 0;
  padding: 22px 24px;
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.85;
  color: var(--body);
  white-space: pre;
  overflow-x: auto;
}
.terminal-body { min-height: 460px; }

.t-prompt { color: var(--accent); font-weight: 600; }
.t-cmd { color: var(--text); font-weight: 500; }
.t-run { color: var(--accent); }
.t-ok { color: var(--accent-bright); }
.t-star { color: var(--warn); }
.t-warn { color: var(--warn); }
.t-dim { color: var(--dim); }
.t-dir { color: var(--accent-bright); font-weight: 500; }
.t-file { color: var(--text); font-weight: 500; }

.t-cursor {
  display: inline-block;
  width: 8px;
  height: 1.05em;
  vertical-align: text-bottom;
  margin-left: 2px;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- architecture ---------- */
.arch {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 48px);
  align-items: center;
}
.tree-line { display: block; border-radius: 6px; padding: 0 8px; margin: 0 -8px; transition: background-color 180ms var(--ease); }
.tree-line:hover { background: rgba(34, 197, 94, 0.08); }

.route-title { font-size: 1.25rem; margin-bottom: 18px; }
.route-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.route-table th, .route-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.route-table tbody tr:last-child th, .route-table tbody tr:last-child td { border-bottom: none; }
.route-table th {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: rgba(34, 197, 94, 0.07);
}
.route-table td { color: var(--muted); }
.route-table td.mono { font-size: 0.82rem; color: var(--text); }
.route-note { color: var(--muted); font-size: 0.97rem; }

/* ---------- principles ---------- */
.principles { grid-template-columns: repeat(4, 1fr); }
.principle h3 { display: flex; align-items: baseline; gap: 10px; font-size: 1.05rem; }
.p-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  flex: none;
}
.principle p { font-size: 0.93rem; }
.principle-cta { display: block; }
.principle-cta h3 { color: var(--accent-bright); }
.principle-cta:hover h3 { color: var(--text); }

/* ---------- stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.9));
  overflow: hidden;
}
.stat { padding: 36px 32px; border-left: 1px solid var(--border); }
.stat:first-child { border-left: none; }
.stat-value {
  font-family: var(--font-head);
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  line-height: 1;
}
.stat-label { color: var(--muted); font-size: 0.94rem; margin: 0; }

/* ---------- explore ---------- */
.explore-card { display: flex; flex-direction: column; gap: 6px; padding: 34px; }
.explore-card .kicker { margin-bottom: 4px; }
.explore-card h3 { font-size: 1.35rem; }
.explore-card p { flex: 1; }
.explore-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  font-weight: 600;
  color: var(--accent-bright);
  transition: gap 200ms var(--ease);
}
.explore-link svg { width: 18px; height: 18px; transition: transform 200ms var(--ease); }
.explore-card:hover .explore-link svg { transform: translateX(4px); }

/* ---------- contact ---------- */
.contact-card {
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: clamp(44px, 7vw, 80px) clamp(24px, 5vw, 64px);
  background:
    radial-gradient(600px 300px at 50% -20%, rgba(34, 197, 94, 0.14), transparent 70%),
    var(--surface);
}
.contact-card .section-sub { margin: 0 auto 32px; }
.contact-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* contact form (about page) */
.contact-form {
  margin: 36px auto 0;
  max-width: 560px;
  display: grid;
  gap: 14px;
  text-align: left;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.field input, .field textarea {
  width: 100%;
  padding: 13px 16px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.98rem;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.field textarea { resize: vertical; min-height: 130px; }
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input::placeholder, .field textarea::placeholder { color: var(--dim); }
.form-note { font-size: 0.85rem; color: var(--dim); margin-top: 4px; }

/* ---------- page hero (inner pages) ---------- */
.page-hero {
  padding-top: calc(var(--nav-h) + clamp(48px, 8vw, 88px));
  max-width: 780px;
}
.page-hero .hero-title { font-size: clamp(2.1rem, 4.6vw, 3.4rem); }
.page-hero .hero-sub { margin-bottom: 0; }

/* ---------- prose blocks ---------- */
.prose { max-width: 720px; }
.prose p { color: var(--body); font-size: 1.08rem; }
.prose strong { color: var(--text); }
.pull {
  border-left: 3px solid var(--accent);
  padding: 6px 0 6px 22px;
  margin: 34px 0;
  font-family: var(--font-head);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ---------- timeline ---------- */
.timeline { position: relative; max-width: 760px; padding-left: 30px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--border));
}
.tl-item { position: relative; padding: 0 0 36px 22px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -30px;
  top: 7px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--bg);
  border: 2.5px solid var(--accent);
  box-shadow: 0 0 0 5px var(--bg);
}
.tl-item.tl-hard::before { border-color: var(--warn); }
.tl-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.tl-item.tl-hard .tl-date { color: var(--warn); }
.tl-item h3 { font-size: 1.15rem; margin-bottom: 6px; }
.tl-item p { color: var(--muted); font-size: 0.99rem; max-width: 60ch; }

/* ---------- decisions / stack lists ---------- */
.decision { margin-bottom: 20px; }
.decision h3 { font-size: 1.12rem; }
.decision .verdict {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  display: block;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.stack-list { display: grid; gap: 14px; }
.stack-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 18px;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  align-items: baseline;
  transition: border-color 250ms var(--ease);
}
.stack-row:hover { border-color: rgba(34, 197, 94, 0.45); }
.stack-name { font-family: var(--font-mono); font-size: 0.9rem; color: var(--text); font-weight: 600; }
.stack-why { color: var(--muted); font-size: 0.97rem; margin: 0; }

/* ---------- learned list (about) ---------- */
.learned { display: grid; gap: 16px; max-width: 760px; }
.learned .card h3 { font-size: 1.08rem; }

/* ---------- links row ---------- */
.links-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }

/* ---------- footer ---------- */
.footer {
  margin-top: clamp(72px, 10vw, 120px);
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
}
.footer-inner {
  width: min(1120px, 100% - 48px);
  margin: 0 auto;
  padding: 40px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
}
.footer-craft { font-family: var(--font-head); font-weight: 600; color: var(--text); margin: 0; }
.footer-avail {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}
.footer-copy { margin: 0 0 0 auto; color: var(--dim); font-size: 0.88rem; }
.footer-copy a { color: var(--muted); }
.footer-copy a:hover { color: var(--accent-bright); }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(22px); }
.reveal.visible {
  opacity: 1;
  transform: none;
  transition: opacity 600ms var(--ease), transform 600ms var(--ease);
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
  .t-cursor { animation: none; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .hero { grid-template-columns: 1fr; min-height: 0; padding-top: calc(var(--nav-h) + 48px); }
  .terminal-body { min-height: 0; }
  .grid-4, .principles { grid-template-columns: repeat(2, 1fr); }
  .arch { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { border-left: none; border-top: 1px solid var(--border); }
  .stat:nth-child(1), .stat:nth-child(2) { border-top: none; }
  .stat:nth-child(even) { border-left: 1px solid var(--border); }
}

@media (max-width: 768px) {
  body { font-size: 1rem; }
  .nav-toggle { display: inline-flex; }
  .nav-inner { flex-wrap: wrap; }
  .nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    padding-top: 10px;
    margin-left: 0;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 14px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stack-row { grid-template-columns: 1fr; gap: 6px; }
  .footer-copy { margin-left: 0; }
}

@media (max-width: 480px) {
  .grid-4, .principles { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .stat { border-left: none !important; border-top: 1px solid var(--border); }
  .stat:first-child { border-top: none; }
  .hero-actions .btn { width: 100%; justify-content: center; }
  .contact-actions .btn { width: 100%; justify-content: center; }
  .terminal-body, .tree-body { font-size: 0.74rem; padding: 16px; }
}
