/**
 * 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: #dd1419;   /* the logo's fire red */
    --aieo-wl-hover:  #b3101a;
    --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 {
    /* Readable text: "not yet" is the outline heart's to say, the empty colour is the icon's. */
    color: inherit;
    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;
}
/* Under the theme's design authority the label is the theme's muted text, the accent as text on
   hover; once favourited it keeps the heart's red (theme brief, 28 Oct 2026). */
html[data-rooster-design="theme"] .aieo-wishlist-heart-label {
    color: var(--wp--preset--color--muted);
}
html[data-rooster-design="theme"] .aieo-wishlist-heart-label:hover {
    color: var(--wp--preset--color--accent-text, var(--wp--preset--color--accent));
}
html[data-rooster-design="theme"] .aieo-wishlist-heart-wrap.is-in-list .aieo-wishlist-heart-label {
    color: var(--aieo-wl-filled);
}
/* The heart's outline on the theme's muted ink (it was a fixed light grey), and on the product page the drawn
   heart starts at the column's edge: the button keeps its 36 px target, its 7 px inset moves outside
   (UI review, 28 Oct 2026). */
html[data-rooster-design="theme"] .aieo-wishlist-heart,
html[data-rooster-design="theme"] .aieo-wishlist-heart-wrap {
    --aieo-wl-empty: var(--wp--preset--color--muted, #6b6b6b);
}
html[data-rooster-design="theme"] .aieo-wishlist-heart-wrap:has(> .aieo-wishlist-heart--single_product) {
    margin-inline-start: -7px;
}

/* 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;
    margin: 0; /* first in a block card, where WooCommerce spaces every part but the last */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
/* On its fixed white disc the outline is a fixed dark grey whatever the scheme: the theme's muted ink turned light in
   the dark scheme (2.52:1 on the disc, 29 Oct 2026), and the plain fallback was a light grey (1.8:1). The disc stays
   white because it sits on product photos; the filled red keeps 3:1 on it even over a black photo. */
.aieo-wishlist-heart.aieo-wishlist-heart--archive,
html[data-rooster-design="theme"] .aieo-wishlist-heart.aieo-wishlist-heart--archive {
    --aieo-wl-empty: #5c5c5c;
}
.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: var(--aieo-shape-panel, 4px);
    font-size: 11px;
    max-width: 200px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease;
    z-index: 10;
}
/* Under the theme the tooltip is on its type scale: its smallest step (census 5, 11 px was off the scale). */
html[data-rooster-design="theme"] .aieo-wishlist-heart-tooltip { font-size: var(--wp--preset--font-size--xs, 0.75rem); }
/* 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;
}

/* Contract C11 (brief section 16): with the theme's heart in the button, our
 * own icon stays out of the way and the pressed state fills the theme's: the
 * mask's filled shape, or the fill of an SVG heart (a child theme's drawing). */
.aieo-wishlist-heart .rooster-icon ~ .aieo-wishlist-heart-icon--own,
[data-aieo-wishlist-product] .rooster-icon ~ .aieo-wishlist-heart-icon--own { display: none; }
[data-aieo-wishlist-product][aria-pressed="true"] .rooster-icon--heart,
[data-aieo-wishlist-product].is-in-list .rooster-icon--heart { --rooster-icon-line: var(--rooster-icon-fill); }
[data-aieo-wishlist-product][aria-pressed="true"] svg.rooster-icon,
[data-aieo-wishlist-product].is-in-list svg.rooster-icon { fill: currentColor; }
