/* Widget flottante "Lista". Foglio autosufficiente: compare anche dove non vale il reset di
   mg-design.css (blog, pagine, account), quindi azzera da se' cio' che usa. */

/* I reset stanno in :where(): battono gli elementi dei fogli legacy ma non le classi del widget. */
.mg-wlw,
.mg-wlw *,
.mg-wlw *::before,
.mg-wlw *::after {
  box-sizing: border-box;
}

.mg-wlw :where(p, ul, li) {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mg-wlw :where(a) {
  text-decoration: none;
}

.mg-wlw :where(svg, img) {
  display: block;
}

.mg-wlw :where(button) {
  margin: 0;
  font-family: inherit;
}

/* Nascosto fino a .is-ready (aggiunta dallo script) e sotto la soglia della barra carrello:
   visibile per default e nascosto con max-width, cosi' le due non coesistono mai. */
.mg-wlw {
  display: none;
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--mg-consent-h, 0px));
  z-index: 95;
  font-family: var(--font-ui);
  line-height: normal;
}
.mg-wlw.is-ready { display: block; }

@media (max-width: 680px) {
  .mg-wlw.is-ready { display: none; }
}

@media not all and (max-width: 680px) {
  /* L'ultima riga del disclaimer non resta sotto il widget. */
  body.mg-has-wlw .mg-footer-meta { padding-bottom: 88px; }

  /* Il link dell'header e' ridondante solo a widget pronto; senza :has() resta visibile. */
  body:has(#mg-wlw.is-ready) .mg-wl-link { display: none; }
}

/* Dove il pannello non entra sopra il banner, il banner prende il posto del widget.
   visibility e non z-index: il widget nascosto esce anche dalla tabulazione. */
@media (max-height: 590px) {
  html.mg-consent-open .mg-wlw { visibility: hidden; }
}

@media print {
  .mg-wlw { display: none; }
}

/* ---------- pulsante ---------- */

.mg-wlw-fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 18px 0 14px;
  border: var(--outline-w) solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.mg-wlw-fab svg {
  width: 22px;
  height: 22px;
  flex: none;
}
.mg-wlw-label {
  padding-top: 2px;
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.mg-wlw-fab:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
}
.mg-wlw-fab:active {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-press);
}
.mg-wlw-fab:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 3px;
  box-shadow: var(--shadow), 0 0 0 3px var(--surface);
}
.mg-wlw-fab[aria-expanded="true"] {
  background: var(--ink);
  color: var(--accent);
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--accent);
}

/* Il frammento non deve aggiungere un elemento al flex del pulsante (il gap). */
.mg-wlw-count { display: contents; }

.mg-wlw-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--ink);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}
.mg-wlw-fab[aria-expanded="true"] .mg-wlw-badge {
  background: var(--accent);
  color: var(--ink);
}
.mg-wlw-badge.is-pop { animation: pop .7s cubic-bezier(.34, 1.56, .64, 1); }

/* ---------- pannello ---------- */

.mg-wlw-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  display: flex;
  flex-direction: column;
  width: 360px;
  max-height: min(520px, calc(100vh - var(--mg-nav-h, 85px) - 100px - var(--mg-consent-h, 0px)));
  overflow: hidden;
  border: var(--outline-w) solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  animation: mg-wlw-in .14s ease-out;
}
/* display:flex sopra batte l'[hidden] dello user agent. */
.mg-wlw-panel[hidden] { display: none; }
@keyframes mg-wlw-in { from { opacity: 0; transform: translateY(8px); } }

.mg-wlw-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding: 8px 8px 8px 16px;
  border-bottom: var(--dash);
}
.mg-wlw-title {
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink);
}
.mg-wlw-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.mg-wlw-close svg { width: 18px; height: 18px; }
.mg-wlw-close:hover { background: var(--accent-soft); }

.mg-wlw-close:focus-visible,
.mg-wlp-link:focus-visible,
.mg-wlp-remove:focus-visible,
.mg-wlp-summary:focus-visible,
.mg-wlp-empty-title:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
}

.mg-wlp-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mg-wlp-loading {
  padding: 24px 16px;
  font-size: 14px;
  text-align: center;
  color: var(--ink-2);
}
.mg-wlp-loading-late { display: none; color: var(--danger); }
.mg-wlw.is-stale .mg-wlp-loading-wait { display: none; }
.mg-wlw.is-stale .mg-wlp-loading-late { display: block; }

.mg-wlp-summary {
  flex: none;
  padding: 12px 16px 4px;
  font-family: var(--font-graff);
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 1.5px;
  color: var(--ink);
}

.mg-wlp-list {
  flex: 1 1 auto;
  /* Viewport basso: la lista non si riduce a zero, scorre il corpo del pannello. */
  min-height: 96px;
  padding: 0 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mg-wlp-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  column-gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1.5px dashed rgba(21, 17, 13, .25);
}
.mg-wlp-row:last-child { border-bottom: 0; }
.mg-wlp-row.is-removing {
  opacity: .6;
  cursor: progress;
  pointer-events: none;
}

.mg-wlp-thumb {
  width: 56px;
  height: 56px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: var(--surface-2);
}
.mg-wlp-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mg-wlp-link {
  display: block;
  min-height: 56px;
  color: var(--ink);
}
.mg-wlp-link:hover .mg-wlp-name { text-decoration: underline; }
.mg-wlp-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}
.mg-wlp-attrs {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.3;
  color: var(--ink-2);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.mg-wlp-price {
  display: block;
  margin-top: 6px;
  font-family: var(--font-graff);
  font-size: 18px;
  line-height: 1;
  letter-spacing: 1.5px;
  color: var(--ink);
}
.mg-wlp-price del {
  margin-right: 4px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink-3);
  text-decoration: line-through;
}
.mg-wlp-price ins {
  background: none;
  color: var(--ink);
  text-decoration: none;
}
/* .screen-reader-text di style.css non nasconde nulla. */
.mg-wlp-price .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.mg-wlp-remove {
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.mg-wlp-remove:hover { color: var(--ink); }

.mg-wlp-more {
  flex: none;
  padding: 8px 16px 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-2);
}

.mg-wlp-foot {
  flex: none;
  padding: 12px 16px 16px;
  border-top: var(--dash);
}

.mg-wlp-error {
  flex: none;
  padding: 12px 16px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--danger);
}

.mg-wlp-empty-title {
  padding: 24px 16px 0;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.2;
  color: var(--ink);
}
.mg-wlp-empty-text {
  margin: 8px 0 16px;
  padding: 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}
.mg-wlp-body > .mg-btn {
  width: auto;
  margin: 0 16px 20px;
}

@media (prefers-reduced-motion: reduce) {
  .mg-wlw-fab { transition: none; }
  .mg-wlw-badge.is-pop,
  .mg-wlw-panel { animation: none; }
}
