/* The Keepers Wishlist – front end. Colours from the theme presets, with fallbacks. */

.tkwl-block-link,
.tkwl-block-button {
    --tkwl-accent: var(--wp--preset--color--custom-primary, #164734);
    --tkwl-accent-soft: var(--wp--preset--color--custom-primary-10, #e8eeeb);
    --tkwl-white: var(--wp--preset--color--custom-white, #fff);
}
.tkwl-page,
.tkwl-btn,
.tkwl-toast,
.tkwl-link {
    --tkwl-accent: var(--wp--preset--color--custom-primary, #164734);
    --tkwl-accent-soft: var(--wp--preset--color--custom-primary-10, #e8eeeb);
    --tkwl-white: var(--wp--preset--color--custom-white, #fff);
    --tkwl-radius: var(--border-radius-md, 8px);
}

/* ── The heart ─────────────────────────────────────────── */
.tkwl-heart {
    display: block;
    width: 1.25em;
    height: 1.25em;
    flex: none;
}
.tkwl-heart path {
    transition: fill .15s ease;
}
.tkwl-btn.is-active .tkwl-heart path {
    fill: currentColor;
}

/* ── Buttons ───────────────────────────────────────────── */
.tkwl-btn {
    display: inline-flex;
    align-items: center;
    gap: .5em;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.tkwl-btn:focus-visible {
    outline: 2px solid var(--tkwl-accent);
    outline-offset: 3px;
    border-radius: 999px;
}
.tkwl-btn.is-active {
    color: var(--tkwl-accent);
}
.tkwl-btn.is-busy {
    cursor: progress;
}
.tkwl-btn.is-popping .tkwl-heart {
    animation: tkwl-pop .45s ease;
}
@keyframes tkwl-pop {
    0% { transform: scale(1); }
    35% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Heart and text: under Add to cart on the product page. */
.tkwl-btn--button {
    padding: .5em 0;
    font-size: .95em;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: .25em;
}
.tkwl-btn--button:hover {
    text-decoration-color: currentColor;
}

/* Heart only. */
.tkwl-btn--icon {
    justify-content: center;
    width: 2.5em;
    height: 2.5em;
    border-radius: 999px;
}
.tkwl-btn--icon:hover {
    background: var(--tkwl-accent-soft);
}

/* Over a product card's image (top right). The card needs position: relative. */
.tkwl-btn--overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .92);
    color: #1e1e1e;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
    transition: opacity .15s ease, transform .15s ease, color .15s ease;
}
.tkwl-btn--overlay .tkwl-heart {
    width: 20px;
    height: 20px;
}
.tkwl-btn--overlay:hover {
    transform: scale(1.06);
}
.tkwl-btn--overlay.is-active {
    color: var(--tkwl-accent);
}
/* With a mouse: only on hovering the card (or when saved / focused). */
@media (hover: hover) and (pointer: fine) {
    .tkwl-btn--overlay {
        opacity: 0;
    }
    :hover > .tkwl-btn--overlay,
    :focus-within > .tkwl-btn--overlay,
    .tkwl-btn--overlay.is-active,
    .tkwl-btn--overlay:focus-visible {
        opacity: 1;
    }
}

/* ── Header link ───────────────────────────────────────── */
.tkwl-block-link {
    display: flex;
    align-items: center;
}
.tkwl-link {
    display: inline-flex;
    align-items: center;
    gap: .4em;
    color: inherit;
    text-decoration: none;
}
.tkwl-link__icon {
    position: relative;
    display: flex;
    align-items: center;
}
/* Sized like the Mini-Cart block's icon (1.5em of the block's font size). */
.tkwl-link .tkwl-heart {
    width: 1.5em;
    height: 1.5em;
}
/*
 * Same as WooCommerce's .wc-block-mini-cart__badge: 0.875em text in a circle
 * of 1.43em, over the icon's top right, so both badges match at any size.
 */
.tkwl-link__count {
    position: absolute;
    left: 100%;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 1.4285714286em;
    height: 1.4285714286em;
    margin-left: -44%;
    padding: 0 .25em;
    border-radius: 1em;
    background: var(--tkwl-accent);
    color: var(--tkwl-white);
    font-size: .875em;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    transform: translateY(-50%);
}
.tkwl-link__count[hidden] {
    display: none;
}

/* Header link hidden until something is saved (html.tkwl-has-items). */
html:not(.tkwl-has-items) .tkwl-block-link--auto,
html:not(.tkwl-has-items) .tkwl-link--auto {
    display: none;
}

/* Hearts of other wishlists (e.g. MoreConvert in a card) stay off the wishlist's own cards. */
.tkwl-item .tkwl-btn:not(.tkwl-item__corner),
.tkwl-item .wlfmc-add-to-wishlist {
    display: none !important;
}
/* Touch screens: no hearts on product cards; they save from the product page. */
@media (hover: none) and (pointer: coarse) {
    .tkwl-btn--card {
        display: none !important;
    }
}

/* ── Message ───────────────────────────────────────────── */
.tkwl-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 100001;
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    border-radius: 999px;
    background: var(--wp--preset--color--custom-primary, #1e1e1e);
    color: var(--wp--preset--color--custom-white, #fff);
    font-size: 14px;
    line-height: 1.3;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: opacity .2s ease, transform .2s ease;
}
.tkwl-toast.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
}
.tkwl-toast a {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    white-space: nowrap;
}

/* ── Wishlist page ─────────────────────────────────────── */
.tkwl-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 0;
    opacity: .7;
}
.tkwl-loading__ring {
    width: 22px;
    height: 22px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: tkwl-spin .8s linear infinite;
}
@keyframes tkwl-spin {
    to { transform: rotate(360deg); }
}
.tkwl-list__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}
.tkwl-list__count {
    margin: 0;
}
/* Fallbacks when the theme has no such presets (has-custom-primary-50-color, has-small-font-size). */
.tkwl-list__count:not(.has-small-font-size) {
    font-size: .875em;
}
/* A bold text link in the text colour, Medium size (has-medium-font-size). */
.tkwl-share {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-family: inherit;
    font-weight: 700;
    line-height: 1.3;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: .25em;
    cursor: pointer;
    transition: text-decoration-color .15s ease;
}
.tkwl-share:not(.has-medium-font-size) {
    font-size: var(--wp--preset--font-size--medium, 1rem);
}
.tkwl-share:hover,
.tkwl-share:focus-visible {
    text-decoration-color: currentColor;
}
.tkwl-share svg {
    flex: none;
}
.tkwl-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 28px 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.tkwl-item {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    transition: opacity .25s ease, transform .25s ease;
}
.tkwl-item.is-leaving {
    opacity: 0;
    transform: scale(.97);
}
.tkwl-item__image {
    display: block;
    overflow: hidden;
    border-radius: var(--tkwl-radius);
    background: var(--tkwl-accent-soft);
    aspect-ratio: 1;
}
.tkwl-item__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.tkwl-item__body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.tkwl-item__title {
    color: inherit;
    font-weight: 700;
    text-decoration: none;
}
.tkwl-item__title:hover {
    text-decoration: underline;
}
.tkwl-item__meta,
.tkwl-item__stock {
    font-size: .875em;
    opacity: .75;
}
.tkwl-item__stock.is-out {
    opacity: 1;
    color: #b32d2e;
}
.tkwl-item__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.tkwl-item__cart {
    flex: 1;
    text-align: center;
    font-size: .9em;
}
.tkwl-item__cart.is-secondary {
    background: transparent;
    border: 1px solid currentColor;
    color: inherit;
}
/* Round "×" (own list) or heart (shared list) on the card's top right. */
.tkwl-item__corner,
.tkwl-item__actions .tkwl-item__corner {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--wp--preset--color--custom-white, #fff);
    color: var(--wp--preset--color--custom-primary, currentColor);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .14);
    font: inherit;
    line-height: 1;
    cursor: pointer;
}
.tkwl-item__corner:hover,
.tkwl-item__corner:focus-visible {
    background: var(--wp--preset--color--custom-primary, #1e1e1e);
    color: var(--wp--preset--color--custom-white, #fff);
}
.tkwl-item__corner svg {
    display: block;
}
.tkwl-item__save .tkwl-heart {
    width: 18px;
    height: 18px;
}
.tkwl-block-actions:not(:has(.tkwl-item__actions)) {
    display: contents;
}
.tkwl-note {
    margin: 0 0 20px;
    padding: 12px 16px;
    border-radius: var(--tkwl-radius);
    background: var(--tkwl-accent-soft);
}
.tkwl-note--login {
    margin: 28px 0 0;
}
.tkwl-note a {
    color: inherit;
    font-weight: 700;
}
.tkwl-empty {
    padding: 40px 0;
    text-align: center;
}
.tkwl-empty p {
    margin: 0 0 20px;
}

/* Editor preview of the Wishlist block. */
.tkwl-editor-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 32px;
    border: 1px dashed currentColor;
    border-radius: 8px;
    text-align: center;
    opacity: .8;
}
.tkwl-editor-placeholder p {
    margin: 0;
    max-width: 420px;
    font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
    .tkwl-btn.is-popping .tkwl-heart,
    .tkwl-loading__ring {
        animation: none;
    }
}

/* Columns set on the Wishlist block (phones keep two, below). */
.tkwl-block-list.has-columns .tkwl-items {
    grid-template-columns: repeat(var(--tkwl-columns), minmax(0, 1fr));
}
/* Own layout (blocks placed in the Wishlist block): the blocks decide, buttons at the bottom. */
.tkwl-item--layout > .tkwl-item__actions,
.tkwl-item--layout .tkwl-block-actions {
    margin-top: auto;
}
.tkwl-item--layout > * {
    margin-block: 0;
}

/*
 * The corner button shows on hover (devices with a mouse) and with keyboard
 * focus inside the card; touch screens always show it. Block setting off =
 * .tkwl-actions-always. A saved heart on a shared list stays visible.
 */
@media (hover: hover) and (pointer: fine) {
    .tkwl-page:not(.tkwl-actions-always) .tkwl-item .tkwl-item__corner:not(.is-active) {
        opacity: 0;
        visibility: hidden;
        transition: opacity .15s ease, visibility 0s linear .15s, background-color .15s ease, color .15s ease;
    }
    .tkwl-page:not(.tkwl-actions-always) .tkwl-item:hover .tkwl-item__corner,
    .tkwl-page:not(.tkwl-actions-always) .tkwl-item:focus-within .tkwl-item__corner {
        opacity: 1;
        visibility: visible;
        transition: opacity .15s ease, visibility 0s, background-color .15s ease, color .15s ease;
    }
}

/* Editor preview of the "Wishlist Buttons" block. */
.tkwl-item__remove.is-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--wp--preset--color--custom-white, #fff);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .14);
    font-size: 18px;
    line-height: 1;
}

/* Editor: the layout is previewed at about one card's width. */
.tkwl-editor-layout {
    max-width: 320px;
    margin-top: 16px;
}

/* Phones: two products per row, actions below each other. */
@media (max-width: 600px) {
    .tkwl-items,
    .tkwl-block-list.has-columns .tkwl-items {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px 14px;
    }
    .tkwl-item__actions {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
}
