/**
 * Shoppable Image – Frontend Styles
 *
 * Styles for [shoppable_image] shortcode.
 * Hotspot pins pulse to attract attention; tooltip cards appear on click.
 *
 * @package BrineAndBloom
 */

/* ============================================================
   CONTAINER
   ============================================================ */

.bnb-shoppable-image {
    position: relative;
    display: inline-block;
    line-height: 0; /* removes gap below <img> */
    width: 100%;
}

.bnb-shoppable-image img {
    display: block;
    width: 100%;
    height: auto;
}

/* ============================================================
   HOTSPOT PIN
   ============================================================ */

.bnb-hotspot {
    position: absolute;
    /* x% / y% set inline via style="left:…; top:…;" */
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 10;
    /* Keep focus ring visible for keyboard users */
    outline-offset: 2px;
}

.bnb-shoppable-image button.bnb-hotspot,
.bnb-shoppable-image button.bnb-hotspot:hover {
    background-color: transparent;
    border: none;
}

/* Hotspot dot container (based on CodePen example)
   Source: https://codepen.io/pdv/pen/VwvmrqB */
.bnb-hotspot-dot {
    position: relative;
    width: 24px;
    height: 24px;
}

.bnb-hotspot-dot .ring {
    display: block;
    position: absolute;
    width: 28px;
    height: 28px;
    top: -2px;
    left: -2px;
    transform-origin: 50% 50%;
    border-radius: 50%;
    border: 2px solid #8DBF6A;
    opacity: 0;
    animation: bnb-pulsate 2000ms ease-out infinite;
}

.bnb-hotspot-dot .circle {
    background: #8DBF6A;
    box-shadow: rgba(86, 99, 129, 0.5) 0px 2px 8px;
    border: 1px solid #fff;
    border-radius: 100%;
    position: absolute;
    top: 0;
    left: 0;
    width: 24px;
    height: 24px;
    opacity: 0.75;
    display: flex;
    align-items: center;
    transition: transform 100ms ease-out;
}

.bnb-hotspot:hover .circle {
    opacity: 1;
    cursor: pointer;
    transform: scale(1.1);
}

.bnb-hotspot:active .circle {
    transform: scale(1);
}

.bnb-hotspot-dot .dot {
    box-shadow: rgba(86, 99, 129, 0.5) 0px 2px 8px;
    display: block;
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    transition: opacity 0.2s ease-in, transform 0.1s ease-out, background 0.2s ease-in;
    margin: 0 auto;
}

/* Pause animation while tooltip is open */
.bnb-hotspot[aria-expanded="true"] .ring {
    animation-play-state: paused;
}

.bnb-hotspot:active .ring {
    animation: bnb-stop-pulsate 0.3s;
}

@keyframes bnb-pulsate {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    66% {
        transform: scale(2);
        opacity: 0;
    }
}

@keyframes bnb-stop-pulsate {
    from {
        opacity: 0.4;
    }
    to {
        transform: scale(2);
        opacity: 0;
    }
}

/* ============================================================
   TOOLTIP CARD
   ============================================================ */

.bnb-hotspot-tooltip {
    position: absolute;
    /* Default: appear above the hotspot.
       JS adds .bnb-tooltip-below when near the top edge. */
    bottom: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    background: var(--e-global-color-white, #ffffff);
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    z-index: 20;

    /* Hidden by default */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    transform: translateX(-50%) translateY(6px);
}

/* Small arrow – above (pointing down) */
.bnb-hotspot-tooltip::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 7px 7px 0;
    border-style: solid;
    border-color: var(--e-global-color-white, #ffffff) transparent transparent;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.08));
}

/* Below variant */
.bnb-hotspot-tooltip.bnb-tooltip-below {
    bottom: auto;
    top: calc(100% + 14px);
    transform: translateX(-50%) translateY(-6px);
}

.bnb-hotspot-tooltip.bnb-tooltip-below::after {
    bottom: auto;
    top: -7px;
    border-width: 0 7px 7px;
    border-color: transparent transparent var(--e-global-color-white, #ffffff);
}

/* Visible state (added by JS) */
.bnb-hotspot-tooltip.bnb-tooltip-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.bnb-hotspot-tooltip.bnb-tooltip-below.bnb-tooltip-visible {
    transform: translateX(-50%) translateY(0);
}

/* Horizontal nudge classes added by JS when near left/right edges */
.bnb-hotspot-tooltip.bnb-tooltip-nudge-right {
    left: 0;
    transform: translateX(0) translateY(6px);
}
.bnb-hotspot-tooltip.bnb-tooltip-nudge-right.bnb-tooltip-visible {
    transform: translateX(0) translateY(0);
}
.bnb-hotspot-tooltip.bnb-tooltip-nudge-right::after {
    left: 24px;
}

.bnb-hotspot-tooltip.bnb-tooltip-nudge-left {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(6px);
}
.bnb-hotspot-tooltip.bnb-tooltip-nudge-left.bnb-tooltip-visible {
    transform: translateX(0) translateY(0);
}
.bnb-hotspot-tooltip.bnb-tooltip-nudge-left::after {
    left: auto;
    right: 24px;
    transform: none;
}

/* ============================================================
   TOOLTIP CONTENT
   ============================================================ */

.bnb-tooltip-img {
    display: block;
    width: 100%;
    height: 130px;
    object-fit: cover;
    object-position: center;
}

.bnb-tooltip-img-placeholder {
    display: block;
    width: 100%;
    height: 130px;
    background: #f4f4f4;
}

.bnb-tooltip-body {
    padding: 10px 12px 12px;
}

.bnb-tooltip-name {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--e-global-color-text, #2c3e50);
    margin-bottom: 4px;
    line-height: 1.3;
    /* Clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bnb-tooltip-price {
    display: block;
    font-size: 0.8rem;
    color: var(--e-global-color-secondary, #555);
    margin-bottom: 8px;
}

/* Inherit WooCommerce price styles if present */
.bnb-tooltip-price .woocommerce-Price-amount {
    font-weight: 600;
    color: var(--e-global-color-text, #2c3e50);
}

.bnb-shoppable-image .bnb-hotspot-tooltip .bnb-tooltip-link {
    display: block;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--e-global-color-white, #ffffff);
    background: var(--e-global-color-primary, #2c3e50);
    border-radius: 3px;
    padding: 5px 10px;
    text-decoration: none;
    transition: background 0.15s ease;
}

.bnb-shoppable-image .bnb-hotspot-tooltip .bnb-tooltip-link:hover,
.bnb-shoppable-image .bnb-hotspot-tooltip .bnb-tooltip-link:focus {
    background: var(--e-global-color-accent, #3d5166);
    color: var(--e-global-color-white, #ffffff);
    text-decoration: none;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 480px) {
    .bnb-hotspot-tooltip {
        width: 170px;
    }

    .bnb-tooltip-img {
        height: 110px;
    }
}
