/* === Elche Se Mueve · Responsive Movil v2 Sin Solapamientos (202612031550) === */
*, *::before, *::after { box-sizing: border-box; }

.esm-nav-backdrop,
.esm-mobile-drawer {
  display: none;
}

.esm-burger-btn .esm-ic-x {
  display: none !important;
}

.leaflet-container img {
  max-width: none !important;
  max-height: none !important;
}

/* Garantizar que ningun <header> interno de articulos o secciones herede posicion sticky */
main header,
article header,
section header {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
}

/* === BARRA SUPERIOR DE 3 WEBS (AGENDA, RENFE, MONUMENTOS) SIEMPRE EN 1 SOLA FILA === */
@media (max-width: 720px) {
  .esm-eco-bar {
    padding: 0.36rem 0.38rem !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  .esm-eco-bar::-webkit-scrollbar {
    display: none !important;
  }
  .esm-eco-bar > .esm-eco-pills {
    padding: 0 !important;
  }
  .esm-eco-pills {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.28rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .esm-eco-pills > a {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 1 auto !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    padding: 0.28rem 0.5rem !important;
    font-size: clamp(0.66rem, 2.85vw, 0.78rem) !important;
    line-height: 1.15 !important;
    gap: 0.22rem !important;
    border-radius: 999px !important;
  }
  .esm-eco-pills > a svg {
    width: 12px !important;
    height: 12px !important;
    flex-shrink: 0 !important;
  }
}

/* === CABECERA Y CAJON MOVIL EN BODY (<= 960px) === */
@media (max-width: 960px) {
  html, body {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    -webkit-text-size-adjust: 100%;
  }

  html.esm-nav-lock,
  html.esm-nav-lock body {
    overflow: hidden !important;
  }

  header.esm-site-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 100000 !important;
    width: 100% !important;
    max-width: 100% !important;
    background-color: #ffffff !important;
  }

  /* Ocultar el <nav> de escritorio y cualquier panel movil antiguo dentro del header */
  header.esm-site-header nav,
  header.esm-site-header .esm-primary-nav,
  header.esm-site-header [id*="mobile"][id*="menu"]:not(#esm-burger-btn),
  header.esm-site-header [class*="mobile-menu"]:not(#esm-burger-btn) {
    display: none !important;
  }

  /* Unico boton circular Hamburguesa / Cerrar */
  #esm-burger-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
    border-radius: 999px !important;
    border: 1px solid #cbd5e1 !important;
    background: #ffffff !important;
    color: #0f172a !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
  }
  html.esm-nav-open #esm-burger-btn {
    background: #0f172a !important;
    border-color: #0f172a !important;
    color: #ffffff !important;
  }
  html.esm-nav-open #esm-burger-btn .esm-ic-bars {
    display: none !important;
  }
  html.esm-nav-open #esm-burger-btn .esm-ic-x {
    display: block !important;
  }

  /* Fondo oscurecido en body */
  html.esm-nav-open #esm-nav-backdrop {
    display: block !important;
    position: fixed !important;
    inset: var(--esm-drawer-top, 58px) 0 0 0 !important;
    background: rgba(15, 23, 42, 0.5) !important;
    z-index: 99990 !important;
  }

  /* Cajon desplegable solido en body (jamas se transparenta ni solapa con el articulo) */
  html.esm-nav-open #esm-mobile-drawer {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.15rem !important;
    position: fixed !important;
    top: var(--esm-drawer-top, 58px) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: calc(100dvh - var(--esm-drawer-top, 58px)) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    background: #ffffff !important;
    color: #0f172a !important;
    padding: 0.75rem 1rem 1.5rem !important;
    margin: 0 !important;
    border-top: 1px solid #e2e8f0 !important;
    border-bottom: 3px solid #0d9488 !important;
    box-shadow: 0 22px 44px rgba(15, 23, 42, 0.28) !important;
    z-index: 99995 !important;
  }

  #esm-mobile-drawer ul {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0.15rem !important;
  }
  #esm-mobile-drawer li {
    width: 100% !important;
  }

  #esm-mobile-drawer a,
  #esm-mobile-drawer summary {
    display: flex !important;
    align-items: center !important;
    gap: 0.6rem !important;
    width: 100% !important;
    padding: 0.68rem 0.75rem !important;
    border-radius: 10px !important;
    color: #0f172a !important;
    background: transparent !important;
    font-size: 0.96rem !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    list-style: none !important;
  }
  #esm-mobile-drawer summary::-webkit-details-marker {
    display: none !important;
  }
  #esm-mobile-drawer a:active,
  #esm-mobile-drawer summary:active {
    background: #f0fdfa !important;
    color: #0f766e !important;
  }

  /* Submenus plegados por defecto y desplegados con toque */
  #esm-mobile-drawer details:not([open]) > *:not(summary) {
    display: none !important;
  }
  #esm-mobile-drawer details[open] > *:not(summary) {
    display: flex !important;
    flex-direction: column !important;
    position: static !important;
    box-shadow: none !important;
    border: 0 !important;
    border-left: 2px solid #0d9488 !important;
    background: #f8fafc !important;
    margin: 0.15rem 0 0.4rem 0.75rem !important;
    padding: 0.25rem 0.4rem 0.25rem 0.65rem !important;
  }

  #esm-mobile-drawer .esm-drawer-group {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    width: 100% !important;
  }
  #esm-mobile-drawer .esm-drawer-group > a,
  #esm-mobile-drawer .esm-drawer-group > span {
    width: calc(100% - 42px) !important;
    flex: 1 1 auto !important;
  }
  #esm-mobile-drawer .esm-drawer-chevron {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    margin-left: auto !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
    color: #0f172a !important;
    cursor: pointer !important;
    transition: transform 0.18s ease;
  }
  #esm-mobile-drawer .esm-drawer-group.is-open > .esm-drawer-chevron {
    transform: rotate(180deg);
    background: #ccfbf1 !important;
    border-color: #99f6e4 !important;
    color: #0f766e !important;
  }
  #esm-mobile-drawer .esm-drawer-group:not(.is-open) > .esm-drawer-sub {
    display: none !important;
  }
  #esm-mobile-drawer .esm-drawer-group.is-open > .esm-drawer-sub {
    display: flex !important;
    flex-direction: column !important;
    position: static !important;
    inset: auto !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    box-shadow: none !important;
    border: 0 !important;
    border-left: 2px solid #0d9488 !important;
    border-radius: 0 !important;
    background: #f8fafc !important;
    width: 100% !important;
    margin: 0.15rem 0 0.45rem 0.75rem !important;
    padding: 0.25rem 0.4rem 0.25rem 0.65rem !important;
  }
}

/* === CONTENIDO RESPONSIVE A 1 COLUMNA EN MOVIL (<= 840px) === */
@media (max-width: 840px) {
  main, article, section, aside, footer,
  main div:not([class*="leaflet"]),
  footer div {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  main {
    padding-left: 0.95rem !important;
    padding-right: 0.95rem !important;
  }

  main [style*="grid-template-columns"],
  footer [style*="grid-template-columns"] {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 1.1rem !important;
  }
  .heritage-bento,
  .ecosystem-dock,
  .monuments-grid,
  .parks-lead,
  .parks-grid,
  .cards-grid,
  .article-layout,
  .footer-grid,
  .sb-cols-2,
  .sb-cols-3,
  .sb-cols-4,
  .article-layout.single-col,
  .related-cards-grid,
  .esm-footer-grid,
  .esm-author-box,
  footer.esm-dyn-footer .esm-footer-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 1.1rem !important;
  }


  main [style*="display:flex"],
  main [style*="display: flex"] {
    flex-wrap: wrap !important;
  }

  main *:has(> aside) {
    flex-direction: column !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }
  main aside {
    width: 100% !important;
    margin-left: 0 !important;
  }

  main img:not(.leaflet-tile):not([class*="leaflet"]),
  footer img,
  main iframe,
  main video {
    max-width: 100% !important;
    height: auto !important;
  }

  article table:not(.esm-sh-table),
  main table:not(.esm-sh-table) {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  h1, h2, h3, p, li, a { overflow-wrap: break-word; word-break: break-word; }
  main h1 { font-size: clamp(1.48rem, 6.2vw, 2rem) !important; line-height: 1.22 !important; }
  main h2 { font-size: clamp(1.2rem, 5vw, 1.5rem) !important; line-height: 1.28 !important; }

  .esm-sheet-bar { flex-direction: column !important; align-items: stretch !important; }
  .esm-sheet-bar .esm-sh-inp { width: 100% !important; min-width: 0 !important; }
  .esm-ph-grid { grid-template-columns: minmax(0, 1fr) !important; }
}
