section.timeline-block {
    margin: 0 !important;
    padding: 0 32px;
}

section.timeline-block .timeline-wrapper{
    max-width: var(--gbg-wide-width);
    margin: auto;
    padding: 40px 0;
    display: flex;
    flex-direction: column;
    gap: clamp(32px, 4vw, 56px);
    color: var(--gbg-color-primary);
}

section.timeline-block.background-light {
    background-color: var(--gbg-color-light);
}

section.timeline-block.background-primary {
    background-color: var(--gbg-color-primary);
}

section.timeline-block.background-primary .timeline-header .timeline-title,
section.timeline-block.background-primary .timeline-wrapper {
    color: var(--gbg-color-light);
}

section.timeline-block.background-primary .timeline-header .timeline-subtitle {
    color: var(--gbg-color-light-citron);
}

section.timeline-block:not(.alignwide).wp-block {
    max-width: inherit;
}

section.timeline-block .timeline-header .timeline-subtitle {
    font-size: clamp(18px, 4vw, 20px);
    margin-bottom: clamp(8px, 4vw, 32px);
}

section.timeline-block .timeline-header .timeline-subtitle:empty,
section.timeline-block .timeline-header .timeline-subtitle[data-visible="false"],
section.timeline-block .timeline-header .timeline-subtitle[data-visible=""],
section.timeline-block .timeline-header .timeline-subtitle[data-visible="0"] {
    display: none !important;
}

section.timeline-block .timeline-header {
    text-align: center;
}

section.timeline-block .timeline-header .timeline-title {
    color: var(--gbg-color-primary);
    font-size: clamp(40px, 4vw, 56px) !important;
    line-height: 1 !important;
    font-weight: 500;
    margin: 0;
}

/* Timeline Grid - Mobile First */
body:not(.block-editor-page) section.timeline-block .timeline-content .timeline-grid,
.editor-styles-wrapper section.timeline-block .timeline-content .timeline-grid > .block-editor-inner-blocks > .block-editor-block-list__layout {
    display: grid;
    grid-template-columns: 1fr; /* Mobile: 1 column only */
    gap: 32px;
    counter-reset: timeline-counter;
    max-width: 900px; /* 900px */
}

/* Hide timeline during initial load to prevent flash */
body:not(.block-editor-page) section.timeline-block:not(.timeline-ready) .timeline-content {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

body:not(.block-editor-page) section.timeline-block.timeline-ready .timeline-content {
    opacity: 1;
}

/* Disable animations in editor */
.editor-styles-wrapper section.timeline-block .timeline-grid p {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    border: 1px solid var(--gbg-color-grey);
}


/* Timeline columns structure */
section.timeline-block .timeline-column {
    position: relative;
}

section.timeline-block .timeline-column.timeline-center {
    display: none;
}

section.timeline-block .timeline-item-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

/* Animated state: visible and in position */
section.timeline-block .timeline-item-wrapper.timeline-animate {
    opacity: 1;
    transform: translateY(0);
}

/* Timeline Item Number */
section.timeline-block .timeline-item-number {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: var(--gbg-color-light-citron);
    border: 1px solid var(--gbg-color-dark-citron);
    color: var(--gbg-color-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 400;
    font-size: 32px;
    position: relative;
    z-index: 2;
}

/* Vertical dotted line connecting numbers */
section.timeline-block .timeline-item-number::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 96px;
    background-image: linear-gradient(to bottom, var(--gbg-color-primary) 60%, transparent 60%);
    background-size: 1px 8px;
    background-repeat: repeat-y;
    z-index: 1;
}

/* Last item in left column - shorter line to connect to center bar */
section.timeline-block .timeline-item-wrapper.timeline-left-last .timeline-item-number::after {
    height: 40px;
}

section.timeline-block.background-primary .timeline-item-number::after {
    background-image: linear-gradient(to bottom, var(--gbg-color-light) 60%, transparent 60%);
}

/* Hide connecting line for last items in each column */
section.timeline-block .timeline-item-wrapper.timeline-last::after,
section.timeline-block .timeline-item-wrapper.timeline-last .timeline-item-number::after {
    display: none;
}

section.timeline-block .timeline-item-content {
    flex: 1;
    min-width: 0;
}

section.timeline-block .timeline-item-content p {
    margin: 0;
    font-size: clamp(16px, 4vw, 20px);
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
}

section.timeline-block .timeline-item-wrapper.timeline-left,
section.timeline-block .timeline-item-wrapper.timeline-right {
    grid-column: 1;
}

/* Desktop Responsive Styles */
@media screen and (min-width: 998px) {
    section.timeline-block {
        padding: 40px 32px 110px;
    }

    section.timeline-block .timeline-header .timeline-title {
        max-width: 70%;
        margin: auto;
        text-wrap: pretty;
    }

    /* Desktop Grid Layout */
    body:not(.block-editor-page) section.timeline-block .timeline-content .timeline-grid,
    .editor-styles-wrapper section.timeline-block .timeline-content .timeline-grid > .block-editor-inner-blocks > .block-editor-block-list__layout {
        position: relative;
        grid-auto-rows: min-content;
        max-width: 1040px;
        margin: auto;
        min-height: 100%;
    }

    .editor-styles-wrapper section.timeline-block .timeline-content .timeline-grid > .block-editor-inner-blocks > .block-editor-block-list__layout {
        grid-template-columns: 1fr 1fr;
    }

    body:not(.block-editor-page) section.timeline-block .timeline-content .timeline-grid {
        grid-template-columns: 1fr 0.3fr 1fr;
        column-gap: 0;
    }

    /* Center Column */
    section.timeline-block .timeline-column.timeline-center {
        display: flex;
        grid-column: 2;
        grid-row: 1 / -1;
        position: relative;
        opacity: 0;
        transition: opacity 0.6s ease-in-out;
        align-items: center;
        justify-content: center;
    }

    section.timeline-block .timeline-column.timeline-center.timeline-center-animate {
        opacity: 1;
    }

    section.timeline-block .timeline-center-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: end;
        width: 100%;
        height: 100%;
        position: relative;
    }

    section.timeline-block .timeline-border-top,
    section.timeline-block .timeline-border-bottom {
        flex-shrink: 0;
        width: 100.5px;
        height: auto;
        position: absolute;
    }

    section.timeline-block .timeline-border-top {
        top: -37px;
        right: -31px;
    }

    section.timeline-block .timeline-border-bottom {
        bottom: -63px;
        left: -33px;
        transform: scaleY(-1);
    }

    section.timeline-block .timeline-center-line {
        width: 2px;
        height: 96%;
        background-image: linear-gradient(to bottom, var(--gbg-color-primary) 60%, transparent 60%);
        background-size: 1px 8px;
        background-repeat: repeat-y;
        position: relative;
        z-index: 2;
    }

    section.timeline-block.background-primary .timeline-center-line {
        background-image: linear-gradient(to bottom, var(--gbg-color-light) 60%, transparent 60%);
    }

    section.timeline-block.background-primary .timeline-border-top path,
    section.timeline-block.background-primary .timeline-border-bottom path {
        fill: var(--gbg-color-light);
    }

    section.timeline-block:not(.background-primary) .timeline-border-top path,
    section.timeline-block:not(.background-primary) .timeline-border-bottom path {
        fill: var(--gbg-color-primary);
    }

    /* Desktop Item Styles */
    section.timeline-block .timeline-item-wrapper {
        gap: 24px;
        margin-bottom: 32px;
    }

    section.timeline-block .timeline-item-wrapper.timeline-left {
        flex-direction: row-reverse;
        grid-column: 1;
    }

    section.timeline-block .timeline-item-wrapper.timeline-right {
        grid-column: 3;
    }

    section.timeline-block .timeline-item-number {
        width: 64px;
        height: 64px;
    }

    section.timeline-block .timeline-item-number::after {
        height: 128px;
    }

    section.timeline-block .timeline-left:last-of-type .timeline-item-number::after {
        display: none;
    }

    section.timeline-block .timeline-item-content p {
        max-width: 80%;
        text-wrap: pretty;
    }
}
