/* ============================================================================
   LOGUETOWN — STOREFRONT MOBILE OPTIMISATIONS
   ----------------------------------------------------------------------------
   Pass mobile-first orienté CONVERSION : sticky CTA, 2 colonnes produits,
   touch targets ≥ 44px, présentoir scroll-snap horizontal, carrousel avis.
   Inspiration : Vinted (densité produits) + Airbnb (sticky CTA) + Booking
   (back-button + chip de partage).

   Scope : .sf uniquement, et appliqué sous breakpoint ≤ 720px par défaut.
   Sur tablette/desktop = rien ne change (le design existant reste en place).
   ============================================================================ */

/* ---------------------------------------------------------------------------
 * 1. BACK BUTTON CONTEXTUEL (top-left flottant sur le hero, mobile + desktop)
 *    Indispensable pour retour à la recherche / scroll précédent.
 * --------------------------------------------------------------------------- */
.sf-back {
  position: absolute;
  top: clamp(0.8rem, 2.5vw, 1.4rem);
  left: clamp(0.8rem, 2.5vw, 1.4rem);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 0.95rem 0 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--sf-line);
  background: rgba(10, 14, 23, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--sf-ink);
  font: 600 0.86rem/1 var(--sf-font-body);
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, transform 0.15s var(--sf-ease-out);
}
.sf-back:hover,
.sf-back:focus-visible {
  background: rgba(10, 14, 23, 0.85);
  border-color: color-mix(in srgb, var(--sf-accent) 55%, var(--sf-line));
  outline: none;
}
.sf-back:active { transform: scale(0.97); }
.sf-back svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------------------------------------------------------------------------
 * 2. STICKY ACTION BAR (mobile uniquement — visible ≤ 720px)
 *    Le booster de conversion #1 : CTA toujours accessible.
 * --------------------------------------------------------------------------- */
.sf-stickybar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 60;
  display: none; /* activé en media query mobile */
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem clamp(0.8rem, 4vw, 1.4rem)
           calc(0.7rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--sf-bg) 70%, transparent) 0%,
    var(--sf-bg) 60%);
  border-top: 1px solid var(--sf-line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transform: translateY(110%);
  transition: transform 0.32s var(--sf-ease-out);
  pointer-events: none;
}
.sf-stickybar.is-visible {
  transform: translateY(0);
  pointer-events: auto;
}
.sf-stickybar__seller {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-width: 0;
  line-height: 1.1;
  margin-right: auto;
}
.sf-stickybar__name {
  font-family: var(--sf-font-display);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--sf-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 38vw;
}
.sf-stickybar__meta {
  margin-top: 2px;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--sf-ink-mute);
}
.sf-stickybar__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 46px;
  padding: 0 1.05rem;
  border: 0;
  border-radius: 999px;
  font: 700 0.92rem/1 var(--sf-font-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s var(--sf-ease-out), filter 0.2s;
}
.sf-stickybar__btn--icon {
  width: 46px;
  padding: 0;
  justify-content: center;
  background: var(--sf-surface);
  border: 1px solid var(--sf-line);
  color: var(--sf-ink);
}
.sf-stickybar__btn--icon svg { width: 20px; height: 20px; }
.sf-stickybar__btn--primary {
  color: var(--sf-accent-ink);
  background: linear-gradient(180deg, var(--sf-accent-2), var(--sf-accent));
  box-shadow: 0 8px 22px -10px var(--sf-glow);
}
.sf-stickybar__btn:active { transform: scale(0.97); }
.sf-stickybar__btn--icon:hover {
  border-color: color-mix(in srgb, var(--sf-accent) 50%, var(--sf-line));
}

/* Ajoute un padding-bottom au body sur mobile pour que la stickybar
   ne recouvre pas le dernier contenu. */
@media (max-width: 720px) {
  .sf { padding-bottom: 80px; }
  .sf-stickybar { display: flex; }
}

/* ---------------------------------------------------------------------------
 * 3. GALERIE PRODUITS — 2 COLONNES OBLIGATOIRES SUR MOBILE
 *    Densité Vinted/Leboncoin : +100% de pièces vues par scroll.
 * --------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .sf-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
  }
  .sf-card__body {
    padding: 0.65rem 0.7rem 0.85rem;
  }
  .sf-card__title {
    font-size: 0.88rem;
    -webkit-line-clamp: 2;
  }
  .sf-card__price {
    font-size: 0.92rem;
  }
  .sf-badge {
    font-size: 0.6rem;
    padding: 3px 7px;
  }
  /* Désactive le tilt 3D coûteux sur touch (déjà fait en JS, mais ceinture
     + bretelles pour la perf). */
  .sf-card { transform: none !important; }
}

/* Très petits écrans (≤ 360px) : on garde 2 colonnes mais on serre */
@media (max-width: 360px) {
  .sf-grid { gap: 0.55rem; }
  .sf-card__body { padding: 0.5rem 0.55rem 0.7rem; }
  .sf-card__title { font-size: 0.82rem; }
}

/* ---------------------------------------------------------------------------
 * 4. TOUCH TARGETS ≥ 44px (WCAG 2.1 AA / Apple HIG / Material)
 * --------------------------------------------------------------------------- */
@media (pointer: coarse) {
  .sf-chip,
  .sf-btn,
  .sf-faq__q,
  .sf-stickybar__btn {
    min-height: 44px;
  }
  .sf-chip {
    padding-inline: 1rem;
    font-size: 0.9rem;
  }
  .sf-faq__chev {
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
  }
}

/* ---------------------------------------------------------------------------
 * 5. STATS BAR — densité horizontale sur mobile (au lieu de 2×2 vertical)
 *    Carrousel scroll-snap façon Booking — chaque stat en chip horizontale.
 * --------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .sf-stats {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 0.55rem;
    padding: 0.25rem clamp(1.1rem, 5vw, 4rem);
    margin-inline: calc(-1 * clamp(1.1rem, 5vw, 4rem));
  }
  .sf-stats::-webkit-scrollbar { display: none; }
  .sf-stat {
    flex: 0 0 auto;
    min-width: 145px;
    scroll-snap-align: start;
    padding: 0.85rem 1rem;
  }
  .sf-stat__num {
    font-size: 1.45rem;
  }
  .sf-stat__label {
    font-size: 0.66rem;
    letter-spacing: 0.14em;
  }
  .sf-section[data-sf-section="stats"] {
    padding-block: clamp(1.3rem, 3.5vw, 2rem);
  }
}

/* ---------------------------------------------------------------------------
 * 6. AVIS — carrousel scroll-snap horizontal sur mobile
 *    Affiche les avis comme Airbnb : 1.2 avis visibles + indication de
 *    swipe via le card qui dépasse.
 * --------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .sf-reviews {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 0.8rem;
    padding-inline: clamp(1.1rem, 5vw, 4rem);
    margin-inline: calc(-1 * clamp(1.1rem, 5vw, 4rem));
    padding-bottom: 0.4rem;
  }
  .sf-reviews::-webkit-scrollbar { display: none; }
  .sf-review {
    flex: 0 0 80%;
    max-width: 320px;
    scroll-snap-align: start;
    padding: 1.1rem 1.2rem;
  }
}

/* ---------------------------------------------------------------------------
 * 7. PRÉSENTOIR VITRINE — compactage mobile
 *    Sur desktop, le cabinet est immersif (3-4 étagères visibles).
 *    Sur mobile, on borne sa hauteur + on assure un scroll vertical fluide
 *    sans qu'il monopolise l'écran. On évite le scroll-snap qui se conflite
 *    avec les animations de halos déjà en place.
 * --------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .sf-section--vitrine .sf__container {
    padding-inline: 0.7rem;
  }
  .sf-vitrine-wrap .mvr-showcase {
    border-radius: 18px;
  }
  /* Réduit le nombre de cases visibles par ligne sur très petit écran :
     on force max 3 colonnes même si le vendeur en a configuré 4-6. */
  .sf-vitrine-wrap .vitrine-cols-4 .etagere,
  .sf-vitrine-wrap .vitrine-cols-5 .etagere,
  .sf-vitrine-wrap .vitrine-cols-6 .etagere {
    grid-template-columns: repeat(3, 1fr);
  }
  /* Réduit le padding interne du cabinet sur mobile */
  .sf-vitrine-wrap .vitrine-showcase {
    padding: 10px 8px 14px;
  }
  /* Allège les animations coûteuses sur mobile (halos qui clignotent) :
     on les garde mais ralenties pour limiter le repaint. */
  .sf-vitrine-wrap .mvr-showcase .slot:not(.slot--empty)::before {
    animation-duration: 8s;
    filter: blur(10px);
  }
  .sf-vitrine-wrap .mvr-showcase .slot__img {
    animation: none; /* coupe la lévitation sur mobile pour la perf */
  }
}

/* ---------------------------------------------------------------------------
 * 8. HERO MOBILE — alignement vertical + meta compactée
 * --------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .sf-hero {
    padding-top: clamp(3rem, 8vw, 4.5rem); /* place pour le back button */
  }
  .sf-hero__inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 1rem;
  }
  .sf-hero__id {
    align-items: center;
    gap: 0.9rem;
  }
  .sf-hero__meta {
    gap: 0.35rem 0.9rem;
    font-size: 0.82rem;
  }
  /* Le sticky bar prend le relais pour le rating en bas ;
     on cache le tagline (souvent vide) pour gagner de la place. */
  .sf-hero--no-banner .sf-hero__tagline:empty {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
 * 9. CTA SECTION CONTACT — masque le bloc dupliqué sur mobile
 *    Quand la stickybar est visible, le CTA "Échangez avec X" en bas devient
 *    redondant. On le compacte (mais on le garde pour le SEO et le desktop).
 * --------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .sf-cta {
    padding: clamp(1.5rem, 5vw, 2.5rem) clamp(0.9rem, 4vw, 1.6rem);
  }
  .sf-cta .sf-title { font-size: 1.45rem; }
  .sf-cta__actions { gap: 0.55rem; }
  .sf-cta .sf-btn {
    padding: 0.85rem 1.5rem;
    font-size: 0.95rem;
  }
}

/* ---------------------------------------------------------------------------
 * 10. SECTIONS — espacement vertical réduit sur mobile pour rythme plus dense
 * --------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .sf {
    --sf-section-y: clamp(2rem, 7vw, 3.5rem);
  }
  .sf-section__head {
    margin-bottom: 1.4rem;
  }
}

/* ---------------------------------------------------------------------------
 * 11. PROPRIÉTAIRE — pas de stickybar "contacter soi-même"
 * --------------------------------------------------------------------------- */
.sf[data-sf-owner="1"] .sf-stickybar { display: none !important; }
.sf[data-sf-owner="1"] { padding-bottom: 0; }

/* ---------------------------------------------------------------------------
 * 12. SHARE BUTTON — feedback visuel quand l'URL est copiée (fallback Web Share)
 * --------------------------------------------------------------------------- */
.sf-share-toast {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 70;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  background: rgba(10, 14, 23, 0.92);
  border: 1px solid color-mix(in srgb, var(--sf-accent) 40%, var(--sf-line));
  color: var(--sf-ink);
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.25s var(--sf-ease-out), transform 0.25s var(--sf-ease-out);
  pointer-events: none;
  white-space: nowrap;
}
.sf-share-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
