/* =========================================================
   SENEGALINFOS — MOBILE PREMIUM V5
   Mobile-first finishing layer for 320–767px.
   Keeps desktop untouched and reduces dashboard-like density.
========================================================= */

@media (max-width: 767px) {
    :root {
        --si-mobile-pad: 14px;
        --si-mobile-line: #e7e7e9;
        --si-mobile-muted: #71717a;
    }

    html {
        overflow-x: hidden;
        background: #fff;
    }

    body {
        overflow-x: hidden;
        background: #fff !important;
        color: #18181b;
        font-size: 16px;
    }

    body > main.mx-auto,
    body > header > div > div,
    body > header nav > div,
    body > footer > div {
        width: 100% !important;
        max-width: none !important;
        padding-left: var(--si-mobile-pad) !important;
        padding-right: var(--si-mobile-pad) !important;
    }

    /* ---------- Header ---------- */
    body > header {
        position: sticky !important;
        top: 0;
        z-index: 60 !important;
        border-bottom: 1px solid var(--si-mobile-line) !important;
        background: rgba(255,255,255,.98) !important;
        box-shadow: 0 2px 14px rgba(0,0,0,.035) !important;
        backdrop-filter: blur(14px);
    }

    body > header > div:first-child > div {
        height: 58px !important;
        gap: 8px !important;
    }

    body > header button[aria-label="Menu"],
    body > header button[aria-label="Rechercher"] {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        border-color: #ededee !important;
        background: #fff !important;
    }

    body > header button[aria-label="Menu"] {
        order: 0;
    }

    body > header a[aria-label="SenegalInfos - Accueil"] {
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    body > header a[aria-label="SenegalInfos - Accueil"] > div:first-child {
        overflow: hidden;
        font-size: 1.55rem !important;
        line-height: 1 !important;
        white-space: nowrap;
        text-overflow: clip;
        letter-spacing: -.06em !important;
    }

    body > header a[aria-label="SenegalInfos - Accueil"] > div:nth-child(2) {
        display: none !important;
    }

    body > header .ml-auto.flex.items-center.gap-2 {
        margin-left: 0 !important;
        gap: 4px !important;
    }

    /* Mobile menu becomes a clean full-width newsroom drawer. */
    body > header > div[x-show="mobileOpen"] {
        position: fixed !important;
        top: 58px !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        z-index: 70 !important;
        max-height: none !important;
        overflow-y: auto !important;
        border-top: 1px solid var(--si-mobile-line) !important;
        background: #fff !important;
        -webkit-overflow-scrolling: touch;
    }

    body > header > div[x-show="mobileOpen"] nav {
        padding-top: 12px !important;
        padding-bottom: 40px !important;
    }

    body > header > div[x-show="mobileOpen"] nav > a:first-child {
        margin-bottom: 8px !important;
        border-radius: 10px !important;
        background: #fff1f2 !important;
        padding: 11px 13px !important;
        font-size: .92rem !important;
    }

    body > header > div[x-show="mobileOpen"] nav > .grid:first-of-type {
        grid-template-columns: 1fr 1fr !important;
        gap: 1px !important;
        overflow: hidden;
        border: 1px solid var(--si-mobile-line);
        border-radius: 12px;
        background: var(--si-mobile-line);
    }

    body > header > div[x-show="mobileOpen"] nav > .grid:first-of-type a {
        border-radius: 0 !important;
        background: #fff !important;
        padding: 12px 13px !important;
        font-size: .86rem !important;
        font-weight: 750 !important;
    }

    /* Search panel */
    body > header > div[x-show="searchOpen"] > div {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    body > header > div[x-show="searchOpen"] input[type="search"] {
        height: 48px !important;
        min-height: 48px !important;
        border-radius: 12px !important;
        font-size: 16px !important;
    }

    body > header > div[x-show="searchOpen"] button[type="submit"] {
        padding-left: 12px !important;
        padding-right: 12px !important;
        font-size: .78rem !important;
    }

    /* ---------- Continuous news bar ---------- */
    body > header + .bg-zinc-950 > div {
        gap: 8px !important;
        padding-top: 7px !important;
        padding-bottom: 7px !important;
    }

    body > header + .bg-zinc-950 span:first-child {
        border-radius: 4px !important;
        padding: 4px 6px !important;
        font-size: 8px !important;
        letter-spacing: .11em !important;
    }

    body > header + .bg-zinc-950 p {
        font-size: 10px !important;
        line-height: 1.2 !important;
    }

    /* ---------- Global main rhythm ---------- */
    body > main.mx-auto {
        padding-top: 12px !important;
        padding-bottom: 30px !important;
    }

    main section {
        scroll-margin-top: 70px;
    }

    /* ---------- Breaking ---------- */
    body main > section.bg-red-700 {
        margin: 0 calc(var(--si-mobile-pad) * -1) 12px !important;
        border-radius: 0 !important;
    }

    body main > section.bg-red-700 > div {
        min-height: 42px;
    }

    body main > section.bg-red-700 > div > div:first-child {
        padding: 10px 11px !important;
        font-size: 8px !important;
        letter-spacing: .12em !important;
    }

    body main > section.bg-red-700 > div > div:last-child {
        gap: 20px !important;
        padding: 9px 12px !important;
        font-size: 12px !important;
    }

    /* ---------- Homepage hero ---------- */
    body:has(#si-main-hero-title) section:has(#si-main-hero-title) {
        margin-bottom: 14px !important;
    }

    body:has(#si-main-hero-title) section:has(#si-main-hero-title) > div:first-child {
        margin-bottom: 8px !important;
        gap: 8px !important;
    }

    body:has(#si-main-hero-title) section:has(#si-main-hero-title) > div:first-child > div:first-child > span:first-child {
        padding: 6px 9px !important;
        font-size: 8px !important;
        letter-spacing: .12em !important;
    }

    body:has(#si-main-hero-title) section:has(#si-main-hero-title) > div:first-child > div:last-child {
        max-width: 44%;
        font-size: 9px !important;
        line-height: 1.2 !important;
        text-align: right;
    }

    body:has(#si-main-hero-title) section:has(#si-main-hero-title) > div.grid {
        display: block !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) {
        width: 100%;
        height: 390px !important;
        min-height: 390px !important;
        border: 0 !important;
        border-radius: 14px !important;
        box-shadow: 0 8px 24px rgba(0,0,0,.10) !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) > img {
        object-position: center 28% !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) > .bg-gradient-to-t {
        background: linear-gradient(to top, rgba(0,0,0,.94) 0%, rgba(0,0,0,.72) 34%, rgba(0,0,0,.18) 68%, transparent 100%) !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) > .absolute.left-5.top-6,
    body:has(#si-main-hero-title) article:has(#si-main-hero-title) > .absolute.left-7.top-7 {
        top: 13px !important;
        left: 13px !important;
        gap: 6px !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) > .absolute.left-5.top-6 span,
    body:has(#si-main-hero-title) article:has(#si-main-hero-title) > .absolute.left-5.top-6 a,
    body:has(#si-main-hero-title) article:has(#si-main-hero-title) > .absolute.left-7.top-7 span,
    body:has(#si-main-hero-title) article:has(#si-main-hero-title) > .absolute.left-7.top-7 a {
        padding: 5px 8px !important;
        font-size: 8px !important;
        letter-spacing: .1em !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) > .absolute.inset-x-0.bottom-0 {
        padding: 16px !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) > .absolute.inset-x-0.bottom-0 > .mb-4 {
        margin-bottom: 7px !important;
    }

    body:has(#si-main-hero-title) #si-main-hero-title {
        max-width: 100% !important;
        font-size: clamp(1.72rem, 7.5vw, 2.12rem) !important;
        line-height: 1.03 !important;
        letter-spacing: -.035em !important;
        -webkit-line-clamp: 4 !important;
        text-wrap: pretty !important;
    }

    body:has(#si-main-hero-title) #si-main-hero-title + p {
        display: none !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) > .absolute.inset-x-0.bottom-0 > div.mt-6 {
        margin-top: 10px !important;
        gap: 8px 10px !important;
        font-size: 9px !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) a.rounded-full.bg-white {
        min-height: 34px !important;
        margin-top: 10px !important;
        padding: 7px 12px !important;
        font-size: 9px !important;
    }

    /* ---------- Follow-now rail becomes 3 compact rows ---------- */
    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside {
        margin-top: 16px !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .mb-3 {
        margin-bottom: 0 !important;
        padding: 0 0 8px !important;
        border-bottom: 2px solid #18181b !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .mb-3 h2 {
        font-size: 10px !important;
        letter-spacing: .12em !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid {
        display: block !important;
        border-bottom: 1px solid var(--si-mobile-line) !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article,
    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article:first-child {
        display: grid !important;
        min-height: 94px !important;
        grid-template-columns: 104px minmax(0,1fr) !important;
        border: 0 !important;
        border-bottom: 1px solid var(--si-mobile-line) !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article:nth-child(n+4) {
        display: none !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article > a.relative,
    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article > div.ml-1 {
        width: 104px !important;
        height: 94px !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article > div.flex {
        min-width: 0 !important;
        justify-content: center !important;
        padding: 9px 0 9px 12px !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article h3,
    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article:first-child h3 {
        font-size: .88rem !important;
        line-height: 1.18 !important;
        letter-spacing: -.012em !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article h3 a {
        -webkit-line-clamp: 3 !important;
    }

    /* ---------- Now ticker ---------- */
    body:has(#si-main-hero-title) section:has(#si-main-hero-title) > div.mt-5 {
        margin-top: 8px !important;
        padding: 9px 0 !important;
        overflow: hidden !important;
        border-bottom: 1px solid var(--si-mobile-line) !important;
    }

    body:has(#si-main-hero-title) section:has(#si-main-hero-title) > div.mt-5 > div {
        overflow-x: auto !important;
        scrollbar-width: none;
    }

    body:has(#si-main-hero-title) section:has(#si-main-hero-title) > div.mt-5 > div::-webkit-scrollbar {
        display: none;
    }

    /* ---------- Category strip ---------- */
    body:has(#si-main-hero-title) main > section.border-y.border-zinc-200.bg-white {
        margin: 0 calc(var(--si-mobile-pad) * -1) 18px !important;
        padding: 0 var(--si-mobile-pad) !important;
        border-top: 1px solid var(--si-mobile-line) !important;
        border-bottom: 1px solid var(--si-mobile-line) !important;
        background: #fafafa !important;
    }

    body:has(#si-main-hero-title) main > section.border-y.border-zinc-200.bg-white > div {
        gap: 16px !important;
        padding: 10px 0 !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        scrollbar-width: none;
    }

    body:has(#si-main-hero-title) main > section.border-y.border-zinc-200.bg-white > div::-webkit-scrollbar {
        display: none;
    }

    body:has(#si-main-hero-title) main > section.border-y.border-zinc-200.bg-white a {
        flex: 0 0 auto;
        font-size: .78rem !important;
        font-weight: 800 !important;
    }

    /* ---------- Home content ---------- */
    body:has(#si-main-hero-title) main > div.grid {
        display: block !important;
    }

    body:has(#si-main-hero-title) main > div.grid > main > section[class*="rounded-[24px]"],
    body:has(#si-main-hero-title) main > div.grid > main > section.mb-14,
    body:has(#si-main-hero-title) main > div.grid > main > section.mb-8 {
        margin-bottom: 26px !important;
        padding: 14px 0 0 !important;
        border-top: 1px solid var(--si-mobile-line) !important;
        background: #fff !important;
    }

    body:has(#si-main-hero-title) main > div.grid > main > section[class*="rounded-[24px]"] > div:first-child,
    body:has(#si-main-hero-title) main > div.grid > main > section.mb-14 > div:first-child,
    body:has(#si-main-hero-title) main > div.grid > main > section.mb-8 > div:first-child {
        margin-bottom: 12px !important;
    }

    body:has(#si-main-hero-title) main > div.grid > main section h2 {
        font-size: 1.65rem !important;
        line-height: .98 !important;
        letter-spacing: -.035em !important;
    }

    /* Main article in each section */
    body:has(#si-main-hero-title) main > div.grid > main > section > div.grid {
        gap: 14px !important;
    }

    body:has(#si-main-hero-title) main > div.grid > main > section article.group > a[class*="aspect-[16/9]"] {
        border-radius: 12px !important;
    }

    body:has(#si-main-hero-title) main > div.grid > main > section article.group h3 {
        font-size: 1.32rem !important;
        line-height: 1.08 !important;
        letter-spacing: -.025em !important;
        text-wrap: pretty;
    }

    body:has(#si-main-hero-title) main > div.grid > main > section article.group p {
        display: none !important;
    }

    /* Secondary story list */
    body:has(#si-main-hero-title) main > div.grid > main > section .divide-y article {
        grid-template-columns: minmax(0,1fr) 84px !important;
        gap: 10px !important;
        padding-top: 11px !important;
        padding-bottom: 11px !important;
    }

    body:has(#si-main-hero-title) main > div.grid > main > section .divide-y article h3 {
        font-size: .93rem !important;
        line-height: 1.17 !important;
    }

    body:has(#si-main-hero-title) main > div.grid > main > section .divide-y article a.h-\[76px\] {
        width: 84px !important;
        height: 66px !important;
        border-radius: 9px !important;
    }

    /* Regions */
    body:has(#si-main-hero-title) main > div.grid > main > section.mb-14 > div.grid {
        gap: 14px !important;
    }

    body:has(#si-main-hero-title) main > div.grid > main > section.mb-14 article {
        border: 0 !important;
        border-bottom: 1px solid var(--si-mobile-line) !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding-bottom: 14px;
    }

    body:has(#si-main-hero-title) main > div.grid > main > section.mb-14 article > div.p-5 {
        padding: 12px 0 0 !important;
    }

    body:has(#si-main-hero-title) main > div.grid > main > section.mb-14 article h3 {
        font-size: 1.18rem !important;
        line-height: 1.12 !important;
    }

    /* ---------- Homepage sidebar becomes curated lower feed ---------- */
    body:has(#si-main-hero-title) main > div.grid > aside {
        margin-top: 8px !important;
        display: block !important;
    }

    body:has(#si-main-hero-title) main > div.grid > aside > section {
        margin-bottom: 16px !important;
        border-radius: 12px !important;
        box-shadow: none !important;
    }

    /* Brand and long directory/sticky modules add little value on mobile. */
    body:has(#si-main-hero-title) main > div.grid > aside > section:last-of-type,
    body:has(#si-main-hero-title) main > div.grid > aside > div.relative.hidden.min-h-\[1200px\] {
        display: none !important;
    }

    /* ---------- Growth controls ---------- */
    [data-si-growth-controls] {
        margin-top: 24px !important;
        margin-bottom: 24px !important;
        padding-left: var(--si-mobile-pad) !important;
        padding-right: var(--si-mobile-pad) !important;
    }

    [data-si-growth-controls] > div {
        gap: 8px !important;
        border-radius: 14px !important;
        padding: 10px !important;
        box-shadow: none !important;
    }

    [data-si-growth-controls] button,
    [data-si-growth-controls] a {
        border-radius: 10px !important;
        padding: 11px 12px !important;
        font-size: .82rem !important;
    }

    [data-si-preferred-header] {
        padding: 6px var(--si-mobile-pad) !important;
    }

    [data-si-preferred-article],
    [data-si-preferred-follow] {
        margin-top: 22px !important;
        margin-bottom: 22px !important;
        border-radius: 14px !important;
        padding: 16px !important;
    }

    /* ---------- Article pages ---------- */
    body main > nav[aria-label="Fil d’Ariane"] {
        margin-bottom: 12px !important;
        overflow-x: auto;
        white-space: nowrap;
        font-size: 10px !important;
        scrollbar-width: none;
    }

    body main > nav[aria-label="Fil d’Ariane"]::-webkit-scrollbar {
        display: none;
    }

    body main > nav[aria-label="Fil d’Ariane"] + header {
        margin-bottom: 18px !important;
    }

    body main > nav[aria-label="Fil d’Ariane"] + header h1 {
        max-width: 100% !important;
        font-size: clamp(2rem, 8.6vw, 2.65rem) !important;
        line-height: 1.01 !important;
        letter-spacing: -.038em !important;
        text-wrap: pretty !important;
    }

    body main > nav[aria-label="Fil d’Ariane"] + header p {
        margin-top: 12px !important;
        font-size: 1.05rem !important;
        line-height: 1.48 !important;
    }

    body main figure {
        margin-top: 18px !important;
        margin-bottom: 18px !important;
    }

    body main figure > div.overflow-hidden {
        border-radius: 12px !important;
    }

    body main figure img {
        width: 100% !important;
        aspect-ratio: 16 / 9;
        object-fit: cover !important;
    }

    .article-body {
        font-size: 1.075rem !important;
        line-height: 1.72 !important;
    }

    .article-body p {
        margin: .9rem 0 1.15rem !important;
        max-width: none !important;
    }

    .article-body h2 {
        margin-top: 1.85rem !important;
        font-size: 1.65rem !important;
        line-height: 1.08 !important;
    }

    .article-body h3 {
        font-size: 1.28rem !important;
    }

    .article-body blockquote {
        margin: 1.35rem 0 !important;
        padding: 1rem !important;
        font-size: 1rem !important;
    }

    /* Generic cards on internal pages */
    body main article.group,
    body main .rounded-2xl,
    body main .rounded-3xl {
        border-radius: 12px;
    }

    /* ---------- Footer ---------- */
    body > footer {
        margin-top: 36px !important;
        padding-bottom: 90px !important;
    }

    body > footer > div {
        padding-top: 34px !important;
        padding-bottom: 34px !important;
    }

    body > footer .grid {
        gap: 28px !important;
    }

    /* Prevent accidental horizontal overflow from embedded media. */
    iframe,
    video,
    embed,
    object {
        max-width: 100% !important;
    }
}

/* Very small phones: preserve hierarchy rather than shrinking everything. */
@media (max-width: 359px) {
    :root { --si-mobile-pad: 11px; }

    body > header a[aria-label="SenegalInfos - Accueil"] > div:first-child {
        font-size: 1.4rem !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) {
        height: 365px !important;
        min-height: 365px !important;
    }

    body:has(#si-main-hero-title) #si-main-hero-title {
        font-size: 1.62rem !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article,
    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article:first-child {
        grid-template-columns: 92px minmax(0,1fr) !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article > a.relative,
    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article > div.ml-1 {
        width: 92px !important;
    }
}

/* Tablet portrait: keep a calm two-column editorial rhythm. */
@media (min-width: 640px) and (max-width: 767px) {
    :root { --si-mobile-pad: 20px; }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) {
        height: 500px !important;
        min-height: 500px !important;
    }

    body:has(#si-main-hero-title) #si-main-hero-title {
        max-width: 22ch !important;
        font-size: 2.65rem !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        border-bottom: 0 !important;
    }

    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article,
    body:has(#si-main-hero-title) article:has(#si-main-hero-title) + aside > .grid > article:first-child {
        border: 1px solid var(--si-mobile-line) !important;
        border-radius: 12px !important;
    }
}
