/**
 * 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;
    --aieo-wl-box:    calc(var(--aieo-wl-size) + 14px); /* the button: the drawing and 7 px around it */

    /* 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: var(--aieo-wl-box) !important;
    min-width: 0 !important;
    max-width: var(--aieo-wl-box) !important;
    height: var(--aieo-wl-box) !important;
    min-height: 0 !important;
    max-height: var(--aieo-wl-box) !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: var(--aieo-wl-box) !important;
        min-width: 0 !important;
        max-width: var(--aieo-wl-box) !important;
        height: var(--aieo-wl-box) !important;
        min-height: 0 !important;
        max-height: var(--aieo-wl-box) !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:not(.aieo-wishlist-heart--ring, .aieo-wishlist-heart--fill-theme, .aieo-wishlist-heart--fill-white)) {
    margin-inline-start: -7px;
}

/* On the product page's title row, at the row's end, the heart is the box of a header action (44 px, the theme's
   .rooster-action), so its drawing stands on the axis of the header's last icon above it (the owner, 10 Nov 2026:
   "totally aligned with the icon in the menu"; in its 36 px box it stood 4 px to the right). */
html[data-rooster-design="theme"] .aieo-wishlist-heart-wrap--title-row > .aieo-wishlist-heart {
    --aieo-wl-box: 2.75rem;
}
/* ... centre on centre with the header's heart (11.3.16, F46; the owner, 19 Nov 2026: "Move the distance of the heart in
   the product page 12 pixels to the left so that it is totally aligned with the heart in the menu"). The share box
   beside it hangs past the column's edge so that its drawing ends there, where the header's bag ends with its count, by
   the theme's measure (Rooster Zero's title row: --rooster-title-icons-overhang, 10 px); the heart's slot takes that
   measure back, so the heart stands one header action (44 px) and the header's gap from the row's end, as the header's
   heart does above it. The theme's value, read here, never a copy (10 px where a theme does not declare it). Only where
   the computer's header shows its heart: a phone's header has none, and there the heart keeps its place. */
html[data-rooster-design="theme"] body:has(.rooster-header:not(.rooster-header--mobile) .rooster-action--wishlist) .rooster-product__title-row > .aieo-dmm-bridge--product_display:has(> .aieo-wishlist-heart-wrap--title-row):has(~ .rooster-share-box) {
    margin-inline-end: var(--rooster-title-icons-overhang, 10px);
}

/* 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 */
}

/* The circle (the owner, 5 Nov 2026: a white ring and a white heart, both red once added; "the white in the inner
   circle ... remove it in the default settings. Only if the user wants it we add it later"). The ring is the heart's
   own colour, so it turns the filled red with it; inside it nothing by default, the theme's background or white when
   the shop chooses (Wishlist → Heart colours and size). */
.aieo-wishlist-heart.aieo-wishlist-heart--ring {
    border: 1.5px solid currentColor;
}
/* Under the theme the heart and its ring are the theme's ink (white on a dark palette), on the product page too. */
html[data-rooster-design="theme"] .aieo-wishlist-heart.aieo-wishlist-heart--ring {
    --aieo-wl-empty: var(--wp--preset--color--fg, #5c5c5c);
}
/* Nothing inside, over a product photo: a halo of the page's background keeps the heart readable on any picture. */
.aieo-wishlist-heart--archive:not(.aieo-wishlist-heart--fill-theme, .aieo-wishlist-heart--fill-white) {
    filter: drop-shadow(0 0 1px var(--wp--preset--color--bg, #fff)) drop-shadow(0 0 2px var(--wp--preset--color--bg, #fff));
}
/* Flat, the default (the owner, 8 Nov 2026: "The proper is to be flat icon ... with no circle, border etc."; "also have
   a plain black line"; "we dont want the bloody shadow!!!"): no ring, no halo, no shadow, the heart a plain black line,
   red once added. The halo above stays for the circle, the alternative. */
.aieo-wishlist-heart--archive:not(.aieo-wishlist-heart--ring, .aieo-wishlist-heart--fill-theme, .aieo-wishlist-heart--fill-white) {
    filter: none;
}
.aieo-wishlist-heart.aieo-wishlist-heart--archive:not(.aieo-wishlist-heart--fill-theme, .aieo-wishlist-heart--fill-white) {
    --aieo-wl-empty: #5c5c5c;
}
html[data-rooster-design="theme"] .aieo-wishlist-heart.aieo-wishlist-heart--archive:not(.aieo-wishlist-heart--fill-theme, .aieo-wishlist-heart--fill-white) {
    --aieo-wl-empty: var(--wp--preset--color--fg, #5c5c5c);
}
.aieo-wishlist-heart.aieo-wishlist-heart--archive:not(.aieo-wishlist-heart--ring, .aieo-wishlist-heart--fill-theme, .aieo-wishlist-heart--fill-white, .aieo-wishlist-heart--embossed, .aieo-wishlist-heart--fill-page),
html[data-rooster-design="theme"] .aieo-wishlist-heart.aieo-wishlist-heart--archive:not(.aieo-wishlist-heart--ring, .aieo-wishlist-heart--fill-theme, .aieo-wishlist-heart--fill-white, .aieo-wishlist-heart--embossed, .aieo-wishlist-heart--fill-page) {
    --aieo-wl-empty: #000;
}
/* In the list view the heart stands on the card's own ground beside the photo, not over it: there the plain line is
   the theme's ink, so it reads in the dark scheme (the owner, 10 Nov 2026, of a list card in the dark: "The add to
   wishlist in dark is still impossible to view"; the black line is for a heart over a photo, light in both schemes). */
html[data-rooster-design="theme"] .rooster-products--list .aieo-wishlist-heart.aieo-wishlist-heart--archive:not(.aieo-wishlist-heart--ring, .aieo-wishlist-heart--fill-theme, .aieo-wishlist-heart--fill-white, .aieo-wishlist-heart--embossed) {
    --aieo-wl-empty: var(--wp--preset--color--fg, #000);
}
/* Embossed, the alternative (Wishlist → Heart colours and size → Heart line): the heart's colour edged in black. */
.aieo-wishlist-heart--archive.aieo-wishlist-heart--embossed:not(.aieo-wishlist-heart--ring, .aieo-wishlist-heart--fill-theme, .aieo-wishlist-heart--fill-white) {
    filter: drop-shadow(0.75px 0 0 #000) drop-shadow(-0.75px 0 0 #000) drop-shadow(0 0.75px 0 #000) drop-shadow(0 -0.75px 0 #000) drop-shadow(0 0 0.5px #000);
}
.aieo-wishlist-heart--fill-theme {
    background: var(--wp--preset--color--bg, #fff);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
html[data-rooster-design="theme"] .aieo-wishlist-heart.aieo-wishlist-heart--fill-theme {
    --aieo-wl-empty: var(--wp--preset--color--fg, #5c5c5c);
}
/* On a white disc the outline is a fixed dark grey whatever the scheme: the theme's light inks of the dark scheme fail
   on it (2.52:1, 29 Oct 2026); the filled red keeps 3:1 on it even over a black photo. */
.aieo-wishlist-heart--fill-white {
    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.aieo-wishlist-heart--fill-white,
html[data-rooster-design="theme"] .aieo-wishlist-heart.aieo-wishlist-heart--fill-white {
    --aieo-wl-empty: #5c5c5c;
}
/* The page's colour, slightly see-through: the designer's card heart (direction B; the owner, 11 Nov 2026, "the exact
   icon of the add to favourites. And that it also has a transparent background to ensure that it works in all
   photos"), the default. A square of the shop's size (Wishlist → Heart colours and size, 44 px by default) in the
   theme's control corners, the page's colour at 88 %, the designer's 20 px heart in the text's colour; under the
   pointer a breath of ink on that ground and the heart a little larger; once added, filled in the shop's colour. Every
   colour a token, the system's colours their fallback. */
.aieo-wishlist-heart.aieo-wishlist-heart--archive.aieo-wishlist-heart--fill-page {
    --aieo-wl-box: var(--aieo-wl-card-box, 44px);
    --aieo-wl-size: 20px;
    --aieo-wl-empty: var(--wp--preset--color--fg, CanvasText);
    --aieo-wl-hover: var(--wp--preset--color--fg, CanvasText);
    border-radius: var(--wp--custom--rooster--shape--control, 4px);
    background: color-mix(in srgb, var(--wp--preset--color--bg, Canvas) 88%, transparent);
    filter: none;
}
.aieo-wishlist-heart.aieo-wishlist-heart--archive.aieo-wishlist-heart--fill-page:hover {
    background: color-mix(in srgb, var(--wp--preset--color--fg, CanvasText) 7%, color-mix(in srgb, var(--wp--preset--color--bg, Canvas) 88%, transparent));
}
.aieo-wishlist-heart--archive.aieo-wishlist-heart--fill-page:active { transform: none; }
.aieo-wishlist-heart--archive.aieo-wishlist-heart--fill-page .aieo-wishlist-heart-icon { transition: transform 120ms ease; }
.aieo-wishlist-heart--archive.aieo-wishlist-heart--fill-page:hover .aieo-wishlist-heart-icon { transform: scale(1.08); }
.aieo-wishlist-heart--archive.aieo-wishlist-heart--fill-page:active .aieo-wishlist-heart-icon { transform: scale(0.94); }
@media (prefers-reduced-motion: reduce) {
    .aieo-wishlist-heart--archive.aieo-wishlist-heart--fill-page,
    .aieo-wishlist-heart--archive.aieo-wishlist-heart--fill-page .aieo-wishlist-heart-icon { transition: none; transform: none; }
}
/* A heart printed in a card's picture (a collection the shop loop does not reach, 11 Nov 2026): the picture holds it. */
.wc-block-components-product-image:has(> .aieo-wishlist-heart--archive) { position: relative; }

.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(--wp--custom--rooster--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; }
