@import url('https://fonts.googleapis.com/css2?family=Momo+Signature&family=Rubik:ital,wght@0,300..900;1,300..900&display=swap');

:root {
    --bg: oklch(0.943 0.001 17.176);
    --text: oklch(0.196 0.012 18.19);
    --accent: oklch(0.656 0.186 34.787);
    --studio: oklch(58.5% 0.233 277.117);
    --card-bg: #fff;
    --font: "Rubik", system-ui, sans-serif;
    --font-handwriting: "League Script", cursive;
    --font-signature: "Momo Signature", cursive;
    --max-width: 640px;
    --tracking: -0.02em;
    --mix-blend-name: normal;
    --mix-blend-lines: normal;
    --transition: linear(0, 0.013 1%, 0.051 2.2%, 0.404 9.8%, 0.51 12.6%, 0.602 15.5%, 0.683 18.7%, 0.754 22.2%, 0.813 26%, 0.861 30.2%, 0.9 34.8%, 0.931 40%, 0.972 52.7%, 0.992 70.2%, 1);
    --spacing: 4px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: oklch(0.178 0 0);
        --text: oklch(0.943 0.001 17.176);
        --accent: oklch(0.656 0.186 34.787);
        --card-bg: oklch(0.238 0 0);
        --mix-blend-name: hard-light;
        --mix-blend-lines: soft-light;
    }
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    line-height: 1.5;
    transition: background 0.4s var(--transition);

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    text-rendering: geometricPrecision;
}

body.studio-hover {
    background: lch(from var(--studio) l c h / 8%);
    transition: background 0.4s var(--transition);
}

::selection {
    background: var(--accent);
    color: var(--bg);
}

.handwriting {
    font-family: var(--font-handwriting);
    font-weight: 600;
    font-style: normal;
}

.signature {
    font-family: var(--font-signature);
    font-weight: 400;
    font-style: normal;
}

main {
    max-width: var(--max-width);
    margin-inline: auto;
    margin-block-end: 4rem;

    > section {
        margin-block-end: 4rem;
    }
}

.hero {
    display: flex;
    flex-direction: column;
    align-items: end;
    padding-inline: 0;
    padding-block-start: 8rem;
    gap: 0.5rem;

    .hero-lines {
        width: 100%;
        height: 300px;
        display: flex;
        justify-content: space-between;
        position: relative;

        .hero-lines-name {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-family: var(--font-signature), cursive;
            font-size: 4.6rem;
            letter-spacing: calc(var(--tracking) * 0);
            z-index: 1;
            width: calc(100% + 10rem);
            text-align: center;
            color: var(--text);
        }

        span {
            width: 1px;
            height: 100%;
            background: lch(from var(--text) l c h / 20%);
            display: block;
            position: relative;
            transition: background-color 0.1s linear;
            mix-blend-mode: var(--mix-blend-lines);

            &:nth-child(odd) {
                background: lch(from var(--text) l c h / 15%);
            }

            @media (prefers-color-scheme: dark) {
                background: lch(from var(--text) l c h / 100%);

                &:nth-child(odd) {
                    background: lch(from var(--text) l c h / 100%);
                }
            }
        }
    }

    .section-inner {
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }

    .hero-header {
        p {
            font-size: 1.1rem;
            letter-spacing: var(--tracking);
            font-weight: 500;

            span {
                display: block;

                &:nth-child(2) {
                    color: lch(from var(--text) l c h / 50%);
                    margin-top: -5px;
                    font-weight: 400;
                    font-size: 1rem;
                }
            }
        }

        .handwriting {
            font-size: 0.8rem;
            opacity: 1;
        }
    }

    .hero-content {
        max-width: 100%;

        p {
            font-size: 1.2rem;
            line-height: 1.5;
            font-weight: 400;
            letter-spacing: -0.01rem;
            color: lch(from var(--text) l c h / 60%);

            span {
                font-weight: 400;
                color: lch(from var(--text) l c h / 100%);
            }
        }
    }
}

.links {
    min-height: 5rem;

    .section-inner {
        height: 100%;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: start;
        gap: calc(var(--spacing) * 4);

        h2 {
            font-weight: 400;
            font-size: 1rem;
            letter-spacing: -0.02rem;
            position: relative;
            display: flex;
            align-items: center;
            gap: var(--spacing);
            transform: translateX(calc(var(--spacing) * -4));

            &::before {
                content: '';
                height: 1px;
                width: 32px;
                background-color: var(--text);
                display: block;
                opacity: 0.5;
            }
        }

        ul {
            display: flex;
            gap: 0;
            height: 100%;
            transition: all 0.4s var(--transition);
            width: 100%;

            &:has(a:hover) {
                gap: 0;

                li:nth-child(2) {
                    margin-inline: calc(var(--spacing) * 3);
                }

                li:has(a:not(:hover)) {
                    flex: 0.8;
                }

                a:not(:hover) {
                    opacity: 0.8;
                }
            }

            &:has(li:nth-child(1) a:hover) {

                li:nth-child(2) {
                    transform: translateX(calc(var(--spacing) * 1.5));
                }
            }

            &:has(li:nth-child(2) a:hover) {

                li:nth-child(1) {
                    transform: translateX(calc(var(--spacing) * -1.5));
                }

                li:nth-child(3) {
                    transform: translateX(calc(var(--spacing) * 1.5));
                }
            }

            &:has(li:nth-child(3) a:hover) {

                li:nth-child(2) {
                    transform: translateX(calc(var(--spacing) * -1.5));
                }
            }

            li {
                list-style: none;
                flex: 1;
                transition: all 0.4s var(--transition);

                &:nth-child(2) {
                    margin-inline: calc(var(--spacing) * 1.5);
                }
            }

            a {
                text-decoration: none;
                display: flex;
                align-items: center;
                justify-content: space-between;
                height: 100%;
                position: relative;
                padding-block: 1rem;
                padding-inline: 1rem;
                font-size: 1.1rem;
                transition: all 0.4s var(--transition);
                background-color: var(--card-bg);
                corner-shape: squircle;
                border-radius: 50px;
                box-shadow: 0 1px 0px 1px lch(from var(--text) l c h / 5%);
                will-change: transform, opacity;

                @supports not (corner-shape: squircle) {
                    border-radius: 16px;
                }

                span {
                    display: block;
                    font-weight: 400;

                    &:nth-child(2) {
                        color: lch(from var(--text) l c h / 50%);
                        font-size: 0.8rem;
                        margin-top: -4px;
                    }
                }

                svg {
                    transition: all 0.4s var(--transition);
                }

                &:hover {
                    color: var(--accent);
                    transform: scale(1.1) rotate(0deg);
                    box-shadow:
                        0 12px 12px -1px lch(from var(--accent) l c h / 8%),
                        0 2px 5px -1px lch(from var(--text) l c h / 5%);
                    z-index: 10;

                    svg {
                        transform: rotate(-45deg);
                    }
                }
            }
        }
    }
}

.projects {
    position: relative;

    .section-inner {
        display: flex;
        flex-direction: column;
        align-items: start;
        gap: calc(var(--spacing) * 4);

        h2 {
            font-weight: 400;
            font-size: 1rem;
            letter-spacing: -0.02rem;
            position: relative;
            display: flex;
            align-items: center;
            gap: var(--spacing);
            transform: translateX(calc(var(--spacing) * -4));

            &::before {
                content: '';
                height: 1px;
                width: 32px;
                background-color: var(--text);
                display: block;
                opacity: 0.5;
            }
        }
    }

    ul {
        --li-h: 80px;
        --li-h-hover: 120px;
        --li-count: 1;
        --li-gap: calc(var(--spacing) * 2);
        /* Height left for each non-hovered row when one row is expanded. */
        --li-h-collapsed: calc(
            (var(--li-h) * var(--li-count) - var(--li-h-hover)) / (var(--li-count) - 1)
        );
        display: flex;
        flex-direction: column;
        width: 100%;
        height: calc(
            var(--li-h) * var(--li-count) + var(--li-gap) * (var(--li-count) - 1)
        );
        gap: var(--li-gap);

        /* Count the items so the fixed height stays correct (up to 12). */
        &:has(> li:nth-child(2)) { --li-count: 2; }
        &:has(> li:nth-child(3)) { --li-count: 3; }
        &:has(> li:nth-child(4)) { --li-count: 4; }
        &:has(> li:nth-child(5)) { --li-count: 5; }
        &:has(> li:nth-child(6)) { --li-count: 6; }
        &:has(> li:nth-child(7)) { --li-count: 7; }
        &:has(> li:nth-child(8)) { --li-count: 8; }
        &:has(> li:nth-child(9)) { --li-count: 9; }
        &:has(> li:nth-child(10)) { --li-count: 10; }
        &:has(> li:nth-child(11)) { --li-count: 11; }
        &:has(> li:nth-child(12)) { --li-count: 12; }

        &:has(li:hover) {

            li:not(:hover) {
                flex-basis: var(--li-h-collapsed);
            }

            li:not(:hover) a {
                opacity: 0.8;

                .project-text {
                    grid-template-rows: auto 0fr;
                }

                p {
                    opacity: 0;
                }
            }
        }
    }

    li {
        position: relative;
        display: flex;
        flex: 0 0 var(--li-h);
        min-height: 0;
        transition: flex-basis 0.4s var(--transition);

        /* Extend the hover target across the gap below the row, so moving
           between rows never leaves the list in a "nothing hovered" state. */
        &::after {
            content: "";
            position: absolute;
            inset-block-start: 100%;
            inset-inline: 0;
            height: var(--li-gap);
        }

        &:last-child::after {
            display: none;
        }
    }

    li:hover {
        flex-basis: var(--li-h-hover);

        a {
            color: var(--accent);
            transform: scale(1.02) rotate(0deg);
            box-shadow:
                0 12px 12px -1px lch(from var(--accent) l c h / 8%),
                0 2px 5px -1px lch(from var(--text) l c h / 5%);
            z-index: 10;
            padding-block: 2rem;

            svg {
                transform: rotate(-45deg);
            }
        }
    }

    .project-link {
        display: flex;
        width: 100%;
        overflow: hidden;
        padding-block: 1.5rem;
        padding-inline: 1.5rem;
        transition: all 0.4s var(--transition);
        background-color: var(--card-bg);
        corner-shape: squircle;
        border-radius: 50px;
        box-shadow: 0 1px 0px 1px lch(from var(--text) l c h / 5%);
        will-change: transform, opacity;

        .project-text {
            width: 100%;
            display: grid;
            grid-template-rows: auto 1fr;
            align-content: start;
            flex: 1;
            padding-inline-end: 0.75rem;
            transition: grid-template-rows 0.4s var(--transition);

            h3 {
                font-size: 1.1rem;
                font-weight: 400;
            }

            p {
                color: lch(from var(--text) l c h / 30%);
                font-size: 0.8rem;
                margin-top: 0px;
                font-family: var(--font-signature);
                text-transform: lowercase;
                overflow: hidden;
                min-height: 0;
                transition: opacity 0.4s var(--transition);
            }
        }

        svg {
            transition: all 0.4s var(--transition);
        }
    }

    .project-wrapper {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
}

.footer {
    max-width: var(--max-width);
    margin-inline: auto;
    margin-block-end: 4rem;

    p {
        display: flex;
        flex-direction: column;

        span {
            font-size: 1rem;
            font-weight: 600;

            &:nth-child(2) {
                font-size: 0.8rem;
                font-weight: 400;
            }

            &:last-child {
                font-size: 0.8rem;
                margin-top: -4px;
                font-weight: 400;
            }
        }
    }
}

@media (max-width: 640px) {
    main,
    footer {
        width: 100vw;
        padding-inline: 2rem;
    }

    .hero {
        .hero-lines {
            .hero-lines-name {
                font-size: 2rem;
                width: calc(100% - 2rem);
                text-align: center;
                line-height: 1.4;
            }
        }
    }

    .hero-header {
        h1 {
            font-size: 2.1rem;
            font-weight: 700;
            letter-spacing: var(--tracking);
            position: relative;

            .handwriting {
                display: inline-block;
                font-size: 1.35rem;
                font-weight: 400;
                opacity: 0.8;
                letter-spacing: calc(var(--tracking) * 3);
                position: absolute;
                top: -16px;
                right: 0;

                i {
                    font-style: normal;
                    /* color: var(--accent); */
                }
            }
        }
    }

    .projects {
        & .project-link {
            & .project-text {
                .handwriting {
                    font-weight: 400;
                    letter-spacing: var(--tracking);
                }
            }
        }
    }
}
