@tailwind base;
@tailwind components;
@tailwind utilities;

/* ============================================
   DESIGN TOKENS — QuizB 2025
   ============================================ */

@layer base {
  :root {
    /* Colors */
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;

    /* Brand — Indigo → Violet */
    --primary: 239 84% 67%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;

    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;

    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;

    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 239 84% 67%;

    --radius: 0.75rem;

    /* QuizB Custom */
    --gradient-from: #6366f1;  /* indigo-500 */
    --gradient-to: #8b5cf6;    /* violet-500 */
    --correct: #10b981;        /* emerald-500 */
    --wrong: #f43f5e;          /* rose-500 */
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
  }

  .dark {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 10% 3.9%;
    --card-foreground: 0 0% 98%;
    --popover: 240 10% 3.9%;
    --popover-foreground: 0 0% 98%;
    --primary: 239 84% 67%;
    --primary-foreground: 240 5.9% 10%;
    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 15.9%;
    --ring: 239 84% 67%;

    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
  }
}

@layer base {
  * {
    @apply border-border;
  }

  body {
    @apply bg-background text-foreground antialiased;
    font-feature-settings: "rlig" 1, "calt" 1;
  }

  html {
    scroll-behavior: smooth;
  }
}

/* ============================================
   CUSTOM UTILITIES
   ============================================ */

@layer utilities {
  /* Brand Gradient */
  .gradient-brand {
    background: linear-gradient(135deg, var(--gradient-from), var(--gradient-to));
  }

  .gradient-text {
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  /* Glassmorphism */
  .glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
  }

  .glass-card {
    @apply glass rounded-2xl p-6;
  }

  /* Glow Effects */
  .glow-indigo {
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
  }

  .glow-violet {
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.3);
  }

  /* Bento Grid */
  .bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
  }

  /* Quiz Answer States */
  .answer-correct {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
    color: #10b981;
  }

  .answer-wrong {
    background: rgba(244, 63, 94, 0.15);
    border-color: #f43f5e;
    color: #f43f5e;
  }

  /* Scrollbar */
  .scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .scrollbar-hide::-webkit-scrollbar {
    display: none;
  }

  /* Noise Texture */
  .noise {
    position: relative;
  }

  .noise::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
  }
}

/* ============================================
   PROGRESS BAR ANIMATION
   ============================================ */

.progress-bar {
  transition: width 1s linear;
}

/* ============================================
   QUIZ TIMER
   ============================================ */

@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.timer-danger {
  animation: pulse-danger 0.5s ease-in-out infinite;
  color: #f43f5e;
}

/* ============================================
   CUSTOM SELECTION
   ============================================ */

::selection {
  background: rgba(99, 102, 241, 0.3);
  color: inherit;
}
