@property --opacity {
    syntax: "<number>";
    initial-value: 0.5;
    inherits: false;
}

@property --angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

@keyframes opacity-change {
    to {
        --opacity: 1;
    }
}

@keyframes rotate {
    to {
        --angle: 360deg;
    }
}

#projects {
    container-type: size;
    container-name: projects;
    display: flex;
    flex-direction: row;
    position: relative;
    width: 95%;
    min-height: 100%;

    & > main {
        display: grid;
        grid-template-rows: repeat(2, 1fr);
        grid-template-columns: repeat(2, 1fr);
        row-gap: 0.25rem;
        width: 100%;

        & .project-card {
            display: flex;
            justify-content: space-around;
            align-items: center;

            &:nth-child(even) {
                flex-direction: row-reverse;
            }

            &:nth-child(3),
            &:nth-child(4) {
                border-top: 3px solid var(--curiosity-color);
            }

            & h2 {
                position: relative;

                &::before,
                &::after {
                    content: "";
                    position: absolute;
                    width: 100%;
                    height: 3px;
                    background-color: var(--empathy-color);
                    transform: scaleX(0);
                    transition: transform 0.3s ease;
                }

                &::before {
                    bottom: 0;
                    transform-origin: right;
                    transition-delay: 0.4s;
                }

                &::after {
                    top: 0;
                    left: 0;
                    transform-origin: left;
                    transform: scaleX(0);
                    transition-delay: 0s;
                }

                &:hover::before {
                    transform: scaleX(1);
                    transition-delay: 0s;
                }

                &:hover::after {
                    transform: scaleX(1);
                    transition-delay: 0.4s;
                }

                & a {
                    position: relative;
                    width: 100%;
                    padding: 0 1cqw 0 1.25cqw;
                    color: var(--empathy-color);
                    font-size: clamp(1.5rem, 3vw, 4.5rem);
                    letter-spacing: 1cqi;
                    text-align: center;
                    text-decoration: none;
                    writing-mode: vertical-rl;
                    filter: drop-shadow(8px -8px 4px rgb(0 0 0 / 100%));
                    transition: padding-top 0.2s ease 0.4s, padding-bottom 0.2s ease;

                    &::before,
                    &::after {
                        content: "";
                        position: absolute;
                        top: 0;
                        width: 3px;
                        height: 100%;
                        background-color: currentcolor;
                        transform-origin: top;
                        transition: transform 0.3s ease;
                    }

                    &::before {
                        right: 0;
                        transform: scaleY(0);
                        transition-delay: 0.2s;
                    }

                    &::after {
                        left: 0;
                        transform: scaleY(1);
                        transition-delay: 0.4s;
                    }
                    &:hover {
                        padding-top: 2cqh;
                        padding-bottom: 1.25cqh;
                        transition-delay: 0s;

                        &::before {
                            transform: scaleY(1);
                            transition-delay: 0.2s;
                        }

                        &::after {
                            transform: scaleY(1);
                            transition-delay: 0s;
                        }
                    }
                }
            }

            &:nth-child(odd) h2 a {
                transform: rotate(180deg);
            }

            &:nth-child(even) {
                & h2 {
                    &::before {
                        transition-delay: 0s;
                    }
                    &::after {
                        transition-delay: 0.4s;
                    }

                    &:hover::before {
                        transition-delay: 0.4s;
                    }

                    &:hover::after {
                        transition-delay: 0s;
                    }
                }
            }

            & .figure-card {
                position: relative;
                width: min(100%, 70cqmin);
                height: auto;
                aspect-ratio: 16 / 9;
                background-color: transparent;
                perspective: 1000px;
                cursor: pointer;

                & figure {
                    display: flex;
                    justify-content: space-around;
                    align-items: center;
                    position: relative;
                    width: 100%;
                    height: 100%;
                    transform: rotateY(0deg);
                    transition: transform 0.6s;
                    transform-style: preserve-3d;
                    pointer-events: auto;

                    & > * {
                        position: absolute;
                        width: 90%;
                        height: 90%;
                        backface-visibility: hidden;
                        border-radius: 1em;
                        /* background-color: var(--light-background); */
                        box-shadow: 10px 10px 10px 0px #000000;
                        pointer-events: auto;
                        transition: border-width 0.5s ease;
                    }

                    & img {
                        /* box-sizing: content-box; */
                        z-index: 1;
                        object-fit: fill;

                        /* &[src*="liberty"] {
                            background-color: #d7ebe1;
                        }
                        &[src*="calendar"] {
                            background-color: #10ccbc;
                        }
                        &[src*="travel"] {
                            background-color: #1c5a90;
                        }
                        &[src*="pirates"] {
                            background-color: #8e7769;
                        } */
                    }

                    & figcaption {
                        display: flex;
                        z-index: 2;
                        overflow: auto;
                        -webkit-overflow-scrolling: touch;
                        padding: 1rem;
                        color: var(--creativity-color);
                        font-size: clamp(1rem, 1.094cqw, 2.25rem);
                        line-height: clamp(1.25rem, 4cqh, 2.75rem);
                        background-color: var(--light-background);
                        transform: rotateY(180deg) translateZ(0);
                    }

                    &::after {
                        content: "";
                        z-index: 10;
                        width: 4cqw;
                        height: 4cqw;
                        padding: 1cqw;
                        background-color: rgba(255, 255, 235, 0.75);
                        background-image: url("/images/icons/flip_arrows.png");
                        background-repeat: no-repeat;
                        background-size: 75%;
                        background-position: center;
                        border: 0.25cqw solid var(--empathy-color);
                        border-radius: 50%;
                        opacity: 1;
                        transition: opacity 0.3s ease;
                        pointer-events: none;
                    }
                }

                &.flipped figure {
                    transform: rotateY(180deg);

                    &::after {
                        opacity: 0;
                    }
                }

                &:not(.flipped) figure {
                    &::after {
                        opacity: 1;
                        transition: opacity 0.3s ease 0.4s;
                    }

                    > img {
                        /* border: calc((0.375cqw + 0.74cqh) / 2) solid transparent; */
                    }
                }

                & figure > *:hover,
                &.flipped figure > * {
                    --border-size: calc((0.375cqw + 0.74cqh) / 2);
                    border: var(--border-size) dotted transparent;
                    background-image: linear-gradient(to right, var(--light-background), var(--light-background)), conic-gradient(from var(--angle), var(--creativity-color) 0deg, #e9b56c 45deg, var(--curiosity-color) 90deg, #a7c49c 135deg, var(--empathy-color) 180deg, #89c2b8 225deg, var(--purpose-color) 270deg, #d49a8b 315deg, var(--creativity-color) 360deg);
                    background-origin: border-box;
                    background-clip: padding-box, border-box;
                    animation: rotate 4s linear infinite;
                }

                &.flipped figure {
                    & > img {
                        opacity: 0;
                    }

                    & > figcaption {
                        --opacity: 1;
                    }
                }
            }
        }

        & .project-card-clone {
            display: none;
        }
    }

    & #carousel-progress {
        display: none;
        justify-content: center;
        column-gap: 1rem;
        position: absolute;
        bottom: clamp(32px, 3.5cqb, 48px);
        left: 0;
        right: 0;

        & .progress-indicator {
            box-sizing: border-box;
            width: clamp(24px, 5cqw, 48px);
            height: clamp(24px, 5cqw, 48px);
            background-color: var(--light-background);
            border: 2px solid var(--curiosity-color);
            border-radius: 50%;
            cursor: pointer;
            transition: background-color 0.5s ease;

            &:not(.current):hover {
                background-color: var(--curiosity-color);
            }

            &.current {
                background-color: var(--empathy-color);
                pointer-events: none;
            }
        }
    }
}

/* Draw animations */
@keyframes draw-horizontal {
    to {
        transform: scaleX(1);
    }
}
@keyframes draw-vertical {
    to {
        transform: scaleY(1);
    }
}

/* Undraw animations (reverse order visually) */
@keyframes undraw-horizontal {
    to {
        transform: scaleX(0);
    }
}
@keyframes undraw-vertical {
    to {
        transform: scaleY(0);
    }
}
