/* Critical CSS - Inline in head for instant first paint */
/* Font Loading - Prevent FOIT and layout shift */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Inter');
}

/* Prevent CLS - Reserve space and prevent shifts */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  scroll-behavior: smooth;
  touch-action: manipulation;
}

body {
  margin: 0;
  line-height: inherit;
  background-color: #f9fafb;
  color: #111827;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

/* Prevent CLS from images - CRITICAL */
img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Navigation - fixed height prevents CLS */
nav {
  height: 80px;
  background: rgba(255, 255, 255, 0.9);
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 50;
  border-bottom: 1px solid #e5e7eb;
  contain: layout;
}

/* Hero section - reserve space */
.hero-section {
  min-height: 500px;
  padding-top: 100px;
}

/* Grid layout - reserve space to prevent CLS */
#irs-forms-grid,
#templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  min-height: 400px;
  contain: layout;
}

@media (min-width: 768px) {
  #irs-forms-grid,
  #templates-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Template cards - fixed dimensions prevent CLS */
.template-card {
  background: #fff;
  border-radius: 1rem;
  padding: 1.5rem;
  border: 2px solid #e5e7eb;
  contain: layout style paint;
}

.template-card .card-image,
.template-card img {
  width: 100%;
  height: 192px;
  object-fit: cover;
  border-radius: 0.75rem;
  background: #f3f4f6;
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

/* Hover effects */
.hover-lift {
  transition: transform 0.3s ease;
  will-change: transform;
}

.hover-lift:hover {
  transform: translateY(-4px);
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

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

/* Scroll animations - disable initially to prevent CLS */
.scroll-appear {
  opacity: 1;
  transform: none;
}

/* Skip to main */
.skip-to-main {
  position: absolute;
  left: -9999px;
  z-index: 999;
}

.skip-to-main:focus {
  left: 50%;
  transform: translateX(-50%);
  padding: 1em;
  background: black;
  color: white;
}
