/* Responsive : page suggestions (fenêtre étroite → large). Tout est scopé body.embed. */

body.embed #page-suggestions{container:pg-sugg / inline-size}

/* Barre de recherche collante : toujours accessible pendant le défilement de la grille */
body.embed #page-suggestions .toolbar-card{
  position:sticky;top:0;z-index:6;
  padding:clamp(10px,1.6cqw,16px) clamp(12px,2cqw,20px);
  box-shadow:0 6px 16px -10px rgba(20,30,40,.25);
}
body.embed #page-suggestions .toolbar-card .muted{overflow-wrap:anywhere}
body.embed #sg-search{max-width:min(520px,100%);min-height:40px}

/* Grille fluide : le nombre de colonnes suit la largeur, les cartes restent lisibles */
body.embed #sg-grid{
  grid-template-columns:repeat(auto-fill,minmax(clamp(150px,20cqw,230px),1fr));
  gap:clamp(10px,1.6cqw,18px);
  align-items:stretch;
}
body.embed #sg-grid>.muted{grid-column:1/-1}
body.embed #sg-grid .product-card{min-width:0;min-height:44px}
body.embed #sg-grid .product-card:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
body.embed #sg-grid .product-thumb{height:auto;aspect-ratio:4/3;max-height:170px}
body.embed #sg-grid .product-body{padding:clamp(8px,1.2cqw,12px) clamp(10px,1.4cqw,14px) clamp(10px,1.4cqw,14px)}
body.embed #sg-grid .product-title,
body.embed #sg-grid .product-meta{overflow-wrap:anywhere;min-width:0}
body.embed .sg-link-count{position:absolute;top:8px;left:8px;max-width:calc(100% - 16px);white-space:nowrap;border-radius:999px}

/* Hauteur basse : vignettes plus petites, barre de recherche compacte */
@media (max-height:700px){
  body.embed #sg-grid .product-thumb{aspect-ratio:16/10;max-height:110px}
  body.embed #page-suggestions .toolbar-card{padding-block:8px}
  body.embed #page-suggestions .toolbar-card .muted{margin-top:4px!important}
}

@container pg-sugg (max-width:620px){
  body.embed #sg-grid{grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:10px}
  body.embed #page-suggestions .toolbar-card .muted{display:none}
}
@container pg-sugg (min-width:1500px){
  body.embed #sg-grid{grid-template-columns:repeat(auto-fill,minmax(240px,1fr))}
}

/* ---------- Fenêtre de liaison : tient dans la fenêtre, défilement interne ---------- */
body.embed #sg-links-modal{padding:clamp(8px,2vw,24px);overflow:hidden}
body.embed #sg-links-modal .modal{
  display:flex;flex-direction:column;
  width:min(900px,100%);max-width:100%;
  max-height:calc(100dvh - 2*clamp(8px,2vw,24px));
  padding:clamp(14px,2.4vw,24px);overflow:hidden;box-sizing:border-box;
}
body.embed #sg-links-modal .modal>.filters-row{flex:none;flex-wrap:nowrap;margin-bottom:12px}
body.embed #sg-links-modal #sgl-photo{flex:none}
body.embed #sg-links-modal #sgl-title,body.embed #sg-links-modal #sgl-subtitle{overflow-wrap:anywhere}
body.embed #sg-links-modal .modal>.filters-row>div:last-child{min-width:0}
body.embed #sg-links-modal .split{
  flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:clamp(12px,2vw,24px);align-items:start;
}
body.embed #sg-links-modal .split-side{min-width:0!important;flex:none!important}
body.embed #sg-links-modal .cart-item{min-height:44px}
body.embed #sg-links-modal .cart-item .name{min-width:0;overflow-wrap:anywhere}
body.embed #sg-links-modal .cart-item .btn,
body.embed #sg-links-modal .cart-item .icon-btn{flex:none;min-height:36px;min-width:36px}
body.embed #sg-links-modal .sg-compat-bad{cursor:pointer;padding-block:4px}
body.embed #sg-links-modal #sgl-search{width:100%;min-height:40px}
body.embed #sg-links-modal .sg-direction-choice{display:flex;flex-direction:column;gap:2px}
body.embed #sg-links-modal .sg-direction-choice label{display:flex;align-items:center;gap:8px;min-height:36px;cursor:pointer}
body.embed #sg-links-modal #sgl-links-list{max-height:none;overflow:visible}
body.embed #sg-links-modal #sgl-search-results{max-height:min(320px,40dvh)!important}
body.embed #sg-links-modal .modal-actions{
  flex:none;margin-top:12px;padding-top:12px;border-top:1px solid var(--border);
}
body.embed #sg-links-modal .modal-actions .btn{min-height:40px}

@media (max-width:760px){
  body.embed #sg-links-modal .split{grid-template-columns:minmax(0,1fr)}
  body.embed #sg-links-modal #sgl-search-results{max-height:none!important}
}
@media (max-width:480px){
  body.embed #sg-links-modal .modal-actions .btn{width:100%}
}
@media (max-height:600px){
  body.embed #sg-links-modal .modal{padding:12px}
  body.embed #sg-links-modal .modal>.filters-row{margin-bottom:8px}
}
