// Caffè Italia · shared components
const { useState, useEffect, useRef, useMemo, useCallback } = React;

// ─── Logo (vintage Italian poster, redrawn original) ──────────────────────────
function CaffeItaliaLogo({ size = 56, mono = false }) {
  const fg = mono ? "currentColor" : "currentColor";
  return (
    <div style={{ display:"inline-flex", flexDirection:"column", alignItems:"center", lineHeight:.84, color:fg, gap:2 }}>
      <div style={{ fontFamily:"var(--font-display)", fontSize:size*.46, letterSpacing:".02em", textTransform:"uppercase" }}>Caffè</div>
      <div style={{ fontFamily:"var(--font-display)", fontSize:size, letterSpacing:".005em", textTransform:"uppercase" }}>Italia</div>
      <div aria-hidden="true" style={{ display:"flex", width:size*1.4, height:size*.08, marginTop:6, borderRadius:1, overflow:"hidden" }}>
        <span style={{ flex:1, background:"#1f8a5b" }}/>
        <span style={{ flex:1, background:"#f4ede0" }}/>
        <span style={{ flex:1, background:"#dc2832" }}/>
      </div>
      <div style={{ fontFamily:"var(--font-serif)", fontStyle:"italic", fontSize:size*.16, opacity:.72, marginTop:6, letterSpacing:".02em" }}>
        Napolitano · dal 2013
      </div>
    </div>
  );
}

// ─── Icons ────────────────────────────────────────────────────────────────────
const Icon = ({ d, size=20, stroke=1.6 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={stroke} strokeLinecap="round" strokeLinejoin="round">{d}</svg>
);
const IconSearch  = (p) => <Icon {...p} d={<><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></>}/>;
const IconUser    = (p) => <Icon {...p} d={<><circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></>}/>;
const IconBag     = (p) => <Icon {...p} d={<><path d="M5 8h14l-1 12H6L5 8z"/><path d="M9 8a3 3 0 1 1 6 0"/></>}/>;
const IconHeart   = (p) => <Icon {...p} d={<path d="M12 20s-7-4.5-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.5-7 10-7 10z"/>}/>;
const IconClose   = (p) => <Icon {...p} d={<><path d="M6 6 18 18"/><path d="M18 6 6 18"/></>}/>;
const IconMenu    = (p) => <Icon {...p} d={<><path d="M4 7h16"/><path d="M4 12h16"/><path d="M4 17h16"/></>}/>;
const IconArrow   = (p) => <Icon {...p} d={<><path d="M5 12h14"/><path d="m13 6 6 6-6 6"/></>}/>;
const IconArrowL  = (p) => <Icon {...p} d={<><path d="M19 12H5"/><path d="m11 6-6 6 6 6"/></>}/>;
const IconStar    = (p) => <Icon {...p} d={<path d="m12 3 2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9L12 3z"/>}/>;
const IconCheck   = (p) => <Icon {...p} d={<path d="m5 12 5 5L20 7"/>}/>;
const IconTruck   = (p) => <Icon {...p} d={<><path d="M2 7h11v9H2z"/><path d="M13 10h5l3 3v3h-8z"/><circle cx="6" cy="18" r="2"/><circle cx="17" cy="18" r="2"/></>}/>;
const IconLeaf    = (p) => <Icon {...p} d={<><path d="M20 4c-7 0-13 4-13 12 0 2 1 4 1 4s2-1 4-1c8 0 12-6 12-13l-4-2z"/><path d="M7 20c0-4 3-7 7-9"/></>}/>;
const IconShield  = (p) => <Icon {...p} d={<><path d="M12 3 4 6v6c0 5 4 8 8 9 4-1 8-4 8-9V6l-8-3z"/><path d="m9 12 2 2 4-4"/></>}/>;

// ─── Announcement bar ─────────────────────────────────────────────────────────
function AnnouncementBar() {
  const items = [t("ann.0"), t("ann.1"), t("ann.2"), t("ann.3"), t("ann.4")];
  return (
    <div style={{background:"var(--ink)",color:"var(--paper)",overflow:"hidden",borderBottom:"1px solid rgba(244,237,224,.1)"}}>
      <div className="marquee" style={{padding:"10px 0",fontSize:11.5,letterSpacing:".18em",textTransform:"uppercase",fontWeight:600,whiteSpace:"nowrap"}}>
        {[...items,...items,...items].map((it,i)=>(
          <span key={i} style={{display:"inline-flex",alignItems:"center",gap:48}}>
            <span>{it}</span>
            <span style={{color:"var(--rosso)"}}>✦</span>
          </span>
        ))}
      </div>
    </div>
  );
}

// Les six catégories du catalogue, regroupées en trois familles pour la
// barre de navigation. Une famille d'une seule catégorie devient un lien
// direct au lieu d'un menu. Renommer ici se répercute partout.
const FAMILIES = [
  { key:"cafes",    label:{ fr:"Cafés",                it:"Caffè" },
    cats:["grain","moulu"] },
  { key:"capsules", label:{ fr:"Capsules & dosettes",  it:"Capsule & cialde" },
    cats:["capsules"] },
  { key:"materiel", label:{ fr:"Machines & accessoires", it:"Macchine & accessori" },
    cats:["machines","tasses","epicerie"] },
];

window.FAMILIES = FAMILIES;

// ─── Header ───────────────────────────────────────────────────────────────────
// Barre persistante avec toutes les catégories visibles d'un clic — pensée
// pour un usage B2B/fournisseur, où la navigation rapide compte plus que
// le burger. Le burger reste comme fallback en dessous de 1100 px.
function Header({ route, navigate, onOpenCart, cartCount, cartPulse, onOpenMenu, lang, onSetLang }) {
  const [scrolled, setScrolled] = useState(false);
  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 8);
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);

  // Ajout au panier : la pastille du header fait un bond. C'est le seul
  // retour visuel — le tiroir ne s'ouvre plus tout seul (il se refermait
  // aussitôt, ce qui clignotait sur mobile).
  const [bump, setBump] = useState(false);
  useEffect(() => {
    if (!cartPulse) return;
    setBump(true);
    const id = setTimeout(() => setBump(false), 600);
    return () => clearTimeout(id);
  }, [cartPulse]);

  const isCat = (id) => route.page === "category" && route.cat === id;
  const isAll = route.page === "all";
  const isPro = route.page === "page" && route.slug === "pro";
  const isStory = route.page === "story";

  // Menu « Boutique » · les six catégories tenaient à plat dans la barre,
  // ce qui faisait huit entrées. Elles vivent maintenant dans un seul menu.
  const [shopOpen, setShopOpen] = useState(null);   // clé de la famille ouverte
  const shopRef = useRef(null);

  useEffect(() => {
    if (!shopOpen) return;
    // Le périmètre est la barre entière : passer d'une famille à l'autre ne
    // doit pas compter comme un clic extérieur.
    const onDown = (e) => { if (shopRef.current && !shopRef.current.contains(e.target)) setShopOpen(null); };
    const onKey  = (e) => { if (e.key === "Escape") setShopOpen(null); };
    document.addEventListener("mousedown", onDown);
    document.addEventListener("keydown", onKey);
    return () => { document.removeEventListener("mousedown", onDown); document.removeEventListener("keydown", onKey); };
  }, [shopOpen]);

  // Naviguer referme le menu, y compris via le bouton retour du navigateur.
  useEffect(() => { setShopOpen(null); }, [route.page, route.cat, route.id, route.slug]);

  return (
    <header className="site-header" style={{
      position:"sticky", top:0, zIndex:50,
      background: scrolled ? "var(--paper-glass)" : "transparent",
      backdropFilter: scrolled ? "blur(14px) saturate(160%)" : "none",
      WebkitBackdropFilter: scrolled ? "blur(14px) saturate(160%)" : "none",
      borderBottom: scrolled ? "1px solid var(--hairline)" : "1px solid transparent",
      transition:"background .25s ease, border-color .25s ease",
    }}>
      <div className="wrap" style={{display:"flex",alignItems:"center",justifyContent:"space-between",gap:24,padding:"14px 32px",minHeight:72}}>
        {/* Left: logo */}
        <a onClick={()=>navigate({page:"home"})} style={{cursor:"pointer",flex:"0 0 auto"}}>
          <CaffeItaliaLogo size={34}/>
        </a>

        {/* Center: category nav (desktop) */}
        <nav ref={shopRef} className="hdr-nav" aria-label="Catégories" style={{
          display:"flex",alignItems:"center",gap:4,flex:1,justifyContent:"center",flexWrap:"nowrap",
        }}>
          {FAMILIES.map(fam => {
            const cats = fam.cats.map(id => window.CATEGORIES.find(c => c.id === id)).filter(Boolean);
            const count = (id) => window.listedProducts().filter(p => p.category === id).length;
            const here = cats.some(c => isCat(c.id))
                      || (route.page === "family" && route.key === fam.key);

            // Une famille qui ne contient qu'une catégorie n'a rien à
            // déplier : elle mène droit au rayon.
            if (cats.length === 1) {
              return (
                <button key={fam.key} onClick={()=>navigate({page:"category",cat:cats[0].id})} style={{
                  padding:"8px 12px",borderRadius:99,whiteSpace:"nowrap",
                  fontSize:12.5,fontWeight:600,letterSpacing:".02em",
                  color: here ? "var(--paper)" : "var(--ink)",
                  background: here ? "var(--ink)" : "transparent",
                  transition:"background .15s ease, color .15s ease",
                }}>{pick(fam.label)}</button>
              );
            }

            const open = shopOpen === fam.key;
            return (
              <div key={fam.key} style={{position:"relative"}}
                   onMouseEnter={()=>setShopOpen(fam.key)} onMouseLeave={()=>setShopOpen(null)}
                   // Le clic navigue, donc il n'ouvre plus le menu : le focus
                   // prend le relais pour qui navigue au clavier, sinon les
                   // catégories deviendraient inatteignables sans souris.
                   onFocus={()=>setShopOpen(fam.key)}
                   onBlur={(e)=>{ if(!e.currentTarget.contains(e.relatedTarget)) setShopOpen(null); }}>
                <button onClick={()=>{ setShopOpen(null); navigate({page:"family",key:fam.key}); }}
                  aria-expanded={open} aria-haspopup="true" style={{
                  display:"inline-flex",alignItems:"center",gap:7,
                  padding:"8px 14px",borderRadius:99,whiteSpace:"nowrap",
                  fontSize:12.5,fontWeight:600,letterSpacing:".02em",
                  color: here ? "var(--paper)" : "var(--ink)",
                  background: here ? "var(--ink)" : "transparent",
                  transition:"background .15s ease, color .15s ease",
                }}>
                  {pick(fam.label)}
                  <span aria-hidden="true" style={{
                    fontSize:9,lineHeight:1,opacity:.7,
                    transform: open ? "rotate(180deg)" : "none",
                    transition:"transform .18s ease",
                  }}>▼</span>
                </button>

                {/* Le rembourrage haut remplace un écart en dur : un enfant en
                    position absolue n'agrandit pas la zone de survol de son
                    parent, donc traverser ce vide fermait le menu avant
                    d'atteindre une catégorie. Ici l'écart est dans la boîte. */}
                <div style={{
                  position:"absolute", top:"100%", left:0, paddingTop:8, minWidth:262,
                  opacity: open ? 1 : 0,
                  transform: open ? "translateY(0)" : "translateY(-6px)",
                  pointerEvents: open ? "auto" : "none",
                  // `visibility` en plus de l'opacité : à 0 d'opacité seule, le
                  // menu reste dans l'arbre d'accessibilité et un lecteur
                  // d'écran annonce les catégories alors qu'il est fermé.
                  visibility: open ? "visible" : "hidden",
                  transition:"opacity .16s ease, transform .16s ease, visibility .16s",
                }}>
                  <div role="menu" aria-label={pick(fam.label)} style={{
                    background:"var(--paper)", border:"1px solid var(--hairline-strong)", borderRadius:4,
                    boxShadow:"0 20px 50px rgba(0,0,0,.35)", padding:6,
                  }}>
                    {cats.map(c => {
                      const on = isCat(c.id);
                      return (
                        <button key={c.id} role="menuitem" tabIndex={open ? 0 : -1}
                          onClick={()=>{ setShopOpen(null); navigate({page:"category",cat:c.id}); }} style={{
                          display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,
                          width:"100%",padding:"9px 12px",borderRadius:3,textAlign:"left",
                          fontSize:13.5,fontWeight:600,
                          color: on ? "var(--paper)" : "var(--ink)",
                          background: on ? "var(--ink)" : "transparent",
                        }}
                        onMouseEnter={(e)=>{ if(!on) e.currentTarget.style.background="var(--paper-2)"; }}
                        onMouseLeave={(e)=>{ if(!on) e.currentTarget.style.background="transparent"; }}>
                          <span>{pick(c.name)}</span>
                          <span style={{fontSize:11.5,opacity:.5,fontVariantNumeric:"tabular-nums"}}>{count(c.id)}</span>
                        </button>
                      );
                    })}

                  </div>
                </div>
              </div>
            );
          })}
          {[
            { on: isStory, label: t("menu.story"), to: {page:"story"} },
            // Sans flèche ni rouge : c'est une entrée de navigation comme les
            // autres, pas un appel à l'action. Le rouge du milieu de barre
            // attirait l'œil plus que la boutique elle-même.
            { on: isAll,   label: t("all.menu"),  to: {page:"all"} },
          ].map(it => (
            <button key={it.label} onClick={()=>navigate(it.to)} style={{
              padding:"8px 12px",borderRadius:99,whiteSpace:"nowrap",
              fontSize:12.5,fontWeight:600,letterSpacing:".02em",
              color: it.on ? "var(--paper)" : "var(--ink)",
              background: it.on ? "var(--ink)" : "transparent",
              transition:"background .15s ease, color .15s ease",
            }}>{it.label}</button>
          ))}
          <button onClick={()=>navigate({page:"page",slug:"pro"})} style={{
            padding:"8px 12px",borderRadius:99,whiteSpace:"nowrap",
            fontSize:12.5,fontWeight:700,letterSpacing:".02em",
            color: isPro ? "#0e0d0c" : "#caa451",
            background: isPro ? "#caa451" : "transparent",
            border: isPro ? "1px solid #caa451" : "1px solid transparent",
          }}>{window.__LANG__==="it" ? "Lato pro" : "Côté pro"}</button>
        </nav>

        {/* Right: lang switch + account + cart + burger (mobile) */}
        <div style={{display:"flex",alignItems:"center",gap:14,flex:"0 0 auto",marginLeft:"auto"}}>
          <LangSwitch lang={lang} onSetLang={onSetLang}/>
          <button onClick={()=>navigate({page:"account"})} aria-label={window.__LANG__==="it"?"Account":"Compte"}
            className="hdr-account" style={{
              display:"inline-flex",alignItems:"center",justifyContent:"center",
              width:34,height:34,
            }}>
            <IconUser size={20}/>
          </button>
          <button onClick={onOpenCart} aria-label={t("header.cart")} style={{
            display:"inline-flex",alignItems:"center",gap:8,
            fontSize:12.5,letterSpacing:".14em",textTransform:"uppercase",fontWeight:600
          }}>
            <IconBag size={18}/>
            <span className="hdr-cart-label">{t("header.cart")}</span>
            {cartCount > 0 && (
              <span className={"hdr-cart-count" + (bump ? " is-bump" : "")}
                style={{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:20,height:20,padding:"0 6px",background:"var(--rosso)",color:"#fff",borderRadius:99,fontSize:11,letterSpacing:0,fontWeight:700}}>{cartCount}</span>
            )}
          </button>
          <button onClick={onOpenMenu} aria-label={t("header.menu")} className="hdr-burger" style={{
            display:"none",alignItems:"center",justifyContent:"center",
            width:34,height:34,
          }}>
            <IconMenu size={20}/>
          </button>
        </div>
      </div>

      {/* Responsive: collapse nav to burger on small screens */}
      <style>{`
        @media (max-width:1100px){
          header .hdr-nav{display:none !important}
          header .hdr-burger{display:inline-flex !important}
        }
        @media (max-width:720px){
          /* Tighten header padding + gaps so logo + lang + cart + burger fit */
          header .wrap{padding-left:16px !important; padding-right:16px !important; gap:12px !important}
          header .wrap > div:last-child{gap:8px !important}
        }
        @media (max-width:560px){
          header .hdr-cart-label{display:none}
        }
        /* Sur mobile la barre reste toujours lisible : elle se superpose au
           contenu qui défile dessous, donc pas de fond transparent. */
        @media (max-width:900px){
          header.site-header{
            background:var(--paper-glass) !important;
            backdrop-filter:blur(14px) saturate(160%);
            -webkit-backdrop-filter:blur(14px) saturate(160%);
            border-bottom:1px solid var(--hairline) !important;
          }
        }
        @keyframes cartBump{
          0%{transform:scale(1)}
          30%{transform:scale(1.55)}
          60%{transform:scale(.92)}
          100%{transform:scale(1)}
        }
        .hdr-cart-count{transition:transform .2s ease}
        .hdr-cart-count.is-bump{animation:cartBump .6s cubic-bezier(.2,.7,.2,1)}
        @media (prefers-reduced-motion:reduce){
          .hdr-cart-count.is-bump{animation:none}
        }
      `}</style>
    </header>
  );
}

// ─── Language switcher (FR / IT) ─────────────────────────────────────────────
function LangSwitch({ lang, onSetLang }) {
  return (
    <div role="group" aria-label="Langue / Lingua" style={{
      display:"inline-flex",alignItems:"center",border:"1px solid var(--hairline-strong)",
      borderRadius:99,padding:2,fontSize:11,fontWeight:700,letterSpacing:".1em",
    }}>
      {(window.SUPPORTED_LANGS || ["fr","it"]).map(l => {
        const on = l === lang;
        return (
          <button key={l} onClick={()=>onSetLang(l)} aria-pressed={on} style={{
            padding:"6px 10px",borderRadius:99,minWidth:32,
            background: on ? "var(--ink)" : "transparent",
            color: on ? "var(--paper)" : "var(--ink)",
            textTransform:"uppercase",cursor:"pointer",
          }}>{l}</button>
        );
      })}
    </div>
  );
}

// ─── Side menu drawer ─────────────────────────────────────────────────────────
function MenuDrawer({ open, onClose, navigate }) {
  return (
    <Drawer open={open} onClose={onClose} side="left" width={420}>
      <div style={{display:"flex",flexDirection:"column",height:"100%"}}>
        <div style={{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"24px 28px",borderBottom:"1px solid var(--hairline)"}}>
          <span className="eyebrow">{t("menu.nav")}</span>
          <button onClick={onClose} aria-label="×"><IconClose size={22}/></button>
        </div>
        <div style={{padding:"12px 0",flex:1,overflowY:"auto"}}>
          {[{page:"home",label:t("menu.home"),sub:t("menu.home_it")},
            {page:"page",slug:"pro",label:(window.__LANG__==="it"?"Lato pro":"Côté pro"),sub:"B2B · Ho.Re.Ca.",accent:"#caa451"},
            {page:"all",label:t("all.menu"),sub:t("all.menu_it")},
            ...window.CATEGORIES.map(c=>({page:"category",cat:c.id,label:pick(c.name),sub:c.it})),
            {page:"story",label:t("menu.story"),sub:t("menu.story_it")},
            {page:"page",slug:"contact",label:t("menu.contact"),sub:t("menu.contact_it")},
          ].map((it,i)=>(
            <button key={i} onClick={()=>{ navigate(it); onClose(); }} style={{
              width:"100%",textAlign:"left",padding:"18px 28px",
              borderBottom:"1px solid var(--hairline)",
              display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,
            }}>
              <span className="display" style={{fontSize:32,color:it.accent||"inherit"}}>{it.label}</span>
              <span className="serif" style={{fontSize:16,opacity:it.accent?.75:.55,color:it.accent||"inherit"}}>{it.sub}</span>
            </button>
          ))}
        </div>
      </div>
    </Drawer>
  );
}

// ─── Cart drawer ──────────────────────────────────────────────────────────────
function Drawer({ open, onClose, side="right", width=460, children }) {
  return (
    <>
      <div onClick={onClose} style={{
        position:"fixed",inset:0,background:"rgba(14,13,12,.42)",zIndex:90,
        opacity:open?1:0,pointerEvents:open?"auto":"none",transition:"opacity .25s ease",
      }}/>
      <aside style={{
        position:"fixed", top:0, bottom:0, [side]:0, width:`min(${width}px, 92vw)`,
        background:"var(--paper)", zIndex:91,
        transform: open ? "translateX(0)" : `translateX(${side==="right"?"100%":"-100%"})`,
        transition:"transform .35s cubic-bezier(.2,.7,.2,1)",
        boxShadow:"-20px 0 60px rgba(0,0,0,.18)",
        display:"flex",flexDirection:"column",
      }}>
        {children}
      </aside>
    </>
  );
}

function CartDrawer({ open, onClose, items, onRemove, onQty, navigate }) {
  const subtotal = items.reduce((s,i)=>s + i.price * i.qty, 0);
  const shipping = subtotal >= 50 ? 0 : 5.90;
  const total = subtotal + shipping;
  const freeShipDelta = Math.max(0, 50 - subtotal);

  const [checkoutLoading, setCheckoutLoading] = useState(false);
  const [checkoutErr,     setCheckoutErr]     = useState(null);

  const onCheckout = async () => {
    setCheckoutErr(null);
    setCheckoutLoading(true);
    try {
      const sess = window.sb ? (await window.sb.auth.getSession()).data.session : null;
      const r = await fetch("/api/checkout", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          items: items.map(i => ({ id: i.id, qty: i.qty })),
          lang: window.__LANG__ || "fr",
          userId: sess?.user?.id || null,
        }),
      });
      const data = await r.json();
      if (!r.ok || !data.url) throw new Error(data.error || "Erreur inconnue");
      window.location.href = data.url;
    } catch (e) {
      setCheckoutErr(e.message);
      setCheckoutLoading(false);
    }
  };

  return (
    <Drawer open={open} onClose={onClose} side="right" width={480}>
      <div style={{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"22px 26px",borderBottom:"1px solid var(--hairline)"}}>
        <div>
          <div className="eyebrow">{t("cart.title")}</div>
          <div style={{fontFamily:"var(--font-serif)",fontStyle:"italic",fontSize:24,marginTop:2}}>{t("cart.title")} · {items.length}</div>
        </div>
        <button onClick={onClose} aria-label="×"><IconClose size={22}/></button>
      </div>

      {/* Free shipping progress */}
      <div style={{padding:"14px 26px",borderBottom:"1px solid var(--hairline)",background:"var(--paper-2)"}}>
        {freeShipDelta > 0 ? (
          <>
            <div style={{fontSize:12.5,marginBottom:8}}>
              {window.__LANG__==="it" ? "Mancano" : "Plus que"} <b>{freeShipDelta.toFixed(2).replace(".",",")} €</b> {window.__LANG__==="it" ? "alla spedizione gratuita" : "pour la livraison offerte"}
            </div>
            <div style={{height:6,background:"var(--paper-3)",borderRadius:99,overflow:"hidden"}}>
              <div style={{width:`${Math.min(100,(subtotal/50)*100)}%`,height:"100%",background:"var(--rosso)",transition:"width .3s ease"}}/>
            </div>
          </>
        ) : (
          <div style={{fontSize:12.5,display:"flex",alignItems:"center",gap:8,color:"var(--rosso)",fontWeight:600}}>
            <IconCheck size={16}/> {t("cart.delivery_free")} · grazie!
          </div>
        )}
      </div>

      <div style={{flex:1,overflowY:"auto",padding:"6px 26px"}}>
        {items.length === 0 ? (
          <EmptyCart navigate={navigate} onClose={onClose}/>
        ) : items.map(item => (
          <CartLine key={item.id} item={item} onRemove={()=>onRemove(item.id)} onQty={(q)=>onQty(item.id,q)}/>
        ))}
      </div>

      {items.length > 0 && (
        <div style={{borderTop:"1px solid var(--hairline)",padding:"18px 26px",background:"var(--paper)"}}>
          <Row label={t("cart.subtotal")} value={`${subtotal.toFixed(2).replace(".",",")} €`}/>
          <Row label={t("cart.delivery")} value={shipping===0?t("cart.delivery_free"):`${shipping.toFixed(2).replace(".",",")} €`}/>
          <div style={{height:1,background:"var(--hairline)",margin:"10px 0"}}/>
          <Row label={<b>{t("cart.total")}</b>} value={<b style={{fontSize:18}}>{total.toFixed(2).replace(".",",")} €</b>}/>
          <button onClick={onCheckout} disabled={checkoutLoading} className="btn btn-rosso btn-lg"
                  style={{width:"100%",marginTop:14,opacity:checkoutLoading?.6:1}}>
            {checkoutLoading
              ? (window.__LANG__==="it"?"Redirezione…":"Redirection…")
              : <>{t("cart.checkout")} <IconArrow size={18}/></>}
          </button>
          {checkoutErr && (
            <div style={{padding:"8px 10px",marginTop:8,background:"rgba(220,40,50,.1)",border:"1px solid var(--rosso)",borderRadius:6,color:"var(--rosso)",fontSize:12.5}}>
              {checkoutErr}
            </div>
          )}
          <div style={{textAlign:"center",fontSize:11.5,color:"var(--muted)",marginTop:10}}>
            {t("cart.pay_note")}
          </div>
        </div>
      )}
    </Drawer>
  );
}

function Row({label,value}){
  return <div style={{display:"flex",justifyContent:"space-between",padding:"4px 0",fontSize:14}}><span>{label}</span><span>{value}</span></div>;
}

function EmptyCart({ navigate, onClose }){
  return (
    <div style={{padding:"40px 4px",textAlign:"center"}}>
      <div className="display" style={{fontSize:56,color:"var(--rosso)"}}>{t("cart.empty_title")}</div>
      <p style={{color:"var(--muted)",marginTop:6}}>{t("cart.empty_msg")}</p>
      <button onClick={()=>{ onClose(); navigate({page:"category",cat:"grain"}); }} className="btn btn-primary" style={{marginTop:18}}>
        {t("cart.empty_cta")} <IconArrow size={16}/>
      </button>
    </div>
  );
}

function CartLine({ item, onRemove, onQty }){
  return (
    <div style={{display:"grid",gridTemplateColumns:"84px 1fr auto",gap:14,padding:"16px 0",borderBottom:"1px solid var(--hairline)"}}>
      {item.image ? (
        <div style={{width:84,height:96,borderRadius:4,background:"var(--paper-2)",
          display:"flex",alignItems:"center",justifyContent:"center",padding:6,overflow:"hidden"}}>
          <img src={item.image} alt={pick(item.name)} loading="lazy"
            style={{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}}/>
        </div>
      ) : (
        <div className="placeholder" style={{width:84,height:96,borderRadius:4,background:item.palette[0],color:item.palette[2]}}>
          <span style={{background:"var(--paper)",color:"var(--ink)"}}>{window.fmtWeight(item)}</span>
        </div>
      )}
      <div style={{minWidth:0}}>
        <div style={{fontWeight:600,fontSize:14,lineHeight:1.25}}>{pick(item.name)}</div>
        <div style={{fontSize:12,color:"var(--muted)",marginTop:2}}>{pick(item.sub)}</div>
        {window.fmtWeight(item) && (
          <div style={{fontSize:11.5,fontWeight:600,letterSpacing:".06em",textTransform:"uppercase",color:"var(--ink)",opacity:.7,marginTop:4}}>{window.fmtWeight(item)}</div>
        )}
        <div style={{display:"flex",alignItems:"center",gap:12,marginTop:10}}>
          <Stepper value={item.qty} onChange={onQty}/>
          <button onClick={onRemove} style={{fontSize:11.5,textDecoration:"underline",color:"var(--muted)"}}>{t("cart.remove")}</button>
        </div>
      </div>
      <div style={{fontWeight:600,fontSize:14,whiteSpace:"nowrap"}}>{(item.price*item.qty).toFixed(2).replace(".",",")} €</div>
    </div>
  );
}

function Stepper({value,onChange}){
  return (
    <div style={{display:"inline-flex",alignItems:"center",border:"1px solid var(--hairline-strong)",borderRadius:99}}>
      <button onClick={()=>onChange(Math.max(1,value-1))} style={{width:30,height:30,fontSize:16}}>−</button>
      <span style={{minWidth:24,textAlign:"center",fontSize:13,fontWeight:600}}>{value}</span>
      <button onClick={()=>onChange(value+1)} style={{width:30,height:30,fontSize:16}}>+</button>
    </div>
  );
}

// ─── Product card ─────────────────────────────────────────────────────────────
function ProductCard({ p, navigate, onAdd, layout="grid" }) {
  const [hover, setHover] = useState(false);
  const onCardClick = () => navigate({page:"product",id:p.id});

  return (
    <article onMouseEnter={()=>setHover(true)} onMouseLeave={()=>setHover(false)}
      onClick={onCardClick}
      style={{cursor:"pointer",display:"flex",flexDirection:"column",gap:12,position:"relative"}}>
      <div style={{position:"relative",aspectRatio:"4/5",overflow:"hidden",borderRadius:4,background:"var(--paper-2)"}}>
        {p.image ? (
          <div style={{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",padding:"8%",
            background:`radial-gradient(circle at 50% 35%, ${p.palette[2]}22 0%, var(--paper-2) 70%)`,
            transition:"transform .6s ease",transform:hover?"scale(1.04)":"scale(1)"}}>
            <img src={p.image} alt={pick(p.name)} loading="lazy"
              style={{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",filter:"drop-shadow(0 12px 24px rgba(0,0,0,.25))"}}/>
          </div>
        ) : (
          <div style={{position:"absolute",inset:0,background:`linear-gradient(180deg, ${p.palette[0]} 0 60%, ${p.palette[2]} 60% 100%)`,transition:"transform .6s ease",transform:hover?"scale(1.04)":"scale(1)"}}>
            <ProductBottle p={p}/>
          </div>
        )}
        <div className="grain" style={{position:"absolute",inset:0}}/>

        {p.badge && (
          <span className="chip chip-rosso" style={{position:"absolute",top:12,left:12}}>{pick(p.badge)}</span>
        )}
        {p.compareAt && (
          <span style={{position:"absolute",top:12,right:12,background:"var(--ink)",color:"var(--paper)",borderRadius:4,padding:"4px 8px",fontSize:11,fontWeight:700}}>
            −{Math.round((1 - p.price/p.compareAt)*100)}%
          </span>
        )}

        {/* Quick add · slide-up on hover (desktop), always visible on touch */}
        <div className="quick-add" style={{
          position:"absolute",left:12,right:12,bottom:12,
          transform: hover ? "translateY(0)" : "translateY(120%)",
          transition:"transform .25s ease",
        }}>
          <button onClick={(e)=>{ e.stopPropagation(); onAdd(p); }}
            className="btn btn-primary" style={{width:"100%",height:44}}>
            {t("prod.add")}
          </button>
        </div>
      </div>
      <div>
        <h3 style={{fontSize:15,fontWeight:600,lineHeight:1.3,margin:0}}>{pick(p.name)}</h3>
        <div style={{fontSize:12.5,color:"var(--muted)",marginTop:3}}>{pick(p.sub)}</div>
        {p.tasting && (
          <div className="serif" style={{fontSize:13,color:"var(--ink)",opacity:.75,marginTop:6}}>{pick(p.tasting)}</div>
        )}
        <div style={{display:"flex",alignItems:"baseline",gap:10,marginTop:10,flexWrap:"wrap"}}>
          {p.compareAt && <span style={{color:"var(--muted)",textDecoration:"line-through",fontWeight:400,fontSize:13.5,whiteSpace:"nowrap"}}>{p.compareAt.toFixed(2).replace(".",",")} €</span>}
          {p.variantCount > 1 && <span style={{fontSize:12.5,color:"var(--muted)"}}>{t("prod.price_from")}</span>}
          <span style={{fontWeight:700,fontSize:16,color:p.compareAt?"var(--rosso)":"var(--ink)",whiteSpace:"nowrap"}}>{(p.priceFrom ?? p.price).toFixed(2).replace(".",",")} €</span>
        </div>
      </div>
    </article>
  );
}

// Stylized product "drawing" so we don't ship a real photo
function ProductBottle({ p }){
  const isBag    = ["Grain","Moulu"].includes(p.type);
  const isMachine= p.type === "Machine";
  const isBox    = p.type === "Capsules" || p.type === "Coffret";
  const isCup    = p.type === "Tasse";
  const isPantry = p.type === "Épicerie";

  // Generic centered shape with weight chip on top
  return (
    <div style={{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}}>
      <div style={{position:"relative",width:"58%",height:"68%"}}>
        {isBag && <BagShape p={p}/>}
        {isMachine && <MachineShape p={p}/>}
        {isBox && <BoxShape p={p}/>}
        {isCup && <CupShape p={p}/>}
        {isPantry && <BottleShape p={p}/>}
        <div style={{position:"absolute",top:-30,left:0,right:0,textAlign:"center"}}>
          <span style={{background:"var(--paper)",color:"var(--ink)",fontSize:10,letterSpacing:".14em",fontWeight:700,padding:"4px 8px",borderRadius:2,fontFamily:"ui-monospace,Menlo,monospace"}}>
            {p.placeholder}
          </span>
        </div>
      </div>
    </div>
  );
}

function BagShape({ p }){
  return (
    <div style={{position:"absolute",inset:0,background:p.palette[0],borderRadius:"10px 10px 6px 6px",
      boxShadow:"inset 0 -40% 0 rgba(0,0,0,.18)",
      display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",
      color:p.palette[2],fontFamily:"var(--font-display)",letterSpacing:".02em",lineHeight:.88,
      padding:"18px 12px",
    }}>
      <div style={{height:8,width:"60%",background:p.palette[2],borderRadius:2,marginBottom:14,opacity:.85}}/>
      <div style={{fontSize:30,textAlign:"center"}}>MORENO</div>
      <div style={{height:3,width:"30%",background:p.palette[1],margin:"8px 0"}}/>
      <div style={{fontFamily:"var(--font-serif)",fontStyle:"italic",fontSize:13,opacity:.85,textAlign:"center"}}>
        {p.type === "Grain" ? "in grani" : "macinato"}
      </div>
      <div style={{position:"absolute",bottom:14,left:0,right:0,textAlign:"center",fontSize:11,letterSpacing:".24em",opacity:.7,fontFamily:"ui-monospace,Menlo,monospace"}}>NAPOLI · IT</div>
    </div>
  );
}
function MachineShape({ p }){
  return (
    <div style={{position:"absolute",inset:"5% 14% 4% 14%",display:"flex",flexDirection:"column",alignItems:"center"}}>
      <div style={{width:"100%",height:"42%",background:p.palette[0],clipPath:"polygon(20% 0,80% 0,100% 100%,0 100%)"}}/>
      <div style={{width:"30%",height:8,background:p.palette[2],marginTop:4,borderRadius:2}}/>
      <div style={{width:"70%",height:"38%",background:p.palette[0],clipPath:"polygon(0 0,100% 0,80% 100%,20% 100%)",marginTop:6}}/>
      <div style={{width:"20%",height:"10%",background:p.palette[1] || p.palette[0],marginTop:4,borderRadius:"2px 2px 0 0"}}/>
    </div>
  );
}
function BoxShape({ p }){
  return (
    <div style={{position:"absolute",inset:"10% 6% 8% 6%",background:p.palette[0],color:p.palette[1],
      display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",
      padding:18,borderRadius:3}}>
      <div style={{fontFamily:"var(--font-display)",fontSize:24,letterSpacing:".02em"}}>MORENO</div>
      <div style={{fontFamily:"var(--font-serif)",fontStyle:"italic",fontSize:13,opacity:.9,marginTop:4}}>Capsule · 50 pz</div>
      <div style={{display:"grid",gridTemplateColumns:"repeat(5,1fr)",gap:4,marginTop:14,width:"82%"}}>
        {Array.from({length:10}).map((_,i)=>(
          <div key={i} style={{aspectRatio:"1",background:p.palette[2],borderRadius:99,opacity:.85}}/>
        ))}
      </div>
    </div>
  );
}
function CupShape({ p }){
  return (
    <div style={{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}}>
      <div style={{position:"relative",width:"66%",aspectRatio:"1.3/1"}}>
        <div style={{position:"absolute",inset:0,background:p.palette[0],borderRadius:"6px 6px 50% 50% / 6px 6px 18% 18%",boxShadow:"inset 0 -8px 0 rgba(0,0,0,.08)"}}/>
        <div style={{position:"absolute",top:"22%",right:-18,width:32,height:38,border:`6px solid ${p.palette[0]}`,borderRadius:"0 100% 100% 0 / 0 50% 50% 0"}}/>
        <div style={{position:"absolute",inset:"14% 18% 38% 18%",borderTop:`3px solid ${p.palette[1]}`}}/>
      </div>
    </div>
  );
}
function BottleShape({ p }){
  return (
    <div style={{position:"absolute",inset:"4% 28% 4% 28%",display:"flex",flexDirection:"column",alignItems:"center"}}>
      <div style={{width:"30%",height:"18%",background:p.palette[1],borderRadius:"2px 2px 0 0"}}/>
      <div style={{width:"24%",height:"6%",background:p.palette[1]}}/>
      <div style={{width:"100%",flex:1,background:p.palette[0],borderRadius:"6px 6px 14px 14px",
        display:"flex",alignItems:"center",justifyContent:"center",padding:12,color:p.palette[2]}}>
        <div style={{textAlign:"center",fontFamily:"var(--font-serif)",fontStyle:"italic",fontSize:16}}>etichetta</div>
      </div>
    </div>
  );
}

// ─── Footer ───────────────────────────────────────────────────────────────────
function Footer({ navigate }){
  return (
    <footer style={{background:"var(--ink)",color:"var(--paper)",marginTop:80}}>
      <div className="wrap" style={{padding:"72px 32px 24px"}}>
        {/* Newsletter row */}
        <div style={{display:"grid",gridTemplateColumns:"1.2fr 1fr",gap:48,alignItems:"end",paddingBottom:48,borderBottom:"1px solid rgba(244,237,224,.14)"}} className="footer-top">
          <div>
            <div className="eyebrow" style={{color:"var(--crema)"}}>{t("sub.eyebrow")}</div>
            <h2 className="display" style={{fontSize:"clamp(48px,6vw,84px)",margin:"8px 0 0",color:"var(--paper)"}}>
              {t("sub.title_l1")}<br/><span style={{color:"var(--rosso)"}}>{t("sub.title_l2")}</span>
            </h2>
            <p className="serif" style={{fontSize:20,opacity:.78,marginTop:14,maxWidth:520}}>{t("sub.lede")}</p>
          </div>
          <form onSubmit={(e)=>e.preventDefault()} style={{
            display:"flex",gap:6,alignItems:"center",
            background:"#ffffff",border:"1px solid rgba(14,13,12,.22)",
            borderRadius:99,padding:"6px 6px 6px 22px",
            boxShadow:"0 1px 0 rgba(14,13,12,.04) inset",
            transition:"border-color .15s ease, box-shadow .15s ease",
          }} className="footer-newsletter">
            <input type="email" placeholder={t("sub.email_placeholder")} style={{
              flex:1,background:"transparent",border:0,color:"#0a0907",
              fontSize:15,padding:"12px 0",outline:"none",fontFamily:"inherit",minWidth:0,
            }}/>
            <button type="submit" className="btn btn-rosso" style={{height:44,padding:"0 22px"}}>
              {t("sub.cta")} <IconArrow size={16}/>
            </button>
            <style>{`
              .footer-newsletter:focus-within{border-color:#0a0907;box-shadow:0 0 0 3px rgba(220,40,50,.12)}
              .footer-newsletter input::placeholder{color:rgba(14,13,12,.55);opacity:1}
            `}</style>
          </form>
        </div>

        {/* Columns */}
        <div style={{display:"grid",gridTemplateColumns:"1.4fr 1fr 1fr 1fr",gap:32,padding:"48px 0 32px"}} className="footer-cols">
          <div>
            <CaffeItaliaLogo size={48}/>
            <p style={{fontSize:13,opacity:.7,maxWidth:340,marginTop:18,lineHeight:1.6}}>{t("footer.tagline")}</p>
            <div style={{display:"flex",gap:10,marginTop:18}}>
              {["IG","FB","YT"].map(s=>(
                <a key={s} style={{width:36,height:36,border:"1px solid rgba(244,237,224,.3)",borderRadius:99,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,letterSpacing:".08em"}}>{s}</a>
              ))}
            </div>
          </div>

          <FooterCol title={t("footer.col_shop")} items={[
            { label: t("all.menu"), onClick: () => navigate({page:"all"}) },
            ...window.CATEGORIES.map(c => ({
              label: pick(c.name),
              onClick: () => navigate({page:"category",cat:c.id}),
            })),
          ]}/>
          <FooterCol title={t("footer.col_house")} items={[
            {label: t("footer.shop_story"),   onClick:()=>navigate({page:"story"})},
            {label: (window.__LANG__==="it"?"Lato pro":"Côté pro"), onClick:()=>navigate({page:"page",slug:"pro"})},
            {label: t("footer.shop_contact"), onClick:()=>navigate({page:"page",slug:"contact"})},
          ]}/>
          <FooterCol title={t("footer.col_help")} items={[
            {label: t("footer.help_delivery"), onClick:()=>navigate({page:"page",slug:"livraison"})},
            {label: t("footer.help_returns"),  onClick:()=>navigate({page:"page",slug:"retours"})},
            {label: t("footer.help_faq"),      onClick:()=>navigate({page:"page",slug:"faq"})},
            {label: t("footer.help_legal"),    onClick:()=>navigate({page:"page",slug:"mentions-legales"})},
            {label: t("footer.help_cgv"),      onClick:()=>navigate({page:"page",slug:"cgv"})},
            {label: t("footer.help_privacy"),  onClick:()=>navigate({page:"page",slug:"confidentialite"})},
          ]}/>
        </div>

        {/* Bottom */}
        <div style={{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,fontSize:12,opacity:.6,paddingTop:24,borderTop:"1px solid rgba(244,237,224,.14)",flexWrap:"wrap"}}>
          <span>{t("footer.copyright")}</span>
          <span>{t("cart.pay_note")}</span>
        </div>

        {/* Made-by credit */}
        <div style={{paddingTop:14,fontSize:11.5,opacity:.5,textAlign:"center",letterSpacing:".06em"}}>
          {window.__LANG__==="it" ? "Realizzato da" : "Fait par"}{" "}
          <a href="https://www.linkedin.com/in/alexander-hills/" target="_blank" rel="noopener noreferrer"
             style={{color:"inherit",textDecoration:"underline",fontWeight:600}}>
            Alexander Hills
          </a>
        </div>
      </div>
      <style>{`
        @media (max-width:900px){
          footer .footer-top{grid-template-columns:1fr !important; gap:24px !important}
          footer .footer-cols{grid-template-columns:1fr 1fr !important; gap:28px !important}
        }
        @media (max-width:560px){
          footer .footer-cols{grid-template-columns:1fr !important}
        }
      `}</style>
    </footer>
  );
}
function FooterCol({title,items}){
  return (
    <div>
      <div className="eyebrow" style={{color:"var(--crema)"}}>{title}</div>
      <ul style={{listStyle:"none",margin:"14px 0 0",padding:0,display:"flex",flexDirection:"column",gap:10}}>
        {items.map((it,i)=>(
          <li key={i}><a onClick={it.onClick} style={{fontSize:14,opacity:.86,cursor:"pointer"}}>{it.label}</a></li>
        ))}
      </ul>
    </div>
  );
}

// ─── Toast d'ajout au panier ───────────────────────────────────────────────
// Deux formes pour une seule logique, choisies en CSS et non en JS — pas de
// listener de redimensionnement, pas d'état à resynchroniser :
//   · ≥ 901 px : carte en haut à droite, sous l'icône panier.
//   · ≤ 900 px : bandeau plat collé en bas, au-dessus de la barre d'accueil.
//
// Le conteneur ne capte jamais le pointeur : seul « Voir le panier » est
// cliquable. Un toucher sur le reste du bandeau traverse et atteint ce qu'il
// y a dessous — c'est ce qui le distingue du popup d'origine, qui bloquait
// le bouton d'ajout pendant toute sa durée d'affichage.
function CartToast({ item, onOpenCart, suppressed }){
  const [shown, setShown] = useState(false);
  const seq = item ? item.seq : 0;

  useEffect(() => {
    if (!seq) return;
    setShown(true);
    const id = setTimeout(() => setShown(false), 3000);
    return () => clearTimeout(id);   // réajouter relance le minuteur
  }, [seq]);

  // Tiroir ouvert : le panier est déjà sous les yeux, et c'est précisément
  // le recouvrement du bouton « Passer la commande » qui posait problème.
  if (!item || suppressed) return null;

  return (
    <div className="cart-toast" role="status" aria-live="polite" style={{
      position:"fixed", zIndex:60,
      opacity: shown ? 1 : 0,
      pointerEvents:"none",
      transition:"opacity .22s ease, transform .22s cubic-bezier(.2,.7,.2,1)",
    }}>
      <div className="ct-card">
        <div className="ct-head"><IconCheck size={15}/> {t("toast.added")}</div>

        <div className="ct-body">
          {item.image && (
            <div className="ct-thumb">
              <img src={item.image} alt="" aria-hidden="true" style={{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"}}/>
            </div>
          )}
          <div style={{minWidth:0}}>
            <div className="ct-name">{item.name}</div>
            <div className="ct-meta">
              {[item.weight, item.qty > 1 ? "\u00d7" + item.qty : null].filter(Boolean).join(" \u00b7 ")}
            </div>
          </div>
        </div>

        <button onClick={onOpenCart} className="btn btn-primary btn-sm ct-cta"
                style={{pointerEvents: shown ? "auto" : "none"}}>
          {t("toast.view_cart")} <IconArrow size={15}/>
        </button>
      </div>

      <style>{`
        .cart-toast{ top:88px; right:24px; width:320px; max-width:calc(100vw - 48px);
                     transform:translateY(${shown ? "0" : "-8px"}); }
        .cart-toast .ct-card{ background:var(--paper-2); color:var(--ink);
          border:1px solid var(--hairline-strong); border-radius:4px; padding:14px 16px;
          box-shadow:0 18px 50px rgba(0,0,0,.35); }
        .cart-toast .ct-head{ display:flex; align-items:center; gap:8px; font-size:12px;
          font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--rosso); }
        .cart-toast .ct-body{ display:flex; gap:12px; margin-top:12px; align-items:center; }
        .cart-toast .ct-thumb{ flex:0 0 auto; width:44px; height:44px; border-radius:3px;
          background:var(--paper-3); display:flex; align-items:center; justify-content:center;
          padding:4px; overflow:hidden; }
        .cart-toast .ct-name{ font-size:13.5px; font-weight:600; line-height:1.3; }
        .cart-toast .ct-meta{ font-size:12px; color:var(--muted); margin-top:2px; }
        .cart-toast .ct-cta{ width:100%; margin-top:12px; }

        /* Mobile · bandeau plat en bas. env(safe-area-inset-bottom) le remonte
           au-dessus de la barre d'accueil des iPhone sans encoche matérielle. */
        @media (max-width:900px){
          .cart-toast{
            top:auto; bottom:calc(12px + env(safe-area-inset-bottom, 0px));
            left:12px; right:12px; width:auto; max-width:none;
            transform:translateY(${shown ? "0" : "12px"});
          }
          .cart-toast .ct-card{
            display:grid; grid-template-columns:1fr auto; align-items:center;
            column-gap:12px; padding:12px 14px;
          }
          .cart-toast .ct-head{ grid-column:1; grid-row:1; font-size:11px; }
          .cart-toast .ct-body{ grid-column:1; grid-row:2; margin-top:3px; }
          .cart-toast .ct-thumb{ display:none; }   /* la place manque, le nom prime */
          .cart-toast .ct-name{ font-size:13px; }
          .cart-toast .ct-cta{ grid-column:2; grid-row:1 / span 2; width:auto; margin-top:0; }
        }
        @media (prefers-reduced-motion:reduce){
          .cart-toast{ transition:opacity .01s !important; transform:none !important }
        }
      `}</style>
    </div>
  );
}

Object.assign(window, {
  CaffeItaliaLogo, AnnouncementBar, Header, MenuDrawer, CartDrawer, CartToast, ProductCard, ProductBottle, Footer, Drawer, Stepper,
  IconSearch, IconUser, IconBag, IconHeart, IconClose, IconMenu, IconArrow, IconArrowL, IconStar, IconCheck, IconTruck, IconLeaf, IconShield,
});
