.sft-grid-background {
    display: block;
    max-width: 900px;
    margin: 10px auto;
    background-color: #f2f2f2;
    border-radius: 16px;
    position: relative;
    z-index: 1;
}

.sft-grid-item {
    aspect-ratio: 1/1;
}

.sft-grid-foreground {
    display: grid;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    column-gap: 7px;
    row-gap: 7px;
    padding: 7px;
    grid-template-areas:
        "one-one one-two one-three"
        "two-one two-two two-three"
        "three-one three-two three-three";
}

/* Highlight */
.sft-grid-highlight {
    background-color: #ccc;
    z-index: 1;
    position: absolute;
    display: flex;
    top: 0;
    left: 0;
}

/* Grid squares */
.sft-grid-item {
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    cursor: pointer;

    &:hover .button-area {
        top: 55%;
        /* Final resting position */
        opacity: 1;
        pointer-events: auto;
    }

}

.sft-grid-item-foreground {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;

}

.sft-grid-headline {
    text-align: center;
    justify-content: center;
    font-weight: 400;
    font-size: 24px;
    z-index: 1;
    position: absolute;
    color: white;
    margin: 0;
    width: 100%;
    padding: 0 10px 20px;
    display: flex;
    align-items: center;
    bottom: 0;
    text-shadow: 0 0 4px black;
    font-family: Lato, Helvetica, Arial, sans-serif;
    /* background-image: linear-gradient(0deg, black, transparent); */
    background-image: linear-gradient(0deg,
            rgba(0, 0, 0, 0.5) 0%,
            rgba(0, 0, 0, 0.5) 33%,
            rgba(0, 0, 0, 0) 100%);
}

/* New headline inside grid item */
.sft-grid-item h4.sft-grid-subheadline {
    position: absolute;
    bottom: 0;
    /* start hidden below */
    left: 50%;
    transform: translateX(-50%) translateY(0px);
    padding: 20px 10px 0;
    opacity: 0;
    margin: 0;
    padding: 8px 12px;
    width: 100%;
    text-align: center;
    font-size: 16px;
    font-weight: 400;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
    color: white;
    /* background-image: linear-gradient(180deg, black, transparent); */
    background-image: linear-gradient(180deg,
            rgba(0, 0, 0, 0.5) 0%,
            rgba(0, 0, 0, 0.5) 33%,
            rgba(0, 0, 0, 0) 100%);
    transition: all 0.3s ease;
    pointer-events: none;
    /* text doesn’t block buttons */
}

.sft-grid-item:hover h4.sft-grid-subheadline {
    bottom: auto;
    top: 0px;
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    z-index: 2;
}

/* Grid colors */
.one-one {
    background-color: #FEDB00;
}

.one-two {
    background-color: #8AC53F;
}

.one-three {
    background-color: #0080C5;
}

.two-one {
    background-color: #00843D;
}

.two-two {
    background-color: #68D2DF;
}

.two-three {
    background-color: #FF7276;
}

.three-one {
    background-color: #8986CA;
}

.three-two {
    background-color: #FFBB61;
}

.three-three {
    background-color: #F16521;
}

/* Jumbotron */
.sft-grid-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    z-index: 0;
    transition: opacity 0.3s ease;
    border-radius: 16px;
    /* match sft-grid-background */
    pointer-events: none;
    /* so it never blocks clicks */
    border: 7px solid #222;
}

.sft-grid-highlight.visible {
    opacity: 1;
    z-index: 2;
    /* sits just under foreground */
}

/* Jumbotron */
.sft-jumbotron-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s ease;
    pointer-events: auto;
    width: 100%;
    position: relative;
    height: auto;
    max-height: 100%;
    overflow: hidden;
}

.sft-grid-highlight.visible .sft-jumbotron-content {
    opacity: 1;
    transform: translateY(0);
}

.sft-jumbotron-content img {
    position: absolute;
    bottom: 0;
    right: 0;
}


.sft-jumbotron-content h2 {
    font-size: 44px;
    font-weight: bold;
    margin: 1rem 0 0;
    color: black;
}

.sft-jumbotron-content a.button {
    border-radius: 500px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: clamp(6px, 3vw, 8px);
    padding-bottom: clamp(6px, 3vw, 8px);
    padding-right: clamp(14px, 6vw, 24px);
    padding-left: clamp(14px, 6vw, 24px);
    background-color: var(--wp--preset--color--primary-light);
    gap: 10px;
    outline: none;
    color: white;
    font-weight: bold;
    margin-top: 1rem;
    z-index: 2;
    position: relative;
    text-decoration: none;

    svg {
        width: 14px;
        height: 14px;
        fill: white;
    }
}

/* Buttons */
.button-area {
    position: absolute;
    left: 50%;
    top: 120%;
    /* Start well below the visible area */
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 1;
    transition: top 0.2s ease, opacity 0.4s ease;
    opacity: 0;
    pointer-events: none;

    button {
        border-radius: 500px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px 16px;
        gap: 10px;
        outline: none;
        color: white;
    }

    .sft-grid-item-outbound {
        border: 0;
        align-self: center;
        justify-self: center;
        background-color: var(--wp--preset--color--primary-light);
        color: white;
        font-weight: 600;
        cursor: pointer;

        svg {
            width: 16px;
            height: 16px;
            fill: currentColor;
            vertical-align: middle;
        }
    }

    .sft-grid-item-internal {
        cursor: pointer;
        background-color: rgba(0, 0, 0, 0.5);
        border: 2px solid white;

        svg {
            width: 16px;
            height: 16px;
            fill: currentColor;
            vertical-align: middle;
        }
    }
}

/* Mobile Grid */
@media (max-width: 768px) {
    .sft-grid-foreground {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
        /* let rows flow naturally */
        grid-template-areas: none;
        /* disable the manual naming */
    }

    .sft-grid-foreground>.sft-grid-item:last-child:nth-child(odd) {
        transform: translatex(50%);
    }
}

/* Animations */
@keyframes pushImageDown {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    90% {
        transform: translateY(90%);
        opacity: 1;
    }

    100% {
        transform: translateY(100%);
        opacity: 0;
    }
}

@keyframes pullHeadlineUp {
    0% {
        transform: translateY(0);
        opacity: 1;

    }

    90% {
        transform: translateY(-90%);
        opacity: 1;
    }

    100% {
        transform: translateY(-100%);
        opacity: 0;
    }
}

@keyframes pullImageUp {
    0% {
        transform: translateY(100%);
        opacity: 0;
    }

    10% {
        transform: translateY(90%);
        opacity: 1;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pushHeadlineDown {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }

    10% {
        transform: translateY(-90%);
        opacity: 1;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Image enters from left */
.jumbotron-img.pull-in-left {
    transform: translateX(-120%);
    transition: transform 0.4s ease;
}

.jumbotron-img.pull-in-left.active {
    transform: translateX(0);
    transition-delay: 0.2s;
}

/* Text enters from right */
.jumbotron-title.pull-in-right {
    transform: translateX(120%);
    transition: transform 0.2s ease;
}

.jumbotron-title.pull-in-right.active {
    transform: translateX(0);
    transition-delay: 0.5s;
}

.sft-grid-item.animate-out .sft-grid-item-foreground {
    animation: pushImageDown 0.2s ease-out forwards;
}

.sft-grid-item.animate-out .sft-grid-headline {
    animation: pullHeadlineUp 0.2s ease-out forwards;
    background: unset;
}

.sft-grid-item.animate-in .sft-grid-item-foreground {
    animation: pullImageUp 0.2s ease-out forwards;
}

.sft-grid-item.animate-in .sft-grid-headline {
    animation: pushHeadlineDown 0.2s ease-out forwards;
}