@import "tailwindcss";

/* ───── THEME ───── */

@theme {
  /* Colors */
  --color-background: #0F1117;
  --color-surface: #1A1D29;
  --color-elevated: #252A3A;
  --color-border: #34384A;

  --color-text-primary: #F5F7FF;
  --color-text-secondary: #A1A8C3;
  --color-text-muted: #6B7290;

  --color-purple-50: #F5F3FF;
  --color-purple-100: #EDE9FE;
  --color-purple-200: #DDD6FE;
  --color-purple-300: #C4B5FD;
  --color-purple-400: #A78BFA;
  --color-purple-500: #8B5CF6;
  --color-purple-600: #7C3AED;
  --color-purple-700: #6D28D9;
  --color-purple-800: #5B21B6;
  --color-purple-900: #4C1D95;

  --color-accent: #C4B5FD;
  --color-error: #F43F5E;

  /* Fonts */
  --font-sans: var(--font-geist-sans), system-ui, sans-serif;
  --font-display: var(--font-sora), system-ui, sans-serif;
  --font-mono: var(--font-jetbrains), monospace;

  /* Font sizes */
  --text-display-2xl: clamp(3rem, 8vw, 6.5rem);
  --text-display-2xl--line-height: 1.02;
  --text-display-2xl--letter-spacing: -0.04em;

  --text-display-xl: clamp(2.5rem, 6vw, 5rem);
  --text-display-xl--line-height: 1.05;
  --text-display-xl--letter-spacing: -0.035em;

  --text-display-lg: clamp(2rem, 4.5vw, 3.5rem);
  --text-display-lg--line-height: 1.08;
  --text-display-lg--letter-spacing: -0.03em;

  /* Shadows */
  --shadow-glow-sm: 0 0 20px -2px rgba(139, 92, 246, 0.25);
  --shadow-glow-md: 0 0 40px -4px rgba(139, 92, 246, 0.35);
  --shadow-glow-lg: 0 0 80px -8px rgba(139, 92, 246, 0.45);
  --shadow-glow-xl: 0 0 120px -12px rgba(139, 92, 246, 0.5);
  --shadow-inner-glow: inset 0 0 30px -8px rgba(139, 92, 246, 0.3);
  --shadow-card: 0 1px 0 0 rgba(255, 255, 255, 0.04) inset,
    0 0 0 0.5px rgba(255, 255, 255, 0.06);
  --shadow-card-hover: 0 1px 0 0 rgba(255, 255, 255, 0.08) inset,
    0 0 0 0.5px rgba(167, 139, 250, 0.3),
    0 20px 60px -20px rgba(139, 92, 246, 0.4);

  /* Animations */
  --animate-fade-up: fade-up 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  --animate-fade-in: fade-in 0.6s ease-out forwards;
  --animate-float: float 8s ease-in-out infinite;
  --animate-float-slow: float 14s ease-in-out infinite;
  --animate-scanline: scanline 8s linear infinite;
  --animate-pulse-glow: pulse-glow 4s ease-in-out infinite;
  --animate-shimmer: shimmer 2.5s ease-in-out infinite;
  --animate-grid-flow: grid-flow 20s linear infinite;
}

/* ───── KEYFRAMES ───── */

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

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes float {
  0%, 100% { transform: translateY(0) translateX(0); }
  33% { transform: translateY(-15px) translateX(10px); }
  66% { transform: translateY(10px) translateX(-10px); }
}

@keyframes scanline {
  from { transform: translateY(-100%); }
  to { transform: translateY(100vh); }
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.4; filter: blur(40px); }
  50% { opacity: 0.7; filter: blur(60px); }
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

@keyframes grid-flow {
  from { transform: translate(0, 0); }
  to { transform: translate(40px, 40px); }
}

/* ───── BASE ───── */

@layer base {
  html {
    @apply antialiased bg-background;
    scroll-behavior: smooth;
    /* Make the root canvas dark so the first painted frame is never white. */
    color-scheme: dark;
  }

  body {
    @apply bg-background text-text-primary font-sans;
    min-height: 100vh;
    overflow-x: hidden;
  }

  /* Decorative gradient as a composited fixed layer instead of
     `background-attachment: fixed`, which Firefox paints on a slower,
     non-composited path that flashes on first paint. The solid
     `bg-background` on html/body already covers the canvas, so this
     layer only adds the gradient — and never causes a white frame. */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
      radial-gradient(ellipse 80% 50% at 50% -20%, rgba(139, 92, 246, 0.12), transparent),
      linear-gradient(180deg, #0F1117 0%, #0A0C12 100%);
  }

  ::selection {
    background: rgba(139, 92, 246, 0.3);
    color: #F5F7FF;
  }

  ::-webkit-scrollbar { width: 10px; }
  ::-webkit-scrollbar-track { background: #0F1117; }
  ::-webkit-scrollbar-thumb {
    background: #34384A;
    border-radius: 5px;
    border: 2px solid #0F1117;
  }
  ::-webkit-scrollbar-thumb:hover { background: #5B21B6; }

  h1, h2, h3, h4, h5, h6 {
    @apply font-display tracking-tight;
  }
}

/* ───── UTILITIES ───── */

@utility glass {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.025) 0%,
    rgba(255, 255, 255, 0.01) 100%
  );
  backdrop-filter: blur(12px);
  border: 0.5px solid rgba(255, 255, 255, 0.08);
}

@utility glass-strong {
  background: linear-gradient(
    180deg,
    rgba(37, 42, 58, 0.6) 0%,
    rgba(26, 29, 41, 0.4) 100%
  );
  backdrop-filter: blur(20px);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
}

@utility text-gradient-purple {
  background: linear-gradient(135deg, #C4B5FD 0%, #A78BFA 50%, #8B5CF6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

@utility text-gradient-fade {
  background: linear-gradient(180deg, #F5F7FF 0%, #A1A8C3 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

@utility grid-bg {
  background-image:
    linear-gradient(rgba(139, 92, 246, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 92, 246, 0.07) 1px, transparent 1px);
  background-size: 40px 40px;
}

@utility scanline-bg {
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(139, 92, 246, 0.04) 2px,
    rgba(139, 92, 246, 0.04) 4px
  );
}

@utility vignette {
  box-shadow: inset 0 0 200px 50px rgba(0, 0, 0, 0.5);
}

/* ───── REDUCED MOTION ───── */

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