/* ==========================================================================
   RESPONSIVE DESIGN & MOBILE UI/UX AUDIT — CANJE BREVETE PERUANO
   Optimizado para vista móvil (320px - 860px) en 1 columna limpia
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. RESET Y CONTROL DE OVERFLOW HORIZONTAL
   -------------------------------------------------------------------------- */
html, body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
  box-sizing: border-box !important;
}

input, select, textarea, button {
  box-sizing: border-box !important;
  max-width: 100% !important;
}

/* --------------------------------------------------------------------------
   2. REGLA MAESTRA: COLAPSO A 1 COLUMNA EN MÓVIL (<860px)
   -------------------------------------------------------------------------- */
@media (max-width: 860px) {
  /* Ocultar topbar de contacto en móvil */
  .site-topbar {
    display: none !important;
  }

  /* Cualquier grid de 2, 3 o 4 columnas colapsa a 1 columna */
  .responsive-grid,
  .grid-responsive,
  .grid-col-2,
  .grid-col-3,
  .grid-col-4,
  [style*="grid-template-columns:repeat(2,1fr)"],
  [style*="grid-template-columns: repeat(2, 1fr)"],
  [style*="grid-template-columns:repeat(2, 1fr)"],
  [style*="grid-template-columns: repeat(2,1fr)"],
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"],
  [style*="grid-template-columns:repeat(3, 1fr)"],
  [style*="grid-template-columns: repeat(3,1fr)"],
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(4, 1fr)"],
  [style*="grid-template-columns: repeat(4,1fr)"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1.2fr 1fr"],
  [style*="grid-template-columns: 1.2fr 1fr"],
  [style*="grid-template-columns:1.35fr 1fr"],
  [style*="grid-template-columns: 1.35fr 1fr"],
  [style*="grid-template-columns:auto 1fr"],
  [style*="grid-template-columns: auto 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* --------------------------------------------------------------------------
     3. HERO SECTION (HOME & INTERNAS)
     -------------------------------------------------------------------------- */
  #top {
    padding: 36px 16px 44px !important;
  }

  #top [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  #top h1 {
    font-size: clamp(28px, 8vw, 38px) !important;
    line-height: 1.12 !important;
    max-width: 100% !important;
    margin: 16px 0 14px !important;
  }

  #top p {
    font-size: 16px !important;
    line-height: 1.55 !important;
    max-width: 100% !important;
  }

  /* Imagen de fondo del hero en móvil: opacidad sutil para máxima legibilidad */
  #top > img {
    width: 100% !important;
    height: 100% !important;
    opacity: 0.18 !important;
    object-position: center !important;
  }

  /* Botones del hero a ancho completo en móvil para fácil pulsación */
  #top [style*="display:flex; gap:14px"],
  #top [style*="display: flex; gap: 14px"] {
    flex-direction: column !important;
    width: 100% !important;
    gap: 12px !important;
    margin-top: 24px !important;
  }

  #top [style*="display:flex; gap:14px"] > a,
  #top [style*="display: flex; gap: 14px"] > a {
    width: 100% !important;
    text-align: center !important;
    justify-content: center !important;
    padding: 15px 18px !important;
    font-size: 15.5px !important;
  }

  /* Insignias de confianza en el hero */
  #top [style*="display:flex; gap:12px"],
  #top [style*="display: flex; gap: 12px"] {
    flex-direction: column !important;
    gap: 8px !important;
    margin-top: 22px !important;
  }

  #top [style*="display:flex; gap:12px"] > span,
  #top [style*="display: flex; gap: 12px"] > span {
    width: 100% !important;
    justify-content: flex-start !important;
    font-size: 12.5px !important;
  }

  /* Títulos H1 en páginas secundarias */
  section h1 {
    font-size: clamp(26px, 7vw, 36px) !important;
    line-height: 1.15 !important;
  }

  /* Títulos H2 en todas las secciones */
  h2 {
    font-size: clamp(22px, 6vw, 30px) !important;
    line-height: 1.2 !important;
  }

  /* --------------------------------------------------------------------------
     4. FEATURE STRIP (FRANJA DE CARACTERÍSTICAS)
     -------------------------------------------------------------------------- */
  section [style*="grid-template-columns:repeat(4,1fr)"],
  section [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  section [style*="grid-template-columns:repeat(4,1fr)"] > div,
  section [style*="grid-template-columns: repeat(4, 1fr)"] > div {
    border-right: none !important;
    border-bottom: 1px solid #eee6d8 !important;
    padding: 20px 16px !important;
  }

  section [style*="grid-template-columns:repeat(4,1fr)"] > div:last-child,
  section [style*="grid-template-columns: repeat(4, 1fr)"] > div:last-child {
    border-bottom: none !important;
  }

  /* --------------------------------------------------------------------------
     5. CATEGORÍAS DE BREVETE (#categorias - CAPTURA DE PANTALLA)
     -------------------------------------------------------------------------- */
  #categorias {
    padding: 30px 16px 50px !important;
  }

  #categorias > div:first-child {
    margin-bottom: 28px !important;
  }

  #categorias [style*="grid-template-columns:repeat(2,1fr)"],
  #categorias [style*="grid-template-columns: repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
  }

  /* Tarjeta de categoría a 1 columna */
  #categorias [style*="border-radius:16px"],
  #categorias [style*="border-radius: 16px"] {
    padding: 22px 20px 20px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  #categorias [style*="border-radius:16px"] a,
  #categorias [style*="border-radius: 16px"] a {
    width: 100% !important;
    text-align: center !important;
    padding: 13px !important;
    margin-top: 18px !important;
    font-size: 14.5px !important;
  }

  /* --------------------------------------------------------------------------
     6. BLOQUES DE IMAGEN + CARACTERÍSTICAS
     -------------------------------------------------------------------------- */
  [style*="background:#0B2A4A"] [style*="grid-template-columns:1fr 1fr"],
  [style*="background:#0B2A4A"] [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
    padding-top: 40px !important;
    padding-bottom: 40px !important;
  }

  /* --------------------------------------------------------------------------
     7. TELEMÁTICA CTA (INICIA TU TRÁMITE ONLINE)
     -------------------------------------------------------------------------- */
  section [style*="padding:16px 16px 16px 44px"],
  section [style*="padding: 16px 16px 16px 44px"] {
    grid-template-columns: 1fr !important;
    padding: 24px 18px !important;
    gap: 20px !important;
  }

  section [style*="padding:16px 16px 16px 44px"] > div:first-child {
    padding: 0 !important;
  }

  section [style*="padding:16px 16px 16px 44px"] [style*="display:flex; gap:14px"],
  section [style*="padding: 16px 16px 16px 44px"] [style*="display: flex; gap: 14px"] {
    flex-direction: column !important;
    width: 100% !important;
    gap: 10px !important;
  }

  section [style*="padding:16px 16px 16px 44px"] a {
    width: 100% !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* --------------------------------------------------------------------------
     8. PASOS NUMERADOS (PASOS 3 Y PASOS 5)
     -------------------------------------------------------------------------- */
  [style*="display:grid; grid-template-columns:64px 1fr"],
  [style*="display: grid; grid-template-columns: 64px 1fr"],
  [style*="display:grid; grid-template-columns:56px 1fr"],
  [style*="display: grid; grid-template-columns: 56px 1fr"] {
    grid-template-columns: 46px 1fr !important;
    gap: 14px !important;
  }

  [style*="display:grid; grid-template-columns:64px 1fr"] > span:first-child,
  [style*="display: grid; grid-template-columns: 64px 1fr"] > span:first-child {
    width: 44px !important;
    height: 44px !important;
    font-size: 17px !important;
    border-radius: 10px !important;
  }

  /* --------------------------------------------------------------------------
     9. FORMULARIO DE CONTACTO (#contacto) & GENERAL FORMS
     -------------------------------------------------------------------------- */
  #contacto {
    padding: 44px 16px !important;
    max-width: 100% !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  #contacto > div {
    max-width: 100% !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }


  #contacto .form-card,
  #contacto [style*="border-radius:20px"],
  #contacto [style*="border-radius: 20px"],
  .form-card {
    padding: 24px 16px !important;
    border-radius: 16px !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  /* HOME form card: edge-to-edge en móvil */
  .form-section-grid .form-card {
    border-radius: 0 !important;
    padding: 28px 20px !important;
    margin-left: -24px !important;
    margin-right: -24px !important;
    width: calc(100% + 48px) !important;
    max-width: none !important;
  }

  /* Campos en fila → columna en móvil */
  .form-fields-row {
    grid-template-columns: 1fr !important;
  }



  #contacto form,
  form.contact-form,
  form.responsive-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 14px !important;
    box-sizing: border-box !important;
  }

  #contacto form label,
  form label {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    grid-column: auto !important;
    box-sizing: border-box !important;
  }

  #contacto form input:not([type="checkbox"]),
  #contacto form select,
  #contacto form textarea,
  form input:not([type="checkbox"]),
  form select,
  form textarea {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    font-size: 16px !important; /* Previene auto-zoom en iOS Safari */
    min-height: 48px !important;
    border-radius: 10px !important;
  }

  /* Desactivar apariencia nativa de select en iOS para evitar desbordes */
  #contacto form select,
  form select {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-color: #fff !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2333424e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    background-size: 16px !important;
    padding-right: 38px !important;
  }

  #contacto form textarea,
  form textarea {
    min-height: 96px !important;
  }

  #contacto form button[type="submit"],
  form button[type="submit"] {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* --------------------------------------------------------------------------
     10. EVALUADOR INTERACTIVO (#evaluador)
     -------------------------------------------------------------------------- */
  #evaluador {
    padding: 44px 16px !important;
  }

  #evaluador [style*="border-radius:20px"],
  #evaluador [style*="border-radius: 20px"] {
    padding: 24px 18px !important;
  }

  #evaluador button {
    font-size: 14.5px !important;
  }

  /* --------------------------------------------------------------------------
     11. TABLA DE EQUIVALENCIAS (#tabla)
     -------------------------------------------------------------------------- */
  #tabla {
    padding: 44px 16px !important;
  }

  #tabla table {
    font-size: 13px !important;
  }

  #tabla th, #tabla td {
    padding: 12px 10px !important;
  }

  /* --------------------------------------------------------------------------
     12. PÁGINAS EDITORIALES / BLOG / JEFATURAS
     -------------------------------------------------------------------------- */
  /* Lista de artículos del blog en 1 columna */
  section [style*="grid-template-columns:repeat(3,1fr)"] > a,
  section [style*="grid-template-columns: repeat(3, 1fr)"] > a {
    width: 100% !important;
  }

  /* Jefaturas provinciales a 1 columna */
  section [style*="grid-template-columns:repeat(3,1fr)"] > div,
  section [style*="grid-template-columns: repeat(3, 1fr)"] > div {
    width: 100% !important;
  }

  /* --------------------------------------------------------------------------
     13. FOOTER
     -------------------------------------------------------------------------- */
  footer [style*="grid-template-columns:repeat(3,1fr)"],
  footer [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
    padding: 36px 16px 20px !important;
  }

  footer h4 {
    margin-bottom: 12px !important;
  }

  /* --------------------------------------------------------------------------
     14. TOP BAR EN MÓVIL
     -------------------------------------------------------------------------- */
  [style*="background:#0B2A4A; color:#cfe0ee; font-size:13px"] > div,
  [style*="background:#0B2A4A; color:#cfe0ee; font-size: 13px"] > div {
    padding: 6px 14px !important;
    font-size: 12px !important;
    gap: 8px !important;
  }
}

/* --------------------------------------------------------------------------
   15. AJUSTES FINOS PARA PANTALLAS MUY PEQUEÑAS (<400px - iPhone SE, etc.)
   -------------------------------------------------------------------------- */
@media (max-width: 400px) {
  #top h1 {
    font-size: 26px !important;
  }

  section {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  [style*="border-radius:16px"],
  [style*="border-radius: 16px"],
  [style*="border-radius:18px"],
  [style*="border-radius: 18px"],
  [style*="border-radius:20px"],
  [style*="border-radius: 20px"] {
    padding: 18px 14px !important;
  }
}

/* --------------------------------------------------------------------------
   16. BOTÓN FLOTANTE ANIMADO MOTION DE LLAMADA (SOLO RESPONSIVE / MÓVIL)
   -------------------------------------------------------------------------- */
.motion-call-btn {
  display: none !important;
}

@media (max-width: 860px) {
  .motion-call-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 11px;
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: 18px;
    z-index: 999999;
    padding: 9px 18px 9px 11px;
    background: linear-gradient(135deg, #12805C 0%, #0c6448 100%);
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 999px;
    box-shadow: 0 10px 28px -4px rgba(18, 128, 92, 0.55), 0 4px 12px rgba(0, 0, 0, 0.18);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-family: 'Public Sans', system-ui, sans-serif;
    cursor: pointer;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease;
    animation: motion-shadow-breathe 3.2s infinite ease-in-out;
    -webkit-tap-highlight-color: transparent;
  }

  .motion-call-btn:hover {
    color: #ffffff !important;
    text-decoration: none !important;
    transform: translateY(-2px);
  }

  .motion-call-btn:active {
    transform: scale(0.93) !important;
  }

  .motion-call-icon-box {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #ffffff;
    color: #12805C;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  /* Radar Pulse Waves */
  .motion-call-pulse,
  .motion-call-pulse-2 {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid #12805C;
    pointer-events: none;
    animation: motion-radar-wave 2.4s cubic-bezier(0.22, 1, 0.36, 1) infinite;
  }

  .motion-call-pulse-2 {
    animation-delay: 1.2s;
  }

  /* Shaking Phone Receiver Motion */
  .motion-phone-icon {
    display: block;
    animation: motion-phone-ring 3.5s infinite ease-in-out;
    transform-origin: center center;
  }

  .motion-call-content {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.15;
  }

  .motion-call-badge {
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.03em;
    color: #c9f5e3;
  }

  .motion-call-number {
    font-family: 'Sora', sans-serif;
    font-size: 14.5px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.01em;
  }
}

@media (max-width: 380px) {
  .motion-call-btn {
    padding: 8px 14px 8px 9px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: 14px;
    gap: 8px;
  }
  .motion-call-icon-box {
    width: 34px;
    height: 34px;
  }
  .motion-call-icon-box svg {
    width: 17px;
    height: 17px;
  }
  .motion-call-badge {
    font-size: 9.5px;
  }
  .motion-call-number {
    font-size: 13px;
  }
}

/* Keyframes */
@keyframes motion-radar-wave {
  0% {
    transform: scale(0.95);
    opacity: 0.9;
  }
  60% {
    transform: scale(1.65);
    opacity: 0;
  }
  100% {
    transform: scale(1.85);
    opacity: 0;
  }
}

@keyframes motion-phone-ring {
  0%, 72%, 100% {
    transform: rotate(0deg) scale(1);
  }
  76% {
    transform: rotate(-18deg) scale(1.15);
  }
  80% {
    transform: rotate(18deg) scale(1.15);
  }
  84% {
    transform: rotate(-14deg) scale(1.15);
  }
  88% {
    transform: rotate(14deg) scale(1.15);
  }
  92% {
    transform: rotate(-6deg) scale(1.08);
  }
  96% {
    transform: rotate(4deg) scale(1.04);
  }
}

@keyframes motion-shadow-breathe {
  0%, 100% {
    box-shadow: 0 10px 28px -4px rgba(18, 128, 92, 0.55), 0 4px 12px rgba(0, 0, 0, 0.18);
  }
  50% {
    box-shadow: 0 14px 36px 0 rgba(18, 128, 92, 0.78), 0 0 0 4px rgba(18, 128, 92, 0.25);
  }
}
