.project-timeline-baf8f9e2 {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 0;
    --timeline-line-color: #d32f2f;
    --timeline-line-width: 2px;
    --timeline-line-length: 60px;
    --timeline-item-spacing: 40px; /* New variable for spacing */
    overflow: hidden; /* Prevent horizontal scroll from animations */
}

/* Central Line */
.project-timeline-baf8f9e2::after {
    content: '';
    position: absolute;
    width: var(--timeline-line-width);
    background-color: var(--timeline-line-color);
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.pt-item-baf8f9e2 {
    /* Use the variable for padding to control spacing */
    padding: 20px var(--timeline-item-spacing);
    position: relative;
    background-color: inherit;
    width: 50%;
    box-sizing: border-box;
    opacity: 0; /* For animation */
    transition: all 0.8s ease-out;
}

/* Animation states */
.pt-item-baf8f9e2.is-visible {
    opacity: 1;
    transform: translateX(0) !important;
}

/* Left item */
.pt-item-baf8f9e2:nth-child(odd) {
    left: 0;
    transform: translateX(-50px);
}

/* Right item */
.pt-item-baf8f9e2:nth-child(even) {
    left: 50%;
    transform: translateX(50px);
}

/* Connecting horizontal line */
.pt-item-baf8f9e2::before {
    content: '';
    position: absolute;
    height: var(--timeline-line-width);
    background-color: var(--timeline-line-color);
    /* Instead of a fixed top value, we'll position it relative to the image wrapper later */
    top: calc(20px + 150px); /* Fallback value */
    width: var(--timeline-line-length);
    z-index: 1;
}

/* Left item connecting line */
.pt-item-baf8f9e2:nth-child(odd)::before {
    right: 0;
}

/* Right item connecting line */
.pt-item-baf8f9e2:nth-child(even)::before {
    left: 0;
}

.pt-content-baf8f9e2 {
    text-align: center;
    position: relative;
}

/* 1. Forzamos que el contenedor del widget permita que el marco sobresalga */
.pt-image-wrapper-baf8f9e2 {
    position: relative !important;
    overflow: visible !important;
    margin-bottom: 30px;
    display: inline-block;
}

/* We use a pseudo-element on the image wrapper to draw the line so it's always centered relative to the image */
.pt-item-baf8f9e2 .pt-image-wrapper-baf8f9e2::before {
    content: '';
    position: absolute;
    height: var(--timeline-line-width);
    background-color: var(--timeline-line-color);
    top: 50%; /* Perfect center of the image */
    transform: translateY(-50%);
    width: var(--timeline-line-length);
    z-index: -1; /* Behind image */
}

/* Hide the old static line */
.pt-item-baf8f9e2::before {
    display: none;
}

/* Left item new connecting line */
.pt-item-baf8f9e2:nth-child(odd) .pt-image-wrapper-baf8f9e2::before {
    /* Position it extending to the right */
    left: 100%;
    /* Add the padding offset */
    width: calc(var(--timeline-item-spacing) + (var(--timeline-line-length) - var(--timeline-item-spacing)));
}

/* Right item new connecting line */
.pt-item-baf8f9e2:nth-child(even) .pt-image-wrapper-baf8f9e2::before {
    /* Position it extending to the left */
    right: 100%;
    /* Add the padding offset */
    width: calc(var(--timeline-item-spacing) + (var(--timeline-line-length) - var(--timeline-item-spacing)));
}

/* We still need to make sure the connection line reaches the center line. 
   Since the line starts at the image edge, we'll use the variable.
   A simpler approach for Elementor integration: 
   Let's just use the outer container for the line, but adjust its top based on typical image height,
   OR we rely on flex/grid to keep things aligned. Let's revert to a simpler CSS solution that works with the existing structure. */

/* OVERRIDE: Simpler approach for centering the line vertically relative to the image */
/* We'll use JS or rely on a CSS trick. For now, let's use the image wrapper's pseudo element but make it reach the exact center */
.pt-item-baf8f9e2 .pt-image-wrapper-baf8f9e2::before {
    width: var(--timeline-line-length);
}
.pt-item-baf8f9e2:nth-child(odd) .pt-image-wrapper-baf8f9e2::before {
    right: calc(-1 * var(--timeline-item-spacing));
    left: auto;
}
.pt-item-baf8f9e2:nth-child(even) .pt-image-wrapper-baf8f9e2::before {
    left: calc(-1 * var(--timeline-item-spacing));
    right: auto;
}

/* 2. Damos bordes redondeados a la imagen real */
.pt-image-wrapper-baf8f9e2 img {
    border-radius: 24px; /* Fallback si no hay Elementor, Elementor lo sobrescribirá */
    display: block;
    position: relative;
    z-index: 1; /* La imagen se queda en la capa inferior */
    max-width: 100%;
    height: auto;
}

/* 3. Creamos el marco rojo superpuesto y desfasado */
.pt-image-wrapper-baf8f9e2::after {
    content: '';
    position: absolute;
    
    /* POSICIÓN Y DESFASE: Valores por defecto, Elementor los sobrescribe */
    top: -18px;
    bottom: 15px;
    left: -18px;
    right: 15px;
    
    border: 3px solid #d32f2f; /* Elementor sobrescribe esto */
    border-radius: 28px; /* Elementor sobrescribe esto */
    
    z-index: 10;                /* CAPA SUPERIOR: Queda encima de la imagen */
    pointer-events: none;      /* Permite hacer clic a través del borde */
}

.pt-title-baf8f9e2 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 700;
}

.pt-year-baf8f9e2 {
    margin: 0;
    font-size: 18px;
}

/* Responsive Styles */
@media screen and (max-width: 767px) {
    .project-timeline-baf8f9e2::after {
        left: 20px;
    }

    .pt-item-baf8f9e2 {
        width: 100%;
        padding-left: calc(20px + var(--timeline-item-spacing));
        padding-right: 10px;
        transform: translateX(-30px); /* Reset animation direction for mobile */
    }

    .pt-item-baf8f9e2:nth-child(even) {
        left: 0%;
    }

    /* Update the connection line for mobile */
    .pt-item-baf8f9e2 .pt-image-wrapper-baf8f9e2::before {
        width: var(--timeline-item-spacing) !important;
    }
    
    .pt-item-baf8f9e2:nth-child(odd) .pt-image-wrapper-baf8f9e2::before,
    .pt-item-baf8f9e2:nth-child(even) .pt-image-wrapper-baf8f9e2::before {
        left: auto;
        right: 100%;
    }
}