/* =============================================
   Blocks: Colonnes Modulo (modulo/columns + modulo/column)
   Toutes les valeurs arrivent en variables CSS posées sur l'élément
   lui-même (voir inc/columns-helpers.php).
   Bascules : tablette ≤ 980 px, mobile ≤ 600 px.
   ============================================= */

/* ─── Conteneur ─── */
.mt-cols {
    --_gxc: var(--_gx);
    --_gyc: var(--_gy);
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: var(--_rjc, flex-start);
    padding: var(--_pt, var(--_pv, 0)) var(--_pr, var(--_ph, 0)) var(--_pb, var(--_pv, 0)) var(--_pl, var(--_ph, 0));
    min-height: var(--_mh, auto);
}
.mt-cols__inner {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: var(--_tpl);
    column-gap: var(--_gxc);
    row-gap: var(--_gyc);
    align-items: var(--_ai, stretch);
    width: 100%;
    max-width: var(--_cw, none);
    margin-inline: auto;
}

/* ─── Colonne ─── */
.mt-col {
    position: relative;
    box-sizing: border-box;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: var(--_jc, flex-start);
    gap: var(--_cg, 1.25rem);
    padding: var(--_pt, var(--_pv, 0)) var(--_pr, var(--_ph, 0)) var(--_pb, var(--_pv, 0)) var(--_pl, var(--_ph, 0));
    min-height: var(--_mh, auto);
}
.mt-cols .mt-col > * { margin-block: 0; max-width: 100%; }

/* ─── Images à la largeur de la colonne ───
   Une image plus petite que sa colonne laisserait un vide à côté d'elle
   (qui ressemble à un espacement trop grand). Les images alignées ou
   redimensionnées à la main gardent leur taille. */
.mt-cols--fill-img > .mt-cols__inner > .mt-col > .wp-block-image:not(.alignleft):not(.alignright):not(.aligncenter):not(.is-resized) {
    display: block;
    width: 100%;
}
.mt-cols--fill-img > .mt-cols__inner > .mt-col > .wp-block-image:not(.alignleft):not(.alignright):not(.aligncenter):not(.is-resized) img {
    width: 100%;
    height: auto;
}

/* ─── Fond : image fixe (désactivée sur écrans tactiles, où elle saccade) ─── */
.has-mt-bg-fixed { background-attachment: fixed; }
@media (hover: none) { .has-mt-bg-fixed { background-attachment: scroll; } }

/* ─── Voile : au-dessus du fond, sous le contenu ─── */
.has-mt-overlay { isolation: isolate; }
.has-mt-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--_ov);
    opacity: var(--_ovo, .5);
    border-radius: inherit;
    pointer-events: none;
}

/* ─── Couleurs du contenu ─── */
.has-mt-heading-color :is(h1, h2, h3, h4, h5, h6) { color: var(--_hc); }
.has-mt-link-color a:not(.wp-element-button):not(.wp-block-button__link):not(.mt-col__link) { color: var(--_lc); }
.has-mt-link-hover-color a:not(.wp-element-button):not(.wp-block-button__link):not(.mt-col__link):is(:hover, :focus-visible) { color: var(--_lhc); }

/* ─── Ordre d'affichage ───
   Rang naturel = (i + 1) × 2, rang inversé = (n − i) × 2 : toujours pairs.
   Une position choisie N donne N × 2 − 1 (impair) et passe donc juste
   avant la colonne qui occupe naturellement ce rang. */
.mt-cols--rev-always > .mt-cols__inner > .mt-col { order: calc((var(--_n, 1) - var(--mtcol-i, 0)) * 2); }

/* ─── Séparateurs ─── */
.mt-cols--divided > .mt-cols__inner > .mt-col::after {
    content: "";
    position: absolute;
    pointer-events: none;
    display: none;
}
/* Ordinateur : un filet vertical avant chaque colonne sauf la première. */
@media (min-width: 981px) {
    .mt-cols--divided > .mt-cols__inner > .mt-col:not(:first-child)::after {
        display: block;
        top: 0;
        bottom: 0;
        left: calc((var(--_gxc) + var(--_dw)) / -2);
        border-left: var(--_dw) var(--_ds) var(--_dc);
    }
    /* Ordre inversé : la première colonne s'affiche à droite. */
    .mt-cols--divided.mt-cols--rev-always > .mt-cols__inner > .mt-col::after { display: none; }
    .mt-cols--divided.mt-cols--rev-always > .mt-cols__inner > .mt-col:not(:last-child)::after {
        display: block;
        top: 0;
        bottom: 0;
        left: calc((var(--_gxc) + var(--_dw)) / -2);
        border-left: var(--_dw) var(--_ds) var(--_dc);
    }
}

/* ─── Colonne collante ─── */
.mt-col--sticky { position: sticky; top: var(--_st, 24px); align-self: start; }
.admin-bar .mt-col--sticky { top: calc(var(--_st, 24px) + var(--wp-admin--admin-bar--height, 32px)); }

/* ─── Colonne cliquable ─── */
.mt-col--link { cursor: pointer; }
.mt-col__link {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}
.mt-col__link:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.mt-col--link :is(a:not(.mt-col__link), button, input, select, textarea, label, summary) { position: relative; z-index: 2; }
.mt-col .screen-reader-text {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ─── Effets au survol (souris uniquement) ─── */
@media (hover: hover) {
    .mt-col--hover { transition: box-shadow .25s ease, transform .25s ease; }
    .mt-col--hover-shadow:hover { box-shadow: 0 14px 34px color-mix(in srgb, var(--mb-c-shadow) 14%, transparent); }
    .mt-col--hover-lift:hover   { transform: translateY(-6px); box-shadow: 0 16px 32px color-mix(in srgb, var(--mb-c-shadow) 12%, transparent); }
    .mt-col--hover-zoom:hover   { transform: scale(1.03); }
    .mt-col--hover-glow:hover   { box-shadow: 0 0 0 1px color-mix(in srgb, currentColor 18%, transparent), 0 0 28px color-mix(in srgb, currentColor 22%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
    .mt-col--hover { transition: none; }
    .mt-col--hover-lift:hover,
    .mt-col--hover-zoom:hover { transform: none; }
}

/* =============================================
   Tablette ≤ 980 px
   ============================================= */
@media (max-width: 980px) {
    .mt-cols { --_gxc: var(--_gxt); --_gyc: var(--_gyt); padding: var(--_ptt, var(--_pvt, 0)) var(--_prt, var(--_pht, 0)) var(--_pbt, var(--_pvt, 0)) var(--_plt, var(--_pht, 0)); min-height: var(--_mht, var(--_mh, auto)); }
    .mt-cols__inner { grid-template-columns: var(--_tplt); }
    .mt-col { padding: var(--_ptt, var(--_pvt, 0)) var(--_prt, var(--_pht, 0)) var(--_pbt, var(--_pvt, 0)) var(--_plt, var(--_pht, 0)); min-height: var(--_mht, var(--_mh, auto)); }

    .mt-cols__inner > .mt-col { order: calc((var(--mtcol-i, 0) + 1) * 2); }
    .mt-cols--rev-stacked > .mt-cols__inner > .mt-col,
    .mt-cols--rev-always > .mt-cols__inner > .mt-col { order: calc((var(--_n, 1) - var(--mtcol-i, 0)) * 2); }
    .mt-cols__inner > .mt-col.has-mt-order-t { order: calc(var(--_ot) * 2 - 1); }
    .mt-col--span-t { grid-column: 1 / -1; }

    /* Séparateurs : verticaux entre colonnes d'une même rangée,
       horizontaux quand les colonnes sont empilées (1 par rangée). */
    .mt-cols--divided.mt-cols--t1 > .mt-cols__inner > .mt-col:not(:first-child)::after {
        display: block;
        left: 0;
        right: 0;
        top: calc((var(--_gyc) + var(--_dw)) / -2);
        border-top: var(--_dw) var(--_ds) var(--_dc);
    }
    .mt-cols--divided.mt-cols--t2 > .mt-cols__inner > .mt-col:not(:nth-child(2n+1))::after,
    .mt-cols--divided.mt-cols--t3 > .mt-cols__inner > .mt-col:not(:nth-child(3n+1))::after,
    .mt-cols--divided.mt-cols--t4 > .mt-cols__inner > .mt-col:not(:nth-child(4n+1))::after,
    .mt-cols--divided.mt-cols--t5 > .mt-cols__inner > .mt-col:not(:nth-child(5n+1))::after,
    .mt-cols--divided.mt-cols--t6 > .mt-cols__inner > .mt-col:not(:nth-child(6n+1))::after {
        display: block;
        top: 0;
        bottom: 0;
        left: calc((var(--_gxc) + var(--_dw)) / -2);
        border-left: var(--_dw) var(--_ds) var(--_dc);
    }
}

/* =============================================
   Mobile ≤ 600 px
   ============================================= */
@media (max-width: 600px) {
    .mt-cols { --_gxc: var(--_gxm); --_gyc: var(--_gym); padding: var(--_ptm, var(--_pvm, 0)) var(--_prm, var(--_phm, 0)) var(--_pbm, var(--_pvm, 0)) var(--_plm, var(--_phm, 0)); min-height: var(--_mhm, var(--_mht, var(--_mh, auto))); }
    .mt-cols__inner { grid-template-columns: var(--_tplm); }
    .mt-col { padding: var(--_ptm, var(--_pvm, 0)) var(--_prm, var(--_phm, 0)) var(--_pbm, var(--_pvm, 0)) var(--_plm, var(--_phm, 0)); min-height: var(--_mhm, var(--_mht, var(--_mh, auto))); }

    .mt-cols--rev-mobile > .mt-cols__inner > .mt-col { order: calc((var(--_n, 1) - var(--mtcol-i, 0)) * 2); }
    .mt-cols__inner > .mt-col.has-mt-order-t { order: calc(var(--_ot) * 2 - 1); }
    .mt-cols__inner > .mt-col.has-mt-order-m { order: calc(var(--_om) * 2 - 1); }
    .mt-col--span-m { grid-column: 1 / -1; }
    .mt-col--sticky-desktop { position: relative; top: auto; align-self: auto; }

    /* Séparateurs : on repart de zéro puis on applique la règle mobile. */
    .mt-cols--divided > .mt-cols__inner > .mt-col::after { display: none !important; }
    .mt-cols--divided.mt-cols--m1 > .mt-cols__inner > .mt-col:not(:first-child)::after {
        display: block !important;
        left: 0;
        right: 0;
        bottom: auto;
        top: calc((var(--_gyc) + var(--_dw)) / -2);
        border-left: 0;
        border-top: var(--_dw) var(--_ds) var(--_dc);
    }
    .mt-cols--divided.mt-cols--m2 > .mt-cols__inner > .mt-col:not(:nth-child(2n+1))::after,
    .mt-cols--divided.mt-cols--m3 > .mt-cols__inner > .mt-col:not(:nth-child(3n+1))::after,
    .mt-cols--divided.mt-cols--m4 > .mt-cols__inner > .mt-col:not(:nth-child(4n+1))::after,
    .mt-cols--divided.mt-cols--m5 > .mt-cols__inner > .mt-col:not(:nth-child(5n+1))::after,
    .mt-cols--divided.mt-cols--m6 > .mt-cols__inner > .mt-col:not(:nth-child(6n+1))::after {
        display: block !important;
        top: 0;
        bottom: 0;
        right: auto;
        left: calc((var(--_gxc) + var(--_dw)) / -2);
        border-top: 0;
        border-left: var(--_dw) var(--_ds) var(--_dc);
    }
}
