/**
 * Timeline Posts - Frontend Styles
 */

.timeline-container {
    position: relative;
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
}

/* Timeline vertical line */
.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, #e0e0e0 0%, var(--theme-palette-color-2) 50%, #e0e0e0 100%);
    transform: translateX(-50%);
    z-index: 0;
}

/* Timeline posts wrapper - for masonry layout */
.timeline-posts-wrapper {
    position: relative;
    display: block;
    margin-bottom: 20px;
    min-height: 100px;
}

.timeline-posts-wrapper::after {
    content: '';
    display: table;
    clear: both;
}

/* Timeline item */
.timeline-item {
    position: relative;
    width: 100%;
    display: block;
    margin-bottom: 60px;
    min-height: 50px;
}

/* Position items on left or right side */
.timeline-item-left {
    text-align: right;
    padding-right: calc(50% + 40px);
    pointer-events: none;
}

.timeline-item-right {
    text-align: left;
    padding-left: calc(50% + 40px);
    pointer-events: none;
}

/* Re-enable pointer events on content */
.timeline-content {
    pointer-events: auto;
}

/* Timeline marker (dot on the line) */
.timeline-marker {
    position: absolute;
    top: 0;
    width: 20px;
    height: 20px;
    background: var(--theme-palette-color-2);
    border: 4px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(62, 71, 66, 0.2);
    transition: all 0.3s ease;
    pointer-events: auto;
}

/* Marker position for left items */
.timeline-item-left .timeline-marker {
    left: 50%;
    transform: translateX(-50%);
}

/* Marker position for right items */
.timeline-item-right .timeline-marker {
    left: 50%;
    transform: translateX(-50%);
}

/* Connecting line from marker to content */
.timeline-marker::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 35px;
    height: 2px;
    background: var(--theme-palette-color-2);
    transform: translateY(-50%);
}

.timeline-item-left .timeline-marker::after {
    right: 100%;
    margin-right: 5px;
}

.timeline-item-right .timeline-marker::after {
    left: 100%;
    margin-left: 5px;
}

.timeline-item:hover .timeline-marker {
    background: var(--theme-palette-color-1);
    transform: translateX(-50%) scale(1.2);
    box-shadow: 0 0 0 8px rgba(62, 71, 66, 0.3);
}

/* Timeline content card */
.timeline-content {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 500px;
    background: var(--theme-palette-color-1);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: all 0.3s ease;
    text-align: left;
    z-index: 10;
}

.timeline-content:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* Year divider */
.timeline-year-divider {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    clear: both;
    margin: 40px 0;
    padding: 0;
    width: 100%;
}

.timeline-year-marker {
    display: none;
}

.timeline-year-label {
    background: var(--theme-palette-color-2);
    color: #fff;
    padding: 12px 40px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 20px;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    position: relative;
}

/* Clearfix after year divider */
.timeline-year-divider::after {
    content: '';
    display: table;
    clear: both;
}

/* Media section (video or image) */
.timeline-media {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    background: #000;
    overflow: hidden;
}

/* Hide media section if empty */
.timeline-media:empty {
    display: none;
    padding-top: 0;
}

.timeline-video,
.timeline-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.timeline-video-thumbnail,
.timeline-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Video play button */
.timeline-video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;
    z-index: 2;
}

.timeline-video-play:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.timeline-video-play svg {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

/* Iframe for embedded video */
.timeline-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Timeline info section */
.timeline-info {
    padding: 24px;
}

.timeline-date {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    color: var(--theme-palette-color-2);
    background: var(--theme-palette-color-10);
    padding: 6px 12px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.timeline-title-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: color 0.3s ease;
}

.timeline-title-link:hover {
    color: var(--theme-selection-text-color);
    text-decoration: none;
}

.timeline-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--theme-palette-color-5);
    margin: 0 0 12px 0;
    line-height: 1.3;
    transition: color 0.3s ease;
}

.timeline-title-link:hover .timeline-title {
    color: var(--theme-selection-text-color);
}

.timeline-excerpt {
    font-size: 15px;
    color: var(--theme-selection-text-color);
    line-height: 1.6;
    margin-bottom: 0;
}

/* Responsive design */
@media screen and (max-width: 992px) {
    /* Switch to single column */
    .timeline-container {
        overflow-x: hidden;
    }

    .timeline-line {
        left: 22px;
        transform: none;
    }

    .timeline-item {
        width: 100%;
        float: none !important;
        clear: both !important;
        margin-left: 0;
        margin-bottom: 40px;
        padding-left: 70px !important;
        padding-right: 20px !important;
    }

    .timeline-item-left,
    .timeline-item-right {
        float: none;
        clear: both;
        text-align: left;
    }

    .timeline-item.timeline-item-left .timeline-marker,
    .timeline-item.timeline-item-right .timeline-marker {
        left: 4px !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }

    .timeline-item-left .timeline-marker::after,
    .timeline-item-right .timeline-marker::after {
        left: 100% !important;
        right: auto !important;
        margin-left: 5px !important;
        margin-right: 0 !important;
        width: 60px;
    }

    .timeline-content {
        margin-left: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .timeline-year-divider {
        padding: 20px 0;
        margin: 30px 0 30px 0;
        padding-left: 70px;
        justify-content: flex-start;
    }

    .timeline-year-label {
        font-size: 18px;
        padding: 10px 30px;
    }
}

@media screen and (max-width: 768px) {
    .timeline-container {
        padding: 10px;
        overflow-x: hidden;
    }

    .timeline-line {
        left: 20px;
        transform: none;
    }

    .timeline-item {
        width: 100%;
        margin-left: 0;
        margin-bottom: 30px;
        padding-left: 50px !important;
        padding-right: 10px !important;
    }

    .timeline-item.timeline-item-left .timeline-marker,
    .timeline-item.timeline-item-right .timeline-marker {
        left: 12px !important;
        width: 16px;
        height: 16px;
        border-width: 3px;
        transform: translateX(-50%) !important;
    }

    .timeline-marker::after {
        width: 60px;
    }

    .timeline-info {
        padding: 16px;
    }

    .timeline-title {
        font-size: 20px;
    }

    .timeline-excerpt {
        font-size: 14px;
    }

    .timeline-year-divider {
        padding: 15px 0;
        margin: 20px 0 20px 0;
        padding-left: 50px;
        justify-content: flex-start;
    }

    .timeline-year-label {
        font-size: 16px;
        padding: 8px 20px;
    }
}

/* Animation on scroll (optional - requires intersection observer) */
.timeline-item {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.6s ease forwards;
}

.timeline-item:nth-child(1) { animation-delay: 0.1s; }
.timeline-item:nth-child(2) { animation-delay: 0.2s; }
.timeline-item:nth-child(3) { animation-delay: 0.3s; }
.timeline-item:nth-child(4) { animation-delay: 0.4s; }
.timeline-item:nth-child(5) { animation-delay: 0.5s; }
.timeline-item:nth-child(n+6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading state for video */
.timeline-video.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Video in single post view */
.timeline-post-video {
    margin-bottom: 30px;
}

.timeline-post-video-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.timeline-post-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Image in single post view */
.timeline-post-image {
    margin-bottom: 30px;
}

.timeline-post-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}
