.timeline {
    box-sizing: border-box;
    position: relative;
    overflow-x: hidden;
    
    /* CSS Custom Properties for dynamic colors */
    --timeline-line-color: #DDD;
    --timeline-node-color: #DDD;
    --timeline-node-bg: #FFF;
    --timeline-nav-color: #FFF;
    --timeline-nav-border: #DDD;
    /* Outline color for the active/current item (defaults to black when no nodeColor is configured) */
    --timeline-active-outline-color: #000;
    
    /* CSS Custom Properties for responsive horizontal layout dimensions */
    --timeline-h-node-width: 200px;
    --timeline-h-node-min-height: 180px;
    --timeline-h-image-size: 150px;
    --timeline-h-title-font-size: 18px;
    --timeline-h-text-font-size: 11px;

    /* Gap for same-side layouts (applies when sameSideNodes is enabled) */
    --timeline-same-side-gap: 20px;
}

/* Hide timeline by default to prevent flash of unstyled/incorrectly-styled content.
   The timeline engine will add the .timeline--loaded class after layout is complete,
   and the fade-in will make the transition smooth. */
.timeline:not(.timeline--loaded) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Semantic node field styles */
.timeline__date {
    font-size: 0.95rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

/* Vertical (non-mobile) cards: center date above the centered image */
.timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__date {
    text-align: center;
}

.timeline__heading {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: #333;
}

/* Page-level timeline title (from JSON timelineName) */
/* Hidden by default to prevent jump; revealed with timeline fade-in */
.timeline__title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 18px 0;
    color: #333;
    text-align: center;
    position: relative;
    z-index: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 500ms ease-in-out, visibility 500ms ease-in-out;
}

/* Show title when visible class is added by JS */
.timeline__title--visible {
    opacity: 1;
    visibility: visible;
}

.timeline__image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    border-radius: 4px;
    margin-bottom: 8px;
}

/* Summary truncation with line-clamp (3 lines) */
.timeline__summary {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #555;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modal content hidden by default */
.timeline__modal-content {
    display: none;
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
}

.timeline__modal-content p {
    margin-bottom: 12px;
}

.timeline__modal-content p:last-child {
    margin-bottom: 0;
}

.timeline *,
.timeline *::before,
.timeline *::after {
    box-sizing: inherit;
}

.timeline:not(.timeline--horizontal)::before {
    background-color: var(--timeline-line-color);
    bottom: 0;
    content: '';
    left: 50%;
    margin-left: -2px;
    position: absolute;
    top: 0;
    width: 4px;
    z-index: 1;
}

.timeline__wrap {
    overflow: hidden;
    position: relative;
    z-index: 2;
}

.timeline--horizontal .timeline__wrap {
    /* Clip items horizontally (past nav buttons) but allow vertical overflow */
    overflow-x: hidden;
    overflow-y: visible;
}

.timeline__item {
    font-size: 1rem;
    padding: 10px 40px 10px 0;
    position: relative;
    width: 50%;
    z-index: 2;
}

/* Mobile layout: vertical timeline, left-aligned, stacked items */
.timeline--mobile {
    padding: 0;
}

.timeline--mobile::before {
    left: 10px !important;
    margin: 0 !important;
}

.timeline--mobile .timeline__item {
    left: 0;
    padding-left: 40px;
    padding-right: 0;
    width: 100%;
    margin-bottom: 20px;
}

/* Gap between items when same-side vertical layout is active (includes mobile) */
.timeline--same-side:not(.timeline--horizontal) .timeline__item {
    margin-bottom: var(--timeline-same-side-gap);
}

.timeline--same-side:not(.timeline--horizontal) .timeline__item:last-child {
    margin-bottom: 0;
}

.timeline--mobile .timeline__item::after {
    left: 2px;
    margin: 0;
    right: auto;
    transform: translateY(-50%);
}

.timeline--mobile .timeline__content {
    background-color: #FFF;
    border: 1px solid #CCC;
    border-radius: 10px;
    padding: 8px;
    position: relative;
    display: grid;
    /* columns: image | date | spacer | content */
    grid-template-columns: 60px 70px 5px 1fr;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 4px;
    align-items: start;
    min-height: auto;
}

/* Mobile + no-summary: keep image/date/heading in one row and center-align them */
.timeline--mobile .timeline__content.no-summary {
    align-items: center;
    column-gap: 12px;
    display: grid;
    /* image | date | spacer | heading */
    grid-template-columns: 80px 110px 5px 1fr;
    grid-template-rows: auto;
    row-gap: 0;
}

.timeline--mobile .timeline__content.no-image.no-summary {
    grid-template-columns: 110px 1fr;
}

.timeline--mobile .timeline__content.no-summary .timeline__image {
    grid-column: 1;
    grid-row: 1;
    width: 80px;
    height: 80px;
    margin: 0;
    object-fit: cover;
}

.timeline--mobile .timeline__content.no-summary .timeline__date {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    white-space: nowrap;
    align-self: center;
}

.timeline--mobile .timeline__content.no-summary .timeline__heading {
    grid-column: 4;
    grid-row: 1;
    margin: 0;
    align-self: center;
    line-height: 1.2;
}

/* Triangle pointers for mobile left-aligned layout */
.timeline--mobile .timeline__content::before {
    content: '';
    position: absolute;
    height: 0;
    width: 0;
    border-bottom: 10px solid transparent;
    border-right: 12px solid #CCC;
    border-left: none;
    border-top: 10px solid transparent;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}

/* Visually-hidden helper for accessibility (screen-reader only) */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.timeline--mobile .timeline__content::after {
    content: '';
    position: absolute;
    height: 0;
    width: 0;
    border-bottom: 9px solid transparent;
    border-right: 10px solid #FFF;
    border-left: none;
    border-top: 9px solid transparent;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

.timeline--mobile .timeline__image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    grid-column: 1;
    grid-row: 1 / span 2;
    margin: 0;
}

.timeline--mobile .timeline__date {
    font-size: 0.9rem;
    font-weight: 700;
    color: #333;
    grid-column: 2;
    grid-row: 1 / span 2;
    white-space: nowrap;
    padding-top: 0;
    align-self: center;
    padding-right: 8px;
}

.timeline--mobile .timeline__heading {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
    color: #333;
    grid-column: 4;
    grid-row: 1;
    min-width: 0;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.timeline--mobile .timeline__summary {
    font-size: 0.8rem;
    line-height: 1.2;
    color: #555;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    grid-column: 4;
    grid-row: 2;
    min-width: 0;
}

/* Ensure a small internal gap between the date column and the text column
   so the separation remains visible on narrow screens. */
.timeline--mobile .timeline__heading,
.timeline--mobile .timeline__summary {
    padding-left: 6px;
}

/* Collapse to two+spacer columns when no image is present */
.timeline--mobile .timeline__content:not(:has(.timeline__image)) {
    /* date | spacer | content */
    grid-template-columns: 70px 5px 1fr;
}

.timeline--mobile .timeline__content:not(:has(.timeline__image)) .timeline__date {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
}

.timeline--mobile .timeline__content:not(:has(.timeline__image)) .timeline__heading {
    grid-column: 3;
    grid-row: 1;
}

.timeline--mobile .timeline__content:not(:has(.timeline__image)) .timeline__summary {
    grid-column: 3;
    grid-row: 2;
}

/* JS fallback: when image is absent, add .no-image to the content element
   Mirror the :has() rules so older browsers work when demo JS adds .no-image */
.timeline--mobile .timeline__content.no-image {
    /* date | spacer | content */
    grid-template-columns: 70px 5px 1fr;
}
.timeline--mobile .timeline__content.no-image .timeline__date {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
}
.timeline--mobile .timeline__content.no-image .timeline__heading {
    grid-column: 3;
    grid-row: 1;
}
.timeline--mobile .timeline__content.no-image .timeline__summary {
    grid-column: 3;
    grid-row: 2;
}

/* Vertical layout: side-by-side alternating */
@media (min-width: 768px) {
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item {
        width: 50%;
        padding: 10px 40px 10px 0;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item::after {
        right: -10px;
        left: auto;
        transform: translateY(-50%);
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item--left {
        left: 0;
        padding: 10px 40px 10px 0;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item--right {
        left: 50%;
        padding: 10px 0 10px 40px;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item--right::after {
        left: -10px;
        right: auto;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item--left .timeline__content::before {
        border-bottom: 10px solid transparent;
        border-left: 12px solid #CCC;
        border-top: 10px solid transparent;
        right: -12px;
        left: auto;
        z-index: 1;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item--left .timeline__content::after {
        border-bottom: 9px solid transparent;
        border-left: 11px solid #FFF;
        border-top: 9px solid transparent;
        right: -10px;
        left: auto;
        z-index: 2;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item--right .timeline__content::before {
        border-bottom: 10px solid transparent;
        border-right: 12px solid #CCC;
        border-left: none;
        border-top: 10px solid transparent;
        left: -12px;
        right: auto;
        z-index: 1;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item--right .timeline__content::after {
        border-bottom: 9px solid transparent;
        border-right: 11px solid #FFF;
        border-left: none;
        border-top: 9px solid transparent;
        left: -10px;
        right: auto;
        z-index: 2;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 16px;
        max-height: none;
        position: relative;
    }

    /* When there is no summary present, lay out image / date / heading in a single row
       for vertical (desktop) timelines. Use :has() where available and provide a
       JS-friendly fallback using the `.no-summary` class (can be added by script). */
    /* Treat "no summary" as: no summary node or summary node is empty/whitespace (JS adds .no-summary fallback too) */
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__summary:not(:empty))),
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-summary {
        display: grid;
        grid-template-columns: 100px 120px 1fr;
        column-gap: 16px;
        gap: 0;
        align-items: center;
        padding: 16px;
    }

    /* If image is absent and no summary, collapse to two columns: [date][heading] */
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__image)):not(:has(.timeline__summary:not(:empty))),
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-image.no-summary {
        grid-template-columns: 120px 1fr;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content .timeline__image {
        grid-column: 1;
        width: 100px;
        height: 100px;
        object-fit: cover;
        margin: 0;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content .timeline__date {
        grid-column: 2;
        margin: 0;
        white-space: nowrap;
        align-self: center;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content .timeline__heading {
        grid-column: 3;
        margin: 0;
        align-self: center;
        line-height: 1.2;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content::before,
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content::after {
        content: '';
        height: 0;
        position: absolute;
        transform: translateY(-50%);
        top: 50%;
        width: 0;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__image {
        max-width: 100%;
        height: auto;
        margin-bottom: 0;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__summary {
        font-size: 0.95rem;
        -webkit-line-clamp: 3;
    }
}

/* Horizontal layout: carousel with fixed card width */
@media (min-width: 1200px) {
    .timeline--horizontal .timeline__content {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 8px;
        padding: 12px;
    }

    .timeline--horizontal .timeline__date {
        order: 2;
        font-weight: bold;
        font-size: 0.95rem;
    }

    .timeline--horizontal .timeline__heading {
        order: 3;
        font-size: 1rem;
        margin: 0;
    }

    .timeline--horizontal .timeline__image {
        order: 1;
        width: auto;
        height: auto;
        object-fit: cover;
        margin-bottom: 0;
    }

    .timeline--horizontal .timeline__summary {
        order: 4;
        font-size: 0.85rem;
        -webkit-line-clamp: 2;
    }
}

.timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item .timeline__image {
    width: 100px;
    height: auto;
    max-height: 100px;
    object-fit: cover;
    margin: 0 auto 12px;
}

.timeline__item::after {
    background-color: var(--timeline-node-bg);
    border: 4px solid var(--timeline-node-color);
    border-radius: 50%;
    content: '';
    height: 20px;
    position: absolute;
    right: -10px;
    transform: translateY(-50%);
    top: 50%;
    width: 20px;
    z-index: 1;
}

.timeline__item.animated {
    animation-duration: 1s;
    animation-fill-mode: both;
    opacity: 0;
}

.timeline__item.fadeIn {
    animation-name: fadeIn;
}

/* Active state for current/deep-linked node */
.timeline__item--active .timeline__content {
    border-color: var(--timeline-active-outline-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Fill the dot for active node */
.timeline__item--active::after {
    background-color: var(--timeline-node-color);
}

.timeline__item--left {
    left: 0;
}

.timeline__item--right {
    left: 50%;
    padding: 10px 0 10px 40px;
}

.timeline__item--right::after {
    left: -10px;
}

.timeline__item--right .timeline__content::before {
    border-bottom: 10px solid transparent;
    border-right: 12px solid #CCC;
    border-left: none;
    border-top: 10px solid transparent;
    left: -12px;
}

.timeline__item--right .timeline__content::after {
    border-bottom: 9px solid transparent;
    border-right: 11px solid #FFF;
    border-left: none;
    border-top: 9px solid transparent;
    left: -10px;
}

.timeline__content {
    background-color: #FFF;
    border: 1px solid #CCC;
    border-radius: 10px;
    color: #333;
    display: block;
    padding: 20px;
    position: relative;
    z-index: 2;
}

/* Vertical (desktop) layout: when summary is absent or empty, lay out items in one row */
@media (min-width: 768px) {
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__summary:not(:empty))),
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-summary {
        display: grid;
        grid-template-columns: 100px 120px 1fr;
        column-gap: 16px;
        row-gap: 0;
        align-items: center;
        padding: 16px;
    }

    /* No image: collapse to two columns */
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__image)):not(:has(.timeline__summary:not(:empty))),
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-image.no-summary {
        grid-template-columns: 120px 1fr;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__summary:not(:empty))) .timeline__image,
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-summary .timeline__image {
        grid-column: 1;
        width: 100px;
        height: 100px;
        object-fit: cover;
        margin: 0;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__summary:not(:empty))) .timeline__date,
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-summary .timeline__date {
        grid-column: 2;
        margin: 0;
        white-space: nowrap;
        align-self: center;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__summary:not(:empty))) .timeline__heading,
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-summary .timeline__heading {
        grid-column: 3;
        margin: 0;
        align-self: center;
        line-height: 1.2;
    }
}

/* Image styling handled in responsive sections above */

.timeline__content::before,
.timeline__content::after {
    content: '';
    height: 0;
    position: absolute;
    transform: translateY(-50%);
    top: 50%;
    width: 0;
}

.timeline__content::before {
    border-bottom: 10px solid transparent;
    border-left: 12px solid #CCC;
    border-top: 10px solid transparent;
    right: -12px;
    z-index: 1;
}

.timeline__content::after {
    border-bottom: 9px solid transparent;
    border-left: 11px solid #FFF;
    border-top: 9px solid transparent;
    right: -10px;
    z-index: 2;
}

.timeline__content h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 10px;
}

.timeline__content h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 10px;
}

.timeline__content p {
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 10px;
}

.timeline--horizontal {
    font-size: 0;
    padding: 0 60px;
    overflow: hidden;
}

.timeline--horizontal .timeline__wrap {
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    z-index: 2;
}

.timeline--horizontal .timeline-divider {
    background-color: var(--timeline-line-color);
    display: block;
    height: 4px;
    left: 40px;
    position: absolute;
    transform: translateY(-50%);
    right: 40px;
    z-index: 1;
}

.timeline--horizontal .timeline__items {
    transition: all 0.8s;
    will-change: transform;
}

.timeline--horizontal .timeline__item {
    display: inline-block;
    left: 0;
    padding: 0 0 60px;
    position: relative;
    transition: none;
    vertical-align: top;
    white-space: normal;
    width: var(--timeline-h-node-width);
}

/* Gap between items when same-side horizontal layout is active */
.timeline--same-side.timeline--horizontal .timeline__item {
    margin-right: var(--timeline-same-side-gap);
}

.timeline--same-side.timeline--horizontal .timeline__item:last-child {
    margin-right: 0;
}

/* Same-side top mode: nodes below the timeline */
.timeline--same-side.timeline--horizontal .timeline__item--top {
    padding: 0 0 60px;
    vertical-align: bottom;
}

/* Same-side bottom mode: nodes above the timeline */
.timeline--same-side.timeline--horizontal .timeline__item--bottom {
    padding: 60px 0 0;
    vertical-align: top;
}

.timeline--horizontal .timeline__item .timeline__content {
    padding: 12px;
    min-height: var(--timeline-h-node-min-height);
}

.timeline--horizontal .timeline__item .timeline__content h3 {
    font-size: var(--timeline-h-title-font-size);
    font-weight: 700;
    margin: 0 0 8px;
}

.timeline--horizontal .timeline__item .timeline__content p {
    font-size: var(--timeline-h-text-font-size);
    line-height: 1.4;
    margin-bottom: 0;
}

.timeline--horizontal .timeline__item::after {
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    top: 100%;
}

/* Same-side layouts: position dots on the divider line */
.timeline--same-side.timeline--horizontal .timeline__item--top::after {
    /* Top mode: divider is at bottom of item minus 30px padding zone */
    top: calc(100% - 30px);
}

.timeline--same-side.timeline--horizontal .timeline__item--bottom::after {
    /* Bottom mode: divider is at 30px from top */
    top: 30px;
}

.timeline--horizontal .timeline__item .timeline__item__inner {
    display: table;
    height: 100%;
    width: 100%;
}

.timeline--horizontal .timeline__item .timeline__content__wrap {
    display: table-cell;
    margin: 0;
    padding: 0;
    vertical-align: bottom;
}

.timeline--horizontal .timeline__item .timeline__content::before {
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid #CCC;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    top: 100%;
}

.timeline--horizontal .timeline__item .timeline__content::after {
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #FFF;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    top: 100%;
}

.timeline--horizontal .timeline__item--bottom {
    padding: 60px 0 0;
}

.timeline--horizontal .timeline__item--bottom::after {
    top: 0;
}

.timeline--horizontal .timeline__item--bottom .timeline__content__wrap {
    vertical-align: top;
}

.timeline--horizontal .timeline__item--bottom .timeline__content::before {
    border-bottom: 12px solid #CCC;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: none;
    bottom: 100%;
    top: auto;
}

.timeline--horizontal .timeline__item--bottom .timeline__content::after {
    border-bottom: 10px solid #FFF;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: none;
    bottom: 100%;
    top: auto;
}

/* Active pointer/arrow outline should match the active outline color */
.timeline--horizontal .timeline__item.timeline__item--active .timeline__content::before {
    border-top-color: var(--timeline-active-outline-color);
}

/* Make the active pointer look integrated with the card (avoid a thick "seam" line) */
.timeline--horizontal .timeline__item.timeline__item--active .timeline__content::after {
    border-left-width: 11px;
    border-right-width: 11px;
    border-top-width: 11px;
}

.timeline--horizontal .timeline__item--bottom.timeline__item--active .timeline__content::before {
    border-bottom-color: var(--timeline-active-outline-color);
}

.timeline--horizontal .timeline__item--bottom.timeline__item--active .timeline__content::after {
    border-left-width: 11px;
    border-right-width: 11px;
    border-bottom-width: 11px;
}

.timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item--active.timeline__item--left .timeline__content::before {
    border-left-color: var(--timeline-active-outline-color);
}

.timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__item--active.timeline__item--right .timeline__content::before {
    border-right-color: var(--timeline-active-outline-color);
}

.timeline--mobile .timeline__item--active .timeline__content::before {
    border-right-color: var(--timeline-active-outline-color);
}

.timeline-nav-button {
    background-color: var(--timeline-nav-color);
    border: 3px solid var(--timeline-nav-border);
    border-radius: 50px;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: block;
    height: 40px;
    outline: none;
    position: absolute;
    text-indent: -9999px;
    transform: translateY(-50%);
    top: 50%;
    width: 40px;
    z-index: 10;
    transition: all 0.3s ease;
}

.timeline-nav-button:hover {
    transform: translateY(-50%) scale(1.15);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.timeline-nav-button:disabled {
    opacity: .5;
    pointer-events: none;
    cursor: not-allowed;
    user-select: none;
}

/* Visual disabled state for at-start and at-end classes (no actual disabled attribute) */
.timeline-nav-button.timeline-nav-button--at-start,
.timeline-nav-button.timeline-nav-button--at-end {
    opacity: 0.5;
    cursor: not-allowed;
}

.timeline-nav-button.timeline-nav-button--at-start:hover,
.timeline-nav-button.timeline-nav-button--at-end:hover {
    transform: translateY(-50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.timeline-nav-button::before {
    display: none;
}

.timeline-nav-button svg {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.timeline-nav-button--prev {
    left: 10px;
}

.timeline-nav-button--next {
    right: 10px;
}

/* Mobile layout styles handled in responsive sections above */

@keyframes fadeIn {
    0% {
        opacity: 0;
        top: 70px;
    }
    100% {
        opacity: 1;
        top: 0px;
    }
}

@keyframes liftUp {
    0% {
        top: 0px;
    }
    100% {
        top: -15px;
    }
}

/* Modal Styles */
.timeline-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.timeline-modal-overlay.timeline-modal-show {
    opacity: 1;
    visibility: visible;
}

.timeline-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background-color: #FFF;
    border-radius: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

.timeline-modal.timeline-modal-show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.timeline-modal__content {
    padding: 40px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
}

/* Use user-agent/default scrollbar styling so OS/browser controls decide width */

.timeline-modal__image {
    width: auto;
    max-width: 100%;
    height: auto;
    border-radius: 0;
    margin: 0 auto 20px;
    display: block;
}

.timeline-modal__title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 20px;
    color: #333;
}

.timeline-modal__text {
    font-size: 16px;
    line-height: 1.6;
    color: #555;
}

.timeline-modal__text p {
    margin-bottom: 15px;
}

.timeline-modal__divider {
    border: 0;
    border-top: 1px solid #ddd;
    margin: 30px 0;
}

.timeline-modal__close-bottom {
    display: inline-block;
    padding: 12px 40px;
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 0;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.timeline-modal__close-bottom:hover {
    background-color: #555;
}

.timeline-modal__footer {
    border-top: 1px solid #ddd;
    padding: 16px 24px;
    background: #fff;
    text-align: center;
    flex: 0 0 auto;
}

.timeline-modal__close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 4px;
    color: #FFF;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeline-modal__close:hover {
    background-color: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.timeline-modal__close::before {
    content: '×';
}

/* Fullscreen modals on small screens (medium and below) */
@media (max-width: 768px) {
    .timeline-modal {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        top: 0;
        left: 0;
        transform: scale(0.95);
        border-radius: 0;
    }
    
    .timeline-modal.timeline-modal-show {
        transform: scale(1);
    }
    
    .timeline-modal__content {
        max-height: 100%;
        padding: 60px 20px 20px; /* More top padding for close button */
    }
    
    .timeline-modal__close {
        top: 10px;
        right: 10px;
        width: 48px;
        height: 48px;
        font-size: 28px;
        border-radius: 50%;
        background-color: rgba(0, 0, 0, 0.7);
    }
    
    .timeline-modal__close:hover {
        background-color: rgba(0, 0, 0, 0.9);
    }
}

/* Make timeline items clickable */
.timeline__item {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.timeline__item:hover .timeline__content {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Horizontal mode: keep hover shadow, but don't translate cards upward.
   This avoids node-1 clipping without impacting divider/dot layout. */
.timeline--horizontal .timeline__item:hover .timeline__content {
    transform: none;
}

/* Error UI */
.timeline__error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    margin: 20px auto;
    max-width: 600px;
    background: #fff;
}

.timeline__error-icon {
    width: 200px;
    max-width: 100%;
    height: auto;
    margin-bottom: 24px;
    opacity: 0.8;
}

/* Hide timeline decorations when showing error UI inside the timeline container */
.timeline.timeline--error::before,
.timeline.timeline--error .timeline-divider,
.timeline.timeline--error .timeline-nav-button {
    display: none !important;
}
.timeline.timeline--error .timeline__items,
.timeline.timeline--error .timeline__wrap {
    display: none !important;
}

.timeline__error-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 16px;
    color: #d32f2f;
}

.timeline__error-message {
    font-size: 16px;
    line-height: 1.6;
    margin: 0 0 16px;
    color: #555;
}

.timeline__error-solution {
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 12px;
    color: #333;
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 12px 16px;
}

/* Responsive horizontal timeline scaling for smaller screens */
/* Medium screens (tablets in landscape, small laptops) */
@media (max-width: 1024px) {
    .timeline--horizontal {
        --timeline-h-node-width: 180px;
        --timeline-h-node-min-height: 160px;
        --timeline-h-image-size: 90px;
    }
}

/* Small screens (tablets in portrait, large phones in landscape) */
@media (max-width: 768px) {
    .timeline--horizontal {
        --timeline-h-node-width: 160px;
        --timeline-h-node-min-height: 140px;
        --timeline-h-image-size: 80px;
        --timeline-h-title-font-size: 16px;
        --timeline-h-text-font-size: 10px;
    }
    /* Hide summary text on smaller screens to save space */
    .timeline--horizontal .timeline__summary {
        display: none;
    }
}

/* Very small screens (phones in landscape) */
@media (max-width: 640px) {
    .timeline--horizontal {
        --timeline-h-node-width: 140px;
        --timeline-h-node-min-height: 120px;
        --timeline-h-image-size: 70px;
        --timeline-h-title-font-size: 14px;
        padding: 0 40px;
    }
    /* Keep summary hidden */
    .timeline--horizontal .timeline__summary {
        display: none;
    }
}

/* Extra small screens (small phones in landscape) */
@media (max-width: 480px) {
    .timeline--horizontal {
        --timeline-h-node-width: 120px;
        --timeline-h-node-min-height: 100px;
        --timeline-h-image-size: 60px;
        --timeline-h-title-font-size: 13px;
        padding: 0 30px;
    }
    /* Show only image and date - hide heading and summary */
    .timeline--horizontal .timeline__heading {
        font-size: 12px;
        margin: 0 0 4px;
        line-height: 1.2;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .timeline--horizontal .timeline__summary {
        display: none;
    }
}

/* Ultra-compact mode for tiny screens */
@media (max-width: 360px) {
    .timeline--horizontal {
        --timeline-h-node-width: 100px;
        --timeline-h-node-min-height: 90px;
        --timeline-h-image-size: 50px;
        --timeline-h-title-font-size: 11px;
        padding: 0 20px;
    }
    /* Show only image and date */
    .timeline--horizontal .timeline__heading {
        font-size: 11px;
        -webkit-line-clamp: 1;
    }
}

/* Micro-screen responsive rules (progressive column hiding)
   1) <=420px: hide summary (keep Image | Date | Heading)
   2) <=360px: hide image (Date | Heading/Summary)
   3) <=320px: compact mode - show only date
*/
@media (max-width: 420px) {
    .timeline--mobile .timeline__summary {
        display: none;
    }
    .timeline--mobile .timeline__content {
        grid-template-columns: 60px 70px 1fr;
    }

    /* On this breakpoint the flexible content column becomes column 3 */
    .timeline--mobile .timeline__heading {
        grid-column: 3;
    }
}

@media (max-width: 360px) {
    .timeline--mobile .timeline__image {
        display: none;
    }
    .timeline--mobile .timeline__content {
        grid-template-columns: 70px 1fr;
        grid-template-rows: auto auto;
    }
    .timeline--mobile .timeline__date {
        grid-column: 1;
        grid-row: 1 / span 2;
        align-self: center;
    }
    .timeline--mobile .timeline__heading {
        grid-column: 2;
        grid-row: 1;
    }
    .timeline--mobile .timeline__summary {
        display: block;
        grid-column: 2;
        grid-row: 2;
    }
}

@media (max-width: 320px) {
    .timeline--mobile .timeline__heading,
    .timeline--mobile .timeline__summary,
    .timeline--mobile .timeline__image {
        display: none;
    }
    .timeline--mobile .timeline__content {
        grid-template-columns: 1fr;
        padding: 6px;
    }
    .timeline--mobile .timeline__date {
        grid-column: 1;
        grid-row: 1;
        align-self: center;
    }
}

.timeline__error-solution strong {
    color: #856404;
}

.timeline__error-details {
    font-size: 13px;
    line-height: 1.5;
    margin: 12px 0 0;
    color: #666;
    font-family: 'Courier New', monospace;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    max-width: 100%;
    overflow-x: auto;
}

.timeline__error-details strong {
    color: #333;
}

/* Final override: ensure vertical no-summary cards stay in a single row (after base .timeline__content rules) */
@media (min-width: 768px) {
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-summary,
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__summary:not(:empty))) {
        display: grid !important;
        grid-template-columns: 100px 120px 1fr;
        column-gap: 16px;
        row-gap: 0;
        align-items: center;
        padding: 16px;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-image.no-summary,
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__image)):not(:has(.timeline__summary:not(:empty))) {
        grid-template-columns: 120px 1fr;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-summary .timeline__image,
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__summary:not(:empty))) .timeline__image {
        grid-column: 1;
        width: 100px;
        height: 100px;
        object-fit: cover;
        margin: 0;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-summary .timeline__date,
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__summary:not(:empty))) .timeline__date {
        grid-column: 2;
        margin: 0;
        white-space: nowrap;
        align-self: center;
    }

    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content.no-summary .timeline__heading,
    .timeline:not(.timeline--horizontal):not(.timeline--mobile) .timeline__content:has(.timeline__heading):not(:has(.timeline__summary:not(:empty))) .timeline__heading {
        grid-column: 3;
        margin: 0;
        align-self: center;
        line-height: 1.2;
    }
}
