/* WP-G "Seguir producto" hearts, "Tus productos bajaron" block, opt-in card, sheet, toast.
   Tokens from css/tokens.css only, so [data-theme="light"] and dark both work. */

/* Text colours with at least 4.5:1 on their backgrounds (WCAG AA). The shared danger/success
   text tokens measure 3.98:1 (dark, on --surface-card) and 3.58:1 (light, on the pale green). */
:root {
    --wl-danger-text: #fb7185;   /* rose-400 on #1e293b: 5.4:1 */
    --wl-pct-text: var(--success-text);
    --wl-pct-bg: var(--success-overlay);
}
[data-theme="light"] {
    --wl-danger-text: var(--danger-text);
    --wl-pct-text: #047857;      /* green-700 on #ecfdf5: 5.2:1 */
    --wl-pct-bg: var(--success-bg);
}

/* --- hearts ---------------------------------------------------------------------- */
.wl-heart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-tertiary);
    cursor: pointer;
    font: inherit;
    line-height: 1;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.wl-heart .wl-heart-svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    flex: 0 0 auto;
}
.wl-heart.is-on {
    color: var(--wl-danger-text);
    border-color: var(--danger-border);
}
.wl-heart.is-on .wl-heart-svg { fill: currentColor; }
.wl-heart:active { transform: scale(0.94); }
.wl-heart:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }

.wl-heart--icon {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 6px;
    margin-left: 0.5rem;
    vertical-align: middle;
}
.product-price-center .wl-heart--icon { margin-left: 0.4rem; }

/* one heart for every product card (js/watchlist.js addHeart): top-right, a 44 px tap target, and
   the card keeps that corner free */
.wl-host { position: relative; padding-right: 44px !important; }
.wl-heart--card {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 1;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
}
.wl-heart--card .wl-heart-svg { width: 22px; height: 22px; }
.wl-heart--card.is-on { border: 0; }

.wl-heart--pill {
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface-control);
}
.wl-heart--pill .wl-heart-hint {
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--text-tertiary);
}
.wl-heart--pill.is-on { background: var(--danger-surface-faint); color: var(--wl-danger-text); }

.wl-follow-row {
    display: flex;
    justify-content: center;
    margin-top: 0.6rem;
}

/* --- home block ------------------------------------------------------------------ */
#watchlist-mount:not([hidden]) {
    display: block;
    width: 100%;
    max-width: 640px;
    margin: 0.9rem auto 0;
    box-sizing: border-box;
}
.wl-block,
.wl-optin {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 0.85rem 0.9rem;
    color: var(--text-primary);
    text-align: left;
}
.wl-optin { margin-top: 0.6rem; }
.wl-block + .wl-optin { margin-top: 0.6rem; }
.wl-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}
.wl-block-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-heading);
}
.wl-block-icon { color: var(--wl-danger-text); }
.wl-link {
    background: none;
    border: 0;
    padding: 0.25rem 0;
    color: var(--text-link);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.wl-drops,
.wl-items {
    list-style: none;
    margin: 0;
    padding: 0;
}
.wl-drop {
    display: flex;
    gap: 0.7rem;
    padding: 0.6rem 0;
    border-top: 1px solid var(--border-subtle);
}
.wl-drop:first-child { border-top: 0; }
.wl-drop-img,
.wl-item-img {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 8px;
    object-fit: contain;
    background: var(--color-white);
}
.wl-drop-img--empty { background: var(--surface-control); }
.wl-drop-body { min-width: 0; flex: 1; }
.wl-drop-name {
    display: block;
    width: 100%;
    background: none;
    border: 0;
    padding: 0;
    text-align: left;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    min-height: 24px;   /* minimum tap target */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wl-drop-line,
.wl-drop-prices {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}
.wl-drop-line strong,
.wl-drop-prices strong { color: var(--text-primary); }
.wl-drop-pct {
    display: inline-block;
    padding: 0.05rem 0.4rem;
    border-radius: var(--radius-full);
    background: var(--wl-pct-bg);
    color: var(--wl-pct-text);
    font-weight: 700;
}
.wl-drop-prices s { color: var(--text-tertiary); }
.wl-drop-since,
.wl-drop-more { color: var(--text-tertiary); }
.wl-drop-link {
    display: inline-block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-link);
    text-decoration: none;
}
.wl-block-note {
    margin: 0.5rem 0 0;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--text-tertiary);
}

/* --- opt-in card ----------------------------------------------------------------- */
.wl-optin-title { font-weight: 700; font-size: 0.95rem; color: var(--text-heading); }
.wl-optin-text {
    margin: 0.35rem 0 0.6rem;
    font-size: 0.84rem;
    line-height: 1.4;
    color: var(--text-secondary);
}
.wl-optin-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.wl-btn {
    border-radius: var(--radius-full);
    padding: 0.5rem 1rem;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
}
.wl-btn--primary { background: var(--brand-primary); color: var(--color-white); }
.wl-btn--primary:hover { background: var(--brand-primary-hover); }
.wl-btn--ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-medium); }
.wl-btn--danger { background: transparent; color: var(--wl-danger-text); border-color: var(--danger-border); width: 100%; }
.wl-btn--danger.is-armed { background: var(--danger-primary); color: var(--color-white); }

/* --- sheet ---------------------------------------------------------------------- */
body.wl-sheet-open { overflow: hidden; }
.wl-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: var(--overlay-dim);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.wl-sheet {
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-sizing: border-box;
    background: var(--surface-popover);
    color: var(--text-primary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-strong);
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 700px) {
    .wl-sheet-backdrop { align-items: center; }
    .wl-sheet { border-radius: var(--radius-lg); }
}
.wl-sheet-head { display: flex; align-items: center; justify-content: space-between; }
.wl-sheet-head h2 { margin: 0; font-size: 1.1rem; color: var(--text-heading); }
.wl-sheet-close {
    background: none;
    border: 0;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
}
.wl-sheet-sub { margin: 0.3rem 0 0.7rem; font-size: 0.84rem; color: var(--text-secondary); }
.wl-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-subtle);
}
.wl-item:first-child { border-top: 0; }
.wl-item-img { width: 40px; height: 40px; flex-basis: 40px; }
.wl-item-name { flex: 1; min-width: 0; font-size: 0.88rem; }
.wl-item .wl-heart--icon { margin-left: 0; flex: 0 0 auto; }
.wl-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: var(--radius-full);
    background: var(--wl-pct-bg);
    color: var(--wl-pct-text);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}
.wl-empty { font-size: 0.88rem; color: var(--text-secondary); }
.wl-sheet-note { margin: 0.5rem 0 0; font-size: 0.72rem; line-height: 1.35; color: var(--text-tertiary); }
.wl-sheet-push {
    margin-top: 0.9rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    background: var(--surface-control);
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.wl-sheet-push h3 { margin: 0 0 0.3rem; font-size: 0.92rem; color: var(--text-heading); }
.wl-sheet-push p { margin: 0 0 0.5rem; line-height: 1.4; }
.wl-sheet-foot { margin-top: 1rem; }
.wl-sheet-legal { margin: 0.6rem 0 0; font-size: 0.72rem; color: var(--text-tertiary); line-height: 1.35; }
.wl-sheet-legal a { color: var(--text-link); }

/* --- toast ---------------------------------------------------------------------- */
.wl-toast {
    position: fixed;
    left: 50%;
    bottom: calc(132px + env(safe-area-inset-bottom, 0px));  /* above the floating cart button */
    transform: translate(-50%, 20px);
    z-index: 3100;
    width: max-content;
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-md);
    background: var(--surface-card-inverse);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
    box-shadow: var(--shadow-strong);
    font-size: 0.86rem;
    line-height: 1.35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.wl-toast.is-visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
body.wl-sheet-open .wl-toast { bottom: auto; top: calc(16px + env(safe-area-inset-top, 0px)); }
.wl-toast-btn {
    flex: 0 0 auto;
    background: none;
    border: 0;
    color: var(--text-link);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    padding: 0.2rem 0;
}

@media (prefers-reduced-motion: reduce) {
    .wl-heart, .wl-toast { transition: none; }
}

/* light theme: the shared link/success tokens are tuned for dark backgrounds */
[data-theme="light"] .wl-link,
[data-theme="light"] .wl-drop-link,
[data-theme="light"] .wl-toast-btn,
[data-theme="light"] .wl-sheet-legal a { color: var(--brand-primary); }
[data-theme="light"] .wl-heart { border-color: var(--border-strong); }
[data-theme="light"] .wl-heart.is-on { border-color: var(--danger-border); }
.wl-sheet-close { border-radius: 8px; }

/* --- the profile's "Productos que seguís" --------------------------------------------- */
#watchlist-following:not([hidden]) {
    display: block;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-subtle);
}
.wl-following-title { margin: 0 0 0.75rem; color: var(--text-heading); }
.wl-follow { align-items: flex-start; min-height: 44px; }
.wl-follow-body { flex: 1; min-width: 0; font-size: 0.88rem; line-height: 1.35; }
.wl-follow-name { display: block; font-weight: 600; color: var(--text-strong); text-decoration: none; }
.wl-follow-price { color: var(--text-secondary); }
.wl-follow-price strong { color: var(--text-primary); }
.wl-follow-drop { margin-top: 0.15rem; font-size: 0.8rem; color: var(--text-secondary); }
