/* Timeline Component Styles */

/* Timeline takes full width like feature articles */
.timeline-container {
    max-width: none;
    width: 100%;
    margin: 0 0 0 0; /* Reduced top margin since title/lede is hidden */
}

/* Timeline Header */
.timeline-header {
    background: #002E5D;
    color: white;
    padding: 20px 0;
    position: relative;
    z-index: 40;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 100%;
}

.timeline-header.sticky-active {
    position: sticky;
    top: 0;
    transform: none;
    animation: none;
}

@keyframes slideDownSticky {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

.decades-bar {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Center align to position labels in middle */
    padding: 0 40px;
    position: relative;
    min-height: 80px; /* Increase height to accommodate larger labels */
}

.timeline-line {
    display: none;
}

.decade-connector {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 2px;
    background: white;
    z-index: 1;
}

.decade-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
    padding: 0 5px; /* Add padding to prevent overlap */
    flex-shrink: 0; /* Prevent shrinking */
    min-width: 60px; /* Minimum width to maintain spacing */
    height: 100%; /* Ensure consistent height */
}

.decade-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    position: absolute;
    bottom: -30px; /* Position dot much lower below the container */
    left: 50%;
    transform: translateX(-50%);
    transition: bottom 0.3s ease;
}

.decade-label {
    font-size: 16px; /* Reduced from 24px */
    color: #FFFFFF;
    font-weight: 300; /* Lighter than normal */
    font-family: "IBM Plex Sans", Helvetica, Arial, sans-serif;
    transition: all 0.3s ease;
    text-align: center;
    white-space: nowrap;
    position: absolute;
    top: 50%; /* Position at center where connectors are */
    left: 50%;
    transform: translate(-50%, -50%); /* Center both horizontally and vertically */
    z-index: 3;
}

.decade-marker.active .decade-label {
    color: white;
    font-weight: bold;
    font-size: 37.6px;
    /* Absolute positioning prevents layout shift */
}

.decade-marker.active .decade-dot {
    background: #FFF;
    bottom: -35px; /* Move dot slightly lower when label is highlighted */
    transform: translateX(-50%) scale(1.2);
    transition: all 0.3s ease;
}

/* Timeline Content */
.timeline-content {
    position: relative;
    padding: 60px 230px;
    max-width: 1400px;
    margin: 0 auto;
}

.timeline-content::before {
    display: none;
}

.decade-section {
    margin-bottom: 80px;
    position: relative;
    padding: 0 0 40px 0;
}

.decade-section:nth-child(even) {
    background: #f6f6f8;
    padding-top: 80px;
    position: relative;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: calc(50vw - 50%);
    padding-right: calc(50vw - 50%);
}

.decade-section:nth-child(odd) {
    background: #ffffff;
    padding-top: 80px;
    position: relative;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: calc(50vw - 50%);
    padding-right: calc(50vw - 50%);
}

.decade-section::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 220px;
    bottom: 0;
    width: 2px;
    background: #e5e7eb;
    transform: translateX(-50%);
    z-index: 1;
}

.decade-section:nth-child(odd)::before {
    top: 220px;
    bottom: -80px;
}

.decade-section:nth-child(odd):last-child::before {
    bottom: 0;
}

.decade-title {
    color: #002E5D;
    text-align: center;
    font-family: "IBM Plex Sans", Helvetica, Arial, sans-serif;
    font-size: 108.047px;
    font-style: normal;
    font-weight: 700;
    line-height: 80px;
    margin-bottom: 60px;
    position: relative;
}

.events-list {
    position: relative;
}

/* Empty decade sections should still have minimum height for intersection observer */
.events-list:empty {
    min-height: 200px;
}

.event-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 60px;
    margin-top: 120px;
    position: relative;
}

.event-item:nth-child(even) {
    flex-direction: row-reverse;
}

.event-year {
    background: #0361b8;
    color: #FFF;
    font-family: "IBM Plex Sans", Helvetica, Arial, sans-serif;
    font-size: 18px;
    font-style: italic;
    font-weight: 400;
    line-height: 22px;
    padding: 6px 20px;
    border-radius: 4px;
    position: absolute;
    z-index: 3;
    top: -60px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.event-item:nth-child(odd) .event-year {
    left: calc(50% + 20px);
}

.event-item:nth-child(even) .event-year {
    right: calc(50% + 20px);
}

.timeline-dot {
    width: 20px;
    height: 20px;
    background: #0361b8;
    border-radius: 50%;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    top: -52px;
    border: 3px solid white;
}

.event-content {
    width: 45%;
    padding: 0 40px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.event-item:nth-child(even) .event-content {
    text-align: left;
}

.event-media {
    width: 45%;
    padding: 0 40px;
    margin-top: 25px;
}

.event-media img {
    width: 100%;
    height: auto;
    background: transparent;
    border: none;
    display: block;
    object-fit: cover;
}

.event-media iframe {
    width: 100%;
    aspect-ratio: 16/9;
    background: #e5e7eb;
    border: none;
}

.event-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 16px;
    line-height: 1.4;
}

.event-description {
    color: #333;
    line-height: 1.6;
    font-size: 14px;
}

/* Handle paragraph tags within event descriptions */
.event-description p {
    margin: 0 0 8px 0;
    line-height: 1.6;
}

.event-description p:last-child {
    margin-bottom: 0;
}

.event-description.truncated {
    overflow: hidden;
}

.read-more-link {
    color: #0361b8;
    font-style: italic;
    cursor: pointer;
    text-decoration: none;
    font-size: inherit;
    font-family: inherit;
    font-weight: inherit;
    border: none;
    background: none;
    padding: 0;
    margin: 0;
    display: inline;
    line-height: inherit;
}

.read-more-link:hover {
    color: #0361b8;
    text-decoration: none;
}

.read-more-link:focus {
    color: #0361b8;
    text-decoration: none;
    outline: none;
}

/* Timeline Article Wrapper */
.timeline-article-wrapper {
    width: 100%;
    max-width: none;
}

.timeline-article-lede {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

.timeline-article-lede .article__lede__category {
    font-family: "IBM Plex Sans", "HCo Ringside Narrow SSm", "Arial", sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--byu-royal);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
    display: block;
}

.timeline-article-lede .article__lede__headline {
    font-family: "IBM Plex Sans", "HCo Ringside Narrow SSm", "Arial", sans-serif;
    font-size: 36px;
    font-weight: 700;
    color: var(--byu-navy);
    margin: 20px 0;
    line-height: 1.2;
}

.timeline-article-lede .article__lede__byline-content {
    font-family: "IBM Plex Sans", "Public Sans", "Arial", sans-serif;
    font-size: 16px;
    color: var(--byu-grey-dark);
    margin: 20px 0 0 0;
}

.timeline-article-lede .article__lede__byline-content a {
    color: var(--byu-royal);
    text-decoration: none;
}

.timeline-article-lede .article__lede__byline-content a:hover {
    color: var(--byu-navy);
    text-decoration: underline;
}

/* Timeline Article Banner Image */
.timeline-article-banner {
    width: 100vw;
    margin: 0; /* Removed bottom margin to eliminate white space */
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

.timeline-article-banner2 {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto 40px auto;
    height: 200px;
    background: var(--byu-grey-light);
}

.timeline-article-image {
    width: 100%;
    height: auto;
    display: block;
}

.timeline-article-banner figcaption {
    font-family: "IBM Plex Sans", "Public Sans", "Arial", sans-serif;
    font-size: 14px;
    color: var(--byu-grey-dark);
    text-align: center;
    padding: 10px 20px;
    font-style: italic;
}

/* Timeline Article Kicker */
.timeline-article-kicker {
    max-width: 1200px;
    margin: 0 auto 40px auto;
    padding: 0 20px;
}

.timeline-article-kicker .deck {
    font-family: "IBM Plex Sans", "Public Sans", "Arial", sans-serif;
    font-size: 18px;
    font-weight: 400;
    color: var(--byu-grey-dark);
    line-height: 1.6;
    text-align: center;
    margin: 0;
    padding: 20px 40px;
    border-left: 3px solid var(--byu-royal);
    background: var(--byu-grey-lightest);
}

.timeline-article-kicker .article-body__hr {
    width: 60px;
    height: 2px;
    background: var(--byu-royal);
    border: none;
    margin: 0 auto;
}

/* Timeline Feature Article Styling - Use body context to target timeline articles */
body.single-article .feature_article__lede__headline + .article__lede {
    max-width: 1200px;
    margin: 40px auto;
    padding: 40px 20px;
    text-align: center;
}

body.single-article .feature_article__lede__headline + .article__lede .article__lede__category {
    font-family: "IBM Plex Sans", "HCo Ringside Narrow SSm", "Arial", sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--byu-royal);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
    display: block;
}

body.single-article .feature_article__lede__headline + .article__lede .article__lede__headline {
    font-family: "IBM Plex Sans", "HCo Ringside Narrow SSm", "Arial", sans-serif;
    font-size: 36px;
    font-weight: 700;
    color: var(--byu-navy);
    margin: 20px 0;
    line-height: 1.2;
}

/* Hide byline/authors section for timeline articles */
body.single-article .feature_article__lede__headline + .article__lede .article__lede__byline-content {
    display: none;
}

/* Timeline Deck Styling within article lede */
body.single-article .feature_article__lede__headline + .article__lede .deck {
    max-width: 340px;
    margin: 20px auto;
    padding: 0;
    font-family: "IBM Plex Sans", "Public Sans", "Arial", sans-serif;
    font-size: 18px;
    font-weight: 400;
    color: var(--byu-grey-dark);
    line-height: 1.6;
    text-align: center;
    font-style: normal;
    border: none;
    background: none;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Timeline HR styling */
body.single-article .feature_article__lede__headline + .article__lede .timeline-hr {
    width: 340px;
    height: 2px;
    background: var(--byu-grey-medium);
    border: none;
    margin: 20px auto;
}

/* Keep original byline styling, only center the container */

/* Also center the featured image for timeline articles */
body.single-article .feature_article__lede__headline ~ .mosaic-column {
    max-width: 1200px;
    margin: 40px auto;
    text-align: center;
}

/* Desktop Timeline - Frozen Layout */
@media (min-width: 769px) {
    .decades-bar {
        overflow: visible !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        padding: 0 40px !important;
    }
    
    .decade-marker {
        position: relative !important;
        flex-shrink: 0 !important;
        min-width: 60px !important;
        padding: 0 5px !important;
    }
    
    /* Hide any pseudo-element connectors on desktop */
    .decade-marker::after {
        display: none !important;
    }
}

/* Switch to mobile-style timeline header at 1300px but keep desktop timeline layout */
@media (max-width: 1299px) {
    .decades-bar {
        padding: 0 25px !important; /* Reduced padding */
        overflow-x: auto !important;
        overflow-y: hidden !important;
        flex-wrap: nowrap !important;
        gap: 0 !important;
        scroll-behavior: smooth !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        position: relative !important;
        justify-content: flex-start !important; /* Override space-between */
    }

    .decades-bar::-webkit-scrollbar {
        display: none !important;
    }

    .decade-marker {
        flex-shrink: 0 !important;
        min-width: 70px !important; /* Reduced minimum width */
        position: relative !important;
        z-index: 2 !important;
        padding: 0 20px !important; /* Reduced padding to match JavaScript spacing */
    }

    /* Remove pseudo-element connectors - JavaScript handles them dynamically */
    .decade-marker::after {
        display: none !important;
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    body.single-article .feature_article__lede__headline + .article__lede {
        padding: 20px 15px;
        margin: 20px auto;
    }

    .events-list {
        left: -2%;
    }

    
    body.single-article .feature_article__lede__headline + .article__lede .article__lede__headline {
        font-size: 28px;
    }
    
    body.single-article .feature_article__lede__headline + .article__lede .deck {
        max-width: 340px;
        margin: 15px auto;
        font-size: 16px;
    }
    
    body.single-article .feature_article__lede__headline + .article__lede .timeline-hr {
        width: 340px;
        margin: 15px auto;
    }
    
    body.single-article .feature_article__lede__headline ~ .mosaic-column {
        margin: 20px auto;
    }
    
    .timeline-article-lede {
        padding: 20px 15px;
    }
    
    .timeline-article-lede .article__lede__headline {
        font-size: 28px;
    }
    
    .timeline-container {
        padding: 0;
        max-width: 100%;
    }

    .timeline-header {
        padding: 15px 0;
    }

    .decades-bar {
        padding: 0 25px; /* Reduced padding */
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
        gap: 0;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        position: relative;
    }

    .decades-bar::-webkit-scrollbar {
        display: none;
    }

    .decade-marker {
        flex-shrink: 0;
        min-width: 70px; /* Reduced minimum width */
        position: relative;
        z-index: 2;
        padding: 0 20px; /* Reduced padding to match JavaScript spacing */
    }

    /* Remove pseudo-element connectors on mobile - JavaScript handles them dynamically */
    .decade-marker::after {
        display: none;
    }

    .timeline-content {
        padding: 40px 20px;
        margin: 0;
    }

    .decade-section {
        padding: 0 0 40px 0;
        margin: 0 0 60px 0;
    }

    .decade-section:nth-child(even) {
        background: #f6f6f8;
        padding: 60px 0 40px 0;
        position: relative;
        margin-left: calc(-50vw + 50%);
        margin-right: calc(-50vw + 50%);
        padding-left: calc(50vw - 50%);
        padding-right: calc(50vw - 50%);
    }

    .decade-section::before {
        left: 13px;
        transform: none;
        top: 180px;
    }

    .decade-section:nth-child(odd)::before {
        top: 180px;
        bottom: -60px;
    }

    .decade-title {
        font-size: 108px;
        line-height: 1.2;
        margin-bottom: 40px;
        text-align: center;
        padding-left: 0;
    }

    .event-item,
    .event-item:nth-child(even) {
        flex-direction: column;
        align-items: flex-start;
        margin: 0 0 40px 0;
        padding-left: 25px;
        position: relative;
    }

    .event-year {
        position: absolute;
        left: 25px;
        top: 0;
        transform: none;
        font-size: 16px;
        padding: 4px 12px;
        margin-bottom: 10px;
    }

    .event-item:nth-child(odd) .event-year,
    .event-item:nth-child(even) .event-year {
        left: 25px;
        right: auto;
    }

    .timeline-dot {
        left: -8px;
        top: 6px;
        transform: none;
        width: 16px;
        height: 16px;
        border: 2px solid white;
    }

    .event-media {
        width: 100%;
        padding: 0;
        margin: 50px 0 15px 0;
        max-width: calc(100vw - 50px);
    }

    /* Hide empty/placeholder media containers on mobile to remove blank space */
    .event-media[style*="opacity: 0"] {
        display: none;
    }

    /* Also hide event-media containers that only contain empty placeholder divs */
    .event-media:has(div[style*="background: #e5e7eb"]) {
        display: none;
    }

    .event-media img,
    .event-media iframe {
        width: 100%;
        height: auto;
    }

    .event-media iframe {
        aspect-ratio: 16/9;
    }

    .event-content {
        width: 100%;
        padding: 0;
        max-width: calc(100vw - 50px);
    }

    /* Add top margin to event content when the previous sibling (media) is hidden */
    .event-media[style*="opacity: 0"] + .event-content,
    .event-media:has(div[style*="background: #e5e7eb"]) + .event-content {
        margin-top: 50px;
    }

    /* Alternative approach: add margin to all event content and remove it when media is visible */
    .event-item .event-content {
        margin-top: 50px;
    }

    .event-item:has(.event-media img) .event-content,
    .event-item:has(.event-media iframe) .event-content {
        margin-top: 0;
    }

    .event-item:nth-child(even) .event-content {
        text-align: left;
    }

    .event-title {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .event-description {
        font-size: 14px;
        line-height: 1.5;
    }

    .read-more-link {
        font-size: inherit;
    }
    
    .timeline-article-image {
        width: 100%;
        height: auto;
    }
    
    .timeline-article-kicker {
        padding: 0 15px;
    }
    
    .timeline-article-kicker .deck {
        padding: 15px 20px;
        font-size: 16px;
    }
}

/* Decade Side Labels (Desktop Only) */
.decade-side-label {
    display: none; /* Hidden by default */
}

@media (min-width: 1200px) {
    .decade-side-label {
        display: block;
        position: absolute;
        right: calc((100vw - 1200px) / 8 - 30px); /* Moved 30px further right from previous position */
        top: 650px; /* Moved down by 150px from previous position */
        font-size: 150px; /* Increased font size for better visibility */
        font-weight: bold;
        transform: rotate(90deg);
        transform-origin: right top;
        white-space: nowrap;
        pointer-events: none;
        z-index: 1;
        font-family: "IBM Plex Sans", Helvetica, Arial, sans-serif;
    }

    /* Position the label horizontally centered in the right margin */
    .timeline-content {
        position: relative;
    }

    /* Color based on decade section background - consistent positioning for all */
    .decade-section:nth-child(even) .decade-side-label {
        color: #eceff3; /* White background sections */
    }

    .decade-section:nth-child(odd) .decade-side-label {
        color: #e4e7ec; /* Grey background sections */
    }
}
