:root {
  --bg: #050505;
  --primary: #ffffff;
  --secondary: #a1a1aa;
  --accent: #3b82f6;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg);
  color: var(--primary);
  font-family: 'Outfit', sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .font-syne {
  font-family: 'Syne', sans-serif;
}

/* Responsive Typography */
.text-huge {
  font-size: clamp(3rem, 12vw, 9rem);
  line-height: 0.85;
}

@media (max-width: 640px) {
  .text-huge {
    font-size: clamp(2.5rem, 14vw, 4rem);
  }
}

.text-mega {
  font-size: clamp(2.5rem, 8vw, 7rem);
  line-height: 1;
}

@media (max-width: 640px) {
  .text-mega {
    font-size: clamp(2rem, 12vw, 3.5rem);
  }
}

.text-huge-contact {
  font-size: clamp(3rem, 5.5vw, 8rem);
  line-height: 0.9;
}

@media (max-width: 640px) {
  .text-huge-contact {
    font-size: clamp(2.5rem, 14vw, 4.5rem);
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #050505;
}
::-webkit-scrollbar-thumb {
  background: #222;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #333;
}

/* Grain Texture */
.grain {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  z-index: 100;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("https://grainy-gradients.vercel.app/noise.svg");
}

/* Hide grain on mobile for performance */
@media (max-width: 768px) {
  .grain {
    display: none;
  }
}

/* Animations */
@keyframes reveal {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.reveal {
  opacity: 0;
}

.is-loaded .reveal {
  animation: reveal 1.5s cubic-bezier(0.77, 0, 0.175, 1) forwards;
  animation-delay: 0.8s;
}

.is-loaded .stagger-1 { animation-delay: 1.1s; }
.is-loaded .stagger-2 { animation-delay: 1.4s; }
.is-loaded .stagger-3 { animation-delay: 1.7s; }

@keyframes flicker {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.6; }
  70% { opacity: 0.3; }
}

.animate-flicker {
  animation: flicker 5s infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

.animate-breathe {
  animation: breathe 4s ease-in-out infinite;
}

@keyframes slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.animate-slide-up {
  animation: slide-up 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scale-up {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.animate-fade-in {
  animation: fade-in 0.4s ease-out forwards;
}

.animate-scale-up {
  animation: scale-up 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

/* Marquee Animation */
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@keyframes marquee-reverse {
  0% { transform: translateX(-50%); }
  100% { transform: translateX(0); }
}

.animate-marquee {
  animation: marquee 60s linear infinite;
  will-change: transform;
}

.animate-marquee-reverse {
  animation: marquee-reverse 60s linear infinite;
  will-change: transform;
}

/* Faster marquee on mobile for smaller cards */
@media (max-width: 768px) {
  .animate-marquee {
    animation-duration: 40s;
  }
  .animate-marquee-reverse {
    animation-duration: 40s;
  }
}

.pause:hover {
  animation-play-state: paused;
}

/* Glassmorphism */
.glass {
  background: rgba(5, 5, 5, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

/* Reduce glass blur on mobile for performance */
@media (max-width: 768px) {
  .glass {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
}

/* Project Card Hover */
.project-card {
  perspective: 1000px;
}
.project-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  background: linear-gradient(45deg, transparent, rgba(59, 130, 246, 0.3), transparent);
  z-index: 1;
  opacity: 0;
  transition: opacity 0.5s ease;
  border-radius: inherit;
  pointer-events: none;
}
.project-card:hover::before {
  opacity: 1;
}
.project-card:hover .project-image {
  transform: scale(1.1) rotateY(10deg) rotateX(5deg);
  filter: brightness(0.8);
}
.project-card:hover .project-overlay {
  opacity: 1;
  transform: translateZ(50px);
}

.project-image {
  transition: transform 0.8s cubic-bezier(0.33, 1, 0.68, 1);
  transform-style: preserve-3d;
}

.project-overlay {
  transform-style: preserve-3d;
  transition: all 0.6s cubic-bezier(0.33, 1, 0.68, 1);
}

.loader {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 2.5s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0s;
}

.loader > .container {
  opacity: 0;
  animation: fade-in 1.5s ease-out forwards;
  transition: opacity 1.5s ease-in-out;
}

.loader.loader-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 2.5s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 2.5s;
}

.loader.loader-hidden > .container {
  opacity: 0;
}

.text-outline {
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.3);
}

.text-brand-about {
  font-size: clamp(1.5rem, 4vw, 2.75rem);
}

@media (max-width: 768px) {
  .text-brand-about {
    font-size: clamp(1rem, 6vw, 1.5rem);
  }
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: white;
  transition: width 0.3s ease;
}

.nav-link:hover::after {
  width: 100%;
}

/* Ambient Glow & Blobs */
.glow {
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
  filter: blur(60px);
  pointer-events: none;
  z-index: -1;
}

@media (max-width: 768px) {
  .glow {
    width: 300px;
    height: 300px;
    filter: blur(40px);
  }
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  opacity: 0.4;
  animation: blob-float 20s infinite alternate;
  pointer-events: none;
}

@media (max-width: 768px) {
  .blob {
    filter: blur(50px);
    opacity: 0.25;
  }
}

@keyframes blob-float {
  0% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(10vw, 5vh) scale(1.1); }
  66% { transform: translate(-5vw, 15vh) scale(0.9); }
  100% { transform: translate(5vw, -5vh) scale(1); }
}

.animate-gradient {
  background-size: 400% 400%;
  animation: gradient 8s ease infinite;
}

@keyframes gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Scroll Progress */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 100;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.1s ease-out;
}

/* Custom Cursor Enhancements */
.cursor-dot {
  width: 8px;
  height: 8px;
  background-color: white;
  position: fixed;
  border-radius: 50%;
  z-index: 9999;
  pointer-events: none;
  display: none;
  opacity: 0;
  will-change: transform;
}
.cursor-dot.active {
  width: 40px;
  height: 40px;
  background-color: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
}
@media (min-width: 769px) {
  .cursor-dot { display: block; }
  * { cursor: none; }
}
.cursor-outline {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  position: fixed;
  border-radius: 50%;
  z-index: 9998;
  pointer-events: none;
  display: none;
  opacity: 0;
  will-change: transform;
}
@media (min-width: 769px) {
  .cursor-outline { display: block; }
}

/* Disable costly effects on reduced-motion or slow devices */
@media (prefers-reduced-motion: reduce), (update: slow) {
  .glass {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(5, 5, 5, 0.95);
  }

  .animate-gradient {
    animation: none;
    background-clip: border-box;
    -webkit-text-fill-color: initial;
  }

  .animate-marquee,
  .animate-marquee-reverse {
    animation-duration: 120s;
  }

  .blob {
    animation: none;
  }

  .animate-flicker,
  .animate-breathe {
    animation: none;
  }
}

/* GPU layer hints for animated elements */
.blob,
.atmospheric-beam,
.lens-glow,
.lens-flare {
  will-change: opacity, transform;
  transform: translateZ(0);
}

/* Reduce light beam complexity on mobile */
@media (max-width: 768px) {
  .lens-glow {
    display: none;
  }
  .lens-flare {
    display: none;
  }
  .atmospheric-beam {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }
}

/* Reduce blob complexity on mobile */
@media (max-width: 768px) {
  .blob {
    filter: blur(40px);
    opacity: 0.15;
    animation-duration: 30s;
  }
}

/* Ensure touch targets are large enough on mobile */
@media (max-width: 768px) {
  button, a, [onclick] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Prevent iOS zoom on input focus */
  input, textarea, select {
    font-size: 16px !important;
  }
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}
