/* Timeline Wrapper */
.timeline-container {
    position: relative;
    max-width: 600px;
    width: 100%;
    margin: var(--timeline-margin, 0 auto);
    padding-left: 30px; /* Leaves room for the line on the far left */
    box-sizing: border-box;
    font-family: var(--timeline-font-family, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif);
}

/* The Main Vertical Line */
.timeline-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: calc( 6px - ( var(--timeline-line-width, 4px) / 2 ) );
    height: 100%;
    width: 0;
    border-left: var(--timeline-line-width, 4px) var(--timeline-line-style, solid) var(--timeline-line-color, #d1d5db);
}

/* Row wrapper for each log entry */
.timeline-item {
    position: relative;
    margin-bottom: var(--timeline-card-gap, 30px);
}

/* Clear margins on final element */
.timeline-item:last-child {
    margin-bottom: 0;
}

/* Timeline Nodes/Dots */
.timeline-dot {
    position: absolute;
    /* Dynamically align dot horizontally with the vertical line based on dot size and 3px border */
    left: calc( -24px - ( var(--timeline-dot-size, 12px) / 2 ) - 3px );
    top: 16px;   /* Vertically aligns with the card body */
    width: var(--timeline-dot-size, 12px);
    height: var(--timeline-dot-size, 12px);
    border-radius: 50%;
    background-color: var(--timeline-dot-color, #3b82f6);
    border: 3px solid #fff;
    z-index: 1;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

/* Right-Sided Content Cards */
.timeline-content {
    background: #ffffff;
    padding: var(--timeline-card-padding, 20px);
    border-radius: var(--timeline-card-radius, 8px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: var(--timeline-card-border, 1px solid #e5e7eb);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Card hover animation */
.timeline-item:hover .timeline-content {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
    border-color: var(--timeline-dot-color, #d1d5db);
}

.timeline-item:hover .timeline-dot {
    background-color: var(--timeline-dot-color, #2563eb);
    transform: scale(1.25);
}

/* Header Text elements */
.timeline-content h3 {
    margin: 0 0 8px 0;
    color: var(--timeline-title-color, #1f2937);
    font-size: var(--timeline-title-size, 1.15rem);
    font-family: inherit;
    font-weight: 700;
}

/* Card Descriptions and inner paragraphs */
.timeline-content p, 
.timeline-description p {
    margin: 0 0 10px 0;
    color: var(--timeline-text-color, #4b5563);
    font-size: var(--timeline-text-size, 0.95rem);
    line-height: 1.5;
}

.timeline-content p:last-child, 
.timeline-description p:last-child {
    margin-bottom: 0;
}

.timeline-description {
    color: var(--timeline-text-color, #4b5563);
    font-size: var(--timeline-text-size, 0.95rem);
}

/* Timestamps */
.timeline-date {
    display: inline-block;
    font-size: var(--timeline-date-size, 0.8rem);
    font-weight: 700;
    text-transform: uppercase;
    color: var(--timeline-date-color, #2563eb);
    margin-bottom: 6px;
    letter-spacing: 0.05em;
}

/* HTML description responsive elements */
.timeline-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin-top: 10px;
    display: block;
}

.timeline-content a {
    color: var(--timeline-date-color, #2563eb);
    text-decoration: none;
    font-weight: 600;
}

.timeline-content a:hover {
    text-decoration: underline;
}

/* Gutenberg Editor-specific overrides */
.timeline-container-editor .timeline-content {
    padding-right: 120px; /* Leaves space for the control buttons */
}

.timeline-item-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 6px;
    z-index: 10;
}

.timeline-item-controls button.components-button {
    height: 30px;
    min-width: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.timeline-image-selector-wrap button.components-button {
    margin-top: 5px;
}

.timeline-empty {
    text-align: center;
    color: #9ca3af;
    font-style: italic;
    padding: 20px;
}

/* Date on the left side of the vertical timeline line layout */
.timeline-container.date-left {
    padding-left: 120px; /* leaves room for the date */
}

.timeline-container.date-left::before {
    left: calc( 96px - ( var(--timeline-line-width, 4px) / 2 ) );
}

.timeline-container.date-left .timeline-date {
    position: absolute;
    left: -120px; /* shifts date to the left of the line */
    width: 80px;
    text-align: right;
    top: 14px; /* vertically aligns with the top of the card / dot */
    margin-bottom: 0;
}

/* Mobile responsive resets for left-aligned date option */
@media (max-width: 600px) {
    .timeline-container.date-left {
        padding-left: 30px; /* reset to standard on mobile */
    }
    .timeline-container.date-left::before {
        left: calc( 6px - ( var(--timeline-line-width, 4px) / 2 ) );
    }
    .timeline-container.date-left .timeline-date {
        position: static;
        width: auto;
        text-align: left;
        display: inline-block;
        margin-bottom: 6px;
    }
}

