/**
 * AIEO Wishlist — single-product + archive heart button.
 *
 * Colors + size come from CSS variables injected inline by the PHP
 * side (see AIEO_Wishlist::enqueue_assets()). Variant classes drive
 * layout differences between single-product (inline block) and
 * archive (absolutely positioned over the card image).
 */
.aieo-wishlist-heart {
    --aieo-wl-empty:  #c0c4c9;
    --aieo-wl-filled: #e0245e;
    --aieo-wl-hover:  #a01c48;
    --aieo-wl-size:   22px;

    /* Defensive button reset — themes ship blanket rules like
       `@media (max-width: 1025px) { button:not(.components-button)... {
       height: 60px; min-width: 60px } }` (femme-fatale theme observed)
       that inflate every button to 60×60 on mobile. The icon stays the
       intended size but the button box around it explodes. !important
       on the dimensional properties forces our explicit sizing through. */
    position: relative;
    box-sizing: border-box !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: calc(var(--aieo-wl-size) + 14px) !important;
    min-width: 0 !important;
    max-width: calc(var(--aieo-wl-size) + 14px) !important;
    height: calc(var(--aieo-wl-size) + 14px) !important;
    min-height: 0 !important;
    max-height: calc(var(--aieo-wl-size) + 14px) !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--aieo-wl-empty);
    cursor: pointer;
    transition: color 160ms ease, background-color 160ms ease, transform 120ms ease;
    line-height: 1;
}

/* High-specificity override against the theme's `@media (max-width:1025px)
   { button:not(...) { height: 60px; min-width: 60px } }` rule (specificity
   (0,3,1)). We match that breakpoint range and double up with a more
   specific selector + !important so the cascade winner is unambiguous.
   Selector specificity here is (0,2,1) for the heart button alone, but
   the !important is what definitively wins. */
@media (max-width: 1025px) {
    button.aieo-wishlist-heart,
    button.aieo-wishlist-heart.aieo-wishlist-heart--archive {
        box-sizing: border-box !important;
        width: calc(var(--aieo-wl-size) + 14px) !important;
        min-width: 0 !important;
        max-width: calc(var(--aieo-wl-size) + 14px) !important;
        height: calc(var(--aieo-wl-size) + 14px) !important;
        min-height: 0 !important;
        max-height: calc(var(--aieo-wl-size) + 14px) !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    button.aieo-wishlist-heart .aieo-wishlist-heart-icon {
        width: var(--aieo-wl-size) !important;
        max-width: var(--aieo-wl-size) !important;
        min-width: 0 !important;
        height: var(--aieo-wl-size) !important;
        max-height: var(--aieo-wl-size) !important;
        min-height: 0 !important;
    }
}
.aieo-wishlist-heart:hover,
.aieo-wishlist-heart:focus-visible {
    color: var(--aieo-wl-hover);
    outline: none;
}
.aieo-wishlist-heart.is-in-list {
    color: var(--aieo-wl-filled);
}
.aieo-wishlist-heart.is-loading {
    opacity: 0.6;
    pointer-events: none;
}
.aieo-wishlist-heart:active { transform: scale(0.9); }

.aieo-wishlist-heart-icon {
    width: var(--aieo-wl-size);
    height: var(--aieo-wl-size);
    display: block;
}

/* Outline vs filled path — default shows outline, is-in-list swaps. */
.aieo-wishlist-heart .aieo-wishlist-heart-outline { opacity: 1; }
.aieo-wishlist-heart .aieo-wishlist-heart-fill    { opacity: 0; }
.aieo-wishlist-heart.is-in-list .aieo-wishlist-heart-outline { opacity: 0; }
.aieo-wishlist-heart.is-in-list .aieo-wishlist-heart-fill    { opacity: 1; }

/* Single-product variant — sits inline in the WC summary column. */
.aieo-wishlist-heart--single_product {
    margin: 0;
}

/* Wrapper around the heart + the inline text label.
 * Layout: heart on the left, label to its right, vertically centered. */
.aieo-wishlist-heart-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0 14px;
}
.aieo-wishlist-heart-label {
    color: var(--aieo-wl-empty);
    font-size: 14px;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: color 160ms ease;
}
.aieo-wishlist-heart-label:hover { color: var(--aieo-wl-hover); text-decoration: underline; }
.aieo-wishlist-heart-wrap.is-in-list .aieo-wishlist-heart-label {
    color: var(--aieo-wl-filled);
    font-weight: 500;
}

/* Archive variant — absolute over the product card image. The parent
 * WC .product / li.product needs `position:relative` which it almost
 * always already has. We add a tiny backdrop so the heart is readable
 * over any product image. */
.aieo-wishlist-heart--archive {
    position: absolute;
    z-index: 5;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.aieo-wishlist-heart--archive.aieo-wishlist-pos-top-right    { top: 8px; right: 8px; }
.aieo-wishlist-heart--archive.aieo-wishlist-pos-top-left     { top: 8px; left:  8px; }
.aieo-wishlist-heart--archive.aieo-wishlist-pos-bottom-right { bottom: 8px; right: 8px; }
.aieo-wishlist-heart--archive.aieo-wishlist-pos-bottom-left  { bottom: 8px; left:  8px; }

/* The heart needs a positioned containing block. Cover both the legacy WC loop
 * markup (`ul.products li.product`) AND WC's block-based product-collection +
 * product-template + product-grid markup. Without this, themes that use the
 * block-based product loop (FSE / WP 6.x+) end up with hearts positioning
 * relative to <body> — which floats them to the top-right of the page. */
ul.products li.product,
.products .product,
.wc-block-product,
.wp-block-woocommerce-product,
.wc-block-product-template > li,
.wp-block-woocommerce-product-template > li,
.wc-block-grid__product,
:where(li, div).type-product {
    position: relative;
}

/* Tooltip — simple pill positioned above the heart icon. The PHP output chooses
 * whether to render the <span> at all based on the admin toggle.
 *
 * Anchor the tooltip to the same edge as the heart icon (top-right card → tooltip
 * right-aligned with heart, extending leftward into the card). Without this, the
 * old `left: 50%; transform: translateX(-50%)` rule centred the tooltip in the
 * containing block and could overflow the viewport on right-edge product cards
 * that sit flush against it — visible on any theme that doesn't itself constrain
 * the parent with overflow:hidden, which is the correct WP 7 behaviour.
 */
.aieo-wishlist-heart-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    background: #1f2937;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    max-width: 200px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease;
    z-index: 10;
}
/* Heart on the right side of the card → tooltip pinned to the right edge of the
 * heart, extending leftward (into the card, away from the viewport edge). */
.aieo-wishlist-pos-top-right    .aieo-wishlist-heart-tooltip,
.aieo-wishlist-pos-bottom-right .aieo-wishlist-heart-tooltip {
    right: 0;
    left:  auto;
}
/* Heart on the left side of the card → tooltip pinned to the left edge. */
.aieo-wishlist-pos-top-left    .aieo-wishlist-heart-tooltip,
.aieo-wishlist-pos-bottom-left .aieo-wishlist-heart-tooltip {
    left:  0;
    right: auto;
}
/* Fallback for any heart that doesn't carry a position class (e.g. single product
 * page) — keep the original centred placement, but allow shrinking. */
.aieo-wishlist-heart:not([class*="aieo-wishlist-pos-"]) .aieo-wishlist-heart-tooltip {
    left: 50%;
    transform: translateX(-50%);
}
.aieo-wishlist-heart:hover .aieo-wishlist-heart-tooltip,
.aieo-wishlist-heart:focus-visible .aieo-wishlist-heart-tooltip {
    opacity: 1;
}
