/**
 * Coberminas — Core Web Vitals Optimization CSS
 * Reduz CLS (Cumulative Layout Shift) e melhora LCP (Largest Contentful Paint)
 *
 * Estratégias:
 * 1. Reserva de espaço para imagens (aspect-ratio)
 * 2. Font display: swap para evitar FOIT
 * 3. Conteúdo acima da dobra com inline styles reduzidos
 * 4. Scroll-behavior suave sem jank
 */

/* ===== 1. RESET MÍNIMO PARA CLS ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

/* ===== 2. RESERVA DE ESPAÇO PARA IMAGENS (evita CLS) ===== */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Aspect ratios fixos para containers de imagem */
.img-hero {
  aspect-ratio: 16/9;
  object-fit: cover;
}

.img-card {
  aspect-ratio: 4/3;
  object-fit: cover;
}

.img-logo {
  width: 140px;
  height: 40px;
  object-fit: contain;
}

/* ===== 3. FONT LOADING — evita FOIT ===== */
/* Usa system fonts enquanto a web font carrega */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ===== 4. HEADER FIXO — reserva espaço para evitar CLS ===== */
#site-header {
  min-height: 64px;
  contain: layout;
}

/* ===== 5. BANNERS E TOASTS — position fixed não afeta CLS ===== */
#cbm-banner,
#cbm-wa-float,
.site-banner {
  position: fixed;
  z-index: 9999;
  will-change: transform;
}

/* ===== 6. ANIMAÇÕES REDUZIDAS (prefer-reduced-motion) ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== 7. SCROLL SUAVE ===== */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ===== 8. LCP OTIMIZAÇÃO — hero section ===== */
/* Garante que o hero renderize sem esperar recursos externos */
.hero {
  contain: layout style;
  min-height: 340px; /* evita refluxo quando o conteúdo carrega */
}

.hero h1 {
  font-display: swap; /* carrega sem bloquear */
}

/* ===== 9. CARDS E GRIDS — prevent layout shifts ===== */
.cards, .fatores, .grid {
  contain: layout;
}

/* ===== 10. BOTÕES — tamanho mínimo para mobile (INP) ===== */
/* INP (Interaction to Next Paint) — botões touch-friendly */
.btn-wa,
.btn-site,
.faq-q,
.faq-nav a,
button {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation; /* remove delay de 300ms no mobile */
  cursor: pointer;
}

/* ===== 11. LAZY LOADING ===== */
img[loading="lazy"] {
  content-visibility: auto;
}

/* ===== 12. CLS PREVENTION — containers com altura definida ===== */
.stats {
  min-height: 80px;
  contain: layout;
}

.stat {
  min-width: 120px;
}

/* ===== 13. PRINT STYLES (não afeta CWV mas boa prática) ===== */
@media print {
  .btn-wa, .btn-site, #cbm-banner, #cbm-wa-float {
    display: none !important;
  }
  a[href]::after {
    content: " (" attr(href) ")";
  }
}

/* ===== 14. CONTAINER QUERY SUPPORT (progressivo) ===== */
@supports (container-type: inline-size) {
  .cards {
    container-type: inline-size;
  }
}

/* ===== 15. COLOR SCHEME ===== */
:root {
  color-scheme: light;
  --color-primary: #1e3a5f;
  --color-accent: #f97316;
  --color-wa: #25D366;
  --color-stats: #ea580c;
  --color-hero-start: #0f172a;
  --color-hero-mid: #1e3a5f;
  --color-hero-end: #1e40af;
}
