/* 
========================================
BASE STYLES (DEFAULT HORIZONTAL)
========================================
*/

.mc-timeline-wrapper {
    position: relative;
    padding: 0;
    margin: 25px 0;
}

.mc-timeline-axis {
    position: absolute;
    top: 50%;
    left: calc(0px - var(--mc-line-left-extra, 0px));
    right: calc(0px - var(--mc-line-right-extra, 0px));
    transform: translateY(-50%);
    background: #000;
    height: 2px;
    z-index: 1;
}

.mc-timeline-items {
    display: flex;
    justify-content: center !important;
    align-items: stretch;
    position: relative;
    z-index: 2;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 20px; /* For scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #8E44AD #f0f0f0;
    width: 100%; /* Ensure full width */
}

.mc-timeline-items::-webkit-scrollbar {
    height: 8px;
}
.mc-timeline-items::-webkit-scrollbar-track {
    background: #f0f0f0;
}
.mc-timeline-items::-webkit-scrollbar-thumb {
    background-color: #8E44AD;
    border-radius: 4px;
}

.mc-timeline-item {
    display: grid;
    grid-template-rows: 1fr auto 1fr;
    align-items: center;
    justify-items: center;
    position: relative;
    flex-shrink: 0;
    text-decoration: none; /* For links */
    color: inherit;
    transition: transform 0.2s ease;
}

/* Grid Sections */
.mc-grid-top, .mc-grid-bottom {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mc-grid-top {
    justify-content: flex-end;
    padding-bottom: var(--mc-content-gap, 20px);
}

.mc-grid-bottom {
    justify-content: flex-start;
    padding-top: var(--mc-content-gap, 20px);
}

.mc-grid-center {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.mc-node {
    border-radius: 50%;
    background: #000;
}

/* Icon & Connector */
.mc-icon-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mc-layout-bottom .mc-grid-bottom .mc-icon-wrapper {
    flex-direction: column-reverse;
}

.mc-timeline-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    position: relative;
    z-index: 5;
    transition: all 0.3s ease;
    overflow: hidden; /* For images */
}

.mc-timeline-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.mc-timeline-item:hover .mc-timeline-icon {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.mc-timeline-arrow {
    position: absolute;
    top: 50%;
    right: -2px;
    transform: translateY(-50%);
    width: 0; 
    height: 0; 
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 10px solid #000;
    z-index: 1;
}

/* Start Dot & Logo */
.mc-timeline-start-dot {
    position: absolute;
    z-index: 2;
    border-radius: 50%;
    background: #000;
    --mc-x: 0px;
    --mc-y: 0px;
}

.mc-timeline-logo {
    position: absolute;
    z-index: 2;
    --mc-x: 0px;
    --mc-y: 0px;
}

.mc-timeline-logo img {
    display: block;
    max-height: 60px;
    width: auto;
}

/* Text Content */
.mc-text-wrapper {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
}

.mc-timeline-year {
    font-weight: 700;
    margin-bottom: 5px;
    margin-top: 5px;
}

.mc-timeline-title {
    margin: 5px 0;
    line-height: 1.2;
}

.mc-timeline-desc {
    margin: 5px 0;
    line-height: 1.5;
}


/* 
========================================
POSITIONING HELPERS
========================================
*/
.mc-pos-top-left { top: 0; left: 0; transform: translate(var(--mc-x), var(--mc-y)); }
.mc-pos-top-center { top: 0; left: 50%; transform: translate(calc(-50% + var(--mc-x)), var(--mc-y)); }
.mc-pos-top-right { top: 0; right: 0; transform: translate(var(--mc-x), var(--mc-y)); }

.mc-pos-middle-left { top: 50%; left: 0; transform: translate(var(--mc-x), calc(-50% + var(--mc-y))); }
.mc-pos-middle-center { top: 50%; left: 50%; transform: translate(calc(-50% + var(--mc-x)), calc(-50% + var(--mc-y))); }
.mc-pos-middle-right { top: 50%; right: 0; transform: translate(var(--mc-x), calc(-50% + var(--mc-y))); }

.mc-pos-bottom-left { bottom: 0; left: 0; transform: translate(var(--mc-x), var(--mc-y)); }
.mc-pos-bottom-center { bottom: 0; left: 50%; transform: translate(calc(-50% + var(--mc-x)), var(--mc-y)); }
.mc-pos-bottom-right { bottom: 0; right: 0; transform: translate(var(--mc-x), var(--mc-y)); }


/*
========================================
FUNCTIONAL OVERRIDES (DESKTOP)
========================================
*/
/* Ensure horizontal line on desktop even if .mc-mobile-stack is present */
@media (min-width: 1025px) {

    .mc-timeline-wrapper {
        margin: 0 40px; /* Use margin to prevent cropping from container edges */
    }
    
    .mc-timeline-items {
        padding: 20px;
        justify-content: center !important;
    }

    .mc-mobile-stack .mc-timeline-axis {
        position: absolute;
        top: 50%;
        bottom: auto;
        left: calc(0px - var(--mc-line-left-extra, 0px));
        right: calc(0px - var(--mc-line-right-extra, 0px));
        transform: translateY(-50%);
        width: auto;
        height: 2px;
    }
}


/* 
========================================
RESPONSIVE SIZING (LARGE -> SMALL)
========================================
*/

/* Hide Logo on screens narrower than 1600px */
@media (max-width: 1599px) {
    .mc-timeline-logo {
        display: none !important;
    }
}

/* High-density desktop – 1920px and up */
@media (min-width: 1920px) {
    .mc-timeline-wrapper {
        margin: 60px auto;
        max-width: 1800px;
    }
    .mc-timeline-icon {
        width: 64px;
        height: 64px;
    }
    .mc-timeline-logo img {
        max-height: 80px;
    }
    .mc-timeline-year {
        font-size: 1.2rem;
    }
    .mc-timeline-title {
        font-size: 1.1rem;
    }
    .mc-timeline-desc {
        font-size: 1rem;
    }
    .mc-timeline-item {
        width: 200px !important;
    }
}

/* Large desktop – 1200px to 1680px */
@media (min-width: 1200px) and (max-width: 1680px) {
    .mc-timeline-wrapper {
        margin: 0;
        padding: 15px;
    }
    /* .mc-timeline-items {
        padding: 20px;
        justify-content: flex-start !important;
    } */
    .mc-timeline-icon {
        width: 56px;
        height: 56px;
    }
    .mc-timeline-logo img {
        max-height: 70px;
    }
    .mc-timeline-year {
        font-size: 1.1rem;
    }
    .mc-timeline-title {
        font-size: 1rem;
    }
    .mc-timeline-desc {
        font-size: 0.95rem;
    }
}

/* Tablets (landscape) – 1025px to 1199px */
@media (min-width: 1025px) and (max-width: 1199px) {
     .mc-timeline-wrapper {
        margin: 0;
        padding: 10px;
    }
    .mc-timeline-items {
        padding: 15px;
        justify-content: flex-start !important;
    }
}

/* Tablets (portrait) – 768px to 1024px */
@media (min-width: 768px) and (max-width: 1024px) {
    .mc-timeline-items {
        padding: 15px;
        justify-content: flex-start !important;
    }
    .mc-timeline-icon {
        width: 44px;
        height: 44px;
    }
    .mc-timeline-logo img {
        max-height: 50px;
    }
    .mc-timeline-year {
        font-size: 0.95rem;
    }
    .mc-timeline-title {
        font-size: 0.9rem;
    }
    .mc-timeline-desc {
        font-size: 0.85rem;
    }
    /* Ensure horizontal line on tablet even if .mc-mobile-stack is present */
    .mc-mobile-stack .mc-timeline-axis {
        position: absolute;
        top: 50%;
        bottom: auto;
        left: calc(0px - var(--mc-line-left-extra, 0px));
        right: calc(0px - var(--mc-line-right-extra, 0px));
        transform: translateY(-50%);
        width: auto;
        height: 2px;
    }
}

/* Small tablets / large phones – 600px to 767px */
@media (min-width: 600px) and (max-width: 767px) {
    .mc-timeline-wrapper {
        margin: 25px 15px;
    }
    .mc-timeline-items {
        padding: 10px;
    }
    .mc-timeline-icon {
        width: 40px;
        height: 40px;
    }
    .mc-timeline-logo img {
        max-height: 45px;
    }
    .mc-timeline-year {
        font-size: 0.9rem;
    }
    .mc-timeline-title {
        font-size: 0.85rem;
        text-align: left;
    }
    .mc-timeline-desc {
        font-size: 0.8rem;
    }
}

/* Very small phones – below 360px */
@media (max-width: 359px) {
    .mc-timeline-wrapper {
        margin: 15px 10px;
    }
    .mc-timeline-items {
        padding: 5px;
    }
    .mc-timeline-icon {
        width: 32px;
        height: 32px;
    }
    .mc-timeline-logo img {
        max-height: 35px;
    }
    .mc-timeline-year {
        font-size: 0.8rem;
    }
    .mc-timeline-title {
        font-size: 0.75rem;
    }
    .mc-timeline-desc {
        font-size: 0.7rem;
    }
}


/* 
========================================
MOBILE RESPONSIVENESS (VERTICAL STACK)
========================================
*/
@media (max-width: 767px) {
    
    .mc-mobile-stack .mc-timeline-wrapper {
        margin: 20px 0;
    }

    .mc-mobile-stack .mc-timeline-items {
        flex-direction: column;
        align-items: flex-start;
        overflow-x: visible;
        padding-bottom: 0;
    }

    /* Transform Axis to Vertical Line on Left */
    .mc-mobile-stack .mc-timeline-axis {
        /* Mobile Vertical Line */
        width: 2px;
        height: 90% !important;
        background: var(--e-global-color-accent) !important;
        top: calc(20px - var(--mc-line-left-extra, 0px));
        left: 38px; /* Fixed horizontal position in mobile */
        right: auto;
        transform: none;
        height: auto; /* Allow top/bottom to define height */
    }

    .mc-mobile-stack .mc-timeline-arrow {
        display: none; /* Hide arrow in vertical mode */
    }

    .mc-mobile-stack .mc-timeline-start-dot,
    .mc-mobile-stack .mc-timeline-logo {
        display: none;
    }

    /* Reset Item Grid for Vertical Layout */
    .mc-mobile-stack .mc-timeline-item {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        width: 100% !important; /* Force full width */
        margin-right: 0 !important;
        margin-bottom: 30px;
        text-align: left;
        padding-left: 70px; /* Space for icon column */
        position: relative;
    }

    /* 
       We need to re-order visual elements.
       In Horizontal: [Icon/Text] -> [Node] -> [Text/Icon]
       In Vertical Mobile: [Icon/Node Column] -> [Content Column]
    */

    /* Hide the center node if we use Icons as nodes */
    .mc-mobile-stack .mc-grid-center {
        display: none;
    }

    /* Make the Icon Wrapper absolute positioned on the left line */
    .mc-mobile-stack .mc-icon-wrapper,
    .mc-mobile-stack .mc-timeline-item .mc-icon-wrapper {
        position: absolute;
        left: 0;
        top: 0;
        width: 60px;
        align-items: center;
        justify-content: flex-start;
    }

    /* Hide the connector lines (vertical ones used in horizontal layout) */
    .mc-mobile-stack .mc-connector {
        display: none;
    }

    /* Text Wrapper */
    .mc-mobile-stack .mc-text-wrapper,
    .mc-mobile-stack .mc-timeline-item .mc-text-wrapper {
        align-items: flex-start;
        text-align: left;
        width: 100%;
        display: flex;
        flex-direction: column;
        padding-left: 10px;
    }

    /* Reset Grid Containers */
    .mc-mobile-stack .mc-grid-top,
    .mc-mobile-stack .mc-grid-bottom {
        width: auto;
        padding: 0;
        display: contents; /* Let children flow naturally */
    }
    
    /* Re-order Year/Title/Desc inside Text Wrapper */
    .mc-mobile-stack .mc-text-wrapper .mc-timeline-year {
        order: -1; /* Always first */
        margin-top: 0;
    }
    .mc-mobile-stack .mc-text-wrapper .mc-timeline-title {
        order: 0;
    }
    .mc-mobile-stack .mc-text-wrapper .mc-timeline-desc {
        order: 1;
    }

}

/* 
========================================
SMALL MOBILE (BELOW 600PX)
========================================
*/
@media (max-width: 599px) {

    .mc-mobile-stack .mc-timeline-wrapper {
        margin: 15px 0;
    }

    /* Adjust Vertical Line Position */
    .mc-mobile-stack .mc-timeline-axis {
        left: 20px; 
        height: 82% !important;
    }

    /* Adjust Icon Wrapper Position */
    .mc-mobile-stack .mc-icon-wrapper,
    .mc-mobile-stack .mc-timeline-item .mc-icon-wrapper {
        width: 40px; /* Smaller icon wrapper width */
    }

    .mc-mobile-stack .mc-timeline-icon {
        width: 60px !important;
        height: 60px !important;
    }

    .mc-mobile-stack .mc-timeline-icon i {
        font-size: 18px !important;
    }
    
    .mc-mobile-stack .mc-timeline-icon svg {
        width: 20px !important;
    }

    /* Reduce left padding for text content */
    .mc-mobile-stack .mc-timeline-item {
        padding-left: 50px; /* Reduced from 70px */
        margin-bottom: 25px;
    }

    /* Typography Adjustments */
    .mc-timeline-year {
        font-size: 0.9rem;
    }
    .mc-timeline-title {
        font-size: 1rem;
        text-align: left;
    }
    .mc-timeline-desc {
        font-size: 0.85rem;
        text-align: left;
    }
}

/* 
========================================
iOS / SAFARI SPECIFIC FIXES
========================================
*/
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS flexbox gap/overflow issues */
    .mc-timeline-items {
        -webkit-overflow-scrolling: touch; /* Smooth scrolling */
    }
    
    /* Fix for Safari flex item height calculation */
    .mc-timeline-item {
        height: auto;
        min-height: min-content;
    }
    
    /* Ensure images don't stretch weirdly in Safari flex containers */
    .mc-timeline-logo img,
    .mc-timeline-image {
        flex-shrink: 0;
    }
}
