/* ============ MÓVIL OPTIMIZADO - CORE WEB VITALS MEJORADOS ============ */

/* 1. TAMAÑOS DE TAP MÍNIMOS (48x48px recomendado por Google) */
a, button, input[type="button"], input[type="submit"], input[type="reset"], input[type="checkbox"], input[type="radio"] {
  min-height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Ajustar padding de enlaces y botones para garantizar tamaño mínimo */
.btn, .nav-link, .taxonomy-btn, .page-link {
  min-height: 48px;
  padding: 0.75rem 1rem !important;
  font-size: 1rem;
}

/* Navbar mobile-friendly */
@media (max-width: 992px) {
  .navbar-custom .navbar-nav .nav-link {
    padding: 0.75rem 1rem !important;
    font-size: 1rem;
    line-height: 1.5;
  }
  
  .navbar-toggler {
    min-height: 48px;
    min-width: 48px;
    padding: 0.5rem;
  }
}

/* 2. MEJORAS DE LEGIBILIDAD EN MÓVIL */
@media (max-width: 768px) {
  /* Aumentar tamaño base del texto en móvil */
  body {
    font-size: 16px; /* Evita zoom automático en iOS */
  }
  
  /* Mejorar contraste y espacio en títulos */
  h1, h2, h3, h4, h5, h6 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    line-height: 1.3;
  }
  
  h1 {
    font-size: 1.75rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  h3 {
    font-size: 1.25rem;
  }
  
  /* Mejorar legibilidad de párrafos */
  p {
    line-height: 1.7;
    margin: 1.5rem 0;
  }
  
  /* Mejor espaciado en listas */
  ul, ol {
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
  }
  
  li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
  }
  
  /* Mejorar legibilidad de blockquotes */
  blockquote {
    padding: 1rem;
    margin: 1.5rem 0;
    border-left: 4px solid var(--link-col);
  }
  
  /* Aumentar tamaño de código en móvil */
  code {
    font-size: 0.95rem;
    padding: 0.2rem 0.4rem;
  }
  
  pre {
    padding: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Mejorar tabla en móvil */
  table {
    width: 100%;
    font-size: 0.9rem;
    border-collapse: collapse;
  }
  
  th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--mid-col);
  }
  
  th {
    background-color: var(--navbar-col);
    font-weight: 600;
  }
}

/* 3. OPTIMIZAR NAVEGACIÓN Y BOTONES EN MÓVIL */
@media (max-width: 768px) {
  /* Botones full-width en móvil si necesario */
  .btn-mobile-block {
    width: 100%;
    display: block;
    margin-bottom: 0.5rem;
  }
  
  /* Mejor espaciado entre botones */
  .pagination {
    gap: 0.5rem;
  }
  
  .page-item .page-link {
    min-height: 48px;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
  }
  
  /* Mejorar cards en móvil */
  .card {
    margin-bottom: 1rem;
    border-radius: 0.5rem;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  /* Grid responsive para related posts */
  .col-md-6 {
    width: 100%;
  }
  
  .col-lg-4 {
    width: 100%;
  }
  
  @media (min-width: 576px) {
    .col-md-6 {
      width: 50%;
    }
  }
  
  @media (min-width: 992px) {
    .col-lg-4 {
      width: 33.333333%;
    }
  }
}

/* 4. OPTIMIZAR IMÁGENES PARA MÓVIL (CLS - Cumulative Layout Shift) */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Aspect ratio para imágenes destacadas */
.card .card-img-top,
.post-image {
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

/* 5. MEJORAR INTERACCIÓN CON TOUCH */
@media (hover: none) and (pointer: coarse) {
  /* Dispositivos táctiles - aumentar tamaños de tap */
  a, button {
    padding: 1rem !important;
    min-height: 56px;
    min-width: 56px;
  }
  
  /* Remover :hover en touch, usar :active */
  a:hover {
    text-decoration: none;
  }
  
  button:hover {
    background-color: inherit;
  }
  
  /* Mejorar respuesta visual en touch */
  a:active, button:active {
    opacity: 0.8;
  }
}

/* 6. OPTIMIZAR FORMULARIOS PARA MÓVIL */
input, textarea, select {
  font-size: 16px; /* Evita zoom en iOS */
  padding: 0.75rem;
  border: 1px solid var(--hover-col);
  border-radius: 0.25rem;
  width: 100%;
  max-width: 100%;
}

/* Mejorar focus visible */
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--link-col);
  box-shadow: 0 0 0 3px rgba(0, 138, 255, 0.1);
}

/* 7. VIEWPORT Y COMPORTAMIENTO */
@media (max-width: 480px) {
  /* Muy pequeño - optimización extrema */
  body {
    font-size: 15px;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  h2 {
    font-size: 1.25rem;
  }
  
  .container-md, .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* 8. PREVENIR LAYOUT SHIFT EN ASPECTOS CRÍTICOS */
.post-header-container,
.card,
.navbar-custom {
  contain: layout style paint;
}

/* 9. OPTIMIZAR SCROLLING Y ANIMACIONES */
* {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Smooth scroll seguro */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* 10. MEJORAR FCP (First Contentful Paint) Y LCP (Largest Contentful Paint) */
/* Usar font-display: swap en Google Fonts para evitar invisible text */
@import url('https://fonts.googleapis.com/css2?family=Lora:wght@400;700&family=Open+Sans:wght@300;400;600;700;800&display=swap');

/* Preload imágenes críticas */
.post-header-container {
  background-size: cover;
  background-position: center;
}

/* 11. DENSIDAD DE PÍXELES Y RETINA */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Ajustes para pantallas de alta densidad si es necesario */
}
