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

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

@layer base {
:root {
    --background: 250 250 250;
    --foreground: 26 26 26;

    --card: 0 0% 100%;
    --card-foreground: 26 26 26;

    --popover: 0 0% 100%;
    --popover-foreground: 26 26 26;

    --primary: 26 26 26;
    --primary-foreground: 250 250 250;

    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 26 26 26;

    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 35%;

    --accent: 240 4.8% 95.9%;
    --accent-foreground: 26 26 26;

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

    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 26 26 26;

    --radius: 0.75rem;
    
    /* Enhanced color contrast tokens */
    --text-high-contrast: 26 26 26;
    --text-medium-contrast: 240 3.8% 35%;
    --text-low-contrast: 240 3.8% 50%;

    --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%;
  }
}

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

  body {
    @apply bg-brand-off-white text-brand-charcoal;
    /* Mobile-first font family with system fallbacks */
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Inter", sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
  }
  
  h1, h2, h3, h4, h5, h6 {
    @apply font-bold;
    contain: layout style paint;
    word-wrap: break-word;
    hyphens: auto;
  }

  html {
    font-display: optional; /* Better for mobile performance */
    overflow-x: hidden;
    scroll-behavior: smooth;
  }
  
  /* Font loading optimization */
  @font-face {
    font-family: 'Inter-fallback';
    size-adjust: 100.06%;
    ascent-override: 90%;
    src: local('BlinkMacSystemFont'), local('Segoe UI'), local('Helvetica Neue'), local('Arial'), sans-serif;
  }

  * {
    -webkit-overflow-scrolling: touch;
  }

  img {
    height: auto;
    max-width: 100%;
  }

  /* Improved typography hierarchy */
  h1 {
    font-size: clamp(1.75rem, 4vw, 3rem);
    line-height: 1.1;
    margin-bottom: 1.5rem;
    font-weight: 900;
  }
  
  h2 {
    font-size: clamp(1.25rem, 3vw, 2rem);
    line-height: 1.2;
    margin-bottom: 1rem;
    font-weight: 700;
  }
  
  h3 {
    font-size: clamp(1.125rem, 2.5vw, 1.5rem);
    line-height: 1.3;
    margin-bottom: 0.75rem;
    font-weight: 600;
  }

  /* Improved mobile typography and spacing */
  @media (max-width: 768px) {
    body {
      font-size: 16px;
      line-height: 1.6;
    }

    /* Better mobile padding and spacing */
    .container {
      padding-left: 1rem;
      padding-right: 1rem;
    }
    
    /* Improved mobile spacing */
    section {
      padding: 2rem 0;
    }
    
    /* Better mobile card spacing */
    .space-y-3 > * + * {
      margin-top: 1rem;
    }
  }
}

@layer components {
  /* Mobile performance optimizations */
  .header-logo {
    width: auto;
    height: 64px;
    object-fit: contain;
    aspect-ratio: 240/112;
    contain: layout style paint;
  }
  
  @media (min-width: 1024px) {
    .header-logo {
      height: 96px;
    }
  }
  
  .mobile-hero-section {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    min-height: 70vh;
    contain: layout style paint;
  }
  
  .mobile-benefit-item {
    opacity: 0;
    animation: fadeInUp 0.3s ease-out forwards;
  }
  
  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .widget-container {
    min-height: 400px;
    aspect-ratio: 1/1.2;
    contain: layout style paint;
  }

  .edition-card {
    @apply transition-transform duration-300;
    contain: layout style paint;
  }
  
  .edition-card:hover {
    transform: scale(1.02);
  }
  
  .cta-button {
    @apply px-8 py-4 rounded-lg font-bold text-lg transition-colors duration-200;
    contain: layout style paint;
  }
  
  .floating-cta {
    @apply fixed z-50 md:hidden;
    contain: layout style paint;
    transform: translate3d(0, 0, 0); /* Force GPU acceleration */
  }
  
  .sticky-cta {
    @apply hidden md:block sticky top-4 z-40;
    contain: layout style paint;
  }

  /* Mobile optimizations */
  @media (max-width: 768px) {
    .edition-card:hover {
      transform: none;
    }
    
    .cta-button:hover {
      transform: none;
    }
    
    .cta-button {
      @apply px-6 py-3 text-base;
    }

    /* Mobile-specific button styling */
    button, .button {
      min-height: 44px;
      font-size: 16px;
    }

    /* Prevent zoom on inputs */
    input, select, textarea {
      font-size: 16px;
    }

    /* Better mobile menu */
    #mobile-menu {
      box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
      border-top: 1px solid #e5e7eb;
    }
  }

  .loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0f0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    will-change: background-position;
  }

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

  /* Mobile touch targets and accessibility */
  @media (max-width: 768px) {
    button, a, input, select, textarea {
      min-height: 48px;
      min-width: 48px;
      padding: 0.75rem 1rem;
    }

    .mobile-hide {
      display: none !important;
    }
    
    .mobile-show {
      display: block !important;
    }
    
    .mobile-full-width {
      width: 100% !important;
    }
    
    .mobile-text-center {
      text-align: center !important;
    }
    
    /* Improved mobile spacing */
    .mobile-space-y-4 > * + * {
      margin-top: 1rem;
    }
    
    /* Better mobile button sizing */
    .cta-button {
      @apply px-8 py-4 text-lg min-h-[3rem];
    }
  }

  /* Scroll-triggered animations */
  .scroll-animate {
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
  }

  .scroll-animate-delayed {
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
  }

  /* Stagger animation delays */
  .animate-stagger-1 { animation-delay: 100ms; }
  .animate-stagger-2 { animation-delay: 200ms; }
  .animate-stagger-3 { animation-delay: 300ms; }
  .animate-stagger-4 { animation-delay: 400ms; }
  .animate-stagger-5 { animation-delay: 500ms; }

  /* Enhanced loading states with GPU acceleration */
  .skeleton-loading {
    background: linear-gradient(90deg, 
      hsl(var(--muted)) 25%, 
      hsl(var(--muted) / 0.7) 50%, 
      hsl(var(--muted)) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    will-change: background-position;
    backface-visibility: hidden;
    transform: translateZ(0);
  }

  @keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }
  
  /* Performance-optimized shimmer effect */
  @keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
  }
}

.container {
  contain: layout style paint;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .scroll-animate,
  .scroll-animate-delayed {
    transition: none !important;
  }
}

.virtualized-list {
  contain: strict;
  will-change: transform;
}

section {
  contain: layout style paint;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
  will-change: transform;
}
