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

:root {
  --bg: #000000;
  --bg2: #03040a;
  --bg3: #07080e;
  --purple: #9c70ff;
  --purple-dim: #6d42d6;
  --purple-glow: rgba(156, 112, 255, 0.11);
  --purple-border: rgba(156, 112, 255, 0.21);
  --text: #e9e7f1;
  --text-muted: #7b7991;
  --text-dim: #4b4961;
  --border: rgba(255,255,255,0.05);
  --font-mono: 'IBM Plex Mono', monospace;
  --font-display: 'DM Sans', sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.7;
  overflow-x: hidden;
}

/* background starfield canvas — fixed, always visible everywhere on page */
#bg-stars-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* noise overlay */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.01;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* nav */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 3rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(12px);
}

.nav-logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--purple);
  letter-spacing: 0.05em;
}

.cursor-blink {
  animation: blink 1.1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.nav-links {
  display: flex;
  gap: 2.5rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--purple);
}

/* hero */
.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

/* galaxy sim canvas — sits inside hero, scrolls with page */
#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  padding: 8rem 3rem 4rem;
  max-width: 900px;
}

/* portrait layout — sim stays at top, text drops to bottom */
@media (orientation: portrait) {
  .hero {
    justify-content: flex-end;
    align-items: center;
  }
  .hero-content {
    padding: 2rem 2rem 4rem;
    max-width: 100%;
    width: 100%;
    text-align: center;
  }
  .hero-links {
    justify-content: center;
  }
}

.scroll-hint {
  margin-top: 1.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--purple-dim);
  opacity: 0;
  animation: fadeUp 0.6s ease 0.9s forwards;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 6.5rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 2rem;
  opacity: 0;
  animation: fadeUp 0.6s ease 0.25s forwards;
}

.hero-sub {
  max-width: 520px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.8;
  margin-bottom: 2.5rem;
  opacity: 0;
  animation: fadeUp 0.6s ease 0.4s forwards;
}

.hero-links {
  display: flex;
  gap: 1rem;
  opacity: 0;
  animation: fadeUp 0.6s ease 0.55s forwards;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  background: var(--purple);
  color: #fff;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 4px;
  transition: background 0.2s, transform 0.15s;
}

.btn-primary:hover {
  background: #b48aff;
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.4rem;
  border: 1px solid var(--purple-border);
  color: var(--purple);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  border-radius: 4px;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.btn-secondary:hover {
  background: var(--purple-glow);
  border-color: var(--purple);
  transform: translateY(-1px);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* sections */
.section {
  position: relative;
  z-index: 1;
  padding: 6rem 3rem;
  max-width: 1400px;
  margin: 0 auto;
}

.section-label {
  font-size: 0.75rem;
  color: var(--purple);
  letter-spacing: 0.12em;
  margin-bottom: 3rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

/* about */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
}

.about-text p {
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.88rem;
  line-height: 1.9;
}

.stack-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
}

.stack-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stack-items span {
  font-size: 0.75rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--purple-border);
  color: var(--purple);
  border-radius: 3px;
  background: var(--purple-glow);
}

/* projects */
.projects-scroll-outer {
  position: relative;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 3%, black 97%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 3%, black 97%, transparent 100%);
}

.projects-grid {
  display: flex;
  gap: 1.25rem;
  overflow-x: scroll;
  overflow-y: visible;
  padding: 0.5rem 2rem 1.5rem;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  user-select: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.projects-grid::-webkit-scrollbar { display: none; }
.projects-grid.dragging { cursor: grabbing; }
div.project-card { cursor: default; }

.project-card {
  position: relative;
  flex: 0 0 340px;
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg2);
  text-decoration: none;
  color: inherit;
  display: block;
  overflow: hidden;
  transition: border-color 0.25s, background 0.25s;
}

@media (min-width: 900px) {
  .project-card { flex: 0 0 380px; }
}

@media (min-width: 1400px) {
  .project-card { flex: 0 0 420px; }
}

.project-card:hover {
  border-color: var(--purple-border);
  background: var(--bg3);
}

.project-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: radial-gradient(ellipse at top left, var(--purple-glow), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.project-card:hover::before {
  opacity: 1;
}

.card-arrow {
  position: absolute;
  bottom: 1.25rem;
  right: 1.25rem;
  color: var(--purple-dim);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s, transform 0.2s;
}

.project-card:hover .card-arrow {
  opacity: 1;
  transform: translateX(0);
}

.card-title-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

.card-icon {
  width: 3.5rem;
  height: 3.5rem;
  object-fit: contain;
  flex: 0 0 3.5rem;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  margin-top: auto;
  margin-bottom: auto;
}

.project-card .card-title-row h3 {
  flex: 1;
  margin: 0;
  padding: 0;
}

.project-status {
  display: inline-block;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--purple);
  background: var(--purple-glow);
  border: 1px solid var(--purple-border);
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.project-card h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.project-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 1.25rem;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.project-tags span {
  font-size: 0.68rem;
  color: var(--text-dim);
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  letter-spacing: 0.04em;
}

/* contact */
.contact-block {
  max-width: 560px;
}

.contact-block p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.contact-links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.contact-links a {
  color: var(--purple);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 0.2s;
}

.contact-links a::before {
  content: '→';
  color: var(--text-dim);
}

.contact-links a:hover {
  opacity: 0.75;
}

/* footer */
footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 3rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

/* responsive */
@media (max-width: 700px) {
  nav { padding: 1rem 1.5rem; }
  .nav-links { gap: 1.5rem; }
  .section { padding: 4rem 1.5rem; }
  .about-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  footer { flex-direction: column; gap: 0.5rem; padding: 1.5rem; text-align: center; }
}