.tpl-tabs-background {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow: hidden;
    margin-top: 32px;
}

.tpl-tabs-background__content {
    position: relative;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
}

.tpl-tabs-background__text {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

@keyframes fadeInText {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOutText {
    from { opacity: 1; }
    to { opacity: 0; }
}

.tpl-tabs-background__image {
    position: relative;
    z-index: 0;
    display: flex;
    min-height: 512px;
    border-radius: 32px;
}

.tpl-tabs-background__image::before,
.tpl-tabs-background__image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 32px;
}

.tpl-tabs-background__image::before {
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, #000 79.66%), var(--background-image) lightgray; background-size: cover; background-position: center; background-repeat: no-repeat;
    opacity: 1;
    z-index: 1;
}
.tpl-tabs-background__image::after {
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, #000 79.66%), var(--background-image-next) lightgray; background-size: cover; background-position: center; background-repeat: no-repeat;
    opacity: 0;
    z-index: 2;
}

.tpl-tabs-background__image.transitioning::before { opacity: 0; z-index: -1; }
.tpl-tabs-background__image.transitioning::after { opacity: 1; z-index: 0; }
.tpl-tabs-background__image.transitioning::before,
.tpl-tabs-background__image.transitioning::after {
    transition: opacity 0.6s ease-in-out;
}

.tpl-tabs-background__tabs {
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-self: end;
    overflow: hidden;
}

.tpl-tabs-background__tab {
    background-color: #F8F7F5;
    border: none;
    cursor: pointer;
    display: flex;
    width: 120px;
    padding: 20px;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    text-align: start;
    gap: 8px;
}

.tpl-tabs-background__tab--active,
.tpl-tabs-background__tab--active h4 {
    background-color: transparent;
    border-radius: 32px 0 0 32px;
    position: relative;
    color: var(--color-primary-white, #FFF)
}

.tpl-tabs-background__tab svg { filter: brightness(0) saturate(100%); }
.tpl-tabs-background__tab--active svg { filter: brightness(0) saturate(100%) invert(100%); }

.tpl-tabs-background__tab--active::after,
.tpl-tabs-background__tab--active::before {
    content: "";
    position: absolute;
    width: 32px;
    aspect-ratio: 1;
    background-image: radial-gradient(circle at 100% 100%, transparent 32px, #F8F7F5 0);
    background-position: center;
}

.tpl-tabs-background__tab--active::before {
    bottom: 0;
    left: 0;
    rotate: 180deg;
    transform: rotateY(180deg);
    background-position: center;
}

.tpl-tabs-background__tab--active::after { top: 0; left: 0; }
.tpl-tabs-background__tab--active:first-child::after,
.tpl-tabs-background__tab--active:last-child::before { content: none; }
.tpl-tabs-background__tab:first-child.tpl-tabs-background__tab--active,
.tpl-tabs-background__tab:last-child.tpl-tabs-background__tab--active { border-radius: 0; }
.tpl-tabs-background__tab:focus { outline: none; }

.tpl-tabs-background__tab-contents {
    grid-column: 1;
    grid-row: 1;
    z-index: 4;
    position: relative;
}

.tpl-tabs-background__tab-content {
    z-index: 2;
    display: none;
    width: calc(100% - 120px);
    position: absolute;
    left: 120px;
    padding: 20px;
    bottom: 0;
    top: 50%;
    transform: translate(0, calc(-50% + 80px));
}

.tpl-tabs-background__tab-content--active { display: inline-table; }
.tpl-tabs-background__tab-content--active .tpl-tabs-background__text {
    animation: fadeInText 0.3s ease-in-out 0.6s forwards;
}

.tpl-tabs-background__tab-content--hiding .tpl-tabs-background__text {
    animation: fadeOutText 0.3s ease-in-out forwards;
}

/* Bordes de las tabs */

.tpl-tabs-background__tab:first-child:not(.tpl-tabs-background__tab--active) {
    border-radius: 0 32px 0 0;
}

.tpl-tabs-background__tab:last-child:not(.tpl-tabs-background__tab--active){
    border-bottom-left-radius: 31px;
}

.tpl-tabs-background__tab:last-child:has(.tpl-tabs-background__tab--active){
    border-bottom-left-radius: 32px;
}

.tpl-tabs-background__tab:has(+ .tpl-tabs-background__tab--active) {
    border-bottom-right-radius: 32px !important;
}

.tpl-tabs-background__tab--active + .tpl-tabs-background__tab {
    border-top-right-radius: 32px !important;
}

@media (min-width: 768px) {
    .tpl-tabs-background__image::before {
        background: linear-gradient(-90deg, transparent 16.11%, #000 100%), var(--background-image-desktop) 0px -14.828px / 100% 162.52% no-repeat;
        background-size: cover;
        background-position: center;
    }

    .tpl-tabs-background__image::after {
        background: linear-gradient(-90deg, transparent 16.11%, #000 100%), var(--background-image-desktop-next) 0px -14.828px / 100% 162.52% no-repeat;
        background-size: cover;
        background-position: center;
    }

    .tpl-tabs-background__tab {
        width: 170.667px;
        height: 170.667px;
    }

    .tpl-tabs-background__tab:first-child:not(.tpl-tabs-background__tab--active){
        border-top-left-radius: 31px;
        border-top-right-radius: 0;
    }

    .tpl-tabs-background__tab--active{
        border-radius: 32px 0 0 32px;
    }

    .tpl-tabs-background__tab svg {
        width: 40px;
        height: 40px;
    }

    .tpl-tabs-background__tab-content {
        position: absolute;
        bottom: 0;
        top: 50%;
        transform: translate(52px, -50%);
        max-width: 320px;
        width: calc(100% - 170.667px);
        padding: 32px;
    }
}