/* ─────────────────────────────────────────────────────────────────────────────
   KTM Product Machine Assembly Modal & Interactive Animation
   ───────────────────────────────────────────────────────────────────────────── */

/* Modal Root Overlay */
.ktm-assemble-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.35s ease;
}

.ktm-assemble-modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Glassmorphism Backdrop */
.ktm-assemble-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    z-index: 1;
}

/* Modal Dialog Window */
.ktm-assemble-modal-dialog {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 980px;
    max-height: 90vh;
    background: #ffffff;
    border-radius: 28px;
    border: 1.5px solid rgba(var(--assemble-color-rgb, 0, 153, 204), 0.28);
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.35), 0 0 35px rgba(var(--assemble-color-rgb, 0, 153, 204), 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.93) translateY(24px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.ktm-assemble-modal.is-open .ktm-assemble-modal-dialog {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.ktm-assemble-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
    gap: 16px;
}

.ktm-assemble-modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.ktm-assemble-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(var(--assemble-color-rgb, 0, 153, 204), 0.1);
    color: var(--assemble-color, #0099cc);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 5px 12px;
    border-radius: 999px;
}

.ktm-assemble-modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.3px;
}

.ktm-assemble-modal-dialog .ktm-assemble-modal-header .ktm-assemble-modal-close {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1.5px solid var(--assemble-color, #638591);
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin: 0;
    line-height: 1;
    outline: none;
    box-shadow: none;
    transition: background-color 0.25s ease, border-color 0.25s ease;
    flex-shrink: 0;
    box-sizing: border-box;
}

.ktm-assemble-modal-dialog .ktm-assemble-modal-header .ktm-assemble-modal-close svg {
    display: block;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    color: var(--assemble-color, #638591);
    stroke: var(--assemble-color, #638591);
    fill: none;
    stroke-width: 2.8px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.25s ease;
    transform-origin: center center;
    pointer-events: none;
}

.ktm-assemble-modal-dialog .ktm-assemble-modal-header .ktm-assemble-modal-close:hover {
    filter: brightness(1.1);
}

.ktm-assemble-modal-dialog .ktm-assemble-modal-header .ktm-assemble-modal-close:hover svg {
    transform: rotate(90deg);
    filter: brightness(1.1);
}

/* Modal Body */
.ktm-assemble-modal-body {
    padding: 28px;
    overflow: visible;
    position: relative;
    background: radial-gradient(circle at center, rgba(var(--assemble-color-rgb, 0, 153, 204), 0.04) 0%, rgba(255, 255, 255, 1) 75%);
}

/* Machine Stage Area */
.ktm-assemble-stage {
    position: relative;
    width: 100%;
    margin: 0 auto;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ktm-assemble-image {
    width: 100%;
    height: auto;
    max-height: 60vh;
    display: block;
    object-fit: contain;
    border-radius: 18px;
    filter: drop-shadow(0 15px 35px rgba(0, 0, 0, 0.08));
}

.ktm-assemble-empty {
    padding: 60px 20px;
    text-align: center;
    color: #64748b;
    font-size: 15px;
}

/* Hotspots Pins Layer */
.ktm-assemble-hotspots-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Pin Item: Initial State (Only image visible, plus hidden at offset) */
.ktm-assemble-pin-item {
    position: absolute;
    transform: translate(-50%, -50%) translate(var(--init-offset-x, 0px), var(--init-offset-y, 40px)) scale(0.4);
    opacity: 0;
    pointer-events: none;
    z-index: 20;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        transform 1.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* Active Pin Animation Triggered 0.8s after Modal Open */
.ktm-assemble-modal.is-pins-animated .ktm-assemble-pin-item {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) translate(0, 0) scale(1);
    transition-delay: calc(var(--pin-index, 0) * 0.1s);
}

.ktm-assemble-pin-item.is-active {
    z-index: 99;
}

/* Assemble Pin Trigger Button */
.ktm-assemble-pin-btn {
    width: 36px;
    height: 36px;
    border-radius: 50% !important;
    background-color: var(--assemble-color, #0099cc);
    border: 2.5px solid #ffffff !important;
    color: #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    padding: 0 !important;
    margin: 0;
    outline: none;
    box-shadow: 0 0 0 3.5px rgba(var(--assemble-color-rgb, 0, 153, 204), 0.35), 0 6px 18px rgba(0, 0, 0, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ktm-assemble-pin-btn:hover,
.ktm-assemble-pin-item.is-active .ktm-assemble-pin-btn {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(var(--assemble-color-rgb, 0, 153, 204), 0.5), 0 8px 22px rgba(0, 0, 0, 0.3);
}

/* Pulsing Outer Ring (Activates when pins are animated) */
.ktm-pin-pulse {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: rgba(var(--assemble-color-rgb, 0, 153, 204), 0.45);
    animation: ktmAssemblePulse 2.2s infinite cubic-bezier(0.25, 1, 0.5, 1);
    pointer-events: none;
    z-index: -1;
    opacity: 0;
}

.ktm-assemble-modal.is-pins-animated .ktm-pin-pulse {
    opacity: 1;
}

.ktm-assemble-pin-item.is-active .ktm-pin-pulse {
    animation: none;
    opacity: 0;
}

@keyframes ktmAssemblePulse {
    0% {
        transform: scale(0.85);
        opacity: 0.95;
    }

    70% {
        transform: scale(1.75);
        opacity: 0;
    }

    100% {
        transform: scale(1.75);
        opacity: 0;
    }
}

/* Icon Switching (+ to X) */
.ktm-pin-icon-inner {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ktm-svg-plus,
.ktm-svg-close {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.ktm-svg-close {
    display: none;
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}

.ktm-assemble-pin-item.is-active .ktm-svg-plus {
    display: none;
    opacity: 0;
}

.ktm-assemble-pin-item.is-active .ktm-svg-close {
    display: flex;
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Tooltip Card (Desktop/Tablet) */
.ktm-assemble-tooltip {
    position: absolute;
    bottom: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: 320px;
    max-width: 86vw;
    background: #ffffff;
    border: 1.5px solid rgba(var(--assemble-color-rgb, 0, 153, 204), 0.3);
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14), 0 0 24px rgba(var(--assemble-color-rgb, 0, 153, 204), 0.1);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 100;
    box-sizing: border-box;
}

.ktm-assemble-pin-item.is-active .ktm-assemble-tooltip {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

@media (hover: hover) and (min-width: 992px) {
    .ktm-assemble-pin-item:hover {
        z-index: 99;
    }

    .ktm-assemble-pin-item:hover .ktm-svg-plus {
        display: none;
    }

    .ktm-assemble-pin-item:hover .ktm-svg-close {
        display: flex;
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }

    .ktm-assemble-pin-item:hover .ktm-assemble-tooltip {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateX(-50%) translateY(0);
    }
}

/* Tooltip Contents */
.ktm-tooltip-tagline {
    display: inline-block;
    background: rgba(var(--assemble-color-rgb, 0, 153, 204), 0.12);
    color: var(--assemble-color, #0099cc);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 4px 10px;
    border-radius: 5px;
    margin-bottom: 8px;
}

.ktm-tooltip-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 6px 0;
    line-height: 1.35;
}

.ktm-tooltip-desc {
    font-size: 13px;
    color: #475569;
    line-height: 1.6;
    margin: 0;
}

.ktm-tooltip-desc p {
    margin: 0 0 6px 0;
}

.ktm-tooltip-desc p:last-child {
    margin-bottom: 0;
}

/* Tooltip Position Flipping */
.ktm-assemble-tooltip.pos-bottom {
    bottom: auto;
    top: calc(100% + 14px);
    transform: translateX(-50%) translateY(-10px);
}

.ktm-assemble-pin-item.is-active .ktm-assemble-tooltip.pos-bottom,
.ktm-assemble-pin-item:hover .ktm-assemble-tooltip.pos-bottom {
    transform: translateX(-50%) translateY(0);
}

.ktm-assemble-tooltip.pos-left {
    left: 0;
    transform: translateX(0) translateY(10px);
}

.ktm-assemble-pin-item.is-active .ktm-assemble-tooltip.pos-left,
.ktm-assemble-pin-item:hover .ktm-assemble-tooltip.pos-left {
    transform: translateX(0) translateY(0);
}

.ktm-assemble-tooltip.pos-right {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(10px);
}

.ktm-assemble-pin-item.is-active .ktm-assemble-tooltip.pos-right,
.ktm-assemble-pin-item:hover .ktm-assemble-tooltip.pos-right {
    transform: translateX(0) translateY(0);
}

/* Mobile Details Box */
.ktm-assemble-mobile-info {
    display: none;
}

/* Modal Footer */
.ktm-assemble-modal-footer {
    padding: 16px 28px;
    border-top: 1px solid #f1f5f9;
    background: #ffffff;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.ktm-modal-view-product {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: var(--assemble-color, #0099cc);
    color: #ffffff !important;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
    text-decoration: none !important;
    transition: all 0.25s ease;
}

.ktm-modal-view-product:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

/* Modal Open Body Lock */
body.ktm-modal-open {
    overflow: hidden !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Responsive Breakpoints
   ───────────────────────────────────────────────────────────────────────────── */

@media (max-width: 991px) {
    .ktm-assemble-modal {
        padding: 16px;
    }

    .ktm-assemble-modal-header {
        padding: 16px 20px;
    }

    .ktm-assemble-modal-title {
        font-size: 17px;
    }

    .ktm-assemble-modal-body {
        padding: 18px 20px;
    }

    .ktm-assemble-pin-btn {
        width: 30px;
        height: 30px;
    }

    .ktm-assemble-pin-btn svg {
        width: 12px;
        height: 12px;
    }

    .ktm-assemble-tooltip {
        width: 270px;
        padding: 15px 16px;
    }

    .ktm-tooltip-title {
        font-size: 15px;
    }

    .ktm-tooltip-desc {
        font-size: 12px;
    }

    .ktm-assemble-modal-footer {
        padding: 14px 20px;
    }
}

@media (max-width: 575px) {
    .ktm-assemble-modal {
        padding: 10px;
    }

    .ktm-assemble-modal-dialog {
        border-radius: 20px;
        max-height: 95vh;
    }

    .ktm-assemble-modal-header {
        padding: 14px 16px;
    }

    .ktm-assemble-modal-title {
        font-size: 15px;
    }

    .ktm-assemble-modal-close {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        border-radius: 8px !important;
    }

    .ktm-assemble-modal-close svg {
        width: 15px !important;
        height: 15px !important;
        min-width: 15px !important;
        min-height: 15px !important;
    }

    .ktm-assemble-modal-body {
        padding: 14px 14px;
    }

    .ktm-assemble-pin-btn {
        width: 26px;
        height: 26px;
        border-width: 1.5px !important;
    }

    .ktm-assemble-pin-btn svg {
        width: 10px;
        height: 10px;
    }

    .ktm-pin-pulse {
        inset: -5px;
    }

    /* Hide floating tooltip on small mobile screens to prevent overflow */
    .ktm-assemble-tooltip {
        display: none !important;
    }

    /* Full width details card under image in mobile modal */
    .ktm-assemble-mobile-info {
        display: block;
        width: 100%;
        margin-top: 14px;
        background: #ffffff;
        border: 1.5px solid rgba(var(--assemble-color-rgb, 0, 153, 204), 0.28);
        border-radius: 14px;
        padding: 14px 16px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06), 0 0 16px rgba(var(--assemble-color-rgb, 0, 153, 204), 0.08);
        box-sizing: border-box;
    }

    .ktm-assemble-mobile-info:empty {
        display: none !important;
    }

    .ktm-assemble-mobile-info .ktm-tooltip-tagline {
        display: inline-block;
        background: rgba(var(--assemble-color-rgb, 0, 153, 204), 0.12);
        color: var(--assemble-color, #0099cc);
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        padding: 3px 8px;
        border-radius: 4px;
        margin-bottom: 6px;
    }

    .ktm-assemble-mobile-info .ktm-tooltip-title {
        font-size: 15px;
        font-weight: 700;
        color: #0f172a;
        margin: 0 0 6px 0;
        line-height: 1.35;
    }

    .ktm-assemble-mobile-info .ktm-tooltip-desc {
        font-size: 12px;
        color: #475569;
        line-height: 1.55;
        margin: 0;
    }

    .ktm-assemble-modal-footer {
        padding: 12px 16px;
        justify-content: center;
    }

    .ktm-modal-view-product {
        width: 100%;
        justify-content: center;
        text-align: center;
        font-size: 12px;
        padding: 9px 16px;
    }
}