@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import '../ui/theme/theme.css';

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

@layer base {
  :root {
    /* Core Theme Colors (from THEME.md) */
    --color-base: #0C0D0F;
    --color-surface: #141619;
    --color-outline: #23272B;
    --color-primary: #198CFF;
    --color-telemetry: #4ED4E0;
    --color-warning: #FFBE4D;
    --color-success: #6FE37A;
    --color-critical: #E35C5C;

    /* Text Colors */
    --color-text-high: #FFFFFF;
    --color-text-med: #A1A1AA;
    --color-text-low: #71717A;

    /* Selection */
    --color-selection-bg: rgba(25, 140, 255, 0.3);
    --color-selection-text: #FFFFFF;

    /* Focus */
    --color-focus-ring: rgba(25, 140, 255, 0.5);

    /* Safe Area Insets */
    --sat: env(safe-area-inset-top);
    --sar: env(safe-area-inset-right);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
  }

  * {
    -webkit-tap-highlight-color: transparent;
    border-color: var(--color-outline);
  }

  html {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    background-color: var(--color-base);
    color: var(--color-text-high);
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  body {
    background-color: var(--color-base);
    color: var(--color-text-high);
    line-height: 1.5;
    overscroll-behavior: none;
    min-height: 100vh;
  }

  ::selection {
    background-color: var(--color-selection-bg);
    color: var(--color-selection-text);
  }

  /* Focus States */
  :focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--color-focus-ring);
  }

  /* Scrollbars */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: var(--color-base);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--color-outline);
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-low);
  }

  /* Typography Scale & Smoothing */
  h1, h2, h3, h4, h5, h6 {
    color: var(--color-text-high);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
  }

  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.875rem; }
  h3 { font-size: 1.5rem; }
  h4 { font-size: 1.25rem; }
  h5 { font-size: 1.125rem; }
  h6 { font-size: 1rem; }

  p {
    color: var(--color-text-med);
    line-height: 1.6;
  }

  /* Link Styles */
  a {
    color: var(--color-primary);
    text-decoration: none;
    transition: opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  a:hover {
    opacity: 0.8;
  }

  button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* Mobile typography optimization */
  @media (max-width: 640px) {
    h1 { font-size: clamp(1.5rem, 6vw, 2rem); }
    h2 { font-size: clamp(1.125rem, 4.5vw, 1.5rem); }
    h3 { font-size: 1.25rem; }
    p { font-size: 0.875rem; }
  }
}

@layer utilities {
  /* Precision Racing Utilities */
  .glass-panel {
    background: rgba(20, 22, 25, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--color-outline);
  }

  .subtle-gradient {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
  }

  .racing-border {
    position: relative;
  }

  .racing-border::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--color-primary) 50%, transparent 100%);
    opacity: 0.5;
  }

  /* Instrument-grade glows */
  .glow-primary {
    box-shadow: 0 0 20px -5px rgba(25, 140, 255, 0.3);
  }

  .glow-telemetry {
    box-shadow: 0 0 20px -5px rgba(78, 212, 224, 0.3);
  }

  /* Entrance animations */
  @keyframes fade-in-up {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .animate-fade-in-up {
    animation: fade-in-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

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

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

  @media (prefers-reduced-motion: reduce) {
    .animate-fade-in-up {
      animation: none;
      opacity: 1;
      transform: none;
    }
  }
}
