:root {
  --bg: #0a0d14;
  --bg-alt: #0f1420;
  --card-bg: #121826;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f6fb;
  --text-dim: #8b93a7;
  --cyan: #22d3ee;
  --blue: #6366f1;
  --magenta: #c026d3;
  --gradient: linear-gradient(135deg, var(--cyan) 0%, var(--blue) 55%, var(--magenta) 100%);
  --radius: 14px;
  --max-width: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

@keyframes floatBlobA {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-3%, 4%) rotate(4deg); }
}

@keyframes floatBlobB {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4%, -5%) scale(1.08); }
}

@keyframes drawLogo {
  from { stroke-dashoffset: 420; }
  to { stroke-dashoffset: 0; }
}

@keyframes blinkCursor {
  0%, 45% { opacity: 1; }
  50%, 95% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes gradientPan {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.35); }
  50% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
}

@keyframes wordIn {
  from { opacity: 0; transform: translateY(115%) rotateX(55deg); }
  to { opacity: 1; transform: translateY(0) rotateX(0deg); }
}

@keyframes preloaderPulse {
  0%, 100% { opacity: 0.55; transform: scale(0.94); }
  50% { opacity: 1; transform: scale(1.02); }
}

@keyframes preloaderAutoHide {
  to { opacity: 0; visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Preloader */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.5s ease, visibility 0.5s ease;
  pointer-events: none;
  /* Safety net: force-hide even if JS never runs (blocked script, race, cache hiccup) */
  animation: preloaderAutoHide 0.01s linear 2.5s forwards;
}
.preloader-logo {
  width: 72px;
  height: 72px;
  animation: preloaderPulse 1.1s ease-in-out infinite;
  filter: drop-shadow(0 0 24px rgba(99, 102, 241, 0.5));
}
.preloader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Scroll progress bar */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: var(--gradient);
  transform: scaleX(0);
  transform-origin: left;
  z-index: 9000;
  will-change: transform;
}

/* Film grain overlay */
.grain-overlay {
  position: fixed;
  inset: -100px;
  z-index: 5;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Custom cursor (desktop, fine pointer only) */
.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 9500;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.cursor-dot {
  width: 6px;
  height: 6px;
  background: var(--cyan);
  transform: translate(-50%, -50%);
}
.cursor-ring {
  width: 34px;
  height: 34px;
  border: 1.5px solid rgba(34, 211, 238, 0.6);
  transform: translate(-50%, -50%);
  transition: opacity 0.2s ease, width 0.25s ease, height 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}
html.has-cursor.cursor-active .cursor-dot,
html.has-cursor.cursor-active .cursor-ring {
  opacity: 1;
}
html.has-cursor.cursor-active { cursor: none; }
html.has-cursor.cursor-active a,
html.has-cursor.cursor-active button {
  cursor: none;
}
.cursor-ring.cursor-hover {
  width: 56px;
  height: 56px;
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(192, 38, 212, 0.7);
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  margin: 0;
  letter-spacing: 0.02em;
}

a { color: inherit; text-decoration: none; }

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

/* Decorative background */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 15% 20%, rgba(34, 211, 238, 0.10), transparent 40%),
    radial-gradient(circle at 85% 60%, rgba(192, 38, 212, 0.10), transparent 45%),
    var(--bg);
  overflow: hidden;
}
.bg-decor::before {
  content: "";
  position: absolute;
  top: -20%;
  right: -10%;
  width: 55vw;
  height: 55vw;
  background: linear-gradient(135deg, #1447e6 0%, #3b82f6 100%);
  clip-path: polygon(30% 0%, 100% 0%, 100% 70%, 0% 100%);
  opacity: 0.12;
  animation: floatBlobA 16s ease-in-out infinite;
  will-change: transform;
}
.bg-decor::after {
  content: "";
  position: absolute;
  bottom: -15%;
  left: -12%;
  width: 40vw;
  height: 40vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(192, 38, 212, 0.28) 0%, transparent 70%);
  animation: floatBlobB 20s ease-in-out infinite;
  will-change: transform;
}

/* Header / nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 13, 20, 0.75);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  display: block;
}

.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.brand-name strong { color: var(--text); }

.nav-links {
  position: relative;
  display: flex;
  gap: 36px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-indicator {
  position: absolute;
  top: 0;
  height: 3px;
  background: var(--gradient);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.7);
  border-radius: 2px;
  transition: transform 0.35s cubic-bezier(0.65, 0, 0.35, 1), width 0.35s cubic-bezier(0.65, 0, 0.35, 1), opacity 0.2s ease;
  will-change: transform, width;
}

.nav-links a {
  position: relative;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 28px 2px;
  display: inline-block;
  transition: color 0.2s ease;
}

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

.nav-links a.active { color: var(--cyan); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

/* Hero */
.hero {
  display: flex;
  align-items: center;
  gap: 64px;
  min-height: 82vh;
  padding-top: 40px;
  padding-bottom: 40px;
}

.hero-mark {
  flex-shrink: 0;
  filter: drop-shadow(0 0 40px rgba(99, 102, 241, 0.35));
  opacity: 0;
}
body.ready .hero-mark {
  animation: fadeInUp 0.8s ease forwards 0.1s;
}
.hero-mark img {
  display: block;
  width: 220px;
  height: 220px;
}

.tagline,
.hero-sub,
.hero-actions {
  opacity: 0;
}
body.ready .tagline,
body.ready .hero-sub,
body.ready .hero-actions {
  animation: fadeInUp 0.8s ease forwards;
}
body.ready .tagline { animation-delay: 0.55s; }
body.ready .hero-sub { animation-delay: 0.7s; }
body.ready .hero-actions { animation-delay: 0.85s; }

.hero-text h1 {
  font-size: clamp(40px, 6vw, 68px);
  font-weight: 700;
  line-height: 1.05;
  color: var(--text);
}

/* Hero title word-by-word reveal */
.split-title { perspective: 700px; }
.split-title .word {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: 0.1em;
  margin-bottom: -0.1em;
}
.split-title .word-inner {
  display: inline-block;
  opacity: 0;
  transform: translateY(115%) rotateX(55deg);
  transform-origin: bottom;
}
.split-title .word.accent .word-inner {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
body.ready .split-title .word-inner {
  animation: wordIn 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
body.ready .split-title .word:nth-child(1) .word-inner { animation-delay: 0.15s; }
body.ready .split-title .word:nth-child(2) .word-inner { animation-delay: 0.25s; }
body.ready .split-title .word:nth-child(3) .word-inner { animation-delay: 0.35s; }

.tagline {
  margin-top: 14px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(18px, 2.4vw, 26px);
  letter-spacing: 0.18em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.tagline .slash { color: var(--cyan); }
.tagline::after {
  content: "_";
  color: var(--cyan);
  margin-left: 4px;
  animation: blinkCursor 1.1s step-end infinite;
}

.hero-sub {
  margin-top: 22px;
  max-width: 520px;
  color: var(--text-dim);
  font-size: 16px;
}

.hero-actions {
  margin-top: 32px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 14px 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.03em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-primary {
  background: var(--gradient);
  background-size: 200% 200%;
  color: #05060a;
  animation: gradientPan 6s ease infinite, pulseGlow 2.6s ease-in-out infinite;
}
.btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
  animation-play-state: paused, paused;
}

.btn-ghost {
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  transform: translateY(-2px);
}

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}
.reveal-stagger.in-view .reveal-item:nth-child(1) { transition-delay: 0s; }
.reveal-stagger.in-view .reveal-item:nth-child(2) { transition-delay: 0.12s; }
.reveal-stagger.in-view .reveal-item:nth-child(3) { transition-delay: 0.24s; }
.reveal-stagger .reveal-item {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal-stagger.in-view .reveal-item {
  opacity: 1;
  transform: translateY(0);
}

/* Sections */
.section {
  padding: 100px 32px;
  border-top: 1px solid var(--border);
}

.section-title {
  font-size: 28px;
  margin-bottom: 40px;
  color: var(--text);
}
.section-title .num {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-right: 8px;
}

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

.project-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  transform-style: preserve-3d;
  will-change: transform;
  overflow: hidden;
}
.project-card:hover {
  transform: translateY(-6px);
  border-color: rgba(34, 211, 238, 0.4);
  box-shadow: 0 16px 40px rgba(99, 102, 241, 0.18);
}
.project-card.tilt::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 50%), rgba(99, 102, 241, 0.18), transparent 65%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.project-card.tilt:hover::before {
  opacity: 1;
}
.project-card > * {
  position: relative;
  z-index: 1;
}
.project-card h3 {
  transition: color 0.25s ease;
}
.project-card:hover h3 {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.project-card.featured {
  border-image: var(--gradient) 1;
}

.project-tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.1);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.project-card h3 {
  font-size: 22px;
  margin-bottom: 10px;
}

.project-card p {
  color: var(--text-dim);
  font-size: 14.5px;
}

.tech-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 18px 0 0;
}
.tech-list li {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

/* About */
.about-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 48px;
}
.about-grid p {
  color: var(--text-dim);
  font-size: 16px;
  max-width: 560px;
}
.about-stack h4 {
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.stack-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.stack-tags span {
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.stack-tags span:hover {
  transform: translateY(-3px);
  border-color: rgba(34, 211, 238, 0.5);
  color: var(--cyan);
}

/* Contact */
.contact { text-align: center; }
.contact-lead {
  color: var(--text-dim);
  max-width: 480px;
  margin: 0 auto 28px;
}
.contact-cta { font-size: 16px; }
.social-links {
  margin-top: 28px;
  display: flex;
  justify-content: center;
  gap: 24px;
}
.social-links a {
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.06em;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.social-links a:hover {
  color: var(--cyan);
  border-color: var(--cyan);
}

/* Blog */
.blog { text-align: center; }
.coming-soon { color: var(--text-dim); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* Responsive */
@media (max-width: 860px) {
  .hero { flex-direction: column; text-align: center; padding-top: 60px; }
  .hero-sub { margin-left: auto; margin-right: auto; }
  .hero-actions { justify-content: center; }
  .about-grid { grid-template-columns: 1fr; }
  .about-grid p { margin: 0 auto; }
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute;
    top: 76px;
    left: 0;
    right: 0;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    gap: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }
  .nav-links.open { max-height: 340px; }
  .nav-links li { border-top: 1px solid var(--border); }
  .nav-links a { display: block; padding: 18px 32px; }
  .nav-indicator { display: none; }
  .brand-name { display: none; }
  .section { padding: 70px 24px; }
}
