/* ============================================
   CHRU Nancy — Single Service de Soins
   Specs Figma pixel-perfect (node 171-4841)
   Layout : sidebar gauche 369px + contenu droite
   ============================================ */

/* === 1. Container global === */

.chru-single-service {
    background-color: #fff;
}

/* Cacher le footer Hello Elementor par défaut */
.single-service_de_soins .site-footer,
.single-service_de_soins footer.site-footer {
    display: none !important;
}

/* === 2. Layout 2 colonnes === */

.chru-single-service__body {
    display: flex;
    gap: 40px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 48px 80px;
    align-items: flex-start;
}

.chru-single-service__sidebar {
    width: 369px;
    flex-shrink: 0;
}

.chru-sidebar-sticky {
    position: sticky;
    top: calc(var(--header-height, 120px) + 20px);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.chru-single-service__content {
    flex: 1;
    min-width: 0;
}

.chru-single-service__content:focus {
    outline: none;
}

/* === 3. Sommaire (TOC) ===
 * Styles de base : voir components.css (.chru-sommaire) — source unique.
 * Ici on ne garde que les variants propres aux services de soins. */

/* === 4. Badge site géographique === */

.chru-sidebar-site {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background-color: var(--chru-grey, #f6f6f6);
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--chru-secondary, #14446b);
}

.chru-sidebar-site svg {
    color: var(--chru-accent, #197caa);
    flex-shrink: 0;
}

/* === 5. Contenu — Sections numérotées === */

.chru-single-service__content {
    counter-reset: chru-section;
}

.chru-single-service__content > h2,
.chru-single-service__content > .wp-block-heading {
    counter-increment: chru-section;
    display: flex;
    align-items: baseline;
    gap: 12px;
    font-size: var(--h2-size, 32px);
    font-weight: 700;
    color: var(--chru-secondary, #14446b);
    margin-top: 48px;
    margin-bottom: 24px;
    padding-bottom: 0;
    border-bottom: none;
    scroll-margin-top: calc(var(--header-height, 150px) + 20px);
    line-height: 1.25;
}

.chru-single-service__content > h2::before,
.chru-single-service__content > .wp-block-heading::before {
    content: counter(chru-section, decimal-leading-zero);
    font-size: 32px;
    font-weight: 700;
    color: var(--chru-secondary, #14446b);
    flex-shrink: 0;
    opacity: 1;
}

/* Premier H2 : pas de margin-top */
.chru-single-service__content > h2:first-of-type,
.chru-single-service__content > .wp-block-heading:first-of-type {
    margin-top: 0;
}

/* Paragraphes */
.chru-single-service__content > p {
    margin-bottom: 16px;
    line-height: 1.5;
    font-size: 16px;
    color: var(--chru-primary, #2d4356);
}

/* Dernier élément d'un bloc/section : pas de margin résiduelle (homogénéise p vs ul/ol en fin de contenu) */
.chru-single-service__content > p:last-child,
.chru-single-service__content > ul:last-child,
.chru-single-service__content > ol:last-child {
    margin-bottom: 0;
}

/* Auto-espacement : tout bloc suivi d'un H2 ajoute de l'air en haut du H2.
   Règle générique : fonctionne même quand le H2 est imbriqué dans un groupe. */
.chru-service-content * + h2:not([class*="__title"]),
.chru-service-content * + .wp-block-heading:is(h2) {
    margin-top: 2.5em;
}
.chru-service-content * + h3:not([class*="__title"]),
.chru-service-content * + .wp-block-heading:is(h3) {
    margin-top: 1.75em;
}

/* Paragraphe juste avant une image : resserrer pour éviter le double espace */
.chru-service-content p:has(+ figure.wp-block-image),
.chru-service-content p:has(+ .wp-block-image),
.chru-service-content p:has(+ .wp-block-gallery),
.chru-service-content p:has(+ .wp-block-embed) {
    margin-bottom: 0.4em;
}

/* Listes — aligné sur margin-bottom des paragraphes pour un rythme homogène */
.chru-single-service__content > ul,
.chru-single-service__content > ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.chru-single-service__content > ul li,
.chru-single-service__content > ol li {
    margin-bottom: 8px;
    line-height: 1.6;
}

/* H3 dans le contenu — exclut les titres internes de blocs (ex: chru-materiel-ecole__title) */
.chru-single-service__content h3:not([class*="__title"]) {
    font-size: var(--h3-size, 24px);
    font-weight: 700;
    color: var(--chru-secondary, #14446b);
    margin-top: 32px;
    margin-bottom: 16px;
}

/* === Galeries / images : légendes en dessous === */
.chru-single-service__content figure.wp-block-image,
.chru-single-service__content .wp-block-gallery figure {
    margin: 24px 0;
}
.chru-single-service__content figure.wp-block-image figcaption,
.chru-single-service__content .wp-block-gallery figcaption {
    position: static !important;
    background: none !important;
    color: var(--chru-gray-text, #6c6c6c) !important;
    font-size: 14px;
    font-style: italic;
    text-align: left;
    margin-top: 8px;
    padding: 0 !important;
}

/* === 6. Zone full-width (articles + structures) === */

.chru-single-service__fullwidth {
    background: var(--chru-grey, #f6f6f6);
    padding: 64px 0;
    width: 100%;
}

.chru-single-service__fullwidth-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 80px;
}

/* Reset marges wrappers Gutenberg dans la zone fullwidth */
.chru-single-service__fullwidth .wp-block-chru-articles-lies,
.chru-single-service__fullwidth .wp-block-chru-structures-associees {
    margin: 0;
    padding: 0;
}

/* Les cartes .chru-article-card sont définies dans components.css
 * (partagées entre single-service et single-post). */

/* === 8. Cartes structures associées === */

.chru-structures-associees {
    margin-top: 0;
}

.chru-structures-associees > h2 {
    font-size: 32px;
    font-weight: 700;
    color: var(--chru-secondary, #14446b);
    margin: 0 0 47px;
}

.chru-structures-associees__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.chru-structure-card {
    flex: 0 0 305px;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    overflow: hidden;
    background-color: #fff;
    border: 1px solid var(--structure-color, var(--chru-secondary, #14446b));
    box-shadow: none;
    transition: box-shadow 250ms ease;
}

.chru-structure-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.chru-structure-card__header {
    padding: 16px 20px;
    background-color: var(--structure-color, var(--chru-secondary, #14446b));
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Flèche dans le header */
.chru-structure-card__header::after {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    flex-shrink: 0;
}

.chru-structure-card__type {
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chru-structure-card__body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.chru-structure-card__title {
    font-size: 18px;
    font-weight: 700;
    color: var(--chru-secondary, #14446b);
    margin: 0;
    line-height: 1.3;
}

.chru-structure-card__desc {
    font-size: 16px;
    color: var(--chru-primary, #2d4356);
    line-height: 1.6;
    margin: 0;
}

.chru-structure-card__link {
    font-size: 16px;
    font-weight: 600;
    color: var(--chru-secondary, #14446b);
    text-decoration: underline;
    text-underline-offset: 3px;
    margin-top: auto;
}

.chru-structure-card__link:hover,
.chru-structure-card__link:focus {
    color: var(--chru-accent, #197caa);
}

/* === 9. Navigation prev/next === */

.chru-service-nav {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: 0;
}

.chru-service-nav .chru-container {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 80px;
}

.chru-service-nav__prev,
.chru-service-nav__next {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--chru-primary, #2d4356);
    max-width: 45%;
    transition: color 150ms ease;
}

.chru-service-nav__prev:hover,
.chru-service-nav__prev:focus,
.chru-service-nav__next:hover,
.chru-service-nav__next:focus {
    color: var(--chru-accent, #197caa);
}

.chru-service-nav__next {
    margin-left: auto;
    text-align: right;
}

.chru-service-nav__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
}

.chru-service-nav__title {
    display: block;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.chru-service-nav svg {
    flex-shrink: 0;
    color: var(--chru-accent, #197caa);
}

/* === 10. Variante Urgences === */

.chru-single-service--urgences .chru-sommaire {
    border-top: 3px solid var(--chru-urgences, #da1500);
}

.chru-single-service--urgences .chru-sommaire__title {
    border-bottom-color: rgba(218, 21, 0, 0.4);
}

.chru-single-service--urgences .chru-sommaire__item.is-active .chru-sommaire__link {
    color: var(--chru-urgences, #da1500);
}

.chru-single-service--urgences .chru-single-service__content > h2::before,
.chru-single-service--urgences .chru-single-service__content > .wp-block-heading::before {
    color: var(--chru-urgences, #da1500);
}

/* === 11. Responsive === */

@media (max-width: 1024px) {
    .chru-single-service__body {
        flex-direction: column;
        gap: 32px;
        padding: 32px 24px;
    }

    .chru-single-service__sidebar {
        width: 100%;
    }

    .chru-sidebar-sticky {
        position: static;
    }

    .chru-single-service__fullwidth-inner {
        padding: 0 24px;
    }

    .chru-service-nav .chru-container {
        padding: 32px 24px;
    }

    .chru-structure-card {
        flex: 1 1 calc(50% - 10px);
        min-width: 250px;
    }
}

@media (max-width: 768px) {
    .chru-single-service__body {
        padding: 24px 16px;
    }

    .chru-single-service__content > h2,
    .chru-single-service__content > .wp-block-heading {
        font-size: 24px;
        margin-top: 32px;
    }

    .chru-single-service__content > h2::before,
    .chru-single-service__content > .wp-block-heading::before {
        font-size: 24px;
    }

    /* Blocs CHRU : espacement réduit en mobile */
    .chru-single-service__content > [class*="wp-block-chru-"] {
        margin-bottom: 32px;
    }

    /* Cartes articles : empilées */
    .chru-article-card {
        flex-direction: column;
        flex: 1 1 100%;
    }

    .chru-article-card__image {
        width: 100%;
        height: 180px;
    }

    /* Cartes structures : pleine largeur */
    .chru-structure-card {
        flex: 1 1 100%;
    }

    /* Sommaire mobile : voir components.css (source unique) */

    /* Nav prev/next empilée */
    .chru-service-nav .chru-container {
        flex-direction: column;
        gap: 16px;
        padding: 24px 16px;
    }

    .chru-service-nav__prev,
    .chru-service-nav__next {
        max-width: 100%;
    }

    .chru-service-nav__next {
        text-align: left;
        flex-direction: row-reverse;
    }

    .chru-single-service__fullwidth {
        padding: 32px 0;
    }

    .chru-single-service__fullwidth-inner {
        padding: 0 16px;
    }

    /* Titres fullwidth : espacement réduit */
    .chru-articles-lies > h2,
    .chru-structures-associees > h2 {
        margin-bottom: 32px;
    }
}

/* === 12. Espacement entre blocs éditoriaux === */

/* Tous les blocs CHRU dans la zone contenu : 48px entre eux */
.chru-single-service__content > [class*="wp-block-chru-"] {
    margin-top: 0;
    margin-bottom: 48px;
}

.chru-single-service__content > [class*="wp-block-chru-"]:last-child {
    margin-bottom: 0;
}

/* Paragraphes standard Gutenberg entre blocs : même rythme */
.chru-single-service__content > .wp-block-group {
    margin-bottom: 48px;
}

.chru-single-service__content > .wp-block-group:last-child {
    margin-bottom: 0;
}

/* Fullwidth : titre → cartes = 47px (Figma) */
.chru-articles-lies > h2,
.chru-single-service__fullwidth .chru-articles-lies > h2 {
    margin: 0 0 47px;
}

.chru-structures-associees > h2,
.chru-single-service__fullwidth .chru-structures-associees > h2 {
    margin: 0 0 47px;
}

/* Événements liés : titre → cartes = 42px (Figma) */
.chru-evenements-lies > h2 {
    margin: 0 0 42px;
}

/* Espacement entre sections fullwidth successives */
.chru-single-service__fullwidth + .chru-single-service__fullwidth {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* === 13. Print === */

@media print {
    .chru-single-service__body {
        display: block;
    }

    .chru-sidebar-sticky {
        position: static;
    }

    .chru-single-service__sidebar {
        width: 100%;
        margin-bottom: 2rem;
    }

    /* Sommaire print : voir components.css (source unique) */

    .chru-article-card,
    .chru-structure-card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .chru-article-card {
        flex-direction: column;
    }

    .chru-article-card__image {
        width: 100%;
        height: 150px;
    }

    .chru-service-nav {
        display: none;
    }

    .chru-single-service__fullwidth {
        background: none;
    }
}