/**
 * Hexagons Grid based on the work by web-tiki
 * @see https://github.com/web-tiki/responsive-grid-of-hexagons/tree/master
 */

#hexGrid {
    --hexagon-gap-mergin: 0.75rem;

    display: flex;
    flex-wrap: wrap;
    width: 100%;
    list-style-type: none;
    margin: 1rem 0;
    padding: 0;

    > li {
        position: relative;
        width: var(--hexgrid-element-width, auto);
        margin-top: -3.5%;

        ul {
            position: absolute;
            top: 27%;
            left: -7%;
            list-style-type: none;
            padding: 0;
            width: 15%;

            li {
                position: relative;
                width: 100%;
                margin-top: -15%;

                .hexagon {
                    width: 100%;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    color: #000;
                }
            }

            li:nth-child(2n) {
                left: 47%;
            }

            li:first-child {
                margin-top: 0;
            }

            li:nth-child(3) {
                left: 0;
                margin-top: -15%;
            }
        }
    }

    /*** HEXAGON SIZING AND EVEN ROW INDENTATION *****************************************************************/
    @media (min-width: 992px) {/* <- 4-3  hexagons per row */
        --hexgrid-element-width: 25%; /* = 100 / 4 */
        > li:nth-child(-n+4){
            margin-top: 0;
        }
        > li:nth-child(7n+5){ /* first hexagon of even rows */
            margin-left:12.5%;  /* = width of .hex / 2  to indent even rows */
        }
    }

    @media (max-width: 991px) and (min-width:578px) { /* <- 3-2  hexagons per row */
        --hexgrid-element-width: 33.333%; /* = 100 / 3 */

        > li:nth-child(-n+3){
            margin-top: 0;
        }
        > li:nth-child(5n+4){ /* first hexagon of even rows */
            margin-left:16.666%;  /* = width of .hex / 2  to indent even rows */
        }
    }

    @media (max-width: 577px) { /* <- 2-1  hexagons per row */
        --hexgrid-element-width: 50%; /* = 100 / 2 */
        > li:nth-child(-n+2){
            margin-top: 0;
        }
        > li:nth-child(3n+3){ /* first hexagon of even rows */
            margin-left:25%;  /* = width of .hex / 2  to indent even rows */
        }
    }

    .hexagon {
        opacity: 1;
        margin: 0 var(--hexagon-gap-mergin);

        figure {
            position: relative;
            width: auto;
            height: 100%;
            margin: 0 auto;
            -webkit-transform: rotate3d(0,0,0,0deg);
            -ms-transform: rotate3d(0,0,0,0deg);
            transform: rotate3d(0,0,0,0deg);

            img {
                width: 100%;
                height: 100%;
                object-fit: cover;
            }

            figcaption {
                position: absolute;
                bottom: 16%;
                background-color: var(--bs-primary);
                padding: 0.5em;
                border-radius: 1em;
                width: 80%;
                justify-self: center;
                color: #000;
                height: 60px;
                display: flex;

                justify-content: center;
                flex-direction: column;
                align-items: center;

                @media (min-width: 1200px) {
                    width: 70%;
                }

                &:not(:has(span:empty)) {
                    > * {
                        font-size: 1.1rem !important;
                    }
                }
                span:not(:empty) {
                    font-size: 0.8rem !important;
                }
            }

            footer {
                color: white;
                position: absolute;
                transform: rotate(-30deg);
                text-shadow: 2px 2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, -2px -2px 0 #000, 2px 0px 0 #000, 0px 2px 0 #000, -2px 0px 0 #000, 0px -2px 0 #000;
                left: 48%;
                bottom: 4%;

                small {
                    font-size: 0.5em;
                }
            }
        }
    }
}
