:root {
    --font-weight-normal: 400;
    --font-weight-bold: 700;

    --accent-color: #0077cc;
    --accent-hover: #005fa3;
    --text-color: #222;

    --button-color: #333;

    --font-size-adjust-body: 0.52;
    --font-size-adjust-heading: 0.54;

    --header-footer-color: #f8f8f8;
    --body-background-color: #f0f0f0;
    --center-line-color: gray;
}

/* Simple reset */
body, h1, h2, h3, ul {
    margin: 0;
    padding: 0;
}

header {
    border-bottom: 2px solid gray;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--header-footer-color, white);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    font-size: clamp(1rem, 1.5vw, 1.45rem);
    z-index:1000;
    
    nav {
        ul {
            display: flex;
            gap: 2rem;
            list-style: none;
        }
    
        a {
            text-decoration: none;
            color: var(--text-color, #0077cc);
            font-weight: 500;
            transition: color 0.3s ease;
            position: relative; 

            &::after {
                content: "";
                position: absolute;
                left: 0;
                bottom: -3px;
                width: 0%;
                height: 2px;
                background-color: var(--accent-color);
                transition: width 0.3s ease, opacity 0.3s ease;
                opacity: 0;
            }

            &:hover {
                color: var(--accent-hover, darkblue);

                &::after {
                    width: 100%;
                    opacity: 1;
                }
            }

            &.active::after {
                width: 100%;
                opacity: 1;
            }
        }
    }
}

footer {
    border-top: 2px solid gray;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--header-footer-color, white);
    padding: 1rem 2rem;
    margin-top: 2rem;

    flex: 0 0 auto;
    position: relative;
    z-index: 2;

    nav ul {
        display: flex;
        gap: 1rem;
        list-style: none;
        margin: 0;
        padding: 0;
    }

    a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background-color: transparent;
        transition: background-color 0.2s ease;
    }


    img {
        width: 24px;
        height: 24px;
        object-fit: contain;
        display: block;
        filter: grayscale(30%) brightness(0.9);
        transition: filter 0.2s ease;
    }

    a:hover {
        background-color: #0077cc15;
    }

    a:hover img {
        filter: none;
    }

    p {
        font-size: 0.9rem;
        color: var(--text-color, #222);
        margin: 0;
    }
}

html, body {
    height: 100%;
}

body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;

    font-family: "Montserrat", sans-serif;
    font-optical-sizing: auto;
    font-style: normal;
    font-weight: var(--font-weight-normal, 400);
    font-size-adjust: var(--font-size-adjust-body, 0.5); /* baseline 2024 feature*/
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--body-background-color);
    margin: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-family: "Montserrat", sans-serif;
    font-optical-sizing: auto;
    font-weight: var(--font-weight-bold, 700);
    font-style: normal;
    font-size-adjust: var(--font-size-adjust-heading, 0.5); /* baseline 2024 feature*/
}

header > span {
    font-weight: 900;
    letter-spacing: 0.02em;
}

em, i {
    font-style: italic;
}

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: #f6f7f9;
                border: 1px solid #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: translateX(-50%); */
                    transform: translateY(-50%);
                    line-height: 1;
                    font-weight: 600;
                    font-size: clamp(.85rem, 1.1vw, 1rem);
                    color: #667788;

                    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 #b8c2cc;
                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: #fff;
            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) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;


        nav ul {
            flex-direction: column;
            gap: 0.6rem;
            width: 100%;

            a {
                font-size: 1.05rem;
                display: block;
            
                &.active::after {
                    width: 100%;
                    opacity: 1;
                }
            }
        }
    }

    #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;
                }
            }
        }

    }
}

/* No Animation Responsiveness */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}