@import url("global.css");

main {
    flex: 1 0 auto;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2dvh 4dvw;
    min-height: 80dvh;
}

#career-timeline {
    --diamond-size: 40px;       /* size of diamond */
    --diamond-gap: 8px;         /* gap between diamond and date */
    --rail-gap: 2.25rem;        /* dotted horizontal line length*/

    & > h1 {
        text-align: center;
        margin: 1.25rem 0 0.25rem;
        font-weight: var(--font-weight-bold, 700);

        animation: fadeInUp .8s ease-out forwards;
        opacity: 0;
    }

    & > p {
        text-align: center;
        margin: 0 0 2rem 0;
        color: color-mix(in oklab, var(--text-color, #222) 80%, white);

        animation: fadeInUp .8s ease-out forwards;
        animation-delay: 0.15s;
        opacity: 0;
    }

    & > ol {
        position: relative;
        list-style: none;
        margin: 0;
        padding: 0;

        display: grid;
        grid-template-columns: 1fr;
        row-gap: 3rem;
        padding-bottom: 6rem;

        /* Vertical line down the center */
        &::before {
            content: "";
            position: absolute;
            inset-block: 0;
            left: 50%;
            transform: translateX(-50%) scaleY(0);
            transform-origin: top;
            animation: growLine 1s ease-out forwards .15s;
            width: 4px;
            border-radius: 2px;
            background: var(--center-line-color);
            opacity: 0.9;
            z-index: 0;
        }

        & > li {
            display: grid;
            grid-template-columns: 1fr 60px 1fr;
            grid-template-rows: 1fr;
            align-items: center;
            column-gap: 2rem;
            position: relative;
            z-index: 1;

            /* Academic/Employment card */
            & > article {
                background: color-mix(in oklab, var(--body-background-color) 85%, #ffffff);
                border: 1px solid color-mix(in oklab, var(--text-color) 12%, #e5e9ef);
                border-radius: 10px;
                padding: 1rem 1.25rem;
                box-shadow: 0 1px 0 rgba(0,0,0,0.04);
                position: relative;
                grid-row: 1;
                animation: fadeInUp .7s ease-out forwards;
                transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
                will-change: transform, opacity;
                opacity: 0; 

                &:hover {
                    transform: translateY(-3px);
                    border-color: color-mix(in oklab, var(--accent-color, #0077cc) 40%, #e5e9e5);
                    box-shadow: 0 10px 22px rgba(0,0,0,0.08);
                }
            }

            & > center-diamond {
                grid-column: 2;
                position: relative;
                display: grid;
                place-items: center;
                min-height: var(--diamond-size);
                padding-top: 0.35rem;
                grid-row: 1;
                animation: fadeInUp .7s ease-out forwards;
                will-change: transform, opacity;
                opacity: 0;

                svg {
                    position: absolute;
                    top: 50%;
                    transform: translateY(-50%);
                    block-size: var(--diamond-size);
                    inline-size: var(--diamond-size);

                    image {
                        transform-origin: center;

                        &.education {
                            transform: scale(0.85);
                        }

                        &.employment {
                            transform: scale(0.9);
                        }

                        &.volunteer {
                            transform: scale(0.85);
                        }

                    }
                }

                time {
                    position: absolute;
                    top: 50%;
                    transform: translateY(-50%);
                    line-height: 1;
                    font-weight: 600;
                    font-size: clamp(0.85rem, 1.1vw, 1rem);
                    color: color-mix(in oklab, var(--text-color) 75%, var(--body-background-color));

                    white-space: nowrap;
                    pointer-events: none;
                }
            }


            &:nth-child(odd) {
                & > article {
                    grid-column: 1;
                }

                & > center-diamond time {
                    left: calc(50% + (var(--diamond-size) / 2) + var(--diamond-gap));
                    text-align: left;
                }
            }

            &:nth-child(even) {
                & > article {
                    grid-column: 3;
                }

                & > center-diamond time {
                    right: calc(50% + (var(--diamond-size) / 2) + var(--diamond-gap));
                    text-align: right;
                }
            }

            /* Dotted horizontal line */
            &:nth-child(odd) > article::after, &:nth-child(even) > article::before {                
                content: "";
                position: absolute;
                top: 50%;
                transform: translateY(-50%);
                height: 0;
                border-top: 2px dotted color-mix(in oklab, var(--center-line-color) 70%, var(--body-background-color));
                width: var(--rail-gap);

                animation: drawRail .6s ease-out forwards;
                animation-delay: inherit;
            }

            &:nth-child(odd) > article::after {
                right: calc(-1 * var(--rail-gap));
            }

            &:nth-child(even) > article::before {
                left: calc(-1 * var(--rail-gap));
            }

            /* Add 0.15s per new card */
            &:nth-child(1) > * { animation-delay: .30s; }
            &:nth-child(2) > * { animation-delay: .45s; }
            &:nth-child(3) > * { animation-delay: .60s; }
            &:nth-child(4) > * { animation-delay: .75s; }
            &:nth-child(5) > * { animation-delay: .90s; }
            &:nth-child(6) > * { animation-delay: 1.05s; }
        }

        polygon {
            fill: color-mix(in oklab, var(--body-background-color) 10%, #ffffff);
            stroke: var(--accent-color, #0077cc);
            stroke-width: 8;
        }

        h2 {
            margin: 0 0 .25rem 0;
            font-size: clamp(1.1rem, 1.6vw, 1.3rem);
        }

        p {
            margin: 0.2rem 0;
        }
    }
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes growLine { 
    to { 
        transform: translateX(-50%) scaleY(1); 
    } 
}

@keyframes drawRail {
    to { 
        width: var(--rail-gap); opacity: 1; 
    }
}

/* Mobile */
@media (max-width: 600px) {
    #career-timeline > ol {
        &::before {
            display: none;
        }
        
        & > li {
            grid-template-columns: 1fr;
            row-gap: 0.5rem;

            & > article {
                margin: 0 auto;
                width: 90%;
                max-width: 500px;

                &::before, &::after {
                    display: none;
                }
            }
    
            & > center-diamond {
                justify-self: center;
                display: none;
            }

            &:nth-child(even) {
                & > article {
                    grid-column: 1;
                }
            }
        }
    }
}