/*
Theme Name: SNPMA
Description: Thème officiel léger du Syndicat National des Praticiens de Mutualité Agricole, optimisé pour Gutenberg.
Version: 0.6.2
Requires at least: 6.6
Requires PHP: 7.4
Text Domain: snpma
*/
:root{--snpma-blue:#003b95;--snpma-link:#123bb2;--snpma-text:#071a37;--snpma-muted:#667085;--snpma-border:#d9e0e8;--snpma-light:#eef4fa;--snpma-width:1250px}
*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:#fff;color:var(--snpma-text);font-family:Arial,Helvetica,sans-serif;line-height:1.55}a{color:var(--snpma-link);text-underline-offset:2px}img{max-width:100%;height:auto}.snpma-site{min-height:100vh}.snpma-main{min-width:0}.snpma-inner{width:min(var(--snpma-width),calc(100% - 48px));margin-inline:auto}
.site-header{background:#fff;border-bottom:1px solid var(--snpma-border)}.header-inner{min-height:124px;display:grid;grid-template-columns:auto minmax(260px,1fr) auto;align-items:center;gap:26px}.site-logo{display:flex;align-items:center}.site-logo img{display:block;width:auto;max-width:285px;max-height:92px}.site-branding{min-width:0}.site-title{margin:0;font-size:25px;line-height:1.2;font-weight:700;color:var(--snpma-text)}.site-title a{color:inherit;text-decoration:none}.site-description{display:none}
.primary-nav{justify-self:end;position:relative}.primary-nav .menu{list-style:none;margin:0;padding:0;display:flex;align-items:center;gap:31px}.primary-nav .menu>li{position:relative;margin:0}.primary-nav a{display:block;padding:18px 0;color:var(--snpma-text);text-decoration:none;font-size:15px;font-weight:400;white-space:nowrap}.primary-nav .current-menu-item>a,.primary-nav .current-menu-ancestor>a,.primary-nav .current_page_item>a{color:#0066cc}.primary-nav .menu-item-has-children>a{padding-right:17px}.primary-nav .menu-item-has-children>a:after{content:"";position:absolute;right:1px;top:50%;width:6px;height:6px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:translateY(-65%) rotate(45deg)}.primary-nav .sub-menu{display:none;position:absolute;z-index:100;top:100%;left:-18px;min-width:235px;list-style:none;margin:0;padding:8px 0;background:#fff;border:1px solid var(--snpma-border);box-shadow:0 10px 28px rgba(0,0,0,.12)}.primary-nav li:hover>.sub-menu,.primary-nav li:focus-within>.sub-menu{display:block}.primary-nav .sub-menu li{position:relative;margin:0}.primary-nav .sub-menu a{padding:10px 18px;white-space:normal}.primary-nav .sub-menu .menu-item-has-children>a{padding-right:34px}.primary-nav .sub-menu .menu-item-has-children>a:after{right:15px;transform:translateY(-50%) rotate(-45deg)}.primary-nav .sub-menu .sub-menu{top:-9px;left:100%}.menu-toggle{display:none;border:1px solid var(--snpma-border);background:#fff;padding:9px 12px;border-radius:4px;font:inherit;color:var(--snpma-text);cursor:pointer}
.entry-content{margin:0}.entry-content:after{content:"";display:table;clear:both}.entry-content>.alignfull{width:100%;max-width:none;margin-left:0;margin-right:0}.entry-content>.alignwide{width:min(1400px,calc(100% - 48px));max-width:none;margin-left:auto;margin-right:auto}.entry-content>:not(.alignfull):not(.alignwide){max-width:1200px;margin-left:auto;margin-right:auto}.entry-content>p:not(.alignfull):not(.alignwide),.entry-content>h1:not(.alignfull):not(.alignwide),.entry-content>h2:not(.alignfull):not(.alignwide),.entry-content>h3:not(.alignfull):not(.alignwide),.entry-content>h4:not(.alignfull):not(.alignwide),.entry-content>h5:not(.alignfull):not(.alignwide),.entry-content>h6:not(.alignfull):not(.alignwide),.entry-content>ul:not(.alignfull):not(.alignwide),.entry-content>ol:not(.alignfull):not(.alignwide),.entry-content>blockquote:not(.alignfull):not(.alignwide){width:min(1200px,calc(100% - 48px))}
.site-footer{background:var(--snpma-blue);color:#fff}.footer-inner{min-height:96px;display:flex;align-items:center;justify-content:center;padding:24px 0}.site-footer p{margin:0;text-align:center}.site-footer a{color:#fff}.singular-wrap,.archive-wrap{width:min(1200px,calc(100% - 48px));margin:42px auto}.single-post .singular-wrap{width:min(900px,calc(100% - 48px));margin:48px auto 56px}.single-post .singular-wrap .entry-title{margin:0 0 18px;font-size:clamp(2rem,3vw,2.5rem);line-height:1.15;letter-spacing:-.02em}.single-post .post-meta{margin:0 0 28px;color:var(--snpma-muted);font-size:.95rem}.single-post .entry-content{font-size:1.075rem;line-height:1.72;color:#101828}.single-post .entry-content>:not(.alignfull):not(.alignwide){max-width:900px}.single-post .entry-content p{margin-top:0;margin-bottom:1.15em}.single-post .entry-content h2{margin-top:1.7em;line-height:1.25}.single-post .entry-content h3{margin-top:1.5em;line-height:1.3}.single-post .entry-content img{max-width:100%;height:auto}.single-post .entry-content iframe,.single-post .entry-content video{max-width:100%}.single-post .entry-content table{display:block;max-width:100%;overflow-x:auto}.single-post .post-back{margin-top:38px;padding-top:22px;border-top:1px solid var(--snpma-border)}.single-post .post-back a{font-weight:600;text-decoration:none}.single-post .post-back a:hover{text-decoration:underline}.singular-wrap .entry-title{margin-top:0}.post-meta{color:var(--snpma-muted);font-size:.92rem}.archive-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:32px}.archive-card{padding:24px;background:#fff;border-radius:6px;box-shadow:0 4px 12px rgba(0,0,0,.10)}
@media(max-width:1050px){.header-inner{grid-template-columns:auto 1fr auto;gap:18px}.site-logo img{max-width:230px}.site-title{font-size:21px}.menu-toggle{display:block}.primary-nav .menu{display:none;position:absolute;right:0;top:48px;z-index:150;width:min(340px,88vw);background:#fff;border:1px solid var(--snpma-border);box-shadow:0 10px 28px rgba(0,0,0,.14);padding:10px 18px;flex-direction:column;align-items:stretch;gap:0}.primary-nav.is-open .menu{display:flex}.primary-nav a{padding:10px 0;white-space:normal}.primary-nav .sub-menu{display:block;position:static;border:0;box-shadow:none;padding:0 0 0 16px;min-width:0}.primary-nav .menu-item-has-children>a:after{display:none}.archive-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:700px){.single-post .singular-wrap{width:min(100% - 32px,900px);margin:30px auto 40px}.single-post .singular-wrap .entry-title{font-size:clamp(1.75rem,8vw,2.1rem);margin-bottom:14px}.single-post .post-meta{margin-bottom:22px}.single-post .entry-content{font-size:1rem;line-height:1.65}.single-post .entry-content>:not(.alignfull):not(.alignwide){max-width:100%}.single-post .entry-content>.alignwide,.single-post .entry-content>.alignfull{width:100%;margin-left:0;margin-right:0}.snpma-inner{width:min(100% - 24px,var(--snpma-width))}.header-inner{min-height:92px;grid-template-columns:auto 1fr auto;gap:10px}.site-logo img{max-width:135px;max-height:68px}.site-title{font-size:15px}.archive-grid{grid-template-columns:1fr}.entry-content>.alignwide{width:min(100% - 24px,1400px)}.entry-content>p:not(.alignfull):not(.alignwide),.entry-content>h1:not(.alignfull):not(.alignwide),.entry-content>h2:not(.alignfull):not(.alignwide),.entry-content>h3:not(.alignfull):not(.alignwide),.entry-content>h4:not(.alignfull):not(.alignwide),.entry-content>h5:not(.alignfull):not(.alignwide),.entry-content>h6:not(.alignfull):not(.alignwide),.entry-content>ul:not(.alignfull):not(.alignwide),.entry-content>ol:not(.alignfull):not(.alignwide),.entry-content>blockquote:not(.alignfull):not(.alignwide){width:min(1200px,calc(100% - 24px))}.singular-wrap,.archive-wrap{width:min(1200px,calc(100% - 24px));margin:28px auto}}

/* Finitions accueil 0.5.2 */
.home .entry-content>.wp-block-group.alignfull:first-child{padding-top:30px}
@media(max-width:700px){.home .entry-content>.wp-block-group.alignfull:first-child{padding-top:20px}}


/* Responsive header 0.5.4
   Desktop (>1050px): logo + nom + navigation complète.
   Tablette (701–1050px): logo + nom + bouton Menu.
   Mobile (<=700px): logo + bouton Menu ; le nom textuel est masqué pour éviter l'écrasement. */
@media (min-width:701px) and (max-width:1050px){
  .header-inner{min-height:108px;grid-template-columns:auto minmax(220px,1fr) auto;gap:16px}
  .site-logo img{max-width:205px;max-height:78px}
  .site-title{font-size:19px;line-height:1.18}
}
@media (max-width:700px){
  .header-inner{min-height:86px;grid-template-columns:1fr auto;gap:14px}
  .site-logo{min-width:0}
  .site-logo img{max-width:165px;max-height:66px}
  .site-branding{display:none}
  .primary-nav{justify-self:end}
  .menu-toggle{min-height:42px;padding:8px 13px;font-size:16px}
  .primary-nav .menu{position:fixed;top:86px;right:12px;left:12px;width:auto;max-height:calc(100vh - 102px);overflow-y:auto;padding:10px 18px;border-radius:4px}
}
@media (max-width:380px){
  .site-logo img{max-width:145px}
  .menu-toggle{padding-inline:10px}
}


/* Pages classiques 0.5.5 */
.page:not(.home) .page-wrap{width:min(1100px,calc(100% - 48px));margin:42px auto 56px}
.page:not(.home) .page-wrap .entry-content>:not(.alignfull):not(.alignwide){max-width:1100px}
.page:not(.home) .page-wrap .entry-content>.alignwide{width:min(1200px,100%);max-width:none;margin-inline:auto}
.page:not(.home) .page-wrap .entry-content>.alignfull{width:100vw;max-width:none;margin-left:calc(50% - 50vw);margin-right:calc(50% - 50vw)}
.page:not(.home) .entry-content img{max-width:100%;height:auto}
.page:not(.home) .entry-content iframe,.page:not(.home) .entry-content video{max-width:100%}
.page:not(.home) .entry-content table{display:block;max-width:100%;overflow-x:auto}

/* Images mises en avant 0.5.5 */
.featured-media{margin:0 0 28px}
.featured-media img{display:block;width:100%;height:auto;border-radius:6px}
.single-post .featured-media img{max-height:520px;object-fit:cover}
.archive-card{overflow:hidden;padding:0}
.archive-card .card-thumbnail{display:block;aspect-ratio:16/9;overflow:hidden;background:var(--snpma-light)}
.archive-card .card-thumbnail img{display:block;width:100%;height:100%;object-fit:cover;transition:transform .2s ease}
.archive-card .card-thumbnail:hover img{transform:scale(1.02)}
.archive-card .card-body{padding:24px}
.archive-card h2{margin:0 0 14px;font-size:1.45rem;line-height:1.35}
.archive-card .post-meta{margin:0 0 16px}
.archive-card .card-excerpt>:first-child{margin-top:0}.archive-card .card-excerpt>:last-child{margin-bottom:0}
.archive-pagination{margin-top:36px}

@media(max-width:700px){
  .page:not(.home) .page-wrap{width:min(100% - 32px,1100px);margin:30px auto 40px}
  .page:not(.home) .page-wrap .entry-content>.alignfull{width:100vw;margin-left:calc(50% - 50vw);margin-right:calc(50% - 50vw)}
  .archive-card .card-body{padding:20px}
  .archive-card h2{font-size:1.3rem}
}


/* Identité visuelle globale 0.5.6
   Le fond bleu très clair appartient au cadre du site.
   Les contenus éditoriaux restent sur des surfaces blanches pour la lisibilité. */
.snpma-main{background:var(--snpma-light)}

/* L'accueil est déjà composé dans Gutenberg : on conserve ses blocs tels quels. */
.home .snpma-main{background:var(--snpma-light)}

/* Pages classiques : carte blanche sur le fond général bleu clair. */
.page:not(.home) .page-wrap{
  background:#fff;
  border-radius:8px;
  padding:40px;
  box-shadow:0 3px 12px rgba(7,26,55,.07);
}

/* Articles : même langage visuel, avec une colonne de lecture plus étroite. */
.single-post .singular-wrap{
  background:#fff;
  border-radius:8px;
  padding:42px 48px;
  box-shadow:0 3px 12px rgba(7,26,55,.07);
}

/* Archives : le fond bleu clair porte naturellement les cartes blanches. */
.archive-wrap>h1{margin-top:0;margin-bottom:28px}

/* 404 et listes de secours gardent également le fond général. */
.error404 .singular-wrap{background:#fff;border-radius:8px;padding:40px;box-shadow:0 3px 12px rgba(7,26,55,.07)}

@media(max-width:700px){
  .page:not(.home) .page-wrap{padding:24px 20px;border-radius:6px}
  .single-post .singular-wrap{padding:26px 20px;border-radius:6px}
  .error404 .singular-wrap{padding:24px 20px}
}


/* =========================================================
   SNPMA 0.5.7 — continuité du fond sous le header
   Le fond de la zone principale commence immédiatement après
   le header. L'espace visuel est créé à l'intérieur (padding)
   et non à l'extérieur (margin).
   ========================================================= */

.snpma-main {
    margin-top: 0 !important;
    padding-top: 0;
    background: var(--snpma-light);
}

/* Supprime une éventuelle marge haute du premier conteneur
   qui laisserait apparaître le fond blanc du body. */
.snpma-main > :first-child {
    margin-top: 0;
}

/* Pages, articles et archives : respiration DANS la zone bleue. */
.archive-wrap,
.page-wrap,
.singular-wrap {
    margin-top: 0;
}

/* L'archive commence directement sur le fond bleu, puis son
   contenu bénéficie de son propre espace intérieur. */
.archive-wrap {
    padding-top: 30px;
}

/* Les pages et articles conservent une respiration au-dessus
   de leur carte blanche, mais cette respiration reste bleue. */
.page:not(.home) .snpma-main,
.single-post .snpma-main {
    padding-top: 30px;
}

/* L'accueil reste piloté par Gutenberg : pas de padding global
   supplémentaire imposé par le thème. */
.home .snpma-main {
    padding-top: 0;
}

@media (max-width: 700px) {
    .archive-wrap {
        padding-top: 22px;
    }

    .page:not(.home) .snpma-main,
    .single-post .snpma-main {
        padding-top: 22px;
    }
}


/* =========================================================
   SNPMA 0.5.8 — Gutenberg et composition "Dernières actualités"
   ========================================================= */

/* Largeur de travail cohérente pour les sections Gutenberg de l'accueil. */
.home .entry-content > :where(:not(.alignfull):not(.alignwide)) {
    width: min(1200px, calc(100% - 48px));
    margin-left: auto;
    margin-right: auto;
}
.home .entry-content > .alignwide {
    width: min(1400px, calc(100% - 48px));
    margin-left: auto;
    margin-right: auto;
}
.home .entry-content > .alignfull {
    width: 100%;
    max-width: none;
}

/* Le pattern utilise cette classe : elle peut aussi être attribuée
   manuellement à n'importe quelle Boucle de requête Gutenberg. */
.snpma-latest-news {
    padding-top: 36px;
    padding-bottom: 44px;
}
.snpma-latest-news .snpma-section-head {
    margin-bottom: 22px;
}
.snpma-latest-news .snpma-section-head h2 {
    margin: 0;
    font-size: clamp(1.65rem, 2.3vw, 2.15rem);
}
.snpma-latest-news .snpma-all-news {
    margin: 0;
    font-weight: 700;
}
.snpma-latest-news .wp-block-post-template {
    align-items: stretch;
}
.snpma-latest-news .wp-block-post {
    height: 100%;
}
.snpma-latest-news .snpma-news-card {
    box-sizing: border-box;
    height: 100%;
    overflow: hidden;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 13px rgba(7,26,55,.12);
}
.snpma-latest-news .wp-block-post-featured-image {
    margin: 0;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}
.snpma-latest-news .wp-block-post-featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.snpma-latest-news .snpma-news-card-body {
    box-sizing: border-box;
    padding: 26px;
}
.snpma-latest-news .wp-block-post-title {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: clamp(1.2rem, 1.7vw, 1.45rem);
    line-height: 1.3;
}
.snpma-latest-news .wp-block-post-date {
    margin-bottom: 14px;
    color: #56657a;
    font-size: .94rem;
}
.snpma-latest-news .wp-block-post-excerpt {
    margin-bottom: 0;
    line-height: 1.55;
}
.snpma-latest-news .wp-block-post-excerpt__more-link {
    display: inline-block;
    margin-top: 14px;
    font-weight: 700;
}

/* Gutenberg utilise 3 colonnes sur grand écran ; on force un repli
   lisible sur tablette et téléphone pour le pattern SNPMA. */
@media (max-width: 900px) {
    .snpma-latest-news .wp-block-post-template.is-layout-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 620px) {
    .home .entry-content > :where(:not(.alignfull):not(.alignwide)),
    .home .entry-content > .alignwide {
        width: min(100% - 32px, 1200px);
    }
    .snpma-latest-news {
        padding-top: 28px;
        padding-bottom: 34px;
    }
    .snpma-latest-news .snpma-section-head {
        align-items: flex-start !important;
        flex-direction: column;
        gap: 8px;
    }
    .snpma-latest-news .wp-block-post-template.is-layout-grid {
        grid-template-columns: 1fr;
    }
    .snpma-latest-news .snpma-news-card-body {
        padding: 22px 20px;
    }
}


/* =========================================================
   SNPMA 0.5.9 — alignement de l'en-tête de la composition
   avec la grille d'actualités.
   ========================================================= */

/*
 * Le bandeau titre/lien et la Query Loop utilisent maintenant
 * exactement la même largeur. Le bord gauche du titre correspond
 * au bord gauche de la première carte ; le lien est calé sur le
 * bord droit de la troisième carte.
 */
.snpma-latest-news .snpma-section-head,
.snpma-latest-news > .wp-block-query {
    box-sizing: border-box;
    width: min(1200px, calc(100% - 48px));
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.snpma-latest-news .snpma-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.snpma-latest-news .snpma-all-news {
    margin-left: auto;
    text-align: right;
}

@media (max-width: 620px) {
    .snpma-latest-news .snpma-section-head,
    .snpma-latest-news > .wp-block-query {
        width: min(100% - 32px, 1200px);
    }

    .snpma-latest-news .snpma-all-news {
        margin-left: 0;
        text-align: left;
    }
}


/* =========================================================
   SNPMA 0.6.0 — respiration avant le footer
   ========================================================= */

/* Le bleu clair reste visible entre le dernier contenu et le footer. */
.page:not(.home) .snpma-main,
.single-post .snpma-main,
.archive .snpma-main {
    padding-bottom: 42px;
}

@media (max-width: 700px) {
    .page:not(.home) .snpma-main,
    .single-post .snpma-main,
    .archive .snpma-main {
        padding-bottom: 28px;
    }
}


/* =========================================================
   SNPMA 0.6.1 — images mises en avant dans les cartes
   ========================================================= */

/*
 * Règles communes :
 * - l'image respire à l'intérieur de la tuile ;
 * - le fond derrière une image transparente reste blanc ;
 * - l'image entière est visible (pas de recadrage) ;
 * - dimensions responsives.
 */

/* Composition Gutenberg "Dernières actualités". */
.snpma-latest-news .snpma-news-card .wp-block-post-featured-image {
    box-sizing: border-box;
    margin: 22px 22px 0;
    width: calc(100% - 44px);
    height: 210px;
    aspect-ratio: auto;
    overflow: hidden;
    background: #fff;
    border-radius: 6px;
}

.snpma-latest-news .snpma-news-card .wp-block-post-featured-image a {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.snpma-latest-news .snpma-news-card .wp-block-post-featured-image img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    object-position: center;
    background: #fff;
}

/* Cartes générées par archive.php.
   Plusieurs noms de classes sont couverts pour rester compatible
   avec la structure actuelle du thème. */
.archive .archive-card .post-thumbnail,
.archive .post-card .post-thumbnail,
.archive .archive-card__image,
.archive .post-card__image {
    box-sizing: border-box;
    margin: 22px 22px 0;
    width: calc(100% - 44px);
    height: 210px;
    overflow: hidden;
    background: #fff;
    border-radius: 6px;
}

.archive .archive-card .post-thumbnail a,
.archive .post-card .post-thumbnail a,
.archive .archive-card__image a,
.archive .post-card__image a {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.archive .archive-card .post-thumbnail img,
.archive .post-card .post-thumbnail img,
.archive .archive-card__image img,
.archive .post-card__image img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    object-position: center;
    background: #fff;
}

/* Secours pour une image mise en avant directement enfant de la carte. */
.archive .archive-card > a > img.wp-post-image,
.archive .post-card > a > img.wp-post-image {
    box-sizing: border-box;
    display: block;
    width: calc(100% - 44px);
    height: 210px;
    margin: 22px 22px 0;
    object-fit: contain;
    object-position: center;
    background: #fff;
    border-radius: 6px;
}

/* Smartphone : marges et hauteur plus compactes. */
@media (max-width: 700px) {
    .snpma-latest-news .snpma-news-card .wp-block-post-featured-image,
    .archive .archive-card .post-thumbnail,
    .archive .post-card .post-thumbnail,
    .archive .archive-card__image,
    .archive .post-card__image {
        margin: 16px 16px 0;
        width: calc(100% - 32px);
        height: 180px;
    }

    .archive .archive-card > a > img.wp-post-image,
    .archive .post-card > a > img.wp-post-image {
        width: calc(100% - 32px);
        height: 180px;
        margin: 16px 16px 0;
    }
}


/* =========================================================
   SNPMA 0.6.2 — lien dynamique des compositions d'actualités
   ========================================================= */

.snpma-taxonomy-link {
    margin: 0 0 0 auto;
    text-align: right;
    font-weight: 700;
}

.snpma-taxonomy-link a {
    text-decoration: none;
}

.snpma-taxonomy-link a:hover,
.snpma-taxonomy-link a:focus {
    text-decoration: underline;
}

@media (max-width: 620px) {
    .snpma-taxonomy-link {
        margin-left: 0;
        text-align: left;
    }
}
