/* ==== SEZIONE CATALOGO COMPATTO ==== */
main.grid{
  max-width: var(--am-maxw);
  margin: 20px auto 80px;
  padding: 0 var(--am-pad);
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: clamp(14px, 2.4vw, 22px);
  font-family: var(--am-font, "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
  color: var(--am-text, #111);
}

main.grid *{ box-sizing: border-box; }

/* Card prodotto */
.card{
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 8px;
  background:#fff;
  border:1px solid var(--am-border, rgba(0,0,0,.12));
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0,0,0,.04);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover{
  transform: translateY(-2px);
  box-shadow: 0 16px 44px rgba(0,0,0,.08);
  border-color: rgba(0,0,0,.16);
}

/* Media con ratio 3:4 (verticale) */
.card > img{
  width:100%; display:block;
  border-radius: 0;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background:#f6f6f6;
  image-rendering: auto;
}

/* Titolo + prezzo */
.card h2{
  margin: 8px 12px 0;
  font-size: 16px; line-height:1.25; font-weight:800;
}
.card .price{
  margin: 0 12px 4px;
  font-weight:800;
}

.card__availability{
  margin: 0 12px 6px;
  font-size: 14px;
  font-weight: 700;
  color: #b00020;
}

.card.is-unavailable .addToCart{
  opacity: .7;
  cursor: not-allowed;
}

.card.is-unavailable input.qty{
  opacity: .7;
}

/* Varianti e quantità */
.card label{
  display:flex; align-items:center; justify-content:space-between;
  gap: 10px; margin: 0 12px;
  font-size: 14px; color: var(--am-muted, #666);
}

.card select.variant,
.card input.qty{
  flex: 0 0 56%;
  height: 40px;
  border:1px solid var(--am-border, rgba(0,0,0,.12));
  border-radius: 10px;
  padding: 0 10px;
  background:#fff; color: var(--am-text, #111);
  font-weight:600;
  min-width:0;
}
.card input.qty{ width: 120px; }

/* Quantity controls with +/- buttons */
.qty-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
}
.qty-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #000;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}
.qty-btn:active {
  transform: translateY(1px);
}
.card input.qty {
  width: 70px;
  font-size: 16px;
  text-align: center;
  border: none;
  outline: none;
  box-shadow: none;
  background: #fff;
}
#psQty {
  width: 70px;
  font-size: 16px;
  text-align: center;
  border: none;
  outline: none;
  box-shadow: none;
  background: #fff;
}
/* Hide browser number spinners for quantity inputs */
.qty-control input[type="number"],
#psQty[type="number"],
.card input.qty[type="number"] {
  -moz-appearance: textfield;
}
.qty-control input[type="number"]::-webkit-outer-spin-button,
.qty-control input[type="number"]::-webkit-inner-spin-button,
#psQty::-webkit-outer-spin-button,
#psQty::-webkit-inner-spin-button,
.card input.qty::-webkit-outer-spin-button,
.card input.qty::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Desktop specific adjustments */
@media (min-width: 769px) {
}

/* CTA */
.card .addToCart{
  margin: 8px 12px 12px;
  width: calc(100% - 24px);
  height: 44px;
  border-radius: 999px;
  background: #111; color:#fff; border:1px solid transparent;
  font-weight: 800; cursor:pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.card .addToCart:hover{
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0,0,0,.12);
}

/* Focus accessibile */
.card select:focus-visible,
.card input.qty:focus-visible,
.card .addToCart:focus-visible{
  outline:2px solid #0b63ff; outline-offset:2px;
}

/* ====== Responsive ====== */
@media (max-width: 1100px){
  main.grid{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .card input.qty{ width: 100px; }
}
@media (max-width: 640px){
  main.grid{ grid-template-columns: 1fr; gap: 14px; }
  .card{ border-radius: 0; }
  .card select.variant,
  .card input.qty{ flex-basis: 60%; height: 38px; }
  .card .addToCart{ height: 42px; }
}


/* ===== Product Sheet (modal) ===== */
:root{
  --ps-z: 1200;
  --ps-backdrop: rgba(17,17,17,.52);
  --ps-border: rgba(17,17,17,.12);
  --ps-radius: 18px;
}

body.ps-lock { overflow: hidden; }
body.ps-dim main,
body.ps-dim header,
body.ps-dim footer {
  filter: none;
  transition: none;
}

.ps-overlay[hidden] { display: none; }
.ps-overlay{
  position: fixed;
  inset: 0;
  z-index: var(--ps-z);
  display: grid;
  place-items: center;
  background: var(--ps-backdrop);
  backdrop-filter: blur(2px);
  animation: psFade .18s ease;
  overscroll-behavior: contain;
}
@keyframes psFade { from { opacity: 0 } to { opacity: 1 } }

.ps-dialog{
  width: min(1120px, calc(100% - 32px));
  max-height: 94vh;
  background: #fff;
  color: #111;
  border-radius: var(--ps-radius);
  box-shadow: 0 32px 90px rgba(17,17,17,.28);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  transform: translateY(12px) scale(.98);
  animation: psRise .22s ease forwards;
}
@keyframes psRise { to { transform: translateY(0) scale(1) } }

.ps-head{
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px 0;
}

.ps-close{
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 26px;
  line-height: 34px;
  text-align: center;
  border: 1px solid var(--ps-border);
  background: #fff;
  cursor: pointer;
  transition: background .18s ease;
}
.ps-close:hover{ background: #f3f3f3; }

.ps-body,
.ps-panel,
.ps-nav{
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 32px;
  padding: 16px clamp(20px, 4vw, 36px) clamp(22px, 4vw, 32px);
  overflow: auto;
  font-family: var(--am-font, "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
}

.ps-gallery{
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 18px;
  align-self: stretch;
}

.ps-main{
  position: relative;
  border-radius: 0;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(17,17,17,.06);
  display: flex;
  align-items: center;
  justify-content: center;
  height: clamp(360px, 65vh, 720px);
  min-height: 320px;
  overflow: hidden;
}
.ps-main img{
  width: auto;
  height: 100%;
  max-width: 100%;
  border-radius: 0;
  object-fit: contain;
  object-position: center;
  display: block;
}

.ps-thumbs{
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.ps-thumbs-viewport{
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.ps-thumbs-viewport::-webkit-scrollbar{ display: none; }

.ps-thumbs-track{
  display: flex;
  gap: 10px;
  padding-bottom: 4px;
}

.ps-thumb{
  flex: 0 0 86px;
  width: 86px;
  height: 86px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(17,17,17,.14);
  background: #fff;
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease;
}
.ps-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ps-thumb:hover{ transform: translateY(-2px); }
.ps-thumb.is-active{
  border-color: #0b63ff;
  box-shadow: 0 0 0 2px rgba(11,99,255,.24);
}

.ps-thumb-nav{
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(17,17,17,.12);
  background: #fff;
  box-shadow: 0 6px 16px rgba(17,17,17,.12);
  cursor: pointer;
  font-size: 20px;
  line-height: 32px;
  text-align: center;
  color: #111;
}
.ps-thumb-nav::before{
  content: '›';
}
.ps-thumb-nav--prev::before{
  content: '‹';
}
.ps-thumb-nav[disabled]{
  opacity: .35;
  cursor: default;
  box-shadow: none;
}

.ps-info{
  display: grid;
  gap: 18px;
  align-content: start;
}

.ps-info-head{
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: baseline;
}

.ps-title{
  margin: 0;
  width: 100%;
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 800;
  line-height: 1.1;
}

.ps-price{
  display: inline;
  font-size: clamp(20px, 2.6vw, 26px);
  font-weight: 700;
  color: #0b63ff;
}

.ps-currency{
  display: inline;
  font-size: clamp(20px, 2.6vw, 26px);
  font-weight: 700;
  color: #0b63ff;
}

.ps-availability{
  width: 100%;
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
  color: #b00020;
}

.ps-desc{
  font-size: 16px;
  line-height: 1.7;
  color: #333;
}
.ps-desc p{ margin: 0 0 12px; }
.ps-desc ul{
  margin: 0 0 12px 20px;
  padding: 0;
}
.ps-desc li{ margin: 6px 0; }

.ps-form{
  display: grid;
  gap: 16px;
}

.ps-variants{
  display: grid;
  gap: 12px;
}

.ps-field{
  display: grid;
  gap: 6px;
}
.ps-field label{
  font-size: 14px;
  color: #555;
}
.ps-field select{
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(17,17,17,.16);
  padding: 0 12px;
  font-weight: 600;
  color: #111;
}

.ps-qty{
  display: grid;
  gap: 6px;
}
.ps-qty label{
  font-size: 14px;
  color: #555;
}
#psQty{
  width: 120px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(17,17,17,.16);
  padding: 0 12px;
  font-weight: 600;
}

.ps-add{
  justify-self: start;
  height: 52px;
  padding: 0 34px;
  border-radius: 999px;
  border: none;
  background: #111;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.ps-add[disabled]{
  opacity: .7;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.ps-add:hover{
  transform: translateY(-1px);
  box-shadow: 0 18px 36px rgba(17,17,17,.24);
}

@media (max-width: 960px){
  .ps-body{
    overflow: hidden;
    overscroll-behavior: contain;
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .ps-gallery{
    order: 1;
    display: flex;
    flex-direction: column;
  }
  .ps-info{ order: 2; }
}

@media (max-width: 640px){
  .ps-overlay{
    justify-items: stretch;
    align-items: start;
    padding: 0;
  }
  .ps-dialog{
    width: 100%;
    min-height: 100dvh;
    max-height: none;
    border-radius: 0;
    margin: 0;
  }
  .ps-head{
    padding: max(env(safe-area-inset-top, 12px),12px) 20px 0;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
  }
  .ps-close{
    width: 44px;
    height: 44px;
    font-size: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .ps-body{
    overflow: hidden;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding:
      12px
      max(18px, env(safe-area-inset-right, 18px))
      max(24px, env(safe-area-inset-bottom, 24px))
      max(18px, env(safe-area-inset-left, 18px));
    height: calc(100dvh - 76px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ps-gallery{
    order: 1;
  }
  .ps-main{
    height: auto;
    aspect-ratio: 3 / 4;
    max-height: 60vh;
  }
  .ps-info{
    order: 2;
    gap: 14px;
  }
  .ps-thumb{
    flex-basis: 64px;
    width: 64px;
    height: 64px;
  }
  .ps-add{
    width: 100%;
    justify-self: stretch;
  }
}

.ps-thumb:focus-visible,
.ps-thumb-nav:focus-visible,
.ps-close:focus-visible,
#psQty:focus-visible,
.ps-field select:focus-visible,
.ps-add:focus-visible{
  outline: 2px solid #0b63ff;
  outline-offset: 2px;
}

/* sicurezza: nessuna descrizione nelle card della griglia */
.card .desc,
.card .description { display: none !important; }
