@import url(https://fonts.googleapis.com/css2?family=Amatic+SC:wght@100;200;300;400;500;600;700&display=swap);
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Amatic SC", handwriting;
    height: 100vh;
    color: #fff;
}
.gallery {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
}
.item1 {
    background-image: url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500);
}
.item2 {
    background-image: url(https://source.unsplash.com/rFKUFzjPYiQ/1500x1500);
}
.item3 {
    background-image: url(https://images.unsplash.com/photo-1465188162913-8fb5709d6d57?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&w=1500&h=1500&fit=crop&s=967e8a7…);
}
.item4 {
    background-image: url(https://source.unsplash.com/ITjiVXcwVng/1500x1500);
}
.item5 {
    background-image: url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500);
}
.item {
    font-size: 50px;
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-size: cover;
    background-position: center;
    background-color: rgb(7, 7, 72);
    box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.1);
    transition: font-size 0.7s cubic-bezier(0.61, -0.19, 0.7, -0.11),
        flex 0.7s cubic-bezier(0.61, -0.19, 0.7, -0.11), background 0.2s;
}
.item p {
    width: 100%;
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.5s;
    text-transform: uppercase;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
}
.item p:first-child {
    transform: translateY(-100%);
}
.item p:last-child {
    transform: translateY(100%);
}

.item.open {
    flex: 5;
    font-size: 85px;
}
.item.open-active p:first-child {
    transform: translateY(0);
}
.item.open p:nth-child(2) {
    transform: scale(1.5);
}
.item.open-active p:last-child {
    transform: translateY(0);
}

@media only screen and (max-width: 600px) {
    .item:nth-child(3),
    .item:last-child {
        display: none;
    }
    .item {
        font-size: 35px;
        transition: font-size 0.5s cubic-bezier(0.61, -0.1, 0.7, -0.1),
            flex 0.5s cubic-bezier(0.61, -0.1, 0.7, -0.1), background 0.2s;
    }
    .item p {
        transition: transform 0.4s;
    }
    .item.open {
        flex: 3;
        font-size: 55px;
    }
    .item.open p:first-child {
        align-items: end;
    }
    .item.open p:nth-child(2) {
        flex: 1.7 0 auto;
    }
    .item.open p:last-child {
        align-items: start;
    }
}
