/* ==========================================================================
   ASUNA PARFUMERIE — Popup Favoris (fenêtre centrée)
   Dépend de tokens.css. Comportement : assets/js/product-card.js (construit le popup à la demande)
   ========================================================================== */

.fav-modal {
  --fav-pad: 32px;
  --fav-line: #e7ded3;
  --fav-success-bg: #eaf6ec;
  --fav-success-line: #b8dfc1;
  --fav-success-ink: #247a3d;
  --fav-error-bg: #fbeeea;
  --fav-error-line: #ecc9be;
  --fav-error-ink: #8e3a26;

  width: min(640px, calc(100% - 32px));
  max-width: none;
  max-height: min(86vh, 720px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--asuna-ivory-light);
  color: var(--asuna-brown);
  font-family: var(--asuna-font-ui);
  box-shadow: 0 30px 80px rgba(28, 13, 5, 0.35);
  overflow: hidden;
}

.fav-modal[open] {
  display: flex;
  animation: fav-modal-in 0.28s var(--asuna-ease);
}

.fav-modal::backdrop {
  background: rgba(28, 13, 5, 0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fav-backdrop-in 0.28s ease;
}

/* Pas de défilement de la page derrière le popup */
html.has-modal {
  overflow: hidden;
}

.fav-modal__inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  padding: 0 var(--fav-pad);
}

/* En-tête */
.fav-modal__head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 0 20px;
  border-bottom: 1px solid var(--fav-line);
}

.fav-modal__title {
  margin: 0;
  color: var(--asuna-brown);
  font-family: var(--asuna-font-display);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.1;
  font-variant-numeric: lining-nums;
}

.fav-modal__close {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-right: -8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--asuna-brown);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.fav-modal__close svg {
  width: 26px;
  height: 26px;
}

.fav-modal__close:hover {
  background: var(--asuna-sand);
}

/* Message de confirmation / d'erreur */
.fav-modal__notice {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 11px 14px;
  border: 1px solid var(--fav-success-line);
  border-radius: 10px;
  background: var(--fav-success-bg);
  color: var(--fav-success-ink);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
}

.fav-modal__notice[hidden] {
  display: none;
}

.fav-modal__notice[data-tone="error"] {
  border-color: var(--fav-error-line);
  background: var(--fav-error-bg);
  color: var(--fav-error-ink);
}

.fav-modal__notice svg {
  flex: none;
  width: 20px;
  height: 20px;
}

.fav-modal__notice.is-visible {
  animation: fav-notice-in 0.35s var(--asuna-ease) both;
}

.fav-modal__notice.is-leaving {
  animation: fav-notice-out 0.45s ease both;
}

/* Liste */
.fav-modal__list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.fav-modal__list[hidden] {
  display: none;
}

.fav-item {
  display: grid;
  grid-template-columns: 28px 120px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 20px;
  padding: 20px 0;
}

.fav-item + .fav-item {
  border-top: 1px solid var(--fav-line);
}

.fav-item__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: -4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--asuna-brown);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.fav-item__remove svg {
  width: 20px;
  height: 20px;
}

.fav-item__remove:hover {
  background: var(--asuna-sand);
}

.fav-item__media {
  display: block;
  width: 120px;
  height: 150px;
  overflow: hidden;
  border-radius: 22px;
  background: var(--asuna-sand);
}

.fav-item__media img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

.fav-item__info {
  min-width: 0;
}

.fav-item__name {
  display: block;
  margin: 0;
  color: var(--asuna-brown);
  font-family: var(--asuna-font-display);
  font-size: 21px;
  line-height: 1.2;
  text-decoration: none;
  overflow-wrap: anywhere;
}

a.fav-item__name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.fav-item__brand {
  margin: 6px 0 0;
  color: var(--asuna-text-muted);
  font-size: 14px;
}

.fav-item__price {
  margin: 10px 0 0;
  color: var(--asuna-brown);
  font-size: 17px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.fav-item__add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--asuna-radius-pill);
  background: var(--asuna-brown);
  color: var(--asuna-on-dark);
  font-family: var(--asuna-font-ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.fav-item__add:hover:not(:disabled) {
  background: var(--asuna-brown-2);
}

.fav-item__add:disabled {
  opacity: 0.75;
  cursor: progress;
}

.fav-item__spinner {
  display: none;
}

.fav-item__add[data-state="loading"] .fav-item__spinner {
  display: block;
  width: 13px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: fav-spin 0.7s linear infinite;
}

/* Aucun favori */
.fav-modal__empty {
  margin: 0;
  padding: 40px 0;
  color: var(--asuna-text-muted);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.fav-modal__empty[hidden] {
  display: none;
}

/* Pied */
.fav-modal__foot {
  display: flex;
  flex: none;
  justify-content: flex-end;
  padding: 18px 0 24px;
  border-top: 1px solid var(--fav-line);
}

.fav-modal__continue {
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--asuna-brown);
  font-family: var(--asuna-font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-underline-offset: 4px;
}

.fav-modal__continue:hover {
  text-decoration: underline;
}

.fav-modal__close:focus-visible,
.fav-modal__continue:focus-visible,
.fav-item__remove:focus-visible,
.fav-item__add:focus-visible,
.fav-item__name:focus-visible {
  outline: 2px solid var(--asuna-champagne);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Mobile : même popup centré, bouton sous les informations
   -------------------------------------------------------------------------- */
@media (max-width: 559.98px) {
  .fav-modal {
    --fav-pad: 18px;
    width: calc(100% - 24px);
    max-height: calc(100% - 120px);
    border-radius: 16px;
  }

  .fav-modal__head {
    padding: 18px 0 14px;
  }

  .fav-modal__title {
    font-size: 27px;
  }

  .fav-modal__close svg {
    width: 22px;
    height: 22px;
  }

  .fav-modal__notice {
    margin-top: 12px;
    padding: 10px 12px;
    font-size: 12.5px;
  }

  .fav-item {
    grid-template-columns: 24px 84px minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 10px;
    padding: 16px 0;
  }

  .fav-item__remove {
    grid-row: 1 / span 2;
    width: 28px;
    height: 28px;
    margin-left: -6px;
  }

  .fav-item__remove svg {
    width: 18px;
    height: 18px;
  }

  .fav-item__media {
    grid-row: 1 / span 2;
    width: 84px;
    height: 105px;
    border-radius: 16px;
  }

  .fav-item__name {
    font-size: 18px;
  }

  .fav-item__brand {
    margin-top: 3px;
    font-size: 12.5px;
  }

  .fav-item__price {
    margin-top: 5px;
    font-size: 14.5px;
  }

  .fav-item__add {
    grid-column: 3;
    justify-self: start;
    height: 36px;
    padding: 0 16px;
    font-size: 10.5px;
  }

  .fav-modal__foot {
    justify-content: center;
    padding: 14px 0 18px;
  }
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes fav-modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes fav-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fav-notice-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

@keyframes fav-notice-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes fav-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .fav-modal[open],
  .fav-modal::backdrop,
  .fav-modal__notice.is-visible,
  .fav-modal__notice.is-leaving {
    animation-duration: 1ms;
  }
}
