/* ============================================
   BOUTIQUE WOOCOMMERCE — PENSEZ SAUVAGE KRAFT
   ============================================ */

/* FOND KRAFT — wrappers GeneratePress WooCommerce */
body.woocommerce .site-content,
body.woocommerce-page .site-content,
body.woocommerce .content-area,
body.woocommerce-page .content-area,
body.woocommerce #primary,
body.woocommerce-page #primary,
body.woocommerce #main,
body.woocommerce-page #main,
body.woocommerce .inside-article,
body.woocommerce-page .inside-article,
body.woocommerce .entry-content,
body.woocommerce-page .entry-content {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

/* ============================================
   SIDEBAR — MASQUÉE SUR WOOCOMMERCE
   La sidebar vide prenait 30% → produits en 3 col.
   On la masque pour donner 100% au contenu.
   ============================================ */

body.woocommerce #right-sidebar,
body.woocommerce-page #right-sidebar,
body.post-type-archive-product #right-sidebar,
body.woocommerce .is-right-sidebar,
body.woocommerce-page .is-right-sidebar {
    display: none !important;
}

body.woocommerce .content-area,
body.woocommerce-page .content-area,
body.post-type-archive-product .content-area {
    width: 100% !important;
}

/* ============================================
   GRILLE PRODUITS — 4 COLONNES FLEX
   ============================================ */

.woocommerce ul.products,
.woocommerce-page ul.products,
body.search ul.products {
    display: flex !important;
    flex-flow: row wrap !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    margin: 0 !important;
    padding: 0.5rem !important;
    list-style: none !important;
    max-width: 100% !important;
}

.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product,
body.search ul.products li.product {
    float: none !important;
    /* Taille fixe par palier — voir media queries plus bas.
       Largeur par défaut (palier laptop 1200-1700px) = 220px. */
    width: 220px !important;
    flex: 0 0 auto !important;
    margin: 0.5rem !important;
    padding: 0 !important;
    border: 3px solid #4C351C !important;
    border-image: url('../images/border.png') 24 24 / 20px 20px / 0.1rem 0.2rem 0.1rem 0.1rem round !important;
    border-radius: 13px 22px 10px 10px !important;
    background: rgba(125, 75, 44, 0.2) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    text-align: center !important;
    position: relative !important;
    box-shadow: none !important;
    transition: box-shadow 0.25s ease !important;
    box-sizing: border-box !important;
}

/* PERFORMANCE — content-visibility sur les vignettes des pages d'archive produit
   uniquement (catalogue, catégories, taxos d'attribut). Le navigateur peut sauter
   le rendu/layout des vignettes hors viewport, ce qui fait passer une page de
   175 produits sans pagination. NE PAS appliquer sur la fiche produit single
   (related/upsells visibles sous la fiche) ni sur le panier.
   contain-intrinsic-size 460px = hauteur cible de la vignette (cf ps_vignette_produit).
   Cf web.dev/articles/content-visibility (Baseline 2024). */
body.archive ul.products li.product,
body.post-type-archive-product ul.products li.product,
body.search ul.products li.product {
    content-visibility: auto;
    contain-intrinsic-size: 0 460px;
}

/* Hover — halo orange statique en fondu (transition box-shadow déclarée plus haut) */
.woocommerce ul.products li.product:hover,
.woocommerce-page ul.products li.product:hover,
body.search ul.products li.product:hover {
    box-shadow:
        0 0 0 2px #D4600A,
        0 0 22px 8px rgba(212, 96, 10, 0.55),
        2px 3px 6px rgba(40, 15, 0, 0.4) !important;
}

/* --- WRAPPER IMAGE + BADGE (carré parfait) --- */
.ps-thumbnail-wrap {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    aspect-ratio: 1 / 1 !important;
    overflow: hidden !important;
    line-height: 0 !important;
}

.ps-thumbnail-wrap img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    margin: 0 !important;
}

/* Image hors wrapper (fallback si filtre PHP inactif) */
.woocommerce ul.products li.product a > img:not(.badge-ab),
body.search ul.products li.product a > img:not(.badge-ab) {
    width: 100% !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: cover !important;
    display: block !important;
    margin: 0 !important;
}

/* --- BADGE AGRICULTURE BIOLOGIQUE --- */
.badge-ab {
    position: absolute !important;
    bottom: 6px !important;
    left: 6px !important;
    width: 32px !important;
    height: 40px !important;
    background-image: url('../images/agriculture-biologique-green.svg') !important;
    background-repeat: no-repeat !important;
    background-size: contain !important;
    z-index: 10 !important;
    pointer-events: none !important;
    display: block !important;
}

/* Lien produit */
.woocommerce ul.products li.product a.woocommerce-LoopProduct-link,
body.search ul.products li.product a.woocommerce-LoopProduct-link {
    display: flex !important;
    flex-wrap: wrap !important;
    text-decoration: none !important;
    border: none !important;
    flex-grow: 1 !important;
    width: 100% !important;
}

/* --- TITRE PRODUIT --- */
.woocommerce ul.products li.product .woocommerce-loop-product__title,
body.search ul.products li.product .woocommerce-loop-product__title {
    font-family: 'OldNewspaperTypesALM', Georgia, serif !important;
    font-size: calc(1rem + 0.18vw) !important;
    font-weight: 400 !important;
    color: #111 !important;
    margin: 0 auto !important;
    padding: 0.3rem !important;
    line-height: 1.3 !important;
    width: 100% !important;
}

/* --- PRIX --- */
.woocommerce ul.products li.product .price,
body.search ul.products li.product .price {
    font-family: 'OldNewspaperTypesALM', Georgia, serif !important;
    color: #D4600A !important;
    font-size: 1.25rem !important;
    font-weight: bold !important;
    display: block !important;
    margin: 0 auto 0.3rem !important;
    padding: 0 0.4rem !important;
}

/* --- BOUTON AJOUTER AU PANIER --- */
.woocommerce ul.products li.product .button,
.woocommerce ul.products li.product .add_to_cart_button,
body.search ul.products li.product .button,
body.search ul.products li.product .add_to_cart_button {
    font-family: 'OldNewspaperTypesALM', Georgia, serif !important;
    background: rgba(255, 254, 253, 0.3) !important;
    color: #4f3b34 !important;
    border: none !important;
    border-top: 1px solid rgba(76, 53, 28, 0.5) !important;
    border-radius: 0 0 5px 5px !important;
    width: 100% !important;
    padding: 0.9rem 0.3rem !important;
    font-size: calc(1rem + 0.18vw) !important;
    letter-spacing: -0.06em !important;
    font-weight: lighter !important;
    text-align: center !important;
    display: block !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    position: relative !important;
    transition: background 0.2s ease !important;
}

.woocommerce ul.products li.product .button:hover,
.woocommerce ul.products li.product .add_to_cart_button:hover,
body.search ul.products li.product .button:hover,
body.search ul.products li.product .add_to_cart_button:hover {
    background: rgba(255, 255, 255, 0.56) !important;
    color: #2C1810 !important;
}

/* Lien "Voir le panier" injecté par WC après ajout AJAX réussi :
   on le masque PARTOUT (catalogue, fiche produit, bloc 11). Le
   mini-panier à droite remplit déjà ce rôle visuel, le lien est
   redondant et pollue le rendu. */
a.added_to_cart,
.added_to_cart {
    display: none !important;
}

/* --- IMAGE PLACEHOLDER --- */
.woocommerce ul.products li.product img.woocommerce-placeholder,
body.search ul.products li.product img.woocommerce-placeholder {
    opacity: 0.5 !important;
    filter: sepia(30%) !important;
}

/* --- TITRES ET INFOS BOUTIQUE --- */
h1.page-title,
.woocommerce-products-header h1,
.woocommerce-products-header__title {
    font-family: 'OldNewspaperTypesALM', Georgia, serif !important;
    color: #D4600A !important;
    text-transform: uppercase !important;
    letter-spacing: 0.02em !important;
    text-align: center !important;
}

.term-description {
    font-family: Georgia, serif !important;
    color: #2C1810 !important;
    font-style: italic !important;
    margin-bottom: 1.5rem !important;
}

.woocommerce-result-count {
    font-family: Georgia, serif !important;
    color: #2C1810 !important;
    display: none !important;
}

.woocommerce-ordering select {
    font-family: Georgia, serif !important;
    color: #2C1810 !important;
    background: rgba(240, 217, 185, 0.6) !important;
    border: 1px solid #c9a47c !important;
    border-radius: 5px !important;
}

/* Tri WooCommerce masqué */
.woocommerce-ordering {
    display: none !important;
}

/* ============================================
   GRAND CADRE CONTENU — STYLE SPIP
   Reproduit .contenu_border du thème SPIP.
   Injecté via PHP autour de la grille produits.
   Le menu tampon (.ps-menu-catalogue) est placé
   à l'intérieur, avec margin-top négatif pour
   chevaucher le bord supérieur du cadre.
   ============================================ */

.ps-contenu-border {
    background: url('../images/kraft-long.jpg') #C8A882;
    background-size: 6%;
    background-attachment: fixed;
    border: 2px solid #4C351C;
    border-image: url('../images/border.png') 40 40 / 30px 50px 50px / 0.5rem stretch;
    padding: 0.003rem;
    margin-bottom: 2rem;
    box-sizing: border-box;
    position: relative;
    z-index: 85;
    min-height: calc(100vh - 220px);
    align-self: stretch;
    /* Flex column pour permettre à .ps-contenu-border-inner de remplir
       toute la hauteur via flex: 1 (sinon le fond clair s'arrête au contenu). */
    display: flex;
    flex-direction: column;
}

.ps-contenu-border-inner {
    padding: 0.3rem 0.3rem 1.5rem;
    backdrop-filter: blur(1px);
    background: transparent;
    background: rgba(255,255,255,0.15);
    /* Étire le fond clair sur toute la hauteur du cadre kraft parent.
       Ne pas mettre display: flex ici, garder block pour ne pas casser
       les layouts internes des templates (single-product, checkout, etc.). */
    flex: 1;
}

/* Le poème catégorie et la description ne doivent pas pousser la largeur du cadre */
.ps-contenu-border-inner > .term-description,
.ps-contenu-border-inner .ps-cat-texte-long {
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
}

/* Titre BOUTIQUE / nom de catégorie : centré, noir, grande police */
.ps-titre-catalogue {
    font-family: 'OldNewspaperTypesALM', Georgia, serif;
    color: #2C1810 !important;
    font-size: 2.4rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0.5rem 0 0.6rem;
    padding: 0;
    text-align: center;
}

/* Description sous le titre : police OldNewspaper du site */
.ps-description-catalogue {
    font-family: 'OldNewspaperTypesALM', Georgia, serif;
    color: #4B3319;
    font-size: 1.15rem;
    line-height: 1.65;
    margin: 0 auto 1.5rem;
    max-width: 100%;
    text-align: center;
    letter-spacing: -0.02em;
}

/* ============================================
   RESPONSIVE BOUTIQUE
   ============================================ */

/* Mode 4 smartphone : cadre kraft invisible, vignettes avec leur propre
   fond kraft opaque pour garder le contraste de carte. */
@media (max-width: 599px) {
    .ps-contenu-border {
        background: transparent !important;
        border: none !important;
        border-image: none !important;
        padding: 0 !important;
        min-height: 0;
    }
    .ps-contenu-border-inner {
        padding: 0.5rem 0 1rem !important;
        background: transparent !important;
        backdrop-filter: none !important;
    }
    /* Vignettes : largeur fluide 50% + fond kraft opaque pour contrer
       la disparition du cadre porteur. Texture identique au cadre. */
    .woocommerce ul.products li.product,
    .woocommerce-page ul.products li.product,
    body.search ul.products li.product {
        width: calc(50% - 0.6rem) !important;
        margin: 0.3rem !important;
        background: url('../images/kraft-long.jpg') #C8A882 !important;
        background-size: 6% !important;
    }
}

/* ============================================
   RÈGLES MANQUANTES — À migrer depuis ps_force_transparent_background()
   Ces règles existaient uniquement en inline. Ajoutées ici avant suppression
   de la fonction.
   ============================================ */

body.woocommerce .grid-container.container,
body.woocommerce-page .grid-container.container,
body.post-type-archive-product .grid-container.container {
    max-width: none !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    background-color: transparent !important;
    background-image: none !important;
}

body.woocommerce ul.products,
body.woocommerce-page ul.products {
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0.4rem !important;
    box-sizing: border-box !important;
}

/* ============================================
   MENU CATALOGUE DANS LE CADRE BOUTIQUE
   Boutons tampon posés sur le bord supérieur du cadre
   ============================================ */

.ps-menu-catalogue {
    margin-top: -24px;
    margin-bottom: 0.5rem;
    text-align: left;
    position: relative;
    z-index: 10;
    overflow: visible;
}

.ps-menu-catalogue-ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 0.5rem;
}

.ps-menu-catalogue-ul li {
    background: url('../images/kraft-long.jpg') #C8A882;
    background-size: 6%;
    background-attachment: fixed;
    border: 1.6pt solid #4C351C;
    border-image: url('../images/border.png') 24 24 / 12px 15px / 0.05rem round;
}

.ps-menu-catalogue-ul li a {
    font-family: 'OldNewspaperTypesALM', Georgia, serif;
    color: #2C1810;
    padding: 0.4em 1.4rem;
    display: inline-block;
    text-decoration: none;
    text-transform: uppercase;
    font-size: 1.3rem;
    letter-spacing: 0.02em;
}

.ps-menu-catalogue-ul li a:hover,
.ps-menu-catalogue-ul li.current-menu-item a {
    background: radial-gradient(#ffffffb5, #e8d3ba2b);
    color: #2C1810;
}

/* ============================================
   FIL D'ARIANE WOOCOMMERCE
   ============================================ */

.woocommerce-breadcrumb {
    color: #6B3A2A !important;
    font-family: 'OldNewspaperTypesALM', Georgia, serif !important;
    font-size: 1rem !important;
}

.woocommerce-breadcrumb a {
    color: #6B3A2A !important;
    text-decoration: none !important;
}

.woocommerce-breadcrumb a:hover {
    color: #D4600A !important;
}

/* FOND KRAFT + WRAPPERS — toutes les pages (pas seulement WooCommerce) */
.site-content,
.content-area,
#primary,
#main,
.inside-article,
.entry-content,
.grid-container.container {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    border: none !important;
    max-width: none !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Libérer les wrappers GP sur toutes les pages */
.grid-container:not(.inside-header):not(.inside-navigation):not(.inside-footer) {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Étirer le cadre sur toutes les pages */
.site-content {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
}

.content-area {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
}

.site-main {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    width: 100% !important;
}

/* ============================================
   CADRE KRAFT + MINIPANIER — largeur fixe par palier
   ============================================
   Le cadre a une largeur fixée par palier d'écran qui correspond
   exactement à N vignettes (2 à 5) — voir .ps-contenu-flex
   .ps-contenu-border plus bas. Le couple cadre + mini-panier est
   centré dans la fenêtre, plafonné globalement à 1700px max.
   L'air se fait toujours à l'extérieur, jamais à l'intérieur du cadre.
*/

.ps-contenu-flex {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    width: 100%;
    max-width: 1700px;
    margin: 0 auto;
    padding: 25px 1rem 2rem;
    box-sizing: border-box;
    min-height: calc(100vh - 200px);
    gap: 26px;
}

/* Largeur du cadre fixée par palier — vignette de 220px partout (≥600px).
   Calcul : 1 vignette + marges 0.5rem×2 = 236px ; padding ul.products 32px ;
   padding inner 20px. Largeur cadre = N × 236 + 52.
   Le minipanier (335px + gap 26 = 361px) apparaît à partir de 1389px (cf
   minicart.css), seuil où le couple "cadre 4 vign + mp" tient enfin :
   996 + 361 + 32 padding = 1389. À ce moment-là la grille recule de 5 vign
   à 4 vign le temps que la place se libère pour 5 vign + mp (à 1625px).
*/
@media (min-width: 600px) {
    .ps-contenu-flex .ps-contenu-border {
        flex: 0 0 auto;
        width: 524px;          /* 2 vign : 2×236 + 52 */
        max-width: 100%;
        margin: 0;
        min-width: 0;
        min-height: 100%;
    }
}

/* --- Tablette (sans minipanier) : on remplit le viewport --- */
@media (min-width: 792px) {
    .ps-contenu-flex .ps-contenu-border { width: 760px; }   /* 3 vign */
}
@media (min-width: 1028px) {
    .ps-contenu-flex .ps-contenu-border { width: 996px; }   /* 4 vign */
}
@media (min-width: 1264px) {
    .ps-contenu-flex .ps-contenu-border { width: 1232px; }  /* 5 vign */
}

/* --- Laptop+ (minipanier visible) : on remplit la place restante --- */
@media (min-width: 1389px) {
    .ps-contenu-flex .ps-contenu-border { width: 996px; }   /* 4 vign + mp */
}
@media (min-width: 1625px) {
    .ps-contenu-flex .ps-contenu-border { width: 1232px; }  /* 5 vign + mp */
}

/* Smartphone : suppression du cadre */
@media (max-width: 599px) {
    .ps-contenu-flex {
        padding: 0;
    }
}

/* Forcer #primary à 100% sur toutes les pages */
#primary,
.content-area {
    width: 100% !important;
}

#right-sidebar,
.is-right-sidebar {
    display: none !important;
}

/* ============================================
   ANIMATION AKÈNE — vignette catalogue
   La graine vole depuis le bouton "Ajouter au panier" jusqu'au
   mini-panier (ou en haut-à-droite si masqué).
   Les positions de départ et d'arrivée sont calculées en JS et
   passées via les variables CSS --ps-akene-dx et --ps-akene-dy.
   ============================================ */

/* Akène : créée dans <body> par js/akene-vignette.js au moment du clic.
   Position fixed pour échapper aux overflow:hidden des parents
   (li.product notamment). left/top sont définis inline en JS = position
   du bouton au clic en coordonnées viewport. translate(-50%, -50%) initial
   pour centrer le sprite sur ce point. */
.ps-akene-hop {
    position: fixed;
    width: 40px;
    height: 58px;       /* ratio 0,69 = ratio natif de l'image refaite par Mikou */
    background: url('../images/akene.png') no-repeat center / contain;
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    --ps-akene-dx: 0px;
    --ps-akene-dy: -200px;
}

.ps-akene-hop.is-flying {
    animation: ps-akene-fly 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Rotation douce 0°→90° (1/4 de tour) sur la durée. Progression
   uniforme des étapes pour préserver la fluidité. Opacité tenue
   jusqu'à 92%, fade rapide ensuite. */
@keyframes ps-akene-fly {
    0%   {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.7) rotate(0deg);
    }
    10%  {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(8deg);
    }
    50%  {
        opacity: 1;
        transform: translate(calc(-50% + var(--ps-akene-dx) * 0.5), calc(-50% + var(--ps-akene-dy) * 0.5)) scale(0.95) rotate(45deg);
    }
    92%  {
        opacity: 1;
        transform: translate(calc(-50% + var(--ps-akene-dx) * 0.94), calc(-50% + var(--ps-akene-dy) * 0.94)) scale(0.85) rotate(82deg);
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--ps-akene-dx)), calc(-50% + var(--ps-akene-dy))) scale(0.75) rotate(90deg);
    }
}

/* ============================================
   TAILLE VIGNETTES — 220px desktop+tablette, 50% smartphone
   Une vignette = 220px (valeur unique posée dans le bloc grille en haut
   du fichier). Le nombre de vignettes par ligne (4 / 5 / 6) est imposé
   par la largeur fixe du cadre à chaque palier — cf .ps-contenu-flex
   .ps-contenu-border plus haut. Le cas smartphone (50% + fond kraft)
   est dans le bloc @media (max-width: 599px) plus haut.
   ============================================ */
