/* ============================================================================
   Wishlist-Stile
   - Herz-Button auf Produktkarten (.product-card__wishlist)
   - Herz-Button auf PDP (.product-hero__wishlist)
   - Header-Badge Counter (.wishlist-toggle + .wishlist-toggle__badge)
   - Wishlist-Seite (.wishlist-page)
   - Inactive-Card-Modifier (.product-card--inactive)
   ============================================================================ */

:root {
  /* Aktives Herz + Badge: Sustainability-Grün (Marken-CI, gleiche Familie wie Footer). */
  --wl-color:       #2d6a4f;
  --wl-color-hover: #1b4332;
}

/* ---------- Produktkarte: Herz-Button ---------- */
.product-card { position: relative; }

/*
 * Herz-Button UX-Pattern (Zalando/ASOS/Amazon):
 * Farbe = State (inaktiv = outline dunkel, aktiv = gefüllt grün).
 * Hover ändert NUR Button-Container (Background/Shadow), niemals die Herz-Farbe.
 * Grund: Nach Klick bleibt die Maus am Button → wenn Hover eine Farb-Vorschau
 * auf den gegenteiligen State zeigte, würde das State-Feedback sofort
 * überschrieben werden.
 * Klick-Feedback: kurze Bump-Animation (wl-pulse-Klasse, vom JS gesetzt).
 */

.product-card__wishlist {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--c-text);
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.product-card__wishlist svg {
  fill: none;
  stroke: currentColor;
}

.product-card__wishlist:focus-visible {
  outline: 2px solid var(--c-text);
  outline-offset: 2px;
}

/* Hover nur auf Geräten mit echtem Zeiger (kein Sticky-Hover auf Touch). */
@media (hover: hover) {
  .product-card__wishlist:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  }
}

/* Sanfter "Herzschlag" beim Hover — gated hinter reduced-motion + hover-fähigem Zeiger. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .product-card__wishlist:hover svg {
    animation: wl-heartbeat 1.6s ease-in-out infinite;
  }
}

@keyframes wl-heartbeat {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.1); }
}

/* Aktiver State: gefülltes grünes Herz — unabhängig vom Hover. */
.product-card__wishlist[aria-pressed="true"] {
  color: var(--wl-color);
}

.product-card__wishlist[aria-pressed="true"] svg {
  fill: var(--wl-color);
  stroke: var(--wl-color);
}

/* Klick-Feedback: Bump-Animation nur bei tatsächlichem Toggle (nicht bei Page-Load-Hydration). */
@media (prefers-reduced-motion: no-preference) {
  .product-card__wishlist.wl-pulse svg {
    animation: wl-bump 200ms ease-out;
  }
}

@keyframes wl-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ---------- Produktkarte: Inactive-Modus ---------- */
.product-card--inactive {
  position: relative;
}

.product-card--inactive .product-card__media img,
.product-card--inactive .product-card__media {
  filter: grayscale(1);
  opacity: 0.6;
}

.product-card--inactive .product-card__title,
.product-card--inactive .product-card__price,
.product-card--inactive .product-card__merchant {
  opacity: 0.6;
}

.product-card--inactive .product-card__price { text-decoration: line-through; }

.product-card__badge--inactive {
  background: #555;
  color: #fff;
}

.product-card__remove {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--c-text);
  background: transparent;
  color: var(--c-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius, 8px);
  transition: background 0.15s ease, color 0.15s ease;
}

.product-card__remove:hover {
  background: var(--c-text);
  color: #fff;
}

.product-card__remove:focus-visible {
  outline: 2px solid var(--c-text);
  outline-offset: 2px;
}

/* ---------- PDP: Herz-Button neben primärem CTA (Zalando-Pattern: Icon-only) ---------- */
/* Container flex, damit Button neben CTA liegt; CTA behält Natural-Width (min-width: 260px). */
.product-hero__cta {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
}

.product-hero__cta-vendor {
  flex-basis: 100%;
  margin-top: 0;
}

.product-hero__wishlist {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  min-height: 52px;
  padding: 0;
  border: 1.5px solid var(--c-text);
  background: transparent;
  color: var(--c-text);
  cursor: pointer;
  border-radius: var(--radius, 8px);
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

/* Einheitlicher sanfter grauer Hover — unabhängig vom aktiven Zustand. */
.product-hero__wishlist:hover {
  background: #f1f1f1;
}

.product-hero__wishlist:focus-visible {
  outline: 2px solid var(--c-text);
  outline-offset: 2px;
}

.product-hero__wishlist[aria-pressed="true"] {
  border-color: var(--wl-color);
  color: var(--wl-color);
}

.product-hero__wishlist[aria-pressed="true"] svg {
  fill: var(--wl-color);
  stroke: var(--wl-color);
}


/* ---------- Header-Badge Counter ---------- */
.wishlist-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--c-text);
  text-decoration: none;
  border-radius: 50%;
  transition: color 0.15s ease, background 0.15s ease;
}

/* Header-Button ist ein Link (Navigation), kein Toggle. Hover gibt nur subtiles "klickbar"-Feedback. */
@media (hover: hover) {
  .wishlist-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
  }
}

.wishlist-toggle:focus-visible {
  outline: 2px solid var(--c-text);
  outline-offset: 2px;
}

.wishlist-toggle__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--wl-color);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

html[data-wishlist-has="1"] .wishlist-toggle__badge { display: inline-flex; }

/* Wenn Wunschliste gefüllt: gefülltes Herz. */
html[data-wishlist-has="1"] .wishlist-toggle svg {
  fill: var(--wl-color);
  stroke: var(--wl-color);
}

/* ---------- Wishlist-Seite ---------- */
.wishlist-page {
  padding-top: clamp(16px, 4vw, 32px);
  padding-bottom: clamp(40px, 8vw, 80px);
}

.wishlist-page__header {
  margin-bottom: 16px;
}

.wishlist-page__title {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 500;
  margin: 0 0 8px;
  color: var(--c-text);
}

.wishlist-page__count {
  margin: 0;
  color: var(--c-muted);
  font-size: 14px;
}

.wishlist-page__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0 24px;
}

.wishlist-page__clear-all,
.wishlist-page__clear-inactive {
  padding: 8px 14px;
  border: 1px solid var(--c-muted);
  background: transparent;
  color: var(--c-muted);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius, 8px);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.wishlist-page__clear-all:hover,
.wishlist-page__clear-inactive:hover {
  border-color: var(--c-text);
  color: var(--c-text);
}

.wishlist-page__clear-all:focus-visible,
.wishlist-page__clear-inactive:focus-visible {
  outline: 2px solid var(--c-text);
  outline-offset: 2px;
}

/* Globale Regel: hidden-Attribut hat Vorrang über display-Deklarationen. */
.wishlist-page [hidden] { display: none !important; }

/* Grid: gleiches Layout wie Archiv */
.wishlist-page__grid,
.wishlist-page__skeleton {
  display: grid;
  gap: clamp(16px, 2vw, 24px);
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 561px) {
  .wishlist-page__grid,
  .wishlist-page__skeleton {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 981px) {
  .wishlist-page__grid,
  .wishlist-page__skeleton {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Skeleton */
.wishlist-page__skeleton-card {
  aspect-ratio: 4/5;
  border-radius: var(--radius, 8px);
  background: linear-gradient(90deg, #ececec 0%, #f7f7f7 50%, #ececec 100%);
  background-size: 200% 100%;
}

@media (prefers-reduced-motion: no-preference) {
  .wishlist-page__skeleton-card {
    animation: wl-shimmer 1.4s infinite linear;
  }
}

@keyframes wl-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty-State */
.wishlist-page__empty {
  text-align: center;
  padding: clamp(40px, 8vw, 80px) 20px;
  color: var(--c-muted);
}

.wishlist-page__empty-icon {
  color: #d8cfc0;
  margin-bottom: 16px;
}

.wishlist-page__empty-title {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 500;
  margin: 0 0 8px;
  color: var(--c-text);
}

.wishlist-page__empty-text {
  margin: 0 0 24px;
  font-size: 15px;
}

.wishlist-page__empty-cta {
  display: inline-block;
  padding: 10px 24px;
  background: var(--c-text);
  color: var(--c-bg, #fff);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius, 8px);
  transition: background 0.15s ease;
}

.wishlist-page__empty-cta:hover { background: #000; }

.wishlist-page__empty-cta:focus-visible {
  outline: 2px solid var(--c-text);
  outline-offset: 2px;
}

/* Error-State */
.wishlist-page__error {
  grid-column: 1 / -1;
  padding: 24px;
  text-align: center;
  color: var(--c-muted);
  font-size: 14px;
}

/* ---------- Bestätigungs-Dialog (nativ <dialog>) ---------- */
.wl-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--c-bg, #fff);
  color: var(--c-text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  /* <dialog> setzt display:none per Default und display:block beim showModal() */
}

.wl-dialog::backdrop {
  background: rgba(38, 32, 21, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

@media (prefers-reduced-motion: no-preference) {
  .wl-dialog[open] {
    animation: wl-dialog-in 160ms ease-out;
  }
  .wl-dialog[open]::backdrop {
    animation: wl-backdrop-in 160ms ease-out;
  }
}

@keyframes wl-dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

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

.wl-dialog__body {
  padding: 28px;
}

.wl-dialog__title {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 8px;
  color: var(--c-text);
}

.wl-dialog__desc {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--c-muted);
}

.wl-dialog__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.wl-dialog__btn {
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius, 8px);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  min-width: 120px;
}

.wl-dialog__btn:focus-visible {
  outline: 2px solid var(--c-text);
  outline-offset: 2px;
}

.wl-dialog__btn--secondary {
  background: transparent;
  color: var(--c-text);
  border-color: var(--c-muted);
}

@media (hover: hover) {
  .wl-dialog__btn--secondary:hover {
    border-color: var(--c-text);
    background: rgba(0, 0, 0, 0.04);
  }
}

.wl-dialog__btn--primary {
  background: var(--c-text);
  color: var(--c-bg, #fff);
  border-color: var(--c-text);
}

@media (hover: hover) {
  .wl-dialog__btn--primary:hover {
    background: #000;
    border-color: #000;
  }
}

@media (max-width: 480px) {
  .wl-dialog__actions {
    flex-direction: column-reverse;
  }
  .wl-dialog__btn {
    width: 100%;
  }
}
