/* ============================================================
   rank.css — Modele "rank" (guide / listicle a sections numerotees)
   Flux vertical simple et robuste. Le corps est du HTML brut
   (<section><h2>..</h2>..</section> + <aside>). Numerotation = compteur CSS.
   Reutilise les variables de style.css si presentes (valeurs de repli).
   ============================================================ */

.rank {
    --rk-max: var(--max-width, 1120px);
    --rk-text: 760px;
    --rk-accent: var(--button-color, #2563eb);
    --rk-accent-hover: var(--button-color-hover, #1e4fd0);
    --rk-ink: #0f172a;
    --rk-muted: #64748b;
    --rk-line: #e6e8ee;
    --rk-bg-soft: #f6f8fc;
    color: var(--rk-ink);
    font-family: "Roboto", system-ui, sans-serif;
}

.rank :where(h1, h2, h3, p, ul, ol, figure) { margin: 0; }

/* ---- Hero ---- */
.rank-hero {
    max-width: var(--rk-max);
    margin: 2.5rem auto 0;
    padding: 0 var(--padding-x, 1.25rem);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.rank-hero-media img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 7;
    object-fit: cover;
    border-radius: 16px;
}
.rank-h1 {
    font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.6rem);
    line-height: 1.15;
    letter-spacing: -0.01em;
    max-width: 20ch;
}
.rank-intro {
    max-width: var(--rk-text);
    font-size: 1.15rem;
    line-height: 1.7;
    color: #334155;
}
.rank-intro > * + * { margin-top: 0.9rem; }
.rank-intro a { color: var(--rk-accent); text-decoration: underline; text-underline-offset: 3px; }

/* ---- Sommaire (TOC) ---- */
.rank-toc {
    max-width: var(--rk-max);
    margin: 2.5rem auto 0;
    padding: 1.25rem 1.5rem;
    background: var(--rk-bg-soft);
    border: 1px solid var(--rk-line);
    border-radius: 14px;
    width: calc(100% - 2 * var(--padding-x, 1.25rem));
}
.rank-toc-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--rk-muted);
    margin-bottom: 0.85rem;
}
.rank-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.5rem 1.5rem;
    grid-template-columns: 1fr;
}
@media (min-width: 720px) { .rank-toc-list { grid-template-columns: 1fr 1fr; } }
.rank-toc-list a {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    text-decoration: none;
    color: #334155;
    padding: 0.3rem 0;
    transition: color 0.15s ease;
}
.rank-toc-list a:hover,
.rank-toc-list a.is-active { color: var(--rk-accent); }
.rank-toc-list a.is-active { font-weight: 600; }
.rank-toc-num {
    flex: 0 0 auto;
    min-width: 1.4rem;
    font-weight: 700;
    color: var(--rk-accent);
    font-variant-numeric: tabular-nums;
}

/* ---- Contenu : sections en flux vertical ---- */
.rank-content {
    counter-reset: rk;
    max-width: var(--rk-max);
    margin: 2.75rem auto 4.5rem;   /* espace en bas, apres la derniere section */
    padding: 0 var(--padding-x, 1.25rem);
}
.rank-content > section {
    counter-increment: rk;
    scroll-margin-top: 90px;
}
.rank-content > section:not(:first-child) {
    margin-top: 4.75rem;
    padding-top: 4.75rem;
    border-top: 1px solid var(--rk-line);
}
.rank-content > section > h2 {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    font-size: clamp(1.35rem, 1.1rem + 1vw, 1.7rem);
    line-height: 1.3;
    letter-spacing: -0.01em;
    margin: 0 0 1.1rem;
    scroll-margin-top: 90px;
}
.rank-content > section > h2::before {
    content: counter(rk);
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 12px;
    background: var(--rk-accent);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* Corps de texte */
.rank-content p,
.rank-content ul,
.rank-content ol { font-size: 1.02rem; line-height: 1.75; color: #334155; }
.rank-content > section > * + * { margin-top: 1rem; }
.rank-content h3 { font-size: 1.12rem; line-height: 1.4; color: var(--rk-ink); margin-top: 1.7rem; }
.rank-content ul,
.rank-content ol { padding-left: 1.25rem; }
.rank-content li + li { margin-top: 0.4rem; }
.rank-content a {
    color: var(--rk-accent);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
}
.rank-content a:hover { color: var(--rk-accent-hover); }

/* Images (figures inline) : jamais plus larges que la colonne, ratio fixe */
.rank-figure { margin: 1.75rem 0 0.5rem; }
.rank-figure img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 14px;
}

/* Encarts libres entre sections */
.rank-content aside {
    max-width: var(--rk-text);
    margin: 1.75rem auto;
    padding: 1.25rem 1.4rem;
    background: var(--rk-bg-soft);
    border: 1px solid var(--rk-line);
    border-left: 4px solid var(--rk-accent);
    border-radius: 12px;
    font-size: 0.98rem;
    line-height: 1.7;
    color: #334155;
}
.rank-content aside > * + * { margin-top: 0.75rem; }
.rank-content aside a { color: var(--rk-accent); text-decoration: underline; text-underline-offset: 3px; }
/* Encart "Bon plan" — carte CTA cliquable */
.rank-content aside.rank-tip {
    position: relative;
    max-width: 620px;
    background: linear-gradient(135deg, #e9f1ff 0%, #f6f8fc 72%);
    border: 1px solid #c8dbff;
    border-left: 4px solid var(--rk-accent);
}
.rank-tip-title {
    margin: 0 0 0.55rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--rk-accent);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
.rank-tip-title::before { content: "\1F4B0"; font-size: 1.05rem; }
.rank-tip-badge {
    margin-left: auto;
    background: var(--rk-accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
}
.rank-tip-cta { margin-top: 1.2rem; margin-bottom: 0; }
.rank-content .rank-tip-cta a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    background: var(--rk-accent);
    color: #fff;
    padding: 0.95rem 1.5rem;
    border-radius: 12px;
    font-size: 1.06rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.rank-content .rank-tip-cta a:hover { box-shadow: 0 8px 22px rgba(37, 99, 235, 0.48); }
.rank-content .rank-tip-cta a::after { content: "\2192"; font-weight: 700; transition: transform 0.15s ease; }
.rank-content .rank-tip-cta a:hover::after { transform: translateX(3px); }
.rank-content .rank-tip-cta a::before { content: ""; position: absolute; inset: 0; border-radius: inherit; }

/* ---- Desktop : image laterale, alternee gauche / droite par section ---- */
@media (min-width: 900px) {
    .rank-content > section.rank-sec--media {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 340px;
        column-gap: 2.6rem;
        align-items: start;
    }
    /* le texte occupe une colonne, l'image l'autre (sur toute la hauteur) */
    .rank-content > section.rank-sec--media > :not(.rank-figure) {
        grid-column: 1;
        min-width: 0;
    }
    .rank-content > section.rank-sec--media > .rank-figure {
        grid-column: 2;
        grid-row: 1 / span 50;   /* couvre toutes les lignes de texte */
        align-self: start;
        margin: 0;
    }
    /* alternance : sections paires -> image a gauche */
    .rank-content > section.rank-sec--media:nth-of-type(even) {
        grid-template-columns: 340px minmax(0, 1fr);
    }
    .rank-content > section.rank-sec--media:nth-of-type(even) > :not(.rank-figure) { grid-column: 2; }
    .rank-content > section.rank-sec--media:nth-of-type(even) > .rank-figure { grid-column: 1; }
    /* sections sans image : largeur de lecture confortable */
    .rank-content > section:not(.rank-sec--media) { max-width: var(--rk-text); }
}

/* ---- Encart "meilleures activités" : lignes entièrement cliquables ---- */
.rank-content aside.rank-activities {
    background: transparent;
    border: 0;
    padding: 0;
    max-width: var(--rk-text);
}
.rank-act-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--rk-ink);
    margin: 0 0 1rem;
}
.rank-act-table { display: flex; flex-direction: column; gap: 0.6rem; }
.rank-content .rank-act-row {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.9rem;
    padding: 0.5rem 0.9rem 0.5rem 0.5rem;
    background: #fff;
    border: 1px solid var(--rk-line);
    border-radius: 14px;
    text-decoration: none;
    color: var(--rk-ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rank-content .rank-act-row:hover {
    border-color: var(--rk-accent);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.16);
}
.rank-act-img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; display: block; }
.rank-content .rank-act-row picture { display: block; line-height: 0; }
.rank-act-main { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.rank-act-name { font-weight: 600; line-height: 1.25; }
.rank-act-tag {
    align-self: flex-start;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--rk-accent);
    background: #eaf1ff;
    padding: 0.13rem 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.15rem;
    line-height: 1.3;
}
.rank-act-meta { font-size: 0.85rem; color: var(--rk-muted); }
.rank-act-price { font-weight: 700; color: var(--rk-accent); white-space: nowrap; font-size: 1.05rem; }

/* ---- Conclusion ---- */
.rank-conclusion {
    max-width: var(--rk-text);
    margin: 3.5rem auto 4rem;
    padding: 1.75rem 1.9rem;
    background: var(--rk-bg-soft);
    border: 1px solid var(--rk-line);
    border-left: 4px solid var(--rk-accent);
    border-radius: 14px;
    font-size: 1.05rem;
    line-height: 1.75;
    color: #334155;
}
.rank-conclusion > * + * { margin-top: 1rem; }
.rank-conclusion a { color: var(--rk-accent); text-decoration: underline; text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}
