/*
 * kin-lists.css — wishlist (wli-*) and compare (cmpi-*) icon buttons.
 *
 * Ported from the two removed plugins so the markup they emitted keeps its
 * behaviour: passive/active image swap, hover preview, counter bubble and the
 * "pulsate" state while a request is in flight (class added by kin-lists.js).
 *
 * The card and the single-product buybox are laid out by the theme's `.fav`
 * rule; the `.fav.<icon>` overrides below win on specificity, not on load
 * order, so the box stays 36/52px wherever the theme puts it.
 */

.wli-icon,
.cmpi-icon {
    text-decoration: none;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
}

.wli-icon img,
.cmpi-icon img {
    width: 75%;
    height: auto;
    display: block;
}

/* --- theme card / buybox box -------------------------------------------------
 * .fav is position:absolute 36x36 on a card and 52x52 in the buybox.
 * Keep that geometry and only supply the icon size.
 */
.fav.wli-icon,
.fav.cmpi-icon {
    width: 36px;
    height: 36px;
    aspect-ratio: auto;
}

.fav.wli-icon img,
.fav.cmpi-icon img {
    width: 20px;
    height: 20px;
}

/* --- single product summary -------------------------------------------------- */
.kin-lists-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0;
}

.kin-lists-actions .fav {
    position: static;
    width: 44px;
    height: 44px;
}

/* The box is the 44px `.fav` above; these class names sit on the same element,
   so a width here overrides that box and every button stretches to the row. */
.kin-lists-actions .wli-icon,
.kin-lists-actions .cmpi-icon {
    aspect-ratio: auto;
}

/* --- passive / active icon --------------------------------------------------- */
.wli-icon .wli-img-passive,
.cmpi-icon .cmpi-img-passive {
    display: block !important;
}

.wli-icon .wli-img-active,
.cmpi-icon .cmpi-img-active {
    display: none !important;
}

.wli-icon:hover .wli-img-passive,
.cmpi-icon:hover .cmpi-img-passive {
    display: none !important;
}

.wli-icon:hover .wli-img-active,
.cmpi-icon:hover .cmpi-img-active {
    display: block !important;
}

.wli-icon.wli-icon-activated .wli-img-passive,
.cmpi-icon.cmpi-icon-activated .cmpi-img-passive {
    display: none !important;
}

.wli-icon.wli-icon-activated .wli-img-active,
.cmpi-icon.cmpi-icon-activated .cmpi-img-active {
    display: block !important;
}

/* --- active: inverted, unmistakable ------------------------------------------
 * The image swap alone was invisible at card size, so an item that is on the
 * list gets a filled chip: the icon flips to white on the accent colour and
 * the box keeps its geometry. Hover does not undo it — an active control must
 * look active even under the cursor.
 */
.wli-icon.wli-icon-activated,
.cmpi-icon.cmpi-icon-activated {
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.wli-icon.wli-icon-activated img,
.cmpi-icon.cmpi-icon-activated img,
.wli-icon.wli-icon-activated:hover img,
.cmpi-icon.cmpi-icon-activated:hover img {
    filter: brightness(0) invert(1);
}

/* Same chip for compare: one list colour across the site. The glyph tells
   the two apart, the colour does not — a red chip read as an error state. */
.cmpi-icon.cmpi-icon-activated {
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.wli-icon.wli-icon-activated:hover,
.cmpi-icon.cmpi-icon-activated:hover {
    background: var(--accent-hover);
}

.cmpi-icon.cmpi-icon-activated:hover {
    background: var(--accent-hover);
}

/* --- counter bubble ---------------------------------------------------------- */
.wli-counter,
.cmpi-counter {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 4px;
    width: 40%;
    height: 40%;
    background-color: #13c694;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: sans-serif !important;
    font-size: calc(0.8 * 100%);
    line-height: calc(0.8 * 1.25);
    text-align: center;
}

/* --- in-flight state --------------------------------------------------------- */
.wli-pulsate,
.cmpi-pulsate {
    animation: pulsate 1s ease-in-out infinite;
}

@keyframes pulsate {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wli-pulsate,
    .cmpi-pulsate {
        animation: none;
    }
}

/* ===========================================================================
 * List pages: the wishlist is a row list, the comparison is a matrix.
 * The theme's card styles (`.fav`, `.p-card`) are for catalog tiles, so these
 * pages carry their own layout and only borrow the tokens.
 * ======================================================================== */

.kin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--r-md, 10px);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}

.kin-btn--primary {
    background: var(--accent, #0B7A6E);
    color: #fff;
}

.kin-btn--primary:hover {
    background: var(--accent-hover, #065F4A);
    color: #fff;
    text-decoration: none;
}

.kin-btn--ghost {
    background: var(--surface, #fff);
    border-color: var(--line2, rgba(15,32,40,.15));
    color: var(--text2, #344A51);
}

.kin-btn--ghost:hover {
    border-color: var(--accent, #0B7A6E);
    color: var(--accent-ink, #066B50);
    text-decoration: none;
}

.kin-btn--ghost[aria-pressed="true"] {
    background: var(--accent-soft, rgba(22,202,136,.14));
    border-color: var(--accent, #0B7A6E);
    color: var(--on-soft, #066B50);
}

.kin-btn--sm {
    min-height: 38px;
    padding: 0 14px;
    font-size: 13px;
}

/* --- toolbar ------------------------------------------------------------- */
.kin-list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line, rgba(15,32,40,.08));
}

.kin-list-toolbar__summary {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text, #0F2028);
}

.kin-list-toolbar__hint {
    margin-left: 10px;
    font-weight: 500;
    color: var(--muted, #5A6B72);
}

.kin-list-toolbar__tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* --- empty state --------------------------------------------------------- */
.kin-list-empty {
    padding: 48px 24px;
    text-align: center;
    border: 1px dashed var(--line2, rgba(15,32,40,.15));
    border-radius: var(--r-xl, 20px);
    background: var(--surface, #fff);
}

.kin-list-empty__title {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text, #0F2028);
}

.kin-list-empty__text {
    max-width: 52ch;
    margin: 0 auto 20px;
    color: var(--text2, #344A51);
}

/* --- wishlist rows ------------------------------------------------------- */
.kin-wl {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.kin-wl__item {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 20px;
    padding: 16px;
    border: 1px solid var(--line, rgba(15,32,40,.08));
    border-radius: var(--r-lg, 14px);
    background: var(--surface, #fff);
    transition: border-color .16s ease, box-shadow .16s ease;
}

.kin-wl__item:hover {
    border-color: var(--line2, rgba(15,32,40,.15));
    box-shadow: 0 8px 24px rgba(15, 32, 40, .07);
}

.kin-wl__media {
    display: block;
    width: 96px;
    height: 96px;
    border-radius: var(--r-md, 10px);
    background: var(--surface2, #F8FAFA);
    overflow: hidden;
}

.kin-wl__media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.kin-wl__body {
    min-width: 0;
}

.kin-wl__title {
    display: block;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text, #0F2028);
    text-decoration: none;
}

.kin-wl__title:hover {
    color: var(--accent-ink, #066B50);
    text-decoration: none;
}

.kin-wl__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: 6px;
    font-size: 13px;
    color: var(--muted, #5A6B72);
}

.kin-wl__stock { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.kin-wl__stock::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}
.kin-wl__stock.is-in { color: var(--stock-ok, #066B50); }
.kin-wl__stock.is-out { color: var(--sale, #B42318); }
.kin-wl__stock.is-back { color: var(--muted, #5A6B72); }

.kin-wl__price {
    font-size: 18px;
    font-weight: 700;
    color: var(--text, #0F2028);
    white-space: nowrap;
}

.kin-wl__price del,
.kin-wl__price .price-old {
    font-size: 13px;
    font-weight: 500;
    color: var(--price-old, var(--muted, #5A6B72));
}

.kin-wl__buy .kin-btn {
    white-space: nowrap;
}

.kin-wl__tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* The card `.fav` is absolute 36px; here it is one control among others. */
.kin-wl__tools .fav {
    position: static;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line2, rgba(15,32,40,.15));
    background: var(--surface, #fff);
}

.kin-wl__remove,
.kin-cmp__remove {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line2, rgba(15,32,40,.15));
    border-radius: 50%;
    background: var(--surface, #fff);
    color: var(--muted, #5A6B72);
    text-decoration: none;
    transition: color .16s ease, border-color .16s ease;
}

.kin-wl__remove:hover,
.kin-cmp__remove:hover {
    color: var(--sale, #B42318);
    border-color: var(--sale, #B42318);
    text-decoration: none;
}

@media (max-width: 899px) {
    .kin-wl__item {
        grid-template-columns: 72px minmax(0, 1fr) auto;
        grid-template-areas:
            "media body tools"
            "media price buy";
        gap: 10px 14px;
        align-items: start;
    }

    .kin-wl__media { grid-area: media; width: 72px; height: 72px; }
    .kin-wl__body { grid-area: body; }
    .kin-wl__price { grid-area: price; }
    .kin-wl__buy { grid-area: buy; justify-self: end; }
    .kin-wl__tools { grid-area: tools; justify-self: end; }
}

/* --- comparison matrix --------------------------------------------------- */
.kin-cmp__scroll {
    border: 1px solid var(--line, rgba(15,32,40,.08));
    border-radius: var(--r-lg, 14px);
    background: var(--surface, #fff);
}

.kin-cmp__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.kin-cmp__table thead th {
    position: sticky;
    top: var(--stick-h, 96px);
    z-index: 3;
    padding: 16px;
    border-bottom: 1px solid var(--line2, rgba(15,32,40,.15));
    background: var(--surface, #fff);
    vertical-align: top;
    text-align: left;
    font-weight: 400;
}

.kin-cmp__corner {
    left: 0;
    z-index: 4 !important;
    width: 220px;
    background: var(--surface2, #F8FAFA) !important;
}

.kin-cmp__corner-text {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted, #5A6B72);
}

.kin-cmp__card { display: flex; flex-direction: column; gap: 6px; }

.kin-cmp__image {
    display: grid;
    place-items: center;
    width: 100%;
    height: 120px;
    border-radius: var(--r-md, 10px);
    background: var(--surface2, #F8FAFA);
    overflow: hidden;
}

.kin-cmp__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.kin-cmp__title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text, #0F2028);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kin-cmp__title:hover { color: var(--accent-ink, #066B50); text-decoration: none; }

.kin-cmp__price { font-size: 17px; font-weight: 700; color: var(--text, #0F2028); }

.kin-cmp__stock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--stock-ok, #066B50);
}

.kin-cmp__stock::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.kin-cmp__stock.is-out { color: var(--sale, #B42318); }
.kin-cmp__stock.is-back { color: var(--muted, #5A6B72); }

.kin-cmp__buy {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.kin-cmp__table tbody th {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 220px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line, rgba(15,32,40,.08));
    border-right: 1px solid var(--line, rgba(15,32,40,.08));
    background: var(--surface2, #F8FAFA);
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted, #5A6B72);
    vertical-align: top;
}

.kin-cmp__table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line, rgba(15,32,40,.08));
    font-size: 14px;
    line-height: 1.45;
    color: var(--text, #0F2028);
    vertical-align: top;
    word-break: break-word;
}

/* A row that differs gets a tint on the values, always — the point of a
   comparison is the difference, not the sameness. */
.kin-cmp__row.is-diff .kin-cmp__value {
    background: var(--accent-soft, rgba(22,202,136,.14));
}

.kin-cmp__dash { color: var(--muted, #5A6B72); }

.kin-cmp.is-diff-only .kin-cmp__row:not(.is-diff) {
    display: none;
}

/* Horizontal scrolling is a phone affordance only: any overflow ancestor
   breaks the sticky thead, so it is switched on below the desktop width. */
@media (max-width: 1023px) {
    .kin-cmp__scroll { overflow-x: auto; }
    .kin-cmp__table { min-width: 720px; }
    .kin-cmp__table thead th { position: static; }
    .kin-cmp__table tbody th { position: static; }
    .kin-cmp__corner { width: 160px; }
    .kin-cmp__table tbody th { width: 160px; }
}

/* --- product page: labelled wishlist/compare controls -------------------- */
.kin-lists-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 0 0;
}

.kin-lists-actions .fav {
    position: static;
}

.fav.is-labelled {
    width: auto;
    min-width: 0;
    height: 44px;
    padding: 0 16px 0 12px;
    gap: 8px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line2, rgba(15,32,40,.15));
    border-radius: var(--r-pill, 999px);
    background: var(--surface, #fff);
    color: var(--text2, #344A51);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.fav.is-labelled img {
    width: 20px;
    height: 20px;
    display: block !important;
}

.fav.is-labelled img.wli-img-active,
.fav.is-labelled img.cmpi-img-active {
    display: none !important;
}

.fav.is-labelled.wli-icon-activated img.wli-img-active,
.fav.is-labelled.cmpi-icon-activated img.cmpi-img-active {
    display: block !important;
}

.fav.is-labelled.wli-icon-activated img.wli-img-passive,
.fav.is-labelled.cmpi-icon-activated img.cmpi-img-passive {
    display: none !important;
}

.fav.is-labelled:hover {
    border-color: var(--accent, #0B7A6E);
    color: var(--accent-ink, #066B50);
    text-decoration: none;
}

.fav.is-labelled.wli-icon-activated,
.fav.is-labelled.cmpi-icon-activated,
.fav.is-labelled.wli-icon-activated:hover,
.fav.is-labelled.cmpi-icon-activated:hover {
    background: var(--accent, #0B7A6E);
    border-color: var(--accent, #0B7A6E);
    color: #fff;
    box-shadow: none;
    filter: none;
}

.fav.is-labelled.cmpi-icon-activated,
.fav.is-labelled.cmpi-icon-activated:hover {
    background: var(--accent, #0B7A6E);
    border-color: var(--accent, #0B7A6E);
}

/* --- catalog cards (the Vue/Typesense app) -------------------------------
 * There the button is `.el-cart`, painted by the app bundle with
 * `background: var(--kw-fill) !important`; the class-based chip cannot win.
 * kin-lists.js therefore paints the pressed state inline (inline !important
 * outranks author !important) and this rule only carries the geometry.
 */
body .el-cart.wli-icon,
body .el-cart.cmpi-icon {
    width: 30px !important;
    height: 30px !important;
    padding: 6px !important;
    flex: none;
    border-radius: 50% !important;
}

body .el-cart.wli-icon img,
body .el-cart.cmpi-icon img {
    width: 16px;
    height: 16px;
}

body .el-cart.wli-icon:before,
body .el-cart.cmpi-icon:before {
    width: 16px;
    height: 16px;
}

/* --- list pages use the container, not the reading measure ---------------
 * `.entry-content` is capped at 78ch for prose pages; a wishlist row list and
 * a comparison matrix are layouts, so they were sitting in a narrow column
 * with empty space either side. The plugin adds `.kin-lists-page` to <body>.
 */
body.kin-lists-page .entry-content {
    max-width: none;
}

body.kin-lists-page .kin-wl,
body.kin-lists-page .kin-cmp {
    width: 100%;
}

/* --- glyphs ---------------------------------------------------------------
 * The shipped icons are black SVGs; an <img> cannot inherit colour, which is
 * why the heart/chart read as stray black marks next to grey text. Painted as
 * masks they take `currentColor` — muted when idle, white on the filled chip —
 * in both themes. The passive/active swap keeps using the .wli-img-*/.cmpi-img-*
 * classes, which the template now puts on the spans.
 */
.kin-lists-glyph {
    display: block;
    width: 20px;
    height: 20px;
    flex: none;
    background-color: currentColor;
    -webkit-mask: var(--glyph) center / contain no-repeat;
    mask: var(--glyph) center / contain no-repeat;
}

/* ==========================================================================
   List pages sit inside .entry-content, whose prose layer paints EVERY <a>
   with the link ink (`.entry-content a { color: var(--accent-ink) }`, two
   classes = 0,2,0). That outranks the button classes (0,1,0), so the buy
   button rendered teal-on-teal and the titles took the link colour.
   These rules carry the wrapper in the selector and win outright.
   ========================================================================== */
.entry-content a.kin-btn--primary,
.entry-content a.kin-btn--primary:link,
.entry-content a.kin-btn--primary:visited,
.entry-content a.kin-btn--primary:hover,
.entry-content a.kin-btn--primary:focus {
    color: #FFFFFF !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    text-decoration: none !important;
    text-shadow: none !important;
}

.entry-content a.kin-btn--ghost {
    color: var(--text2, #344A51) !important;
    text-decoration: none !important;
}

.entry-content a.kin-btn--ghost:hover {
    color: var(--accent-ink, #066B50) !important;
}

.entry-content a.kin-btn--ghost[aria-pressed="true"] {
    color: var(--on-soft, #066B50) !important;
}

.entry-content a.kin-wl__title,
.entry-content a.kin-cmp__title {
    color: var(--text, #0F2028) !important;
    text-decoration: none !important;
}

.entry-content a.kin-wl__title:hover,
.entry-content a.kin-cmp__title:hover {
    color: var(--accent-ink, #066B50) !important;
}

.entry-content a.kin-wl__remove {
    color: var(--muted, #5A6B72) !important;
    text-decoration: none !important;
}

.entry-content a.kin-wl__media {
    text-decoration: none !important;
}

.entry-content a.kin-wl__remove:hover {
    color: var(--sale, #B42318) !important;
}

/* The prose layer indents every list (`.entry-content ul { padding-left: 1.35em }`),
   which pushed the wishlist off the container edge and cost it ~16px of width.
   The page block spans the container exactly, like the header. */
.entry-content ul.kin-wl {
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    list-style: none;
}

.entry-content .kin-list-toolbar,
.entry-content .kin-cmp {
    margin-left: 0;
    margin-right: 0;
}

/* --- empty states ---------------------------------------------------------
 * `.entry-content p` / `.entry-content h2` (0,2,1) outrank the state's own
 * classes, so the 52ch paragraph lost its `margin: 0 auto` and sat against the
 * left edge while the card was full width. Wrapper-qualified rules put the
 * empty state back on the centre line.
 */
.entry-content .kin-list-empty {
    text-align: center;
}

.entry-content .kin-list-empty__title {
    margin: 0 0 8px !important;
    text-align: center;
}

.entry-content .kin-list-empty__text {
    margin: 0 auto 20px !important;
    max-width: 52ch;
    text-align: center;
}

.entry-content .kin-list-empty .kin-btn {
    margin-left: auto;
    margin-right: auto;
}
