/* ==========================================================================
   AFRICA HEALTH NEWS — ÉQUILIBRE DES COLONNES, DÉBORDEMENTS & PUBLICITÉS
   ========================================================================== */

/* ---------- 1. Débordements de texte ---------- */
h1, h2, h3, h4, .rank-title, .rail-body strong, .short-content strong, .science-item strong, .world-card strong, .public-tile strong {
  overflow-wrap: break-word;
}
.entry-content { overflow-wrap: break-word; }
.entry-content a { overflow-wrap: anywhere; }
.entry-content iframe, .entry-content embed, .entry-content object, .entry-content video { max-width: 100%; }
.entry-content table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.entry-content pre { max-width: 100%; white-space: pre; }
.hero .hero-title { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero p { -webkit-line-clamp: 2; }
.single-title { overflow-wrap: break-word; }
.breadcrumbs > span { max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.utility-headline { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { row-gap: 3px; }
.public-tile strong, .world-card strong, .science-item strong { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rank-title { -webkit-line-clamp: 2; }

/* Les enfants de grilles peuvent rétrécir (évite les colonnes qui poussent la page). */
.hero-layout > *, .mag-layout > *, .single-layout > *, .footer-top > *, .footer-widgets > *, .field > *, .newsletter > *, .science-layout > * { min-width: 0; }

/* ---------- 2. Équilibre des colonnes ---------- */
/* Accueil : la colonne latérale s'étire sur toute la hauteur des rubriques ; le dernier bloc reste visible en défilant. */
.mag-layout { align-items: stretch; }
.mag-layout > .sidebar { align-self: stretch; }
.sidebar-sticky { position: sticky; top: 88px; margin-top: auto; display: flex; flex-direction: column; gap: 16px; }
body:not(.ahn-sticky) .sidebar-sticky { top: 16px; }
.newsroom > .rubric:last-child { padding-bottom: 0; }

/* Article : la barre latérale suit toute la hauteur du texte. */
.single-layout { align-items: start; }
.single-layout .single-sidebar { position: static; align-self: stretch; }

/* Rubriques : grilles qui se remplissent sans trou. */
.rubric-public .rubric-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; flex-direction: row; }
.rubric-public .rubric-grid > :last-child:nth-child(odd) .imagebox { flex: 0 0 48%; aspect-ratio: auto; min-height: 180px; }
.rubric-public .rubric-grid > :last-child:nth-child(odd) .tile-body { justify-content: center; }
.world-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.science-list { display: flex; flex-direction: column; justify-content: space-between; }

/* Carte orpheline sur une grille à 2 colonnes : passe en format horizontal pleine largeur. */
@media (min-width: 601px) and (max-width: 860px) {
  .articles > .article:last-child:nth-child(odd),
  .articles > .ahn-ad-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .articles > .article:last-child:nth-child(odd) .article-link { flex-direction: row; }
  .articles > .article:last-child:nth-child(odd) .imagebox { flex: 0 0 46%; aspect-ratio: auto; min-height: 200px; }
  .articles > .article:last-child:nth-child(odd) .article-link > :not(.imagebox) { margin-left: 16px; }
  .articles > .article:last-child:nth-child(odd) .article-link { flex-wrap: wrap; align-content: flex-start; }
}

/* ---------- 3. Emplacements publicitaires ---------- */
.ahn-ad-row { margin-top: 18px; display: flex; justify-content: center; }
.ahn-ad-row-top { margin-top: 10px; margin-bottom: -2px; }
.ahn-ad-row-single { margin-top: 22px; }
.ahn-ad-row-footer { margin-top: 36px; }
.ahn-ad { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; max-width: calc(var(--ad-w, 728) * 1px); margin-inline: auto; }
.ahn-ad-label { display: inline-flex; align-items: center; gap: 5px; font-size: 9px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--text-sub); }
.ahn-ad-label .ahn-i { width: 12px; height: 12px; }
.ahn-ad-inner { position: relative; width: 100%; overflow: hidden; border-radius: var(--radius-md); }
/* Hauteur réservée d'avance = pas de saut de mise en page au chargement de l'annonce. */
.ahn-ad-image .ahn-ad-inner, .ahn-ad-empty .ahn-ad-inner { aspect-ratio: var(--ad-w, 728) / var(--ad-h, 90); }
.ahn-ad-code .ahn-ad-inner { min-height: calc(var(--ad-h, 90) * 1px); display: block; text-align: center; overflow: visible; }
/* Les régies (AdSense, GAM…) mesurent la largeur disponible : le conteneur doit occuper toute la largeur. */
.ahn-ad-code { align-items: stretch; }
.ahn-ad-code .ahn-ad-label { align-self: center; }
.ahn-ad-code .ahn-ad-code, .ahn-ad-code ins.adsbygoogle, .ahn-ad-code iframe { width: 100%; max-width: 100%; }
.ahn-ad-code ins.adsbygoogle { display: block; }
.sidebar .ahn-ad-code, .ahn-ad-card.ahn-ad-code { width: 100%; }
.ahn-ad-inner > a:not(.ahn-ad-ph) { display: block; width: 100%; height: 100%; }
.ahn-ad-img { width: 100%; height: 100%; object-fit: cover; background: var(--surface-subtle); }
.ahn-ad-img-m { display: none; }
.ahn-ad-image .ahn-ad-inner { box-shadow: var(--shadow-card); transition: transform .3s, box-shadow .3s; }
.ahn-ad-image .ahn-ad-inner:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }

/* Espace libre « Votre publicité ici » */
.ahn-ad-ph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px 18px; text-align: left;
  border: 1.5px dashed var(--brand-blue-border); border-radius: inherit; color: var(--text-muted);
  background:
    radial-gradient(circle at 12% 50%, var(--brand-blue-light), transparent 45%),
    repeating-linear-gradient(135deg, transparent 0 12px, color-mix(in srgb, var(--brand-blue) 4%, transparent) 12px 24px),
    var(--surface);
  transition: border-color .25s, background-color .25s;
}
.ahn-ad-ph:hover { border-style: solid; border-color: var(--brand-blue); }
.ahn-ad-ph-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-blue); color: #fff; box-shadow: 0 6px 14px -6px rgba(var(--brand-blue-rgb), .6); }
.ahn-ad-ph-icon .ahn-i { width: 20px; height: 20px; animation: ahnWiggle 3.5s ease-in-out infinite; }
.ahn-ad-ph-txt { display: flex; flex-direction: column; min-width: 0; }
.ahn-ad-ph-txt strong { font-family: var(--font-display); font-size: 15px; color: var(--text-main); }
.ahn-ad-ph-txt small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ahn-ad-ph-cta { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 800; color: var(--brand-blue); background: var(--brand-blue-light); padding: 6px 12px; border-radius: var(--radius-pill); }
.ahn-ad-ph-cta .ahn-i { width: 12px; height: 12px; }
/* Formats compacts (90 px de haut) : texte sur une ligne. */
.ahn-ad-f-leaderboard .ahn-ad-ph, .ahn-ad-f-superleader .ahn-ad-ph { gap: 12px; padding: 8px 16px; }
.ahn-ad-f-leaderboard .ahn-ad-ph-icon, .ahn-ad-f-superleader .ahn-ad-ph-icon { width: 34px; height: 34px; border-radius: 10px; }
/* Formats verticaux : contenu empilé. */
.ahn-ad-f-mrec .ahn-ad-ph, .ahn-ad-f-halfpage .ahn-ad-ph, .ahn-ad-card .ahn-ad-ph { flex-direction: column; text-align: center; }
.ahn-ad-f-mrec .ahn-ad-ph-txt, .ahn-ad-f-halfpage .ahn-ad-ph-txt, .ahn-ad-card .ahn-ad-ph-txt { align-items: center; }
.ahn-ad-f-mrec .ahn-ad-ph-txt small, .ahn-ad-f-halfpage .ahn-ad-ph-txt small, .ahn-ad-card .ahn-ad-ph-txt small { white-space: normal; }
.ahn-ad-f-halfpage .ahn-ad-ph-icon { width: 56px; height: 56px; border-radius: 16px; }
.ahn-ad-f-halfpage .ahn-ad-ph-txt strong { font-size: 19px; }
.ahn-ad-f-halfpage .ahn-ad-ph { background:
    radial-gradient(circle at 50% 18%, var(--brand-blue-light), transparent 55%),
    repeating-linear-gradient(135deg, transparent 0 12px, color-mix(in srgb, var(--brand-blue) 4%, transparent) 12px 24px),
    var(--surface); }
/* Barre latérale : le pavé occupe toute la largeur de la colonne. */
.sidebar .ahn-ad { max-width: 100%; }

/* Carte native dans les grilles d'articles */
.ahn-ad-card { min-width: 0; height: 100%; max-width: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 10px; gap: 8px; align-items: stretch; }
.ahn-ad-card .ahn-ad-label { align-self: flex-start; margin-left: 4px; color: var(--brand-blue); }
.ahn-ad-card .ahn-ad-inner { flex: 1; min-height: 260px; aspect-ratio: auto; }
.ahn-ad-card.ahn-ad-image .ahn-ad-inner { aspect-ratio: auto; }

/* Annonce dans le texte d'un article */
.entry-content .ahn-ad-incontent, .single-content .ahn-ad-inline { clear: both; margin: 2em auto; }
.entry-content .ahn-ad-incontent::before { content: ''; display: block; width: 100%; height: 1px; background: var(--line); margin-bottom: 10px; }

/* Barre collante mobile */
.ahn-ad-mobile_sticky { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; max-width: none; padding: 6px 44px 8px; background: var(--surface-glass); backdrop-filter: blur(12px); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px -12px rgba(15, 23, 42, .25); animation: ahnSlideUp .45s cubic-bezier(.2,0,0,1) both; }
.ahn-ad-mobile_sticky .ahn-ad-label { position: absolute; left: 10px; top: 50%; transform: translateY(-50%) rotate(-90deg); font-size: 7px; }
.ahn-ad-mobile_sticky .ahn-ad-inner { max-width: 320px; margin: 0 auto; }
.ahn-ad-mobile_sticky .ahn-ad-ph { padding: 4px 10px; gap: 8px; }
.ahn-ad-mobile_sticky .ahn-ad-ph-icon { width: 28px; height: 28px; border-radius: 8px; }
.ahn-ad-mobile_sticky .ahn-ad-ph-txt small, .ahn-ad-mobile_sticky .ahn-ad-ph-cta { display: none; }
.ahn-ad-close { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-subtle); color: var(--text-muted); border: 1px solid var(--line); }
.ahn-ad-close .ahn-i { width: 14px; height: 14px; }
@keyframes ahnSlideUp { from { transform: translateY(100%); } to { transform: none; } }

/* Appareils */
@media (min-width: 601px) {
  .ahn-ad-mobile_sticky, .ahn-ad-dev-mobile, .ahn-ad-row:has(> .ahn-ad-dev-mobile) { display: none !important; }
}
@media (max-width: 860px) {
  .sidebar-sticky { position: static; grid-column: 1 / -1; margin-top: 0; }
  .sidebar > .ahn-ad { grid-column: 1 / -1; }
  .single-layout .single-sidebar { align-self: start; }
}
@media (max-width: 600px) {
  .ahn-ad-dev-desktop, .ahn-ad-row:has(> .ahn-ad-dev-desktop) { display: none !important; }
  body.has-mobile-ad { padding-bottom: 72px; }
  body.has-mobile-ad .top { bottom: 84px; }
  /* Formats larges : bannière mobile si fournie, sinon hauteur minimale lisible. */
  .ahn-ad-inner:has(.ahn-ad-img-m) .ahn-ad-img-d { display: none; }
  .ahn-ad-inner:has(.ahn-ad-img-m) { aspect-ratio: 320 / 100; }
  .ahn-ad-img-m { display: block; }
  .ahn-ad-f-leaderboard.ahn-ad-empty .ahn-ad-inner, .ahn-ad-f-superleader.ahn-ad-empty .ahn-ad-inner, .ahn-ad-f-billboard.ahn-ad-empty .ahn-ad-inner { aspect-ratio: auto; min-height: 96px; }
  .ahn-ad-f-leaderboard .ahn-ad-ph-txt small, .ahn-ad-f-superleader .ahn-ad-ph-txt small { display: none; }
  .ahn-ad-code .ahn-ad-inner { min-height: 100px; }
  .ahn-ad-ph-cta { padding: 5px 9px; }
  .rubric-public .rubric-grid > :last-child:nth-child(odd) { flex-direction: column; }
  .rubric-public .rubric-grid > :last-child:nth-child(odd) .imagebox { flex: none; aspect-ratio: 16 / 9; min-height: 0; }
  .breadcrumbs > span { max-width: 26ch; }
}

.entry-content .ahn-ad a, .entry-content .ahn-ad a:hover { text-decoration: none; }

/* ---------- v1.2 : corrections ---------- */
/* Bouton « Lecture rapide » : la règle de la maquette `.article button` l'étirait en grand cercle. */
.article .quick-btn {
  position: absolute; top: 10px; right: 10px; left: auto; bottom: auto;
  width: 32px; height: 32px; min-width: 0; padding: 0; flex-direction: row;
  display: grid; place-items: center; text-align: center;
  border-radius: 50%; background: rgba(15, 23, 42, .62); color: #fff;
}
.article:has(.editorial-badge) .quick-btn { top: 36px; }
.article .quick-btn:hover { background: var(--tone, var(--brand-blue)); }

/* Menu : icône maison */
.navrow nav a.nav-home { width: 36px; height: 34px; padding: 0; justify-content: center; }
.navrow nav a.nav-home .ahn-i { width: 17px; height: 17px; }
.navrow nav a.nav-home .nav-home-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.navrow nav a.nav-home::after { display: none; }
@media (max-width: 860px) {
  .navrow nav.open a.nav-home { width: auto; height: auto; padding: 8px 13px; justify-content: flex-start; }
  .navrow nav.open a.nav-home .nav-home-label { position: static; width: auto; height: auto; clip: auto; }
}

/* Recherche scientifique : image de taille fixe (elle s'étirait sur toute la hauteur de la liste). */
.science-layout { align-items: start; }
.science-feature { height: 340px; min-height: 0; }
.science-feature img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.science-list { justify-content: flex-start; }
@media (max-width: 600px) { .science-feature { height: 260px; } }

/* ---------- v1.2 : connexion ---------- */
.login-toggle { width: auto; padding: 0 14px 0 11px; gap: 7px; border-radius: var(--radius-pill); display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 700; color: var(--text-main); }
.login-toggle .ahn-i { width: 16px; height: 16px; color: var(--brand-blue); }
.login-toggle:hover { color: var(--brand-blue); border-color: var(--brand-blue-border); background: var(--brand-blue-light); }
.account-menu { position: relative; }
.account-toggle { padding: 0; overflow: hidden; }
.account-toggle img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.account-dropdown { position: absolute; right: 0; top: calc(100% + 10px); z-index: 70; width: 250px; padding: 8px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: 0 18px 40px -14px rgba(15, 23, 42, .35); animation: ahnPop .25s cubic-bezier(.2,0,0,1) both; }
.account-dropdown[hidden] { display: none; }
.account-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.account-head img { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.account-head span { display: flex; flex-direction: column; min-width: 0; }
.account-head strong { font-size: 13px; }
.account-head small { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-dropdown a { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600; color: var(--text-main); }
.account-dropdown a .ahn-i { width: 16px; height: 16px; color: var(--brand-blue); }
.account-dropdown a:hover { background: var(--brand-blue-light); color: var(--brand-blue); }
.account-dropdown .account-logout { color: var(--brand-red); }
.account-dropdown .account-logout .ahn-i { color: var(--brand-red); }

.login-modal { width: min(820px, 94vw); max-height: 92vh; padding: 0; display: none; grid-template-columns: 0.85fr 1fr; overflow: hidden; }
.login-modal[open] { display: grid; }
.login-modal.shake { animation: ahnShake .45s ease; }
.login-close { position: absolute; top: 14px; right: 14px; z-index: 3; }
.login-aside { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; padding: 34px 30px; color: #fff; background: radial-gradient(circle at 80% 10%, rgba(239,68,68,.45), transparent 50%), linear-gradient(150deg, #0f172a 0%, #1e3a8a 55%, var(--brand-blue) 100%); }
.login-aside .float-icons .fi { color: rgba(255,255,255,.16); }
.login-aside .float-icons .fi-0 { left: 12%; top: 10%; } .login-aside .float-icons .fi-1 { left: 66%; top: 14%; }
.login-aside .float-icons .fi-2 { left: 40%; top: 30%; } .login-aside .float-icons .fi-3 { left: 76%; top: 44%; }
.login-aside .float-icons .fi-4 { left: 14%; top: 46%; } .login-aside .float-icons .fi-5 { left: 50%; top: 58%; }
.login-mark { position: relative; z-index: 2; width: 62px; height: 62px; border-radius: 18px; display: grid; place-items: center; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); }
.login-mark svg { width: 38px; height: 38px; }
.login-mark .heart-shape { transform-origin: 24px 26px; animation: ahnBeat 1.8s ease-in-out infinite; }
.login-aside p { position: relative; z-index: 2; margin: 0; font-family: var(--font-display); font-size: 19px; line-height: 1.35; font-weight: 700; }
.login-form { padding: 34px 32px 28px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.login-form .eyebrow { color: var(--brand-blue); font-size: 9.5px; }
.login-form h2 { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.login-intro { margin: -4px 0 4px; font-size: 13px; color: var(--text-muted); }
.login-field { display: flex; flex-direction: column; gap: 5px; }
.login-field > span:first-child { font-size: 11.5px; font-weight: 700; }
.login-input { display: flex; align-items: center; gap: 9px; padding: 0 6px 0 13px; border-radius: var(--radius-md); border: 1.5px solid var(--line); background: var(--canvas); transition: border-color .2s, box-shadow .2s; }
.login-input:focus-within { border-color: var(--brand-blue); box-shadow: 0 0 0 4px var(--brand-blue-light); }
.login-input > .ahn-i { width: 16px; height: 16px; color: var(--text-sub); }
.login-input input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 11px 0; font-size: 13.5px; color: var(--text-main); }
.login-input input:focus { outline: none; }
.login-eye { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--text-sub); }
.login-eye .ahn-i { width: 16px; height: 16px; }
.login-eye.is-on, .login-eye:hover { color: var(--brand-blue); background: var(--brand-blue-light); }
.login-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.login-remember { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-weight: 600; }
.login-row a, .login-register a { color: var(--brand-blue); font-weight: 700; }
.login-message { min-height: 0; margin: 0; font-size: 12.5px; font-weight: 700; }
.login-message:empty { display: none; }
.login-message.is-error { color: #b91c1c; background: var(--brand-red-light); border: 1px solid var(--brand-red-border); padding: 9px 12px; border-radius: var(--radius-sm); }
.login-message.is-ok { color: var(--color-emerald); background: var(--color-emerald-light); border: 1px solid var(--color-emerald-border); padding: 9px 12px; border-radius: var(--radius-sm); }
.login-submit { width: 100%; padding: 12px 18px; font-size: 13px; display: inline-flex; justify-content: center; gap: 8px; }
.login-submit .ahn-i { width: 16px; height: 16px; transition: transform .25s; }
.login-submit:hover .ahn-i { transform: translateX(3px); }
.login-form.is-loading .login-submit { opacity: .7; }
.login-register { margin: 2px 0 0; text-align: center; font-size: 12.5px; color: var(--text-muted); }
@keyframes ahnShake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@media (max-width: 860px) { .login-toggle-label { display: none; } .login-toggle { width: 36px; padding: 0; justify-content: center; } }
@media (max-width: 640px) { .login-modal[open] { grid-template-columns: 1fr; } .login-aside { display: none; } .login-form { padding: 28px 22px 22px; } }
.top[hidden], .icon[hidden] { display: none !important; }
