.counter {
    padding-block: 80px;
}

.counter-item {
    position: relative;
    overflow: hidden;
    background: var(--wp--preset--color--purple-light);
    box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    padding: 40px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    box-sizing: border-box;
}

.counter-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(121deg, #F7F7FF 16.13%, #F1EDFC 100%);
    opacity: 1;
    transition: opacity .3s ease;
    z-index: 0;
}

.counter-item:hover::before {
    opacity: 0;
}

.counter-item>* {
    position: relative;
    z-index: 1;
}

/* ── Counter animation ─────────────────────────── */

.counter-anim {
    display: flex;
    align-items: baseline;
    justify-content: center;
    font-family: var(--wp--preset--font-family--text);
    font-size: 60px;
    font-weight: 400;
    color: var(--wp--preset--color--black);
    line-height: normal;
    font-variant-numeric: tabular-nums;
}

.counter-anim .spacer {
    display: inline-block;
    width: 0.25em;
}

.counter-anim .number {
    display: inline-block;
    position: relative;
    min-height: 1em;
    text-align: center;
}

.counter-anim .placeholder {
    display: block;
    transition: opacity 0.1s ease;
}

.counter-anim .placeholder.go-out {
    opacity: 0;
}

.counter-anim .animate-number {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.counter-anim .animate-number.blur {
    animation: counter-blur 0.15s ease-out both;
}

.counter-anim .animate-number.slow {
    animation: counter-fade 0.3s ease-out both;
}

.counter-anim .animate-number.final {
    animation: counter-final 0.2s ease-out both;
}

@keyframes counter-blur {
    from {
        opacity: 0;
        filter: blur(6px);
    }

    to {
        opacity: 1;
        filter: none;
    }
}

@keyframes counter-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes counter-final {
    from {
        opacity: 0;
        transform: scale(0.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.counter-text {
    font-size: 18px;
    font-weight: 400;
    color: var(--wp--preset--color--purple-500);
    line-height: 24px;
    text-align: center;
}

/* Desktop: grid layout, bypass Swiper */
@media (min-width: 992px) {
    .counter-swiper.swiper {
        overflow: visible;
    }

    .counter-swiper .swiper-wrapper {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
        transform: none !important;
        will-change: auto;
    }

    /* min-width: 0 is required for a 1fr grid track to actually shrink below
       its content's intrinsic width - without it, a nowrap flex row like
       .counter-anim (long numbers, e.g. "60 000+") forces the whole grid
       (and with it the page) to overflow horizontally at narrower desktop
       widths, since grid items default to min-width: auto. */
    .counter-swiper .swiper-slide {
        width: auto !important;
        min-width: 0;
        margin: 0 !important;
    }

    .counter-swiper .swiper-pagination {
        display: none;
    }
}

/* Between 992-1300px the 4-column grid doesn't have room for "60px" numbers
   like "60 000+" at their full Figma size without clipping against
   .counter-item's overflow:hidden - scale down until there's enough column
   width, then hand back to the fixed 60px above that. */
@media (min-width: 992px) and (max-width: 1300px) {
    .counter-anim {
        font-size: 40px;
    }
}

/* Tablet + Mobile: Swiper slider */
@media (max-width: 991px) {
    .counter {
        padding-block-start: 48px;
        padding-block-end: 64px;
    }

    .counter-swiper.swiper {
        overflow: hidden;
    }

    .counter-swiper .swiper-wrapper {
        display: flex;
    }

    .counter-swiper .swiper-slide {
        width: 100%;
    }

    .counter-item {
        padding: 32px 24px;
    }

    .counter-swiper .swiper-pagination {
        position: static;
        margin-top: 24px;
        display: flex;
        justify-content: center;
        gap: 8px;
    }

    .counter-swiper .swiper-pagination-bullet {
        width: 8px;
        height: 8px;
        background-color: var(--wp--preset--color--neutral-200);
        opacity: 1;
        border-radius: 50%;
        transition: background-color 0.3s ease;
    }

    .counter-swiper .swiper-pagination-bullet-active {
        background-color: var(--wp--preset--color--purple);
    }
}

/* ── Dark mode ─────────────────────────────────────────────────────────────── */

html[data-theme="dark"] .counter {
    background: var(--wp--preset--color--black, #1A1A25);
}

html[data-theme="dark"] .counter-swiper .swiper-pagination-bullet {
    background-color: rgba(255, 255, 255, .2);
}

html[data-theme="dark"] .counter-swiper .swiper-pagination-bullet-active {
    background-color: var(--wp--preset--color--purple);
}