/* Optimizations Consolidated - Acessibilidade, Performance e Core Web Vitals */

/* === ACCESSIBILITY OPTIMIZATIONS === */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px;
  text-decoration: none;
  z-index: 10000;
  border-radius: 4px;
}

.skip-link:focus {
  top: 6px;
}

a {
  color: #0066cc;
  text-decoration: underline;
}

a:hover, a:focus {
  color: #004499;
  text-decoration: none;
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

button:focus, input:focus, select:focus, textarea:focus, [tabindex]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);
}

button, .cta-button {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 16px;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

input, textarea, select {
  min-height: 44px;
  padding: 12px;
  border: 2px solid #ccc;
  border-radius: 4px;
  font-size: 16px;
  background: #fff;
}

input:focus, textarea:focus, select:focus {
  border-color: #0066cc;
  background: #f8f9fa;
}

.error {
  color: #d32f2f;
  font-size: 14px;
  margin-top: 4px;
  display: flex;
  align-items: center;
}

.error::before {
  content: "⚠️";
  margin-right: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === PERFORMANCE OPTIMIZATIONS === */
.tile, .mode-card, .settings-card, .report-card {
  transform: translateZ(0);
  will-change: transform;
}

@keyframes optimized-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes optimized-slideIn {
  from { transform: translate3d(-30px, 0, 0); opacity: 0; }
  to { transform: translate3d(0, 0, 0); opacity: 1; }
}

canvas {
  image-rendering: optimizeSpeed;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: optimize-contrast;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
}

.chart-container canvas, #canvas {
  will-change: contents;
}

.shape {
  will-change: transform, opacity;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--accent-color);
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  will-change: transform;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* === CORE WEB VITALS === */
.hero {
  contain: layout style paint;
}

.hero h1 {
  font-display: swap;
  will-change: auto;
}

.cta-button {
  touch-action: manipulation;
  user-select: none;
}

.nav-menu a {
  touch-action: manipulation;
}

.logo {
  aspect-ratio: 1 / 1;
  width: 50px;
  height: 50px;
}

.hero img {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.card {
  min-height: 200px;
}

.ad-skyscraper-left, .ad-skyscraper-right {
  width: 160px;
  min-height: 600px;
}

.ad-mobile-banner {
  width: 300px;
  height: 250px;
  margin: 20px auto;
}

@font-face {
  font-family: 'Segoe UI';
  font-display: swap;
  src: local('Segoe UI'), local('SegoeUI');
}

.modal {
  contain: layout style paint;
}

.non-critical {
  content-visibility: auto;
  contain-intrinsic-size: 200px;
}

.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* === 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;
  }
  
  .tile:hover, .mode-card:hover {
    transform: none !important;
  }
  
  .loading-spinner {
    animation: none;
    border: 2px solid #ccc;
    border-top: 2px solid #0066cc;
  }
}

/* === HIGH CONTRAST === */
@media (prefers-contrast: high) {
  * {
    border-color: #000 !important;
  }
  
  a {
    color: #0000ff !important;
    text-decoration: underline !important;
  }
  
  button, .cta-button {
    border: 2px solid #000 !important;
    background: #fff !important;
    color: #000 !important;
  }
  
  .card {
    border: 2px solid var(--text-color);
  }
}

/* === MOBILE OPTIMIZATIONS === */
@media (max-width: 768px) {
  .tile, .mode-card, .settings-card {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
  }
  
  .welcome-banner {
    background: rgba(30, 30, 30, 0.9) !important;
    backdrop-filter: none !important;
  }
  
  .invix-sidebar {
    backdrop-filter: none !important;
    background: rgba(0, 10, 10, 0.95) !important;
  }
  
  body {
    text-rendering: optimizeSpeed !important;
    -webkit-font-smoothing: subpixel-antialiased !important;
  }
  
  .hero {
    padding-top: 60px;
  }
  
  .main-layout-container {
    display: block;
  }
  
  .ad-skyscraper-left, .ad-skyscraper-right {
    display: none;
  }
}

/* === TOUCH DEVICES === */
@media (pointer: coarse) {
  button, .cta-button, a, input, select, textarea {
    min-height: 48px;
    min-width: 48px;
  }
}

/* === PRINT OPTIMIZATIONS === */
@media print {
  .invix-sidebar, #back-button, .cta-button, .portrait-warning {
    display: none !important;
  }
  
  .invix-main {
    margin-left: 0 !important;
  }
  
  * {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
  }
}

/* === REDUCED DATA === */
@media (prefers-reduced-data: reduce) {
  .hero {
    background-image: none;
    background-color: #667eea;
  }
  
  .ad-skyscraper-left, .ad-skyscraper-right {
    display: none;
  }
}