* {
    box-sizing: border-box;
}

body {
    /* or any other parent wrapper */
    margin: 0;
    display: flex;
    height: 100dvh;
    perspective: 1000px;
    font: 16px/1.4 sans-serif;
    overflow: hidden;
    background-image: url("assets/image0.png");
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-position-x: center;
    background-position-y: 60%;
    background-size: cover;
}

.nav {
    position: absolute;
    width: 40vw;
    height: 4vh;
    left: 50%;
    top: 1vh;
    transform: translate(-50%, 0);
    display: flex;
    flex-grow: 1;
    flex-shrink: 1;
    align-items: center;
    justify-content: space-evenly;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
    background-image: linear-gradient(to right, #ff0000 0%, #ff7b00 20%, #fbff00 40%, #00a31b 60%, #3a4ed5 80%, #ff00bf 100%);

    label {
        font-size: 1vw;
        background-color: whitesmoke;
        opacity: 0.9;
        border-radius: 8px;
        padding: 0.5%;
        font-weight: bolder;
    }
}

.book {
    --c: 0;
    --p: 0;
    display: flex;
    margin: auto;
    width: 65vh;
    /*1* let pointer event go trough pages of lower Z than .book */
    pointer-events: none;
    transform-style: preserve-3d;
    transition: translate 0.8s;
    translate: calc(min(var(--p), 2) * 50%) 0%;
    /* DEMO ONLY: incline on the X axis for pages preview */
    rotate: 1 0 0 8deg;

    [name^=book] {
        display: none;
    }

    &:has(#c0:checked) {
        --c: 0;
        --p: 0;
    }

    &:has(#c1:checked) {
        --c: 1;
        --p: 1;
    }

    &:has(#c2:checked) {
        --c: 2;
        --p: 1;
    }

    &:has(#c3:checked) {
        --c: 3;
        --p: 2;
    }
}

.page {
    --thickness: 5;
    /* PS: Don't go below thickness 0.4 or the pages might transpare */
    flex: none;
    display: flex;
    width: 100%;
    aspect-ratio: 4 / 5;
    /*1* allow pointer events on pages */
    pointer-events: all;
    user-select: none;
    transform-style: preserve-3d;
    transform-origin: left center;
    transition:
        transform 0.8s,
        rotate 0.8s ease-in calc((min(var(--i), var(--c)) - max(var(--i), var(--c))) * 50ms);
    translate: calc(var(--i) * -100%) 0px 0px;
    transform: translateZ(calc((var(--c) - var(--i) - 0.5) * calc(var(--thickness) * 1px)));
    rotate: 0 1 0 calc(clamp(0, var(--c) - var(--i), 1) * -180deg);

    .barlabel {
        position: absolute;
        top: 0;
        background: gray;
        display: block;
        width: 10%;
        height: 100%;
        opacity: 0.15;
    }

    label:hover {
        opacity: 0.2;
    }

    div {
        font-size: 1.8vh;
        padding-left: 15%;
        padding-right: 15%;
    }

    img {
    width: 100%;
    object-fit: cover;
    }

    iframe {
        width: 100%;
        object-fit: cover;
    }

    .linky {
        font-weight: bolder;
        font-size: 200%;
    }
}

.iframe-label {
    size: 10%;
}

.back {
    label {
        left: 0;
        right: auto;
    }

        border-top: 5px;
        border-bottom: 5px;
        border-left: 5px;
        border-right: 0px;
}

.front {
    label {
        right: 0;
        left: auto;
    }

    border-top: 5px;
    border-bottom: 5px;
    border-right: 5px;
    border-left: 0px;
}

.footer {
    position: absolute;
    bottom: 0%;

    pointer-events: none;
}

.front .footer {
    left: auto;
    right: 1%;
}

.back .footer {
    left: 1%;
    right: auto;
}

.front,
.back {
    flex: none;
    width: 100%;
    height: 100%;
    padding: 2rem;
    backface-visibility: hidden;
    background-color: #fff;
    /* Fix backface visibility Firefox: */
    translate: 0px;

    border-style: solid;
    border-image: linear-gradient(to top, #ff0000 0%, #ff7b00 20%, #fbff00 40%, #00a31b 60%, #3a4ed5 80%, #ff00bf 100%) 1;
}

.back {
    background-image: linear-gradient(to right, #fff 80%, #ddd 100%);
    translate: -100% 0;
    rotate: 0 1 0 180deg;
}