/* Dark terminal theme — GitHub-dark palette, elevated. */
:root {
  --bg: #0d1117;
  --bg-deep: #090c10;
  --panel: #161b22;
  --panel-deep: #10151c;
  --border: #30363d;
  --border-bright: #3d444d;
  --text: #c9d1d9;
  --bright: #e6edf3;
  --dim: #8b949e;
  --green: #7ee787;
  --blue: #79c0ff;
  --purple: #d2a8ff;
  --orange: #ffa657;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

/* Ambient glows live on a fixed, composited layer — never repainted on scroll
   (background-attachment: fixed forces a full-viewport repaint per frame). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(55rem 38rem at 85% -12%, rgba(126, 231, 135, 0.07), transparent 60%),
    radial-gradient(48rem 34rem at -12% 25%, rgba(121, 192, 255, 0.06), transparent 60%),
    radial-gradient(50rem 42rem at 75% 115%, rgba(210, 168, 255, 0.06), transparent 60%);
}

main {
  position: relative;
  z-index: 1;
  max-width: 62rem;
  margin: 0 auto;
  padding: 3.5rem 1.25rem 2rem;
}

/* Neural-net background canvas (injected by enhance.js) */
#nn {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

a { color: var(--blue); text-decoration: none; transition: color 0.15s ease; }
a:hover { text-decoration: underline; text-underline-offset: 0.2em; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 2px; }

::selection { background: rgba(121, 192, 255, 0.32); color: var(--bright); }

.prompt { color: var(--green); font-family: var(--mono); }

/* Hero — terminal window */
.hero { margin-bottom: 4rem; }

.term {
  background: linear-gradient(180deg, var(--panel), var(--panel-deep));
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(126, 231, 135, 0.04),
    0 0 80px rgba(126, 231, 135, 0.05);
  overflow: hidden;
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}
.dot { width: 0.72rem; height: 0.72rem; border-radius: 50%; }
.dot-r { background: #ff5f56; }
.dot-y { background: #ffbd2e; }
.dot-g { background: #27c93f; }
.term-title {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--dim);
}

.term-body { padding: 1.9rem 2.1rem 2.1rem; }

.hero .prompt { margin: 0 0 0.4rem; font-size: 1rem; }

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

/* Scroll-triggered entrances (enhance.js adds .reveal/.in; replays on every re-entry).
   Hidden state only applies when JS is running (.js on <html>), so no-JS visitors
   and crawlers always see everything. Animations use fill-mode backwards so card
   hover transforms keep working after the entrance finishes. */
.js .reveal { opacity: 0; will-change: transform, opacity; }
.js .reveal.in {
  opacity: 1;
  animation: pop 0.6s cubic-bezier(0.18, 1.25, 0.4, 1) backwards;
  animation-delay: var(--d, 0ms);
}
.js .card.reveal.in { animation-name: card-pop; animation-duration: 0.65s; }
@keyframes pop {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes card-pop {
  from { opacity: 0; transform: translateY(26px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

/* While enhance.js types a command, show a trailing block cursor. */
.cmd { white-space: pre-wrap; }
.typing::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  margin-left: 0.12em;
  vertical-align: text-bottom;
  background: var(--green);
  animation: blink 0.7s steps(1) infinite;
}
/* Avoid double cursor in the hero while typing (it has a permanent one). */
.hero .typing + .cursor { display: none; }

.hero h1 {
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 3.2rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  background: linear-gradient(92deg, var(--bright) 15%, var(--blue) 60%, var(--green));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero .role {
  margin: 0.4rem 0 1.1rem;
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--purple);
}
.hero .role::before { content: "// "; color: var(--dim); }

.hero .pitch { margin: 0 0 1.7rem; color: var(--text); }

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.4rem;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.95rem;
}
.contact a:not(.btn) { color: var(--dim); }
.contact a:not(.btn):hover { color: var(--green); text-decoration: none; }

.btn {
  display: inline-block;
  padding: 0.5rem 1.15rem;
  border: 1px solid var(--green);
  border-radius: 6px;
  color: var(--green);
  font-family: var(--mono);
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.btn:hover, .btn:focus {
  background: var(--green);
  color: var(--bg-deep);
  text-decoration: none;
  box-shadow: 0 0 22px rgba(126, 231, 135, 0.35);
}

/* Sections */
section { margin-bottom: 4rem; }

h2 {
  position: relative;
  font-family: var(--mono);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--bright);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.55rem;
  margin: 0 0 1.4rem;
}
h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 4.5rem;
  height: 1px;
  background: linear-gradient(90deg, var(--green), transparent);
}

#about p { margin: 0; color: var(--text); }

/* Tags / skills strip */
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.55rem; margin: 0; padding: 0; }
.tags li {
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.18rem 0.68rem;
  border: 1px solid var(--border);
  border-radius: 2em;
  background: var(--panel);
  color: var(--orange);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.tags li:hover { border-color: var(--orange); transform: translateY(-1px); }
.skills li { color: var(--blue); }
.skills li:hover { border-color: var(--blue); }

/* Featured Project Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1.1rem; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  background: linear-gradient(180deg, var(--panel), var(--panel-deep));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.3rem 1.15rem;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--purple));
  opacity: 0;
  transition: opacity 0.18s ease;
}
.card:hover {
  transform: translateY(-4px) scale(1.012);
  border-color: var(--border-bright);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}
.card:hover::before { opacity: 1; }

.card h3 { margin: 0; font-family: var(--mono); font-size: 1.05rem; font-weight: 600; }
.card h3 a { color: var(--green); }
.card h3 a::before { content: "▸ "; color: var(--dim); }
.card .summary { margin: 0; font-size: 0.95rem; flex-grow: 1; color: var(--text); }
.card .tags li { background: var(--bg); }
.card-links {
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 0.85rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.75rem;
}
.stars { color: var(--orange); }

/* Rest list */
.rest { list-style: none; margin: 0; padding: 0; }
.rest li {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px dashed var(--border);
  border-radius: 4px;
  transition: background 0.15s ease;
}
.rest li:hover { background: rgba(255, 255, 255, 0.025); }
.rest a { font-family: var(--mono); color: var(--green); }
.rest a::before { content: "▸ "; color: var(--dim); }

.dim { color: var(--dim); }

footer { border-top: 1px solid var(--border); padding-top: 1.6rem; }
footer .contact { margin-bottom: 1rem; }
footer p { font-size: 0.85rem; }

@media (min-width: 760px) {
  .rest { columns: 2; column-gap: 2.5rem; }
  .rest li { break-inside: avoid; }
}

@media (max-width: 480px) {
  main { padding-top: 2rem; }
  .cards { grid-template-columns: 1fr; }
  .term-body { padding: 1.4rem 1.2rem 1.5rem; }
  .term-title { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cursor { animation: none; }
  .card, .tags li, .btn { transition: none; }
  .card:hover, .tags li:hover { transform: none; }
  .reveal { opacity: 1 !important; animation: none !important; }
}
