/* ==========================================================================
   tvplusafrique.com — corrections responsive
   Feuille chargée en dernier : elle ne corrige que ce qui casse sur petit écran.
   ========================================================================== */

/* --- Socle : images fluides, focus visible, retour tactile --- */
html {
  -webkit-text-size-adjust: 100%;
}

img,
video,
picture {
  max-width: 100%;
}

.content_item img,
.content_item_cover img,
.une_item img,
.block_fleuve img,
.block_carousel img {
  height: auto;
}

a,
button {
  -webkit-tap-highlight-color: rgba(28, 72, 197, 0.18);
}

:focus-visible {
  outline: 2px solid #1c48c5;
  outline-offset: 3px;
}

/* --- Tablettes et mobiles (< 992 px) --- */
@media (max-width: 991px) {

  /* Le site ne doit jamais créer de défilement horizontal global. */
  body {
    overflow-x: clip;
  }

  @supports not (overflow: clip) {
    body {
      overflow-x: hidden;
    }
  }

  /* Cible tactile minimale de 44 x 44 px pour le bouton du menu. */
  .header_menu,
  .header_top button {
    min-width: 44px;
    min-height: 44px;
  }

  .header_menu#header_menu_show {
    top: 0;
    left: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px !important;
  }

  /* Les petits liens sociaux n'apportent rien sur écran étroit. */
  .header_direct {
    display: none !important;
  }

  /* Le menu mobile doit être défilable en entier, pas coupé. */
  .main_menu_nav {
    background: #fff;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .main_menu_nav.active {
    height: auto;
    max-height: calc(100vh - 62px);
    max-height: calc(100dvh - 62px);
    border-top: 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  /* Le panneau était en position absolue : il s'effondrait sur mobile. */
  .menu_right {
    position: relative;
    height: auto;
    overflow-y: visible;
  }

  .menu_nav {
    display: flow-root;
    padding: 0 0 calc(16px + env(safe-area-inset-bottom));
  }

  .menu_center_left {
    padding: 0 16px;
    overflow: visible;
  }

  .menu_center_left li {
    display: flex;
    align-items: center;
    height: auto;
    min-height: 48px;
    line-height: 1.4;
  }

  .menu_center_left a span,
  .menu_center_right a span {
    font-size: 1rem;
    white-space: normal;
  }

  .menu_center_right ul {
    padding: 0 16px 16px;
  }

  .menu_center_right li {
    display: flex;
    align-items: center;
    min-height: 48px;
    line-height: 1.4;
  }

  /* Tableaux internes : défilement local au lieu de casser la page. */
  .content_top_episode table,
  .content_item table,
  .block_fleuve table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
}

/* --- Téléphones (< 641 px) --- */
@media (max-width: 640px) {

  /* Le carrousel reçoit des cartes lisibles au doigt et un défilement net. */
  .block.block_carousel {
    padding-left: 16px;
  }

  .slider_container {
    scroll-snap-type: x mandatory;
    scroll-padding-left: 16px;
  }

  .carousel_item {
    width: 78vw;
    max-width: 320px;
    margin-left: 14px;
    scroll-snap-align: start;
  }

  .carousel_item .content_item_title {
    font-size: 1.05rem !important;
    line-height: 1.3;
  }

  /* Typographie : jamais en dessous de 14 px, corps à 16 px. */
  body {
    font-size: 16px;
    line-height: 1.55;
  }

  .content_item_title {
    font-size: 1.15rem;
    line-height: 1.3;
  }

  .content_item_time,
  .content_item_text,
  .item_chapo,
  .flag_article {
    font-size: 0.875rem;
    line-height: 1.5;
  }

  /* Les liens « Tout … » deviennent de vraies cibles tactiles. */
  .block_links a,
  .alink,
  .block_header a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 6px;
  }

  /* Évite qu'un titre long déborde de sa carte. */
  .content_item_title,
  .content_item_text,
  .item_chapo {
    overflow-wrap: break-word;
  }
}

/* --- Préférences utilisateur --- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Zones sûres des mobiles à encoche --- */
@supports (padding: env(safe-area-inset-bottom)) {
  .site_footer,
  footer {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}
