/* ========= Market Mobile-First Theme (Alibaba / Yango Market vibes) ========= */
:root{
  --brand:#ff6a00;           /* orange vif */
  --brand-700:#e65d00;
  --text:#1f2937;            /* gris foncé lisible */
  --muted:#6b7280;
  --bg:#f7f7f8;
  --card:#ffffff;
  --success:#16a34a;
  --danger:#ef4444;
  --ring: 0 6px 18px rgba(0,0,0,.08);
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{
  background:#fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color:var(--text);
  line-height:1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------- Layout --------- */
.container{
  max-width: clamp(960px, 92vw, 1200px);
  margin:0 auto;
  padding:12px;
}

h1,h2{
  margin:0 0 12px;
  text-align:center;
  color:#222;
  font-weight:700;
  letter-spacing:.2px;
}
h1{font-size:clamp(1.6rem,4vw,2.1rem)}
h2{font-size:clamp(1.2rem,3.2vw,1.6rem)}

/* --------- Rail de PUB (bannières aléatoires) --------- */
.home-ads{ margin:4px 0 16px; }
.ad-rail{
  display:flex; gap:12px; overflow-x:auto; padding:4px 2px 8px;
  scroll-snap-type:x proximity;
}
.ad-card{
  flex:0 0 88%;
  height:170px; position:relative; border-radius:14px; overflow:hidden;
  background:#eee; box-shadow:var(--ring); scroll-snap-align:start;
}
@media (min-width:768px){ .ad-card{ flex-basis:calc(50% - 6px); height:220px; } }
.ad-card a{ display:block; width:100%; height:100%; position:relative; color:#fff; text-decoration:none !important; }
.ad-img{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; filter:contrast(1.05) saturate(1.05); }
.ad-overlay{ position:absolute; inset:0; background:linear-gradient(90deg, rgba(0,0,0,.55), rgba(0,0,0,.15) 60%); }
.ad-content{ position:absolute; left:14px; right:14px; bottom:14px; }
.ad-title{ margin:0 0 4px; font-weight:800; font-size:1.05rem; }
.ad-sub{ margin:0; font-weight:700; font-size:.95rem; opacity:.95; }
.ad-cta{
  position:absolute; top:12px; right:12px;
  background:var(--brand); color:#fff; border-radius:999px;
  padding:8px 12px; font-weight:700; font-size:.86rem; box-shadow:0 8px 16px rgba(255,106,0,.35);
}

/* --------- Grid Articles (mobile first) --------- */
.articles-list{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap:10px;
  margin-top:14px;
}
@media (min-width:480px){
  .articles-list{ grid-template-columns: repeat(3, minmax(0,1fr)); gap:12px; }
}
@media (min-width:768px){
  .articles-list{ grid-template-columns: repeat(4, minmax(0,1fr)); gap:16px; }
}
@media (min-width:1024px){
  .articles-list{ grid-template-columns: repeat(5, minmax(0,1fr)); gap:18px; }
}

/* --------- Card --------- */
.article-card{
  position:relative;
  background:var(--card);
  border:1px solid #eee;
  border-radius:12px;
  overflow:hidden;
  box-shadow:var(--ring);
  transition:transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  will-change: transform;
}
@media (hover:hover){
  .article-card:hover{
    transform:translateY(-2px);
    box-shadow:0 10px 26px rgba(0,0,0,.10);
    border-color:#e7e7e7;
  }
}
.article-card:focus-within{ outline:2px solid rgba(255,106,0,.35); outline-offset:2px; }

/* --------- Image slider (aspect ratio carré) --------- */
.images-slider{
  position:relative;
  background:#f4f5f7;
  aspect-ratio:1/1;
  overflow:hidden;
}
.slides-container{
  display:flex;
  height:100%;
  width:100%;
  transition:transform .7s ease-in-out;
  will-change:transform;
  touch-action: pan-y;
}
.slide{ min-width:100%; height:100%; }
.slide img{
  width:100%; height:100%;
  object-fit:cover; display:block;
  background:#f6f7f9;
}
.clickable-image{ cursor:zoom-in; }

/* --------- Footer de carte --------- */
/* Lignes: 1) Titre  2) Store-chip  3) Prix + bouton  4) Prix barré */
.article-footer{
  display:grid;
  grid-template-columns: 1fr auto;   /* prix | bouton sur la 3e ligne */
  grid-template-rows: auto auto auto auto;
  align-items:center;
  gap:0px 8px;
  padding:6px 10px;
  background:#fff;
  border-top:1px solid #f0f0f0;
}

/* --------- Titre article --------- */
.nom_article{
  grid-column: 1 / -1;
  margin:0;
  font-weight:600;
  font-size:clamp(.92rem, 2.4vw, 1rem);
  color:var(--text);
  overflow:hidden;
  line-height:1.2;
  min-height:1.3em;
  overflow-wrap: break-word;
  word-break: normal;
  white-space: normal;
  line-clamp:2;
}
@supports (-webkit-line-clamp: 2) {
  .nom_article{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
  }
}

/* --------- Store chip (magasin) --------- */
.store-chip{
  grid-column:1 / -1;
  display:flex; align-items:center; gap:8px;
  margin:4px 0 6px;
}
.store-link{
  display:inline-flex; align-items:center; gap:8px;
  text-decoration:none; color:inherit;
}
.store-avatar{
  width:26px; height:26px; border-radius:50%; overflow:hidden;
  border:1px solid rgba(17,24,39,.08);
  box-shadow:0 2px 6px rgba(0,0,0,.08);
  background:#fff; display:grid; place-items:center;
}
.store-avatar img{ width:100%; height:100%; object-fit:cover; display:block; }
.store-initial{
  font-size:.85rem; font-weight:700; color:#2563EB;
  display:inline-grid; place-items:center; width:100%; height:100%;
}
.store-name{
  font-size:.87rem; font-weight:600; color:#1f2937;
  letter-spacing:.2px; line-height:1;
}
@media (min-width:768px){
  .store-name{ font-size:.92rem; }
}

/* --------- Prix --------- */
.price{
  grid-row: 3; grid-column: 1;
  margin:0;
  font-weight:800;
  font-size:clamp(1rem, 2.6vw, 1.06rem);
  color:var(--brand);
  white-space:nowrap;
}

/* --------- Prix barré --------- */
.old-price{
  grid-row: 4; grid-column: 1;
  margin:2px 0 0 0;
  color:#9ca3af;
  font-size:.92rem;
  text-decoration: line-through;
  white-space:nowrap;
}

/* --------- Bouton WhatsApp --------- */
.acheter-btn{
  grid-row: 3; grid-column: 2;
  justify-self:end;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:44px; height:44px;
  border-radius:50%;
  background:var(--brand);
  color:#fff !important;
  text-decoration:none !important;
  box-shadow:0 6px 18px rgba(255,106,0,.35);
  border:0;
  transform:translateZ(0);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
@media (hover:hover){
  .acheter-btn:hover{ transform:translateY(-1px); background:var(--brand-700); }
}
.acheter-btn:active{ transform:translateY(0); box-shadow:0 4px 12px rgba(255,106,0,.25); }
.acheter-btn:focus-visible{ outline:2px solid rgba(255,106,0,.45); outline-offset:3px; }
.acheter-btn i{ color:#fff !important; font-size:1.1rem; line-height:1; }

/* --------- Liens neutres dans les cartes --------- */
.article-card a,
.article-card a:visited,
.article-card a:hover,
.article-card a:active{
  text-decoration:none !important;
  color:inherit !important;
}

/* --------- Toasts / Messages --------- */
.message-interceptor{
  position:fixed; top:16px; right:12px; left:12px;
  display:flex; flex-direction:column; gap:10px;
  z-index:1000; pointer-events:none;
}
.alert{
  pointer-events:auto;
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; padding:12px 14px;
  background:#fff; border-radius:10px;
  border-left:4px solid #e5e7eb;
  box-shadow:var(--ring);
  animation:fadeInDown .28s ease-out;
}
.alert-success{ border-left-color:var(--success); }
.alert-error{ border-left-color:var(--danger); }
.alert-content{ display:flex; align-items:center; gap:10px; }
.close-alert{
  background:none; border:0; cursor:pointer;
  font-size:1.25rem; color:#667085;
  padding:0 0 0 8px; line-height:1;
}

/* --------- Helpers --------- */
.no-articles{
  grid-column:1 / -1;
  text-align:center; color:var(--muted);
  padding:22px 0;
}

@keyframes fadeInDown{
  from{opacity:0; transform:translateY(-12px)}
  to{opacity:1; transform:translateY(0)}
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; scroll-behavior:auto !important; }
}

/* --------- Fix héritages --------- */
.article-card{ width:auto; height:auto; }
.fab.fa-whatsapp{ color:inherit; }
.whatsapp .fab.fa-whatsapp{ color:inherit; }


/* --- Store chip (magasin) --- */
.store-chip{
  grid-column:1 / -1;
  display:flex; align-items:center; gap:8px;
  margin:4px 0 6px;
}
.store-link{
  display:inline-flex; align-items:center; gap:8px;
  text-decoration:none; color:inherit;
}
.store-avatar{
  width:26px; height:26px; border-radius:50%; overflow:hidden;
  border:1px solid rgba(17,24,39,.08);
  box-shadow:0 2px 6px rgba(0,0,0,.08);
  background:#fff; display:grid; place-items:center;
}
.store-avatar img{ width:100%; height:100%; object-fit:cover; display:block; }
.store-initial{
  font-size:.85rem; font-weight:700; color:#2563EB;
  display:inline-grid; place-items:center; width:100%; height:100%;
}
.store-name{
  font-size:.87rem; font-weight:600; color:#1f2937;
  letter-spacing:.2px; line-height:1;
}
@media (min-width:768px){
  .store-name{ font-size:.92rem; }
}
