/**
 * mac-sticky-buy.css — Sticky achat mobile PDP (Mission Phase 2B, §5)
 * Additif, scopé `.mac-sticky-buy` — n'altère aucune règle existante.
 * Mobile uniquement (<=899px, cohérent avec le point de rupture PDP déjà
 * en place pour la bascule galerie/buy-zone en une colonne, voir theme.md).
 */

#mac-sticky-buy {
  display: none; /* activé uniquement <=899px ci-dessous */
}

@media (max-width: 899px) {
  #mac-sticky-buy {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    /* Phase 4.2 — même mécanisme générique que l'Assistant Projet (macrgpd
       expose --mac-rgpd-visible-height, 0px par défaut/bandeau masqué) :
       sans ça, un visiteur neuf voyait sa barre d'achat mobile intégralement
       recouverte par le panneau de consentement (z-index tout du site). */
    bottom: var(--mac-rgpd-visible-height, 0px);
    z-index: 9997; /* sous le bandeau cookies (999999) mais au-dessus du contenu courant */
    background: #FFFFFF;
    border-top: 1px solid var(--lin-dark, #E4DFD7);
    box-shadow: 0 -6px 20px rgba(58, 56, 53, 0.10);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: mac-sticky-buy-in 0.18s ease-out;
  }

  #mac-sticky-buy[hidden] { display: none; }

  @keyframes mac-sticky-buy-in {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  .mac-sticky-buy__inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    max-width: 100%;
  }

  .mac-sticky-buy__media {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--lin, #F7F5F2);
  }
  .mac-sticky-buy__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .mac-sticky-buy__info {
    flex: 1 1 auto;
    min-width: 0;
  }
  .mac-sticky-buy__name {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--silex, #3A3835);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mac-sticky-buy__meta {
    margin: 2px 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .mac-sticky-buy__price {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--argile, #C4A882);
  }
  .mac-sticky-buy__teinte {
    font-size: 0.6875rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
  }
  .mac-sticky-buy__avail {
    margin: 1px 0 0;
    font-size: 0.65rem;
    color: #64748b;
  }

  .mac-sticky-buy__actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .mac-sticky-buy__qty {
    display: flex;
    align-items: center;
    border: 1px solid var(--lin-dark, #E4DFD7);
    border-radius: 3px;
    overflow: hidden;
  }
  .mac-sticky-buy__qty-btn {
    width: 30px;
    height: 36px;
    min-width: 44px; /* cible tactile >=44px malgré la largeur visuelle réduite */
    background: #fff;
    border: none;
    font-size: 1rem;
    line-height: 1;
    color: var(--silex, #3A3835);
    cursor: pointer;
  }
  .mac-sticky-buy__qty-value {
    min-width: 22px;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 600;
  }

  .mac-sticky-buy__cta {
    min-height: 44px;
    padding: 0 16px;
    background: var(--silex, #3A3835);
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: none;
    cursor: pointer;
    white-space: nowrap;
  }
  .mac-sticky-buy__cta.is-disabled,
  .mac-sticky-buy__cta:disabled {
    background: #C9C5BE;
    cursor: not-allowed;
  }

  /* Réserve l'espace du sticky en bas de page pour éviter tout contenu masqué
     (footer, dernier bloc) quand le sticky est visible — anti-CLS. */
  body.mac-has-sticky-buy {
    padding-bottom: 62px;
  }
  body.mac-has-sticky-buy #mac-back-to-top,
  body.mac-has-sticky-buy .mac-rgpd__reopen {
    /* voir §6 — coexistence des éléments fixes bas de page, cf. bloc dédié
       plus bas dans ce fichier (ne fixe QUE l'offset, jamais les couleurs/
       tailles propres à chacun de ces composants, qui restent définies dans
       leurs propres feuilles/scripts). */
    bottom: calc(62px + 14px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (max-width: 359px) {
  .mac-sticky-buy__teinte { display: none; } /* trop étroit pour rester lisible sous 360px */
  .mac-sticky-buy__name { font-size: 0.7rem; }
}

/* ==========================================================================
   §6 — Coexistence des éléments fixes bas de page (mission Phase 2B)
   Mécanisme générique, pas une rustine locale à un bloc : tout élément fixe
   bas-de-page connu (bandeau/bouton cookies macrgpd, bouton retour-haut) se
   décale au-dessus du sticky achat mobile dès que celui-ci est visible
   (classe `body.mac-has-sticky-buy`, posée par mac-sticky-buy.js). Au-delà
   de 899px le sticky achat n'existe pas — ces règles n'ont alors aucun effet
   (la classe peut être présente mais les propriétés qu'elle modifie ne sont
   plus utiles puisque #mac-sticky-buy est display:none).
   ========================================================================== */
