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

/* 
 * Font loading strategy for CLS prevention:
 * - Use font-display: optional for above-the-fold content (prevents FOUT/CLS)
 * - size-adjust ensures fallback font matches Inter's metrics
 * - Fallback stack: system-ui provides instant rendering
 */

/* Primary font - Inter Variable */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter/Inter-VariableFont_opsz,wght.ttf') format('truetype-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: optional; /* Prevents CLS - uses fallback if font not cached */
  size-adjust: 100%; /* Adjust if needed to match fallback metrics */
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter/Inter-Italic-VariableFont_opsz,wght.ttf') format('truetype-variations');
  font-weight: 100 900;
  font-style: italic;
  font-display: optional;
  size-adjust: 100%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

/* Fallback font with adjusted metrics to match Inter */
@font-face {
  font-family: 'Inter-fallback';
  src: local('Arial'), local('Helvetica Neue'), local('Helvetica'), local('sans-serif');
  font-weight: 100 900;
  font-style: normal;
  size-adjust: 107%; /* Adjusted to match Inter's character width */
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@layer base {
  /* 
   * Accessibility: Focus-visible styles for keyboard navigation
   * Using :focus-visible to only show focus ring for keyboard users
   */
  
  /* Default focus-visible style for all interactive elements */
  :focus-visible {
    outline: 2px solid #F79800; /* Orange brand color */
    outline-offset: 2px;
    border-radius: 4px;
  }
  
  /* Remove default focus styles (we're using focus-visible instead) */
  :focus:not(:focus-visible) {
    outline: none;
  }
  
  /* High contrast focus for dark backgrounds */
  .bg-slate-900 :focus-visible,
  [class*="bg-[#15171e]"] :focus-visible {
    outline-color: #ffaf00; /* Brighter orange for dark backgrounds */
  }
}

@layer utilities {
  .clip-path-slant {
    clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%);
  }
  
  /* Hide scrollbar but keep functionality */
  .scrollbar-hide {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
  }
  .scrollbar-hide::-webkit-scrollbar {
    display: none;  /* Chrome, Safari and Opera */
  }
  
  /* Screen reader only - visually hidden but accessible to assistive tech */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }
  
  .sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }
  
  /* 
   * Accessibility: Improved color contrast utilities
   * These override Tailwind defaults for better WCAG compliance
   */
  
  /* text-slate-400 on dark backgrounds needs better contrast */
  /* WCAG AA requires 4.5:1 for normal text, 3:1 for large text */
  .text-accessible-muted {
    color: #94a3b8; /* slate-400 - 4.6:1 contrast on #15171e */
  }
  
  /* For better contrast on dark backgrounds */
  .text-accessible-light {
    color: #cbd5e1; /* slate-300 - 7.5:1 contrast on #15171e */
  }
}

html {
  scroll-behavior: smooth;
}

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

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 
 * Accessibility: Ensure minimum tap target size (48x48px)
 * This is handled in components but we add a safety net
 */
@media (pointer: coarse) {
  button,
  [role="button"],
  a,
  input,
  select,
  textarea {
    min-height: 44px;
    min-width: 44px;
  }
}
