/**
 * Modal «afegit a la cistella». Es carrega global (glob de pages/*.css) però
 * només es veu quan el JS lleva [hidden] del host #reclam-added.
 * Layout propi: targeta centrada en desktop, bottom-sheet en mòbil.
 */

.afegit[hidden] { display: none; }

.afegit {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.afegit__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 20, 24, 0.5);
  animation: afegit-fade 0.2s ease-out;
}

.afegit__panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--paper-card);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -12px rgba(28, 20, 24, 0.35);
  padding: 28px 30px 26px;
  animation: afegit-rise 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.afegit__x {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  padding: 6px;
  color: var(--ink-soft);
  border-radius: var(--radius);
  transition: color 0.15s ease, background 0.15s ease;
}
.afegit__x:hover { color: var(--ink); background: var(--paper-2); }

/* Cap: check verd + títol + comptador */
.afegit__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: 24px;
}
.afegit__check {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
}
.afegit__msg {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.2;
  color: var(--ink);
  margin: 0;
}
.afegit__count {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-soft);
  margin: 2px 0 0;
}

/* Producte: una sola fila (portada + dades), sense divisor vertical */
.afegit__product {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin: 22px 0;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.afegit__cover {
  flex: 0 0 auto;
  width: 56px;
  height: 82px;
  object-fit: contain;
  border-radius: 2px;
}
.afegit__pinfo {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.afegit__ptitle {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  color: var(--wine);
}
.afegit__ptitle:hover { color: var(--wine-deep); }
.afegit__pauthor {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-soft);
}
.afegit__pprice {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 4px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
}
.afegit__qty {
  font-weight: 400;
  font-size: 13px;
  color: var(--ink-soft);
}

/* Totals: llista compacta, total ressaltat per pes i regla */
.afegit__totals {
  margin: 0 0 22px;
}
.afegit__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-soft);
  padding: 5px 0;
}
.afegit__row dt { margin: 0; }
.afegit__row dd { margin: 0; }
.afegit__row--total {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.afegit__row--total small {
  font-weight: 400;
  font-size: 12px;
  color: var(--ink-faint);
}

/* Accions: jerarquia de tres nivells (sòlid → contorn → enllaç) */
.afegit__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.afegit__checkout {
  width: 100%;
  justify-content: center;
}

/* Secundari: botó buit, mateixa alçada que el primari però recessiu */
.afegit__continue {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15px;
  padding: 13px 26px;
  border-radius: 2px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--paper-card);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.afegit__continue:hover {
  background: var(--paper-2);
  border-color: var(--ink-soft);
}

/* Terciari: enllaç discret, centrat sota els dos botons */
.afegit__cartlink {
  align-self: center;
  margin-top: 2px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}
.afegit__cartlink:hover { color: var(--ink); }

.fitxa-buy__cart.is-loading { opacity: 0.6; pointer-events: none; }

body.afegit-open { overflow: hidden; }

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

/* Mòbil: hoja inferior (bottom-sheet) que puja des de baix */
@media (max-width: 600px) {
  .afegit {
    align-items: flex-end;
    padding: 0;
  }
  .afegit__panel {
    max-width: none;
    border-radius: 14px 14px 0 0;
    padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
    animation: afegit-sheet 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes afegit-sheet {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .afegit__backdrop,
  .afegit__panel { animation: none; }
}
