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

/* Scandinavian Design System - Clean, minimal, natural tones */

@layer base {
  :root {
    /* Core Scandinavian palette */
    --background: 0 0% 99%;
    --foreground: 220 15% 20%;

    /* Card system */
    --card: 0 0% 100%;
    --card-foreground: 220 15% 20%;

    /* Popover system */
    --popover: 0 0% 100%;
    --popover-foreground: 220 15% 20%;

    /* Primary - Deep Nordic blue-gray */
    --primary: 215 25% 27%;
    --primary-foreground: 0 0% 98%;
    --primary-hover: 215 30% 22%;

    /* Secondary - Warm stone gray */
    --secondary: 20 8% 95%;
    --secondary-foreground: 220 15% 25%;
    --secondary-hover: 20 10% 90%;

    /* Muted tones - Enhanced contrast for accessibility */
    --muted: 210 10% 96%;
    --muted-foreground: 220 10% 40%;

    /* Accent - Sage green with improved contrast för bättre läsbarhet */
    --accent: 145 25% 75%;
    --accent-foreground: 145 35% 20%;
    --accent-hover: 145 30% 70%;

    /* Natural warm accent */
    --warm-accent: 35 15% 88%;
    --warm-accent-foreground: 35 25% 25%;

    /* Destructive */
    --destructive: 0 65% 58%;
    --destructive-foreground: 0 0% 98%;

    /* Borders and inputs - Subtle Nordic */
    --border: 220 13% 91%;
    --input: 220 13% 91%;
    --ring: 215 25% 27%;

    --radius: 0.5rem;

    /* Scandinavian gradients */
    --gradient-hero: linear-gradient(135deg, hsl(var(--background)), hsl(var(--accent)));
    --gradient-card: linear-gradient(180deg, hsl(var(--card)), hsl(var(--secondary)));
    
    /* Shadows with Nordic feel */
    --shadow-soft: 0 4px 20px -4px hsl(var(--primary) / 0.1);
    --shadow-elegant: 0 10px 40px -10px hsl(var(--primary) / 0.15);
    
    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-background: 0 0% 98%;

    --sidebar-foreground: 240 5.3% 26.1%;

    --sidebar-primary: 240 5.9% 10%;

    --sidebar-primary-foreground: 0 0% 98%;

    --sidebar-accent: 240 4.8% 95.9%;

    --sidebar-accent-foreground: 240 5.9% 10%;

    --sidebar-border: 220 13% 91%;

    --sidebar-ring: 217.2 91.2% 59.8%;
  }

  .dark {
    --background: 215 25% 12%;
    --foreground: 0 0% 98%;

    --card: 215 25% 15%;
    --card-foreground: 0 0% 98%;

    --popover: 215 25% 15%;
    --popover-foreground: 0 0% 98%;

    --primary: 0 0% 98%;
    --primary-foreground: 215 25% 12%;
    --primary-hover: 0 0% 90%;

    --secondary: 215 20% 20%;
    --secondary-foreground: 0 0% 98%;
    --secondary-hover: 215 20% 25%;

    --muted: 215 20% 18%;
    --muted-foreground: 220 8% 65%;

    --accent: 145 20% 25%;
    --accent-foreground: 145 20% 85%;
    --accent-hover: 145 25% 30%;

    --warm-accent: 35 15% 25%;
    --warm-accent-foreground: 35 15% 85%;

    --destructive: 0 65% 45%;
    --destructive-foreground: 0 0% 98%;

    --border: 215 20% 22%;
    --input: 215 20% 22%;
    --ring: 0 0% 98%;
    --sidebar-background: 240 5.9% 10%;
    --sidebar-foreground: 240 4.8% 95.9%;
    --sidebar-primary: 224.3 76.3% 48%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 240 3.7% 15.9%;
    --sidebar-accent-foreground: 240 4.8% 95.9%;
    --sidebar-border: 240 3.7% 15.9%;
    --sidebar-ring: 217.2 91.2% 59.8%;
  }
}

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

  body {
    @apply bg-background text-foreground;
  }
  
  html {
    scroll-behavior: smooth;
    /* Performance optimizations */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  /* Critical performance optimizations */
  * {
    box-sizing: border-box;
  }

  /* Mobile-optimized typography with performance in mind */
  h1, h2, h3, h4, h5, h6 {
    @apply leading-tight;
    font-display: swap; /* Improve font loading performance */
  }

  /* Optimize image loading */
  img {
    height: auto;
    max-width: 100%;
  }

  /* Reduce layout shift for lazy-loaded content */
  .lazy-placeholder {
    background: linear-gradient(90deg, hsl(var(--muted)) 25%, transparent 50%, hsl(var(--muted)) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
  }

  @keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
  }
}

@layer components {
  /* Mobile-friendly button improvements */
  .btn-touch {
    @apply min-h-[44px] min-w-[44px] touch-manipulation;
  }
  
  /* Mobile navigation improvements */
  .mobile-nav-link {
    @apply block py-3 px-4 text-base font-medium touch-manipulation;
  }
  
  /* Responsive container with better mobile padding */
  .container-responsive {
    @apply container mx-auto px-4 sm:px-6 lg:px-8;
  }
  
  /* Mobile-optimized cards */
  .card-mobile {
    @apply p-4 sm:p-6 lg:p-8;
  }
}

@layer utilities {
  /* Touch-friendly utilities */
  .touch-target {
    @apply min-h-[44px] min-w-[44px];
  }
  
  /* Safe area handling for mobile devices */
  .safe-top {
    padding-top: env(safe-area-inset-top);
  }
  
  .safe-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  /* Mobile viewport handling */
  .min-h-screen-mobile {
    min-height: 100vh;
    min-height: 100dvh;
  }
  
  /* Mobile Sticky CTA Animations */
  @keyframes slide-up {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  @keyframes scale-in {
    from {
      transform: scale(0.95);
      opacity: 0;
    }
    to {
      transform: scale(1);
      opacity: 1;
    }
  }

  .animate-slide-up {
    animation: slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .animate-scale-in {
    animation: scale-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }
}