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

/* Definition of the design system. All colors, gradients, fonts, etc should be defined here. 
All colors MUST be HSL.
*/

@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 225 20% 20%;

    --card: 0 0% 100%;
    --card-foreground: 225 20% 20%;

    --popover: 0 0% 100%;
    --popover-foreground: 225 20% 20%;

    --primary: 225 100% 25%;
    --primary-foreground: 0 0% 100%;
    --primary-light: 225 100% 35%;
    --primary-glow: 225 100% 55%;

    --secondary: 0 0% 100%;
    --secondary-foreground: 225 100% 25%;

    --muted: 0 0% 98%;
    --muted-foreground: 225 20% 35%;

    --accent: 0 0% 100%;
    --accent-foreground: 225 100% 25%;

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

    --border: 220 13% 91%;
    --input: 220 13% 91%;
    --ring: 225 100% 55%;

    --radius: 0.75rem;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, hsl(225 100% 25%), hsl(225 100% 35%));
    --gradient-hero: linear-gradient(180deg, hsl(225 100% 25%) 0%, hsl(225 100% 35%) 100%);
    --gradient-accent: linear-gradient(135deg, hsl(225 100% 35%), hsl(210 100% 50%));

    /* Shadows */
    --shadow-soft: 0 2px 8px hsl(225 100% 25% / 0.08);
    --shadow-medium: 0 4px 16px hsl(225 100% 25% / 0.12);
    --shadow-large: 0 8px 32px hsl(225 100% 25% / 0.16);

    /* Food Safety accents mapped to brand palette (#000D80 → #0014B3) */
    --teal: 225 100% 45%;
    --teal-foreground: 0 0% 100%;
    --teal-soft: 225 100% 94%;
    --petroleum: 231 100% 15%;
    --gradient-food-safety: linear-gradient(135deg, hsl(231 100% 15%) 0%, hsl(230 100% 35%) 100%);

    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }


  .dark {
    --background: 225 40% 8%;
    --foreground: 0 0% 98%;

    --card: 225 40% 10%;
    --card-foreground: 0 0% 98%;

    --popover: 225 40% 10%;
    --popover-foreground: 0 0% 98%;

    --primary: 225 100% 55%;
    --primary-foreground: 0 0% 100%;
    --primary-light: 225 100% 65%;
    --primary-glow: 225 100% 75%;

    --secondary: 0 0% 100%;
    --secondary-foreground: 220 13% 96%;

    --muted: 220 13% 18%;
    --muted-foreground: 220 9% 60%;

    --accent: 220 13% 25%;
    --accent-foreground: 220 13% 96%;

    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 100%;

    --border: 220 13% 25%;
    --input: 220 13% 25%;
    --ring: 225 100% 65%;
  }
}

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

  body {
    @apply bg-background text-foreground font-sans;
  }

  /* Accessible focus styles */
  *:focus-visible {
    @apply outline-none ring-2 ring-ring ring-offset-2 ring-offset-background;
  }

  /* Ensure buttons have visible focus */
  button:focus-visible,
  a:focus-visible {
    @apply outline-none ring-2 ring-primary ring-offset-2;
  }
}

/* Performance-optimized animations */
@layer utilities {
  /* Float animation - GPU accelerated, replaces bounce for better performance */
  @keyframes float {
    0%, 100% {
      transform: translateY(0);
    }
    50% {
      transform: translateY(-8px);
    }
  }

  .animate-float {
    animation: float 4s ease-in-out infinite;
    will-change: transform;
  }

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

  /* GPU-accelerated transforms */
  .gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
  }

  /* Content visibility for off-screen elements - saves rendering */
  .content-visibility-auto {
    content-visibility: auto;
    contain-intrinsic-size: 0 400px;
  }

  /* Mobile-optimized touch targets */
  @media (max-width: 640px) {
    .touch-target {
      min-height: 44px;
      min-width: 44px;
    }
  }

  /* Faster transitions on mobile for perceived performance */
  @media (max-width: 768px) {
    .transition-all {
      transition-duration: 200ms !important;
    }
  }

  /* Optimized image rendering */
  img {
    content-visibility: auto;
  }

  /* Prevent layout shifts */
  .aspect-preserve {
    aspect-ratio: attr(width) / attr(height);
  }
}
