/* ==========================================================
   Arraytics Integrations Icons widget (pure CSS, no JS)
   Round bubbles joined by a "gooey" neck. The neck is a masked
   pseudo-element whose concave edges are two fillet circles that
   sit exactly tangent to both neighbouring bubbles.

   Unitless inputs (set from Elementor controls, px):
     --tw-int-s    bubble size
     --tw-int-g    horizontal gap
     --tw-int-f    fillet (curve) radius   -> must be > gap / 2
     --tw-int-cols items per row
   ========================================================== */
.tw-integrations {
    --tw-int-s: 100;
    --tw-int-g: 20;
    --tw-int-f: 18;
    --tw-int-o: 6;               /* how far the neck tucks under each bubble */
    --tw-int-cols: 10;
    --tw-int-row-gap: 20px;
    --tw-int-icon: 60px;
    --tw-int-bg: #f7f7ff;
    --tw-int-bg-hover: #ffffff;
    --tw-int-connector: var(--tw-int-bg);
    --tw-int-hover-scale: 1.08;
    --tw-int-speed: 0.3s;

    /* derived lengths */
    --tw-int-size: calc(var(--tw-int-s) * 1px);
    --tw-int-gap: calc(var(--tw-int-g) * 1px);

    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    column-gap: var(--tw-int-gap);
    row-gap: var(--tw-int-row-gap);
    max-width: calc(var(--tw-int-cols) * var(--tw-int-size) + (var(--tw-int-cols) - 1) * var(--tw-int-gap));
    margin: 0 auto;
    padding: 0;
    list-style: none;
}

.tw-integrations__item {
    /* neck geometry (unitless math, converted with * 1px) */
    --R: calc(var(--tw-int-s) / 2);
    --F: max(var(--tw-int-f), calc(var(--tw-int-g) / 2 + 0.5));
    --FY: calc(var(--R) - sqrt(max(0, pow(var(--R) + var(--F), 2) - pow(var(--tw-int-g) / 2 + var(--R), 2))));
    --r: calc(var(--R) * 1px);
    --o: calc(var(--tw-int-o) * 1px);
    --f: calc(var(--F) * 1px);
    --fy: calc(var(--FY) * 1px);
    --w: calc(var(--tw-int-gap) + var(--o) * 2);

    position: relative;
    flex: 0 0 auto;
    width: var(--tw-int-size);
    height: var(--tw-int-size);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* The neck: reaches back to the previous bubble */
.tw-integrations--connected .tw-integrations__item:not(:first-child)::before {
    content: "";
    position: absolute;
    z-index: 0;
    top: 0;
    right: calc(100% - var(--o));
    width: var(--w);
    height: 100%;
    background: var(--tw-int-connector);
    pointer-events: none;
    -webkit-mask:
        linear-gradient(#000 0 0) 50% 50% / 100% calc(100% - var(--fy) * 2) no-repeat,
        radial-gradient(circle var(--r) at calc(var(--o) - var(--r)) 50%, transparent calc(var(--r) - 0.5px), #000 var(--r)) no-repeat,
        radial-gradient(circle var(--r) at calc(var(--w) - var(--o) + var(--r)) 50%, transparent calc(var(--r) - 0.5px), #000 var(--r)) no-repeat,
        radial-gradient(circle var(--f) at 50% var(--fy), transparent calc(var(--f) - 0.5px), #000 var(--f)) no-repeat,
        radial-gradient(circle var(--f) at 50% calc(100% - var(--fy)), transparent calc(var(--f) - 0.5px), #000 var(--f)) no-repeat;
    -webkit-mask-composite: source-in;
    mask:
        linear-gradient(#000 0 0) 50% 50% / 100% calc(100% - var(--fy) * 2) no-repeat,
        radial-gradient(circle var(--r) at calc(var(--o) - var(--r)) 50%, transparent calc(var(--r) - 0.5px), #000 var(--r)) no-repeat,
        radial-gradient(circle var(--r) at calc(var(--w) - var(--o) + var(--r)) 50%, transparent calc(var(--r) - 0.5px), #000 var(--r)) no-repeat,
        radial-gradient(circle var(--f) at 50% var(--fy), transparent calc(var(--f) - 0.5px), #000 var(--f)) no-repeat,
        radial-gradient(circle var(--f) at 50% calc(100% - var(--fy)), transparent calc(var(--f) - 0.5px), #000 var(--f)) no-repeat;
    mask-composite: intersect;
}

.tw-integrations__circle {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--tw-int-bg);
    text-decoration: none;
    box-sizing: border-box;
    transition: background-color var(--tw-int-speed) ease, box-shadow var(--tw-int-speed) ease, transform var(--tw-int-speed) ease, border-color var(--tw-int-speed) ease;
}

a.tw-integrations__circle:focus-visible {
    outline: 2px solid #5959ff;
    outline-offset: 3px;
}

.tw-integrations__item:hover .tw-integrations__circle {
    background: var(--tw-int-bg-hover);
}

.tw-integrations__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--tw-int-icon);
    height: var(--tw-int-icon);
    line-height: 1;
    font-size: var(--tw-int-icon);
    transition: transform var(--tw-int-speed) ease, filter var(--tw-int-speed) ease, opacity var(--tw-int-speed) ease;
}

.tw-integrations__icon img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
}

.tw-integrations__icon svg {
    width: 100%;
    height: 100%;
}

.tw-integrations__item:hover .tw-integrations__icon {
    transform: scale(var(--tw-int-hover-scale));
}

/* Grayscale mode */
.tw-integrations--grayscale .tw-integrations__icon {
    filter: grayscale(100%);
    opacity: 0.7;
}

.tw-integrations--grayscale .tw-integrations__item:hover .tw-integrations__icon {
    filter: none;
    opacity: 1;
}

/* Tooltip */
.tw-integrations__tooltip {
    position: absolute;
    z-index: 5;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translate(-50%, 6px);
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--tw-int-tooltip-bg, #111827);
    color: #fff;
    font-size: 14px;
    line-height: 1.35;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--tw-int-speed) ease, transform var(--tw-int-speed) ease, visibility var(--tw-int-speed);
}

.tw-integrations__tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--tw-int-tooltip-bg, #111827);
}

.tw-integrations__item:hover .tw-integrations__tooltip,
.tw-integrations__item:focus-within .tw-integrations__tooltip {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

/* Badge (e.g. "Coming Soon") */
.tw-integrations__badge {
    position: absolute;
    z-index: 4;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 7px;
    border-radius: 999px;
    background-color: #FFE94D;
    color: #1D1D35;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.02em;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(29, 29, 53, 0.12);
}

@media (max-width: 767px) {
    .tw-integrations__badge {
        top: -6px;
        padding: 1px 5px;
        font-size: 8px;
    }
}

/* Staggered entrance animation (CSS only, runs on page load) */
@keyframes tw-int-pop {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.tw-integrations--animate .tw-integrations__item {
    animation: tw-int-pop 0.5s ease both;
    animation-delay: calc(var(--tw-int-i, 0) * 60ms);
}

@media (prefers-reduced-motion: reduce) {
    .tw-integrations--animate .tw-integrations__item {
        animation: none;
    }
    .tw-integrations__circle,
    .tw-integrations__icon {
        transition: none;
    }
}

/* Touch screens have no hover: drop the hidden tooltip so it can't widen the page */
@media (hover: none) {
    .tw-integrations__tooltip {
        display: none;
    }
}

/* Hidden tooltips of edge items must never widen the page horizontally */
.elementor-widget-arraytics-integrations {
    overflow-x: clip;
}
