:root {
  --bg: #07090d;
  --bg-elev: rgba(18, 24, 33, 0.72);
  --border: #1f2935;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #4ade80;
  --accent-rgb: 74, 222, 128;
  --accent-dim: rgba(var(--accent-rgb), 0.12);
  --wip: #fbbf24;
  --archived: #94a3b8;
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  overflow-x: hidden;
}
::selection { background: var(--accent); color: #000; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* ---------- Background layers ---------- */
#bg { position: fixed; inset: 0; z-index: -2; width: 100%; height: 100%; }
.spotlight {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(600px circle at var(--x, 50%) var(--y, 30%), rgba(var(--accent-rgb), 0.07), transparent 60%);
}
#progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 20;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem clamp(1rem, 5vw, 4rem);
  background: rgba(7, 9, 13, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo { font-family: var(--mono); font-weight: 600; white-space: nowrap; margin-right: 1rem; }
.prompt, .cursor { color: var(--accent); }
.cursor, .caret { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.nav nav { display: flex; gap: 1.5rem; align-items: center; font-family: var(--mono); font-size: 0.9rem; }
.nav nav a { color: var(--muted); transition: color 0.2s; position: relative; }
.nav nav a::after {
  content: ""; position: absolute; left: 0; bottom: -4px; height: 1px; width: 0;
  background: var(--accent); transition: width 0.25s;
}
.nav nav a:hover, .nav nav a.active { color: var(--accent); }
.nav nav a:hover::after, .nav nav a.active::after { width: 100%; }
.theme-btn {
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
  background: var(--accent); border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px var(--accent);
  transition: transform 0.3s;
}
.theme-btn:hover { transform: rotate(180deg) scale(1.2); }

/* ---------- Layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 0 1.5rem; }
.section { padding: 6rem 0; }
.section h2 {
  font-size: 1.85rem; margin-bottom: 2rem;
  display: flex; align-items: center; gap: 0.6rem;
}
.section h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); margin-left: 1rem; }
.num { font-family: var(--mono); color: var(--accent); font-size: 1.1rem; }
.hint { font-size: 0.8rem; margin: -1.25rem 0 1.75rem; }

/* ---------- Hero ---------- */
.hero { min-height: calc(100vh - 70px); display: flex; flex-direction: column; justify-content: center; position: relative; }
.hero h1 {
  font-size: clamp(3rem, 10vw, 6.5rem); line-height: 1; letter-spacing: -0.04em; font-weight: 800;
  background: linear-gradient(120deg, var(--text) 30%, var(--accent) 70%, var(--text));
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 6s linear infinite;
  margin-top: 0.5rem;
}
@keyframes shine { to { background-position: 200% center; } }
.role { color: var(--accent); font-size: clamp(1.1rem, 2.5vw, 1.4rem); margin: 1rem 0 1.25rem; min-height: 2em; }
.tagline { color: var(--muted); font-size: 1.15rem; max-width: 600px; }
.hero-actions { display: flex; gap: 1rem; margin-top: 2.5rem; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 2.5rem; margin-top: 3.5rem; flex-wrap: wrap; }
.stat strong { display: block; font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat span { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.scroll-hint { position: absolute; bottom: 2rem; left: 50%; transform: translateX(-50%); font-size: 0.8rem; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, 6px); } }

.btn {
  display: inline-block;
  font-family: var(--mono); font-size: 0.9rem;
  padding: 0.8rem 1.5rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-elev);
  backdrop-filter: blur(6px);
  color: var(--text); cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s ease-out;
}
.btn:hover { border-color: var(--accent); box-shadow: 0 0 24px rgba(var(--accent-rgb), 0.25); }
.btn.primary { background: var(--accent); color: #04130a; border-color: var(--accent); font-weight: 600; }

/* ---------- About + terminal ---------- */
.about-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 2.5rem; align-items: start; }
.about p { color: var(--muted); font-size: 1.05rem; margin-bottom: 1rem; }
.terminal {
  background: rgba(10, 13, 18, 0.9); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(var(--accent-rgb), 0.05);
  cursor: text;
}
.term-bar { display: flex; align-items: center; gap: 0.45rem; padding: 0.7rem 1rem; background: #0f141b; border-bottom: 1px solid var(--border); }
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
.term-title { margin-left: auto; margin-right: auto; font-size: 0.75rem; color: var(--muted); transform: translateX(-20px); }
.term-body { height: 340px; overflow-y: auto; padding: 1rem; font-size: 0.85rem; line-height: 1.55; }
.term-body::-webkit-scrollbar { width: 6px; }
.term-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#term-output > div { white-space: pre-wrap; word-break: break-word; }
.term-line { display: flex; gap: 0.5rem; }
.term-prompt { color: var(--accent); white-space: nowrap; }
#term-input { flex: 1; background: none; border: none; outline: none; color: var(--text); font: inherit; caret-color: var(--accent); }
.t-accent { color: var(--accent); }
.t-muted { color: var(--muted); }
.t-err { color: #f87171; }
.t-cmd { color: var(--accent); cursor: pointer; text-decoration: underline dotted; }

/* ---------- Stack ---------- */
.stack-groups { display: grid; gap: 2.25rem; }
.stack-group h3 {
  font-family: var(--mono); font-size: 0.8rem; font-weight: 400;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 1rem;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.65rem; }
.chip {
  font-family: var(--mono); font-size: 0.875rem;
  padding: 0.5rem 0.95rem; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--border);
  backdrop-filter: blur(6px);
  transition: border-color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
  cursor: pointer; color: var(--text);
  opacity: 0; transform: translateY(10px);
}
.visible .chip { opacity: 1; transform: none; transition-delay: calc(var(--i) * 30ms); }
.visible .chip:hover { transition-delay: 0s; }
.chip:hover { border-color: var(--accent); background: var(--accent-dim); transform: translateY(-3px); box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.15); }
.chip .note { color: var(--muted); font-size: 0.72rem; margin-left: 0.4rem; }
.chip .count { font-size: 0.68rem; margin-left: 0.4rem; color: var(--accent); }
.chip.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- Projects ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 2rem; }
.filter {
  font-family: var(--mono); font-size: 0.8rem; color: var(--muted);
  padding: 0.4rem 0.9rem; border-radius: 999px;
  background: transparent; border: 1px solid var(--border); cursor: pointer;
  transition: all 0.2s;
}
.filter:hover { color: var(--text); border-color: var(--muted); }
.filter.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; perspective: 1000px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--bg-elev); border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  border-radius: var(--radius); padding: 1.6rem;
  transform-style: preserve-3d;
  transition: transform 0.15s ease-out, border-color 0.3s, box-shadow 0.3s;
  animation: cardIn 0.5s backwards;
  animation-delay: calc(var(--i) * 70ms);
  overflow: hidden;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(20px) scale(0.97); } }
.card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), rgba(var(--accent-rgb), 0.12), transparent 50%);
}
.card:hover { border-color: rgba(var(--accent-rgb), 0.5); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45); }
.card:hover::before { opacity: 1; }
.card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.status { font-family: var(--mono); font-size: 0.72rem; display: inline-flex; align-items: center; gap: 0.45rem; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status.live::before { animation: pulse 2s infinite; }
.status.wip::before { background: var(--wip); box-shadow: 0 0 8px var(--wip); }
.status.archived::before { background: var(--archived); box-shadow: none; }
@keyframes pulse { 50% { opacity: 0.4; } }
.year { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.card h3 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.card p { color: var(--muted); font-size: 0.93rem; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.2rem 0; }
.tag { font-family: var(--mono); font-size: 0.74rem; color: var(--accent); }
.card-links { display: flex; gap: 1.2rem; font-family: var(--mono); font-size: 0.82rem; }
.card-links a { color: var(--text); border-bottom: 1px solid var(--border); transition: border-color 0.2s, color 0.2s; }
.card-links a:hover { border-color: var(--accent); color: var(--accent); }
.empty { color: var(--muted); font-family: var(--mono); }

/* ---------- Contact ---------- */
.contact-big { font-size: clamp(2rem, 6vw, 3.5rem); font-weight: 800; letter-spacing: -0.03em; margin-bottom: 0.5rem; }
.contact-links { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2rem; }

/* ---------- Footer / toast ---------- */
.footer { text-align: center; padding: 2.5rem 1rem; font-size: 0.8rem; border-top: 1px solid var(--border); }
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; z-index: 30;
  transform: translate(-50%, 150%); opacity: 0;
  background: #0f141b; border: 1px solid var(--accent); color: var(--text);
  padding: 0.7rem 1.2rem; border-radius: var(--radius); font-size: 0.85rem;
  transition: transform 0.3s, opacity 0.3s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s, transform 0.7s; }
.reveal.visible { opacity: 1; transform: none; }

@media (max-width: 800px) {
  .about-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .nav nav { gap: 0.8rem; font-size: 0.78rem; }
  .section { padding: 4rem 0; }
  .hero-stats { gap: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { transition: none !important; animation: none !important; }
  .reveal, .chip { opacity: 1; transform: none; }
}
