/* Mejoras visuales de la portada en móvil. Se mantienen intactos el layout
   de escritorio y el comportamiento original del carrusel. */
@media (max-width: 768px) {
  /* Vidrio suficientemente opaco para que el hero no compita con el logo. */
  header,
  header.scrolled {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(255, 255, 255, 0.92);
    box-shadow:
      0 10px 30px rgba(0, 47, 112, 0.14),
      inset 0 1px 0 rgba(255, 255, 255, 0.95);
  }

  header::before {
    background: linear-gradient(
      115deg,
      rgba(255, 255, 255, 0.7),
      rgba(255, 255, 255, 0.18) 52%,
      rgba(255, 255, 255, 0.42)
    );
    -webkit-backdrop-filter: blur(14px) saturate(165%);
    backdrop-filter: blur(14px) saturate(165%);
  }

  .hero-carousel .carousel-content {
    width: min(100%, 430px);
    max-width: none;
    padding: 0 24px clamp(164px, 24vh, 196px);
  }

  .hero-carousel .carousel-title {
    max-width: 11ch;
    margin-bottom: 14px;
    font-size: clamp(30px, 9.5vw, 36px);
    line-height: 1.04;
    letter-spacing: -0.035em;
    text-wrap: balance;
    text-shadow:
      0 3px 18px rgba(0, 0, 0, 0.82),
      0 1px 4px rgba(0, 0, 0, 0.75);
  }

  /* El CTA vuelve a ser la acción principal visible del primer pantallazo. */
  .hero-carousel .carousel-actions {
    display: flex;
    gap: 0;
  }

  .hero-carousel .carousel-actions .hero-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 11px 24px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    letter-spacing: 0.035em;
    box-shadow:
      0 10px 24px rgba(241, 0, 117, 0.38),
      inset 0 1px 0 rgba(255, 255, 255, 0.24);
  }

  /* En táctil se desliza el carrusel; las flechas ya no bloquean el chip. */
  .hero-carousel .carousel-hud-arrows {
    display: none;
  }

  .hero-carousel .floating-trust-widget {
    top: auto;
    right: auto;
    left: 50%;
    bottom: clamp(84px, 13vh, 108px);
    margin: 0;
    max-width: calc(100vw - 32px);
    transform: translateX(-50%);
    animation: none;
  }

  .hero-carousel .trust-badge-card {
    padding: 9px 13px;
    border-radius: 14px;
    background: linear-gradient(
      135deg,
      rgba(12, 24, 43, 0.78),
      rgba(12, 24, 43, 0.58)
    );
    box-shadow:
      0 10px 28px rgba(0, 0, 0, 0.28),
      inset 0 1px 0 rgba(255, 255, 255, 0.16);
  }

  .hero-carousel .trust-badge-icons {
    width: 32px;
  }

  .hero-carousel .trust-badge-rating {
    margin-left: 2px;
  }

  .hero-carousel .trust-rating-text {
    font-size: 11px;
  }

  .hero-carousel .trust-rating-text span {
    font-size: 9px;
  }

  /* 2. Franja de convenios: lectura compacta y marcas más reconocibles. */
  .institutions-ticker > div:first-child {
    gap: 8px;
    margin-bottom: 16px;
    padding-inline: 16px;
  }

  .institutions-ticker > div:first-child > div:first-child,
  .institutions-ticker > div:first-child > div:last-child {
    flex: 1 1 28px;
    width: auto;
    min-width: 18px;
    max-width: 34px;
  }

  .institutions-ticker > div:first-child > .animate-elegant {
    flex: 0 1 232px;
    animation: none;
  }

  .institutions-ticker > div:first-child p {
    max-width: 232px;
    margin-inline: auto;
    font-size: 12px;
    line-height: 1.35;
    letter-spacing: 0.14em;
    text-align: center;
    text-wrap: balance;
  }

  .institutions-ticker .ticker-logo {
    padding-inline: 30px;
    filter: grayscale(100%) contrast(1.15);
    opacity: 0.8;
  }

  .institutions-ticker .ticker-container::before,
  .institutions-ticker .ticker-container::after {
    width: 64px;
  }

  /* 3. Carrusel de servicios. */
  #terapia .services-header {
    margin-bottom: 28px;
  }

  #terapia .services-accordion-wrapper {
    margin-inline: 0;
    overflow: hidden;
  }

  #terapia .services-accordion-wrapper::before {
    content: "Desliza para ver más  →";
    display: table;
    min-height: 30px;
    margin: 0 auto 12px;
    padding: 7px 13px;
    border: 1px solid rgba(241, 0, 117, 0.12);
    border-radius: 999px;
    color: #e6006e;
    background: #fff0f7;
    box-shadow: 0 5px 16px rgba(241, 0, 117, 0.1);
    font-size: 11px;
    font-weight: 750;
    line-height: 1.35;
    letter-spacing: 0.015em;
    opacity: 1;
    animation: service-hint-nudge 1800ms ease-in-out infinite;
  }

  #terapia .services-accordion {
    gap: 12px;
    height: 450px;
    padding: 8px 16px 20px;
    scroll-padding-inline: 16px;
    scroll-snap-type: x mandatory;
  }

  #terapia .accordion-card {
    flex: 0 0 86% !important;
    width: 86% !important;
    min-width: 0 !important;
    border-radius: 22px;
    scroll-snap-align: start;
    box-shadow: 0 12px 30px rgba(14, 31, 53, 0.16);
  }

  #terapia .accordion-overlay {
    background: linear-gradient(
      to top,
      rgba(3, 12, 27, 0.96) 0%,
      rgba(3, 12, 27, 0.82) 43%,
      rgba(3, 12, 27, 0.28) 72%,
      rgba(3, 12, 27, 0.05) 100%
    );
  }

  #terapia .accordion-expanded {
    padding: 28px 18px 20px;
  }

  #terapia .accordion-expanded .service-title {
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  }

  #terapia .accordion-expanded p {
    display: -webkit-box;
    margin-bottom: 18px;
    color: rgba(255, 255, 255, 0.96);
    font-size: 13px;
    line-height: 1.5;
    text-shadow: 0 1px 7px rgba(0, 0, 0, 0.9);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
  }

  #terapia .accordion-expanded .service-btn {
    width: 100%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* 4. Indicadores táctiles y CTA secundario. */
  #terapia .services-scroll-dots {
    gap: 0;
    margin-top: 2px;
  }

  #terapia .services-scroll-dots span {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 0;
    background: transparent;
  }

  #terapia .services-scroll-dots span::after {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #d1d5db;
    transition: width 180ms ease, background-color 180ms ease;
  }

  #terapia .services-scroll-dots span.active {
    width: 44px;
    background: transparent;
  }

  #terapia .services-scroll-dots span.active::after {
    width: 26px;
    background: #f10075;
  }

  #btn-ver-terapias {
    width: auto;
    max-width: calc(100vw - 32px);
    min-height: 44px;
    padding: 11px 18px;
    gap: 8px;
    font-size: 11px;
    line-height: 1;
    letter-spacing: 0.035em;
    white-space: nowrap;
  }

  #btn-ver-terapias svg {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
  }

  /* 5. Encabezado de Áreas de atención. */
  #areas-atencion {
    padding-block: 64px;
  }

  #areas-atencion .text-center > h2 {
    max-width: 12ch;
    font-size: clamp(30px, 9vw, 38px);
    line-height: 1.05;
    letter-spacing: -0.035em;
    text-wrap: balance;
  }

  /* 6. Mosaico uniforme de dos columnas. */
  #areas-atencion .areas-wrapper > div:last-child {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #areas-atencion .areas-grid-container,
  #areas-atencion .areas-bottom-row {
    display: contents;
  }

  #areas-atencion .areas-grid-container button,
  #areas-atencion .areas-bottom-row button {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 104px;
    margin: 0;
    padding: 12px 8px;
    border-radius: 18px;
    align-items: center;
    justify-content: center;
  }

  #areas-atencion .areas-grid-container button > div,
  #areas-atencion .areas-bottom-row button > div {
    width: 100%;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
  }

  #areas-atencion .areas-grid-container button .w-10,
  #areas-atencion .areas-bottom-row button .w-10 {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }

  #areas-atencion .areas-grid-container button span,
  #areas-atencion .areas-bottom-row button span {
    width: 100%;
    padding: 0;
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
    overflow-wrap: anywhere;
  }

  /* 7 y 8. Contacto y mapa dentro del ancho útil del teléfono. */
  #ubicanos .ubicanos-premium-inner {
    box-sizing: border-box;
    width: calc(100% - 32px);
    max-width: 100%;
    margin: 30px auto;
    padding: 0;
    grid-template-columns: minmax(0, 1fr);
    border-radius: 20px;
  }

  #ubicanos .ubicanos-info-card {
    min-width: 0;
    padding: 30px 20px;
    border-radius: 20px 20px 0 0;
  }

  #ubicanos .ubicanos-contact-item,
  #ubicanos .ubicanos-contact-item > div:last-child {
    min-width: 0;
  }

  #ubicanos .ubicanos-value {
    font-size: 13px;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  #ubicanos .ubicanos-wa-btn {
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    align-self: stretch;
    font-size: 15px;
    line-height: 1.25;
    text-align: center;
  }

  #ubicanos .ubicanos-map-modern {
    width: 100%;
    height: 280px;
    border-radius: 0 0 20px 20px;
  }

  /* 9. El contenido final queda libre detrás de los controles flotantes. */
  footer {
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }

  .accessibility-fab {
    width: 44px;
    height: 44px;
    left: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-width: 1px;
    box-shadow: 0 7px 20px rgba(0, 79, 176, 0.32);
  }

  .accessibility-fab svg {
    width: 22px;
    height: 22px;
  }

  .whatsapp-widget {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

@keyframes service-hint-nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(3px); }
}

@media (max-width: 360px) {
  .hero-carousel .carousel-content {
    padding-inline: 20px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .hero-carousel .floating-trust-widget {
    animation: none;
  }

  #terapia .services-accordion-wrapper::before {
    animation: none;
  }
}
