/**
 * Vitrine Afinity — responsive multi-écrans (mobile / tablette / desktop).
 * Utilisé par HTML publié TEMP, local-preview, local-catalogue.
 * Breakpoints alignés Tailwind : sm 640 · md 768 · lg 1024 · xl 1280
 */

/* —— Header barre —— */
#afinity-storefront-header {
  width: 100%;
  max-width: 100%;
}
#afinity-storefront-header > .bg-white {
  width: 100%;
}
.afinity-sf-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #ede9fe;
  background: #fff;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.afinity-sf-header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex-shrink: 0;
}
.afinity-sf-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}
.afinity-i18n-header-globe {
  box-sizing: border-box;
  width: 1.75rem;
  height: 1.75rem;
  padding: 2px;
  border-radius: 9999px;
  border: 1px solid #0f172a;
  background: #0f172a;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  z-index: 60;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
}
.afinity-i18n-header-globe svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.afinity-i18n-header-globe:hover,
.afinity-i18n-header-globe[aria-expanded="true"] {
  background: #d97706;
  border-color: #d97706;
  color: #0f172a;
}
@media (min-width: 640px) {
  .afinity-sf-header-actions { gap: 0.75rem; }
}
@media (min-width: 768px) {
  /* Une seule barre : logo | recherche | menu | compte/panier — comme le builder */
  .afinity-sf-header-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.75rem 1rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
  .afinity-sf-header-brand { flex-shrink: 0; }
  .afinity-sf-search {
    order: 0 !important;
    width: auto !important;
    flex: 1 1 12rem !important;
    max-width: 20rem !important;
    margin: 0 !important;
  }
  .afinity-nav-desktop {
    flex: 1 1 auto;
    width: auto !important;
  }
  .afinity-sf-header-actions {
    margin-left: 0;
    flex-shrink: 0;
  }
}

/* Burger : visible < md uniquement */
.afinity-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  cursor: pointer;
}
.afinity-burger:hover { background: #f8fafc; color: #8B4513; }
.afinity-burger[aria-expanded="true"] {
  border-color: #FFA500;
  background: #FFF9E6;
  color: #8B4513;
}
@media (min-width: 768px) {
  .afinity-burger { display: none !important; }
}

/* Nav desktop : masquée < md — espacement comme le builder (padding items, pas seulement gap) */
.afinity-nav-desktop { display: none !important; }
@media (min-width: 768px) {
  .afinity-nav-desktop {
    display: flex !important;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem 1.1rem !important;
    width: auto;
    min-width: 0;
    padding: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
  }
  .afinity-nav-desktop > a,
  .afinity-nav-desktop > div {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.2rem 1.1rem 0.2rem 0;
  }
  .afinity-nav-desktop a {
    text-decoration: none;
    color: inherit;
  }
}

/* Panneau menu mobile (trois traits) */
.afinity-nav-mobile {
  display: none;
  border-top: 1px solid #f1f5f9;
  background: #fff;
  padding: 0.5rem 0.75rem 0.75rem;
  max-height: min(70vh, 28rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.afinity-nav-mobile.is-open { display: block; }
@media (min-width: 768px) {
  .afinity-nav-mobile,
  .afinity-nav-mobile.is-open { display: none !important; }
}
.afinity-nav-mobile a {
  display: block;
  padding: 0.65rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
  text-decoration: none;
}
.afinity-nav-mobile a:hover {
  background: rgba(255, 249, 230, 0.85);
  color: #8B4513;
}
.afinity-nav-mobile a.afinity-nav-child {
  padding-left: 1.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
}

/* Recherche : pleine largeur sous la 1ʳᵉ ligne en mobile */
.afinity-sf-search {
  order: 99;
  width: 100%;
  flex: 0 0 100%;
  min-width: 0;
  position: relative;
}
@media (min-width: 768px) {
  .afinity-sf-search {
    order: 0;
    width: auto;
    flex: 1 1 auto;
    max-width: 28rem;
    margin-left: 1rem;
    margin-right: 1rem;
  }
}

/* Libellés compte / slogan : moins de clutter mobile */
@media (max-width: 639px) {
  .afinity-account-label { display: none !important; }
  .afinity-sf-slogan { display: none !important; }
}

/* Menu Mon compte (icône profil + déroulant) */
#storefront-header-account { position: relative; z-index: 50; }
.afinity-account-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 12.5rem;
  z-index: 70;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  padding: 0.35rem;
}
.afinity-account-menu.is-open { display: block; }
.afinity-account-menu a,
.afinity-account-menu button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.afinity-account-menu a:hover,
.afinity-account-menu button:hover {
  background: #fff7ed;
  color: #9a3412;
}
.afinity-account-menu .is-logout:hover {
  background: #fef2f2;
  color: #b91c1c;
}
#storefront-header-account-btn .afinity-account-chevron {
  transition: transform 0.15s ease;
}
#storefront-header-account-btn[aria-expanded="true"] .afinity-account-chevron {
  transform: rotate(180deg);
}

/* Grilles articles */
@media (max-width: 639px) {
  .afinity-product-grid {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }
}
@media (min-width: 640px) and (max-width: 1023px) {
  .afinity-product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Hero / titres longs */
@media (max-width: 767px) {
  #afinity-storefront-content h2.text-5xl,
  #afinity-storefront-content .text-5xl,
  #afinity-storefront-content .text-6xl {
    font-size: 1.875rem !important;
    line-height: 2.25rem !important;
  }
  #afinity-storefront-content .min-h-\[420px\],
  #afinity-storefront-content .min-h-\[480px\] {
    min-height: 280px !important;
  }
}

/* Footer colonnes empilées */
@media (max-width: 767px) {
  footer .grid.md\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }
}

/*
 * Pied de page collé en bas de viewport (contenu court : livraison, connexion…).
 * Accueil (storefront-body) a déjà min-h-screen flex flex-col ; les pages checkout
 * n’avaient que min-h-full → le footer remontait au milieu de l’écran.
 */
html.h-full {
  height: 100%;
}
body.bg-metier-cream {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body.bg-metier-cream > header,
body.bg-metier-cream > .afinity-sf-header-bar {
  flex-shrink: 0;
}
body.bg-metier-cream > main {
  flex: 1 0 auto;
  width: 100%;
}
body.bg-metier-cream > footer {
  margin-top: auto;
  flex-shrink: 0;
}

/* Alignement vignettes catalogue (bouton panier) */
.afinity-product-grid > article[data-afinity-product],
.afinity-product-grid > article.group {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.afinity-product-grid > article .afinity-product-cart {
  margin-top: auto;
}
