:root {
    --accent-color: #3498db; /* Custom accent color */
    --bg-color: #ffffff; /* Background color for timeline cards */
    --col-gap: 2rem; /* Column gap */
    --row-gap: 2rem; /* Row gap between timeline items */
    --line-w: 0.25rem; /* Width of the timeline line */
    --timeline-width: min(70rem, 90%); /* Max width for the timeline */
}

.timeline {
    display: grid;
    grid-template-columns: var(--line-w) 1fr;
    grid-auto-columns: max-content;
    column-gap: var(--col-gap);
    width: var(--timeline-width);
    margin-top: 2rem;
    margin-inline: auto;
    transition: all 0.3s ease-in-out;
    overflow: visible;
}

.timeline::before {
    content: "";
    grid-column: 1;
    grid-row: 1 / span 20;
    background: rgb(225, 225, 225); /* Timeline line color */
    border-radius: calc(var(--line-w) / 2);
}

/* Row gap between items */
.timeline li:not(:last-child) {
    margin-bottom: var(--row-gap);
}

/* Individual Timeline Cards */
.timeline li {
    grid-column: 2;
    margin-inline: 1.5rem;
    grid-row: span 2;
    display: grid;
    grid-template-rows: min-content min-content min-content;
    background-color: transparent; /* Remove the background color */
    box-shadow: none; /* Remove any shadow */
    text-decoration: none; /* Remove any underlining */
}

/* Timeline Time Indicator */
.timeline li .time {
    --timeH: 3rem;
    height: var(--timeH);
    margin-inline: calc(1.5rem * -1);

    text-align: center;
    background-color: var(--accent-color);
    color: white;
    font-size: 1.25rem;
    font-weight: 700;

    display: grid;
    place-content: center;
    position: relative;
    border-radius: calc(var(--timeH) / 2) 0 0 calc(var(--timeH) / 2);
}

/* Time Flap */
.timeline li .time::before {
    content: "";
    width: 1.5rem;
    aspect-ratio: 1;
    background: var(--accent-color);
    position: absolute;
    top: 100%;
    clip-path: polygon(0 0, 100% 0, 0 100%);
    right: 0;
}

/* Circle Indicator */
.timeline li .time::after {
    content: "";
    position: absolute;
    width: 2rem;
    aspect-ratio: 1;
    background: var(--bg-color);
    border: 0.3rem solid var(--accent-color);
    border-radius: 50%;
    top: 50%;
    transform: translate(50%, -50%);
    right: calc(100% + var(--col-gap) + var(--line-w) / 2);
}

/* Timeline Title and Description */
.timeline li .title,
.timeline li .subjects {
    background: var(--bg-color);
    position: relative;
    padding-inline: 1.5rem;
}

.timeline li .title {
    overflow: hidden;
    padding-block-start: 1.5rem;
    padding-block-end: 1rem;
    font-weight: 500;
}

.timeline li .subjects {
    padding-block-end: 1.5rem;
    font-weight: 300;
}

/* Shadows for Title and Subjects */
.timeline li .title::before,
.timeline li .subjects::before {
    content: "";
    position: absolute;
    width: 90%;
    height: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    left: 50%;
    border-radius: 50%;
    filter: blur(4px);
    transform: translate(-50%, 50%);
}

.timeline li .title::before {
    bottom: calc(100% + 0.125rem);
}

.timeline li .subjects::before {
    z-index: -1;
    bottom: 0.25rem;
}

/* Collapsible Section Styling */
.timeline-details {
    margin-bottom: 2rem;
    border: 1px solid #ddd;
    padding: 1rem;
}

.timeline-details summary {
    font-weight: bold;
    cursor: pointer;
}

.timeline-details[open] .timeline {
    display: grid;  /* Ensure it's displayed when open */
}

/* Remove text underlining on hover */
.timeline li:hover {
    text-decoration: none; /* Prevent underlining on hover */
}

/* Responsive Design */
/* Responsive Design */
@media (min-width: 40rem) {
    .timeline {
        grid-template-columns: 1fr var(--line-w) 1fr;
    }

    /* Make the middle line of the timeline shorter */
    .timeline::before {
        content: "";
        grid-column: 2;
        grid-row: 1 / span 10; /* Shorter line */
        background: rgb(225, 225, 225); /* Timeline line color */
        border-radius: calc(var(--line-w) / 2);
    }

    .timeline li:nth-child(odd) {
        grid-column: 1;
    }

    .timeline li:nth-child(even) {
        grid-column: 3;
    }

    /* Start second card */
    .timeline li:nth-child(2) {
        grid-row: 2/4;
    }

    .timeline li:nth-child(odd) .time::before {
        clip-path: polygon(0 0, 100% 0, 100% 100%);
        left: 0;
    }

    .timeline li:nth-child(odd) .time::after {
        transform: translate(-50%, -50%);
        left: calc(100% + var(--col-gap) + var(--line-w) / 2);
    }

    .timeline li:nth-child(odd) .time {
        border-radius: 0 calc(var(--timeH) / 2) calc(var(--timeH) / 2) 0;
    }
}

@media (max-width: 768px) {
    /* Adjust font sizes and time indicator for smaller screens */
    .timeline li .time {
        font-size: 0.9rem; /* Smaller font size for time indicator */
        --timeH: 2.5rem; /* Reduce height for time indicator */
    }

    /* Adjust title and subjects for smaller screens */
    .timeline li .title,
    .timeline li .subjects {
        padding-block-end: 0.7rem; /* Reduce bottom padding */
    }

    .timeline li .title {
        font-size: 0.8rem; /* Smaller font size for title */
    }

    .timeline li .subjects {
        font-size: 0.8rem; /* Smaller font size for subjects */
        margin: 0;
    }

    /* Reduce column and row gaps */
    .timeline {
        column-gap: 0.5rem;
        row-gap: 0.9rem;
    }

    /* Adjust margin between timeline items */
    .timeline li {
        margin-inline: 1rem; /* gap between dots of the two columns on either side of timeline */
    }

    /* Adjust size of the circle indicator */
    .timeline li .time::after {
        width: 1.3rem;
        border: 0.2rem solid var(--accent-color);
    }
}