/**
 * Engagement features — wishlist, recently viewed, mobile bottom-nav,
 * WhatsApp float, trust strips.
 *
 * Mobile-first. Desktop enhancements via @media (min-width: 768px).
 *
 * @package LimarkWellness
 */

/* =========================================================================
   DESIGN TOKENS (local fallbacks — global.css tokens take precedence)
   ========================================================================= */

:root {
    --lm-eng-brand:        var(--color-safease-purple, #4A2366);
    --lm-eng-brand-alt:    var(--color-limark-navy, #1B2A5B);
    --lm-eng-white:        #ffffff;
    --lm-eng-off-white:    var(--color-off-white, #FAF8F5);
    --lm-eng-border:       var(--color-border-light, #E8E4DD);
    --lm-eng-text:         var(--color-text-primary, #1A1A1A);
    --lm-eng-text-sub:     var(--color-text-secondary, #6B6B6B);
    --lm-eng-wa-green:     #25D366;
    --lm-eng-heart-active: #e53e3e;
    --lm-eng-radius:       8px;
    --lm-eng-bottom-nav-h: 56px;
}

/* =========================================================================
   WISHLIST HEART BUTTON — product card + single-product hero overlay
   ========================================================================= */

.lm-wishlist-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 44px;
    min-height: 44px;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    transition: transform 0.18s ease, background 0.15s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.lm-wishlist-btn:focus-visible {
    outline: 2px solid var(--lm-eng-brand);
    outline-offset: 2px;
}

.lm-wishlist-btn:active {
    transform: scale(0.92);
}

.lm-wishlist-btn__icon {
    width: 20px;
    height: 20px;
    stroke: var(--lm-eng-text);
    fill: none;
    transition: stroke 0.15s ease, fill 0.15s ease;
    pointer-events: none;
}

/* Active / wishlisted state */
.lm-wishlist-btn.is-active .lm-wishlist-btn__icon,
.lm-wishlist-btn[aria-pressed="true"] .lm-wishlist-btn__icon {
    stroke: var(--lm-eng-heart-active);
    fill: var(--lm-eng-heart-active);
}

/* Pulse animation on toggle */
@keyframes lmHeartPulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.28); }
    70%  { transform: scale(0.92); }
    100% { transform: scale(1); }
}

.lm-wishlist-btn.lm-animate-pulse .lm-wishlist-btn__icon {
    animation: lmHeartPulse 0.38s ease forwards;
}

/* On product CARD — absolute overlay top-right */
.limark-pcard {
    position: relative;
}

.limark-pcard .lm-wishlist-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* On single-product hero — inline, smaller */
.pr-hero__wish-btn {
    flex-shrink: 0;
}

/* =========================================================================
   WISHLIST PAGE
   ========================================================================= */

.lm-wishlist-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 16px 80px;
}

.lm-wishlist-page__loading {
    text-align: center;
    padding: 64px 0;
    color: var(--lm-eng-text-sub);
    font-size: 15px;
}

.lm-wishlist-page__empty {
    text-align: center;
    padding: 64px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--lm-eng-text-sub);
}

.lm-wishlist-page__empty svg {
    color: var(--lm-eng-border);
}

.lm-wishlist-page__empty h2 {
    font-size: 22px;
    color: var(--lm-eng-text);
    margin: 0;
}

.lm-wishlist-page__empty p {
    font-size: 15px;
    margin: 0;
    max-width: 320px;
}
.lm-wishlist-page__empty a,
.lm-wishlist-page__empty .lm-btn,
.lm-wishlist-page__empty .lm-btn--primary {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 0 28px;
    height: 48px;
    background: #1B2A5B !important;
    color: #FFFFFF !important;
    border: none !important;
    border-radius: 999px !important;
    font-family: 'Inter', system-ui, sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: 0.06em;
    text-decoration: none !important;
    text-transform: uppercase;
    transition: background 0.2s;
}
.lm-wishlist-page__empty a:hover,
.lm-wishlist-page__empty .lm-btn:hover {
    background: #0F1D42 !important;
    color: #FFFFFF !important;
}

.lm-wishlist-page__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (min-width: 600px) {
    .lm-wishlist-page__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .lm-wishlist-page {
        padding: 48px 32px 80px;
    }

    .lm-wishlist-page__grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* =========================================================================
   RECENTLY VIEWED STRIP
   ========================================================================= */

.lm-recent {
    padding: 48px 0;
    background: var(--lm-eng-off-white);
}

.lm-recent .lm-section-head {
    text-align: center;
    margin-bottom: 28px;
    padding: 0 16px;
}

.lm-recent .lm-eyebrow {
    display: block;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--lm-eng-text-sub);
    margin-bottom: 6px;
}

.lm-recent .lm-section-head h2 {
    font-size: 22px;
    margin: 0;
    color: var(--lm-eng-text);
}

.lm-recent__grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 0 16px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.lm-recent__grid::-webkit-scrollbar {
    display: none;
}

/* JS-rendered mini-cards inside recently viewed */
.lm-recent-card {
    flex: 0 0 140px;
    scroll-snap-align: start;
    background: var(--lm-eng-white);
    border-radius: var(--lm-eng-radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--lm-eng-text);
    border: 1px solid var(--lm-eng-border);
    transition: box-shadow 0.18s ease;
}

.lm-recent-card:hover,
.lm-recent-card:focus {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
    outline: none;
}

.lm-recent-card__img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    padding: 10%;
    background: var(--lm-eng-off-white);
    display: block;
}

.lm-recent-card__img-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--lm-eng-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lm-eng-text-sub);
    font-size: 24px;
}

.lm-recent-card__body {
    padding: 10px 10px 12px;
}

.lm-recent-card__name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.lm-recent-card__price {
    font-size: 12px;
    color: var(--lm-eng-text-sub);
}

@media (min-width: 768px) {
    .lm-recent__grid {
        padding: 0 32px;
        gap: 16px;
    }

    .lm-recent-card {
        flex: 0 0 180px;
    }
}

@media (min-width: 1024px) {
    .lm-recent {
        padding: 64px 0;
    }

    .lm-recent__grid {
        padding: 0 48px;
    }
}

/* =========================================================================
   MOBILE BOTTOM NAV
   ========================================================================= */

.lm-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--lm-eng-bottom-nav-h);
    background: var(--lm-eng-white);
    border-top: 1px solid var(--lm-eng-border);
    display: flex;
    align-items: stretch;
    z-index: 900;
    /* Safe-area inset for iPhone home bar */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transition: transform 0.25s ease;
}

/* Hidden state — used by JS when sticky-cta is visible */
.lm-bottom-nav.is-hidden {
    transform: translateY(100%);
}

/* Only show on ≤899px */
@media (min-width: 900px) {
    .lm-bottom-nav {
        display: none;
    }
}

.lm-bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--lm-eng-text-sub);
    font-size: 10px;
    font-weight: 400;
    line-height: 1;
    padding: 6px 0;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

.lm-bottom-nav__item:focus-visible {
    outline: 2px solid var(--lm-eng-brand);
    outline-offset: -2px;
}

.lm-bottom-nav__item.is-active {
    color: var(--lm-eng-brand);
}

.lm-bottom-nav__icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* Cart icon with count badge */
.lm-bottom-nav__cart-wrap {
    position: relative;
    display: inline-flex;
}

.lm-bottom-nav__cart-count {
    position: absolute;
    top: -5px;
    right: -7px;
    min-width: 16px;
    height: 16px;
    background: var(--lm-eng-brand);
    color: var(--lm-eng-white);
    font-size: 9px;
    font-weight: 600;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
}

.lm-bottom-nav__cart-count:empty {
    display: none;
}

/* Body offset so content isn't hidden under nav bar */
@media (max-width: 899px) {
    body.has-bottom-nav {
        padding-bottom: calc(var(--lm-eng-bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    }
}

/* =========================================================================
   WHATSAPP FLOAT BUTTON
   ========================================================================= */

.lm-wa-float {
    position: fixed;
    bottom: calc(var(--lm-eng-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--lm-eng-wa-green);
    color: var(--lm-eng-white);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 850;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.lm-wa-float:hover,
.lm-wa-float:focus-visible {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(37, 211, 102, 0.55);
    outline: 3px solid rgba(37, 211, 102, 0.35);
    outline-offset: 2px;
}

.lm-wa-float__icon {
    width: 28px;
    height: 28px;
}

/* On desktop, sit above bottom of viewport (no bottom-nav offset) */
@media (min-width: 900px) {
    .lm-wa-float {
        bottom: 24px;
        right: 24px;
    }
}

/* Mobile — push above cart sticky bar AND bottom-nav. Hide on checkout. */
@media (max-width: 899px) {
    body.lm-page-cart .lm-wa-float {
        bottom: calc(var(--lm-eng-bottom-nav-h, 56px) + 64px + env(safe-area-inset-bottom, 0px));
    }
    body.lm-page-checkout .lm-wa-float {
        display: none !important;
    }
}

/* Pulse animation — fires once on first scroll into view */
@keyframes lmWaPulse {
    0%   { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.55); }
    70%  { box-shadow: 0 0 0 16px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

.lm-wa-float.lm-pulse {
    animation: lmWaPulse 1.2s ease 0.5s 2;
}

/* =========================================================================
   TRUST STRIP — cart + checkout
   ========================================================================= */

.lm-trust-strip--cart {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    background: var(--lm-eng-off-white);
    border-radius: var(--lm-eng-radius);
    padding: 14px 16px;
    margin-bottom: 20px;
}

.lm-trust-strip__item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 500;
    color: var(--lm-eng-text);
    white-space: nowrap;
}

.lm-trust-strip__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--lm-eng-brand);
}

@media (min-width: 600px) {
    .lm-trust-strip--cart {
        gap: 16px;
        padding: 16px 24px;
    }

    .lm-trust-strip__item {
        font-size: 13px;
    }
}

/* =========================================================================
   JS-RENDERED PRODUCT CARD (wishlist page + recently-viewed)
   ========================================================================= */

.lm-eng-card {
    background: var(--lm-eng-white);
    border: 1px solid var(--lm-eng-border);
    border-radius: var(--lm-eng-radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--lm-eng-text);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.18s ease;
}

.lm-eng-card:hover,
.lm-eng-card:focus-visible {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10);
    outline: none;
}

.lm-eng-card__img-wrap {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background: var(--lm-eng-off-white);
}

.lm-eng-card__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10%;
    display: block;
    transition: transform 0.3s ease;
}

.lm-eng-card:hover .lm-eng-card__img {
    transform: scale(1.03);
}

.lm-eng-card__body {
    padding: 12px 14px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lm-eng-card__brand {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--lm-eng-text-sub);
}

.lm-eng-card__name {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.lm-eng-card__price {
    font-size: 13px;
    color: var(--lm-eng-text-sub);
    margin-top: auto;
}

.lm-eng-card__wish-wrap {
    position: absolute;
    top: 8px;
    right: 8px;
}

/* =========================================================================
   REDUCED MOTION — disable animations for accessibility
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
    .lm-wishlist-btn,
    .lm-wishlist-btn__icon,
    .lm-wa-float,
    .lm-bottom-nav,
    .lm-eng-card__img {
        transition: none !important;
        animation: none !important;
    }

    .lm-wishlist-btn.lm-animate-pulse .lm-wishlist-btn__icon {
        animation: none !important;
    }

    .lm-wa-float.lm-pulse {
        animation: none !important;
    }
}
