/* Community surfaces v42 · compatibility cleanup */
@supports selector(body:has(*)) {
  body.community-hub-mode:has(.community-v42-channels) .community-hub-profile-strip,
  body.community-hub-mode:has(.community-v42-channels) .community-hub-tabs {
    display: none !important;
  }

  body.community-hub-mode:has(.community-v42-channels) .community-hub-content {
    gap: .72rem !important;
  }
}

/*
 * COMMUNITY NAVIGATION LABEL FIREWALL
 * ----------------------------------
 * La etiqueta visible de la cabecera NO depende ya del textContent que escriban
 * los distintos runtimes de Comunidad. Hub v19, Chat v41, Surfaces v42 o incluso
 * una copia antigua servida desde caché pueden cambiar el texto interno del botón,
 * pero ese texto queda a tamaño 0 y el único rótulo visible lo decide el estado
 * real de la pantalla (data-screen + modo interno).
 *
 * Esto elimina de raíz el parpadeo "Volver a Home" / "Salir de comunidad" al
 * cambiar entre Última hora, Canales y Temas.
 */
html body.community-hub-mode .community-hub-header .community-hub-exit {
  position: relative !important;
  min-width: 7.9rem !important;
  font-size: 0 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

html body.community-hub-mode .community-hub-header .community-hub-exit::before {
  display: none !important;
  content: none !important;
}

html body.community-hub-mode .community-hub-header .community-hub-exit::after {
  display: inline !important;
  color: inherit !important;
  font-size: .68rem !important;
  font-weight: 850 !important;
  line-height: 1 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
}

/* Pantallas raíz de Comunidad: el texto es SIEMPRE el mismo, cambie la pestaña que cambie. */
html body.community-hub-mode[data-screen="community"]:not(.community-v36-inner) .community-hub-header .community-hub-exit::after {
  content: "← Salir de comunidad" !important;
}

/* Dentro de un canal concreto. */
html body.community-hub-mode[data-screen="community"].community-v36-inner .community-hub-header .community-hub-exit::after {
  content: "← Volver a canales" !important;
}

/* Dentro del chat de un tema. */
html body.community-hub-mode[data-screen="communityPostDetail"] .community-hub-header .community-hub-exit::after {
  content: "← Volver a temas" !important;
}

@media (max-width: 390px) {
  html body.community-hub-mode .community-hub-header .community-hub-exit {
    min-width: 6.9rem !important;
  }
  html body.community-hub-mode .community-hub-header .community-hub-exit::after {
    font-size: .59rem !important;
  }
}
