:root {
  --bg: #0b0f19;
  --fg: #e8ecf4;
  --muted: #9aa3b5;
  --accent: #7c5cff;
  --accent-2: #00d4ff;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.14);
  --radius: 20px;
  --max-width: 960px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Preloader ---------- */
body.loading {
  overflow: hidden;
}

.preloader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s;
}

.preloader.done {
  opacity: 0;
  visibility: hidden;
}

.preloader-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  animation: preloader-pulse 1s ease-in-out infinite;
}

@keyframes preloader-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(124, 92, 255, 0.5); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 18px rgba(124, 92, 255, 0); }
}

/* ---------- Background ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background: linear-gradient(135deg, #0b0f19 0%, #141a33 50%, #1a1030 100%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  opacity: 0.6;
  will-change: transform;
}

.blob-1 {
  width: 560px;
  height: 560px;
  top: -140px;
  left: -120px;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.55) 0%, rgba(124, 92, 255, 0) 65%);
  animation: float-1 18s ease-in-out infinite;
}

.blob-2 {
  width: 520px;
  height: 520px;
  top: 30%;
  right: -160px;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.5) 0%, rgba(0, 212, 255, 0) 65%);
  animation: float-2 22s ease-in-out infinite;
}

.blob-3 {
  width: 460px;
  height: 460px;
  bottom: -140px;
  left: 30%;
  background: radial-gradient(circle, rgba(255, 77, 141, 0.45) 0%, rgba(255, 77, 141, 0) 65%);
  animation: float-3 26s ease-in-out infinite;
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 20%, #000 20%, transparent 70%);
}

#particles {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

@keyframes float-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 50px) scale(1.15); }
}

@keyframes float-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-70px, -40px) scale(1.1); }
}

@keyframes float-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -60px) scale(1.2); }
}

/* ---------- Glass ---------- */
.glass {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}

.glass-card {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  transition: border-color 0.3s, transform 0.3s, box-shadow 0.3s;
}

.glass-card:hover {
  border-color: rgba(124, 92, 255, 0.6);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  border-radius: 999px;
  padding: 8px 24px;
  width: min(calc(100% - 32px), var(--max-width));
  transition: box-shadow 0.3s;
}

.nav.scrolled {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0 9px;
  background: transparent;
  border: none;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  border-radius: 999px;
  background: var(--fg);
  transition: transform 0.3s, opacity 0.3s;
}

.nav-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-brand {
  font-weight: 800;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--fg);
}

.nav-links {
  display: flex;
  gap: 22px;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.92rem;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--fg);
}

.nav-links a.active {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 0 80px;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--accent);
  text-transform: uppercase;
  opacity: 0;
  animation: fade-up 0.8s ease forwards;
}

.hero-avatar {
  width: 96px;
  height: 96px;
  margin: 0 auto 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 3px solid var(--glass-border);
  animation: fade-up 0.8s ease both, avatar-glow 4s ease-in-out infinite;
}

@keyframes avatar-glow {
  0%, 100% { box-shadow: 0 12px 40px rgba(124, 92, 255, 0.35); }
  50% { box-shadow: 0 12px 56px rgba(0, 212, 255, 0.5); }
}

.hero-title {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 12px 0 10px;
  background: linear-gradient(120deg, #fff 20%, var(--accent) 55%, var(--accent-2) 90%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradient-flow 6s ease infinite, fade-up 0.8s 0.1s ease both;
}

.hero-typed {
  font-size: 1.4rem;
  font-weight: 600;
  min-height: 2.2rem;
  color: var(--muted);
  opacity: 0;
  animation: fade-up 0.8s 0.25s ease both;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  margin-left: 4px;
  vertical-align: text-bottom;
  background: var(--accent-2);
  animation: blink 0.9s steps(1) infinite;
}

.hero-desc {
  max-width: 520px;
  margin: 18px auto 32px;
  color: var(--muted);
  opacity: 0;
  animation: fade-up 0.8s 0.4s ease both;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  opacity: 0;
  animation: fade-up 0.8s 0.55s ease both;
}

.spotlight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(
    circle 300px at var(--mx, 50%) var(--my, 50%),
    rgba(124, 92, 255, 0.15),
    transparent 70%
  );
  transition: background 0.1s;
}

/* Scroll hint */
.scroll-hint {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  display: flex;
  justify-content: center;
  opacity: 0;
  animation: fade-up 0.8s 0.9s ease both;
}

.scroll-hint-line {
  width: 4px;
  height: 10px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--accent-2);
  animation: scroll-drop 1.8s ease-in-out infinite;
}

@keyframes scroll-drop {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(14px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes gradient-flow {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

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

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 12px 30px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.25s, box-shadow 0.25s, background 0.25s, color 0.25s;
}

button.btn {
  font-family: inherit;
  cursor: pointer;
  color: var(--fg);
  -webkit-appearance: none;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 30px rgba(124, 92, 255, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(0, 212, 255, 0.45);
}

.btn-ghost {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
}

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

/* ---------- Sections ---------- */
.section {
  padding: 96px 0;
}

.section-title {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-desc {
  color: var(--muted);
  margin: 10px 0 44px;
  max-width: 560px;
}

/* Reveal */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- About ---------- */
.about-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.stat {
  padding: 32px 24px;
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 2.6rem;
  font-weight: 800;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-label {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Skills ---------- */
.skill-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 640px;
}

.skill-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.skill-name {
  font-weight: 600;
}

.skill-level {
  color: var(--muted);
  font-size: 0.9rem;
}

.skill-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.skill-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Projects ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.project-card {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform-style: preserve-3d;
  will-change: transform;
}

.project-card .project-title,
.project-card .project-desc,
.project-card .project-tags,
.project-card .project-link {
  transform: translateZ(24px);
}

.project-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.project-desc {
  color: var(--muted);
  font-size: 0.95rem;
  flex: 1;
}

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

.tag {
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.15);
  color: var(--accent);
}

.project-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-2);
  text-decoration: none;
}

.project-link:hover {
  text-decoration: underline;
}

/* ---------- Contact ---------- */
.contact-card {
  padding: 56px 48px;
  text-align: center;
}

.contact-card .section-desc {
  margin: 10px auto 32px;
}

.contact-links {
  display: flex;
  justify-content: center;
  gap: 14px;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 28px;
}

.social-link {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  transition: color 0.25s, transform 0.25s, border-color 0.25s;
}

.social-link svg {
  width: 20px;
  height: 20px;
}

.social-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-3px);
}

/* ---------- Footer ---------- */
.footer {
  padding: 32px 0 80px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s, border-color 0.3s;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: 72px;
    left: 16px;
    right: 16px;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border-radius: 18px;
    background: rgba(20, 24, 44, 0.9);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
  }

  .nav-links.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .nav-links a {
    padding: 10px 14px;
    border-radius: 12px;
  }

  .nav-links a:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

@media (max-width: 600px) {
  .hero-title {
    font-size: 2.6rem;
  }

  .about-stats {
    grid-template-columns: 1fr;
  }

  .contact-card {
    padding: 40px 24px;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .blob {
    opacity: 1;
    transform: none;
    animation: none;
    transition: none;
  }

  .hero-eyebrow,
  .hero-title,
  .hero-typed,
  .hero-desc,
  .hero-actions {
    animation: none;
    opacity: 1;
  }

  .skill-fill {
    width: 100%;
  }
}
