/* ---------- Design tokens ---------- */
:root {
  --bg-color: #0f172a;
  --card-color: #111827;
  --accent-color: #6366f1;
  --accent-hover: #818cf8;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;

  --font-heading: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;

  --space-section: clamp(4rem, 10vw, 8rem);
  --space-gap: clamp(1rem, 3vw, 2rem);
  --radius: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Reset and base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  background: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { display: block; width: 100%; height: auto; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }

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

.container {
  width: min(100% - 2.5rem, 1100px);
  margin-inline: auto;
}
.center { text-align: center; }

/* ---------- Cursor glow ---------- */
.cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 400px;
  height: 400px;
  margin: -200px 0 0 -200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.18), transparent 65%);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.4s;
  will-change: transform;
}
.cursor-glow.active { opacity: 1; }

main, footer { position: relative; z-index: 1; }

/* ---------- Glassmorphism navbar ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.3);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.3s, border-color 0.3s;
}
.site-header.scrolled {
  background: rgba(15, 23, 42, 0.8);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4.5rem;
}

.logo {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.25rem;
}

.nav-menu { display: flex; gap: 2rem; }

.nav-menu a {
  position: relative;
  display: block;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.5rem 0;
  transition: color 0.25s;
}
.nav-menu a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0.1rem;
  width: 100%;
  height: 2px;
  background: var(--accent-hover);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease);
}
.nav-menu a:hover,
.nav-menu a.active { color: var(--text-primary); }
.nav-menu a.active::after,
.nav-menu a:hover::after { transform: scaleX(1); }

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  width: 44px;
  height: 44px;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: transform 0.3s var(--ease), opacity 0.3s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 6rem 0 3rem;
  overflow: hidden;
}

.hero-bg { position: absolute; inset: 0; z-index: 0; }

.shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
  will-change: transform;
}
.shape-1 {
  width: clamp(220px, 40vw, 480px);
  aspect-ratio: 1;
  top: 5%;
  left: 8%;
  background: var(--accent-color);
  animation: float 14s ease-in-out infinite alternate;
}
.shape-2 {
  width: clamp(180px, 32vw, 380px);
  aspect-ratio: 1;
  bottom: 8%;
  right: 8%;
  background: #4f46e5;
  animation: float 18s ease-in-out infinite alternate-reverse;
}
.shape-3 {
  width: clamp(120px, 20vw, 240px);
  aspect-ratio: 1;
  top: 45%;
  right: 35%;
  background: var(--accent-hover);
  opacity: 0.25;
  animation: float 22s ease-in-out infinite alternate;
}

@keyframes float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(40px, -50px, 0) scale(1.15); }
}

.hero-inner { position: relative; z-index: 1; }

.hero-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(3rem, 12vw, 8rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  background: linear-gradient(120deg, #f9fafb 20%, #818cf8 60%, #6366f1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: rise 0.9s var(--ease) both;
}

.hero-tagline {
  margin: 1.5rem 0 2.5rem;
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  color: var(--text-secondary);
  animation: rise 0.9s 0.15s var(--ease) both;
}

.hero .btn { animation: rise 0.9s 0.3s var(--ease) both; }

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

/* ---------- Button ---------- */
.btn {
  display: inline-block;
  padding: 0.9rem 2rem;
  min-height: 48px;
  background: var(--accent-color);
  color: var(--text-primary);
  font-weight: 500;
  border-radius: 999px;
  transition: background 0.25s, transform 0.25s var(--ease), box-shadow 0.25s;
}
.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.35);
}

/* ---------- Sections ---------- */
.section { padding: var(--space-section) 0; }

.section-title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3.25rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: clamp(1.5rem, 4vw, 3rem);
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
}
.about-image { max-width: 400px; }
.about-image img {
  border-radius: var(--radius);
  border: 2px solid rgba(129, 140, 248, 0.4);
  box-shadow: 12px 12px 0 rgba(99, 102, 241, 0.25);
}
.about-text p {
  color: var(--text-secondary);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  max-width: 60ch;
}

/* ---------- Projects ---------- */
.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-gap);
}
@media (min-width: 640px) { .project-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .project-grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  display: block;
  background: var(--card-color);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease), border-color 0.4s, opacity 0.8s var(--ease);
}
.card:hover,
.card:focus-visible {
  transform: translateY(-8px);
  border-color: rgba(129, 140, 248, 0.5);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.card-media { position: relative; overflow: hidden; aspect-ratio: 3 / 2; }
.card-media img {
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease);
}
.card:hover .card-media img,
.card:focus-visible .card-media img { transform: scale(1.08); }

.card-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
  background: rgba(15, 23, 42, 0.82);
  color: var(--text-primary);
  opacity: 0;
  transition: opacity 0.35s;
}
.card:hover .card-overlay,
.card:focus-visible .card-overlay { opacity: 1; }

.card h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  padding: 1.25rem 1.5rem;
}

/* ---------- Skills ---------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}
.tags li {
  padding: 0.7rem 1.4rem;
  background: var(--card-color);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: var(--text-secondary);
  transition: transform 0.3s var(--ease), color 0.3s, border-color 0.3s, background 0.3s, box-shadow 0.3s;
}
.tags li:hover {
  transform: translateY(-4px);
  color: var(--text-primary);
  border-color: var(--accent-color);
  background: rgba(99, 102, 241, 0.15);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.35);
}

/* ---------- Contact ---------- */
.contact-text { color: var(--text-secondary); margin-bottom: 2rem; }
.social { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; }
.social a {
  display: inline-block;
  padding: 0.8rem 1.8rem;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  transition: background 0.25s, border-color 0.25s, transform 0.25s var(--ease);
}
.social a:hover {
  background: var(--accent-color);
  border-color: var(--accent-color);
  transform: translateY(-3px);
}

/* ---------- Footer ---------- */
.footer {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ---------- Scroll animation (only active when JS runs) ---------- */
.js .animate-on-scroll {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.js .animate-on-scroll.animated { opacity: 1; transform: none; }

/* Stagger cards one after another */
.project-grid .animate-on-scroll:nth-child(3n + 2) { transition-delay: 0.12s; }
.project-grid .animate-on-scroll:nth-child(3n + 3) { transition-delay: 0.24s; }

/* Keep hover transitions snappy once a card has faded in */
.js .card.animated { transition-delay: 0s; transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease), border-color 0.4s; }

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

  .nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 1.25rem 1.25rem;
    background: rgba(15, 23, 42, 0.95);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s var(--ease), visibility 0.3s;
  }
  .nav-menu.open { opacity: 1; visibility: visible; transform: none; }
  .nav-menu a { padding: 0.9rem 0; font-size: 1.1rem; }

  .card-overlay { opacity: 1; background: linear-gradient(transparent 40%, rgba(15, 23, 42, 0.9)); place-items: end center; font-size: 0.9rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
  .js .animate-on-scroll { opacity: 1; transform: none; }
}
