/*
 * Styles for the Elementor Timeline Widget.
 *
 * This stylesheet defines a vertical timeline layout with alternating cards on the left and right side of a central line. Each card has
 * subtle shadows and smooth transition effects on hover. The timeline dots are placed on the central line and animate in tandem with
 * their respective cards when hovered or activated.
 */

/* Root variables provide defaults but are overridable from Elementor's style controls via inline styles. */
:root {
    --timeline-line-color: #e30613;
    --timeline-card-bg: #fff;
    --timeline-card-text: #333;
}

.timeline-container {
    position: relative;
    margin: 0 auto;
    padding: 2rem 0;
    max-width: 100%;
    overflow: hidden;
}

/* Vertical line down the middle */
/*
 * The vertical centre line. Its height starts at 0 to enable draw animation on scroll.
 */
.timeline-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: 3px;
    height: 0;
    background-color: var(--timeline-line-color);
    transform: translateX(-50%);
}

/* When the container receives the line-animate class via JS, animate the line height from 0 to full. */
.line-animate .timeline-line {
    animation: line-grow 1s ease forwards;
}

@keyframes line-grow {
    from { height: 0; }
    to { height: 100%; }
}

/* Each timeline entry */
.timeline-item {
    position: relative;
    width: 50%;
    padding: 1rem 2rem;
    box-sizing: border-box;
}

/* Left aligned items */
.timeline-item.left {
    left: 0;
    text-align: right;
}

/* Right aligned items */
.timeline-item.right {
    left: 50%;
    text-align: left;
}

/* Dot linking the card to the central line */
.timeline-dot {
    position: absolute;
    top: 1.3rem;
    left: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--timeline-line-color);
    border: 3px solid var(--timeline-line-color);
    transform: translate(-50%, -50%);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 3;
}

/* The content card itself */
.timeline-card {
    position: relative;
    display: inline-block;
    background-color: var(--timeline-card-bg);
    color: var(--timeline-card-text);
    padding: 1.2rem 1.5rem;
    border-radius: 8px;
    border-style: solid;
    border-width: 0;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
}

.timeline-card h4 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.timeline-card .timeline-year {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--timeline-line-color);
    margin-bottom: 0.2rem;
}

.timeline-card .timeline-description {
    font-size: 0.88rem;
    line-height: 1.4;
    margin: 0;
}

/* Hover state for cards and dots */
.timeline-card:hover,
.timeline-item.active .timeline-card {
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.timeline-dot:hover,
.timeline-item.active .timeline-dot {
    box-shadow: 0 0 0 4px rgba(227, 6, 19, 0.25);
    transform: translate(-50%, -50%) scale(1.2);
}

/*
 * When hover effects are disabled via the Elementor toggle, override the hover/active styles.
 */
.no-hover .timeline-card:hover,
.no-hover .timeline-item.active .timeline-card {
    transform: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.no-hover .timeline-dot:hover,
.no-hover .timeline-item.active .timeline-dot {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: none;
}

/* Badge shapes for timeline items */
.timeline-badge {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    vertical-align: middle;
    background-color: inherit;
}
.timeline-badge.badge-circle {
    border-radius: 50%;
}
.timeline-badge.badge-square {
    border-radius: 3px;
}
.timeline-badge.badge-star {
    position: relative;
    background: none;
}
.timeline-badge.badge-star::before {
    content: "\2605";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: 14px;
    line-height: 14px;
    text-align: center;
    color: inherit;
}

/* Text animations */
.text-anim-fade {
    opacity: 0;
    animation: text-fade-in 0.8s forwards;
}
@keyframes text-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.text-anim-typewriter {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid currentColor;
    animation: typewriter 2s steps(40) forwards, blinkCaret 0.75s step-end infinite;
}
@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}
@keyframes blinkCaret {
    50% { border-color: transparent; }
}

.text-anim-bounce {
    animation: text-bounce 0.8s;
    display: inline-block;
}
@keyframes text-bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* Entrance animations on timeline items using data attributes on the container */
[data-entrance="fade"] .timeline-item {
    opacity: 0;
    transform: translateY(20px);
    animation: item-fade-in 0.6s forwards;
}
@keyframes item-fade-in {
    to { opacity: 1; transform: translateY(0); }
}
[data-entrance="slide-left"] .timeline-item {
    opacity: 0;
    transform: translateX(-30px);
    animation: item-slide-left 0.6s forwards;
}
@keyframes item-slide-left {
    to { opacity: 1; transform: translateX(0); }
}
[data-entrance="slide-right"] .timeline-item {
    opacity: 0;
    transform: translateX(30px);
    animation: item-slide-right 0.6s forwards;
}
@keyframes item-slide-right {
    to { opacity: 1; transform: translateX(0); }
}
[data-entrance="zoom"] .timeline-item {
    opacity: 0;
    transform: scale(0.8);
    animation: item-zoom-in 0.6s forwards;
}
@keyframes item-zoom-in {
    to { opacity: 1; transform: scale(1); }
}

/* Disable hover scaling and sync when no-hover class is set on container */
.timeline-container.no-hover .timeline-card:hover,
.timeline-container.no-hover .timeline-item.active .timeline-card {
    transform: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.timeline-container.no-hover .timeline-dot:hover,
.timeline-container.no-hover .timeline-item.active .timeline-dot {
    box-shadow: none;
    transform: translate(-50%, -50%);
}

/* Entrance animation classes */
.animate-fade {
    opacity: 0;
    transform: translateY(30px);
    animation: timeline-fade-in 0.6s ease forwards;
}

.animate-slide {
    opacity: 0;
    transform: translateX(50px);
    animation: timeline-slide-in 0.6s ease forwards;
}

.animate-zoom {
    opacity: 0;
    transform: scale(0.8);
    animation: timeline-zoom-in 0.6s ease forwards;
}

@keyframes timeline-fade-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes timeline-slide-in {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes timeline-zoom-in {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Text animation classes */
.text-anim-fade {
    opacity: 0;
    animation: text-fade-in 0.8s ease forwards;
}

@keyframes text-fade-in {
    to { opacity: 1; }
}

.text-anim-bounce {
    animation: text-bounce 1s ease infinite;
}

@keyframes text-bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-4px);
    }
    60% {
        transform: translateY(-2px);
    }
}

.text-anim-typewriter {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid currentColor;
    animation: typing 3s steps(40, end) forwards, blink 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    from, to { border-color: transparent; }
    50% { border-color: currentColor; }
}

/* Badge styles */
.timeline-badge {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    z-index: 10;
}

.timeline-badge.badge-circle {
    border-radius: 50%;
}
.timeline-badge.badge-square {
    border-radius: 4px;
}
.timeline-badge.badge-star {
    background: transparent;
    color: inherit;
}
.timeline-badge.badge-star::before {
    content: '\2605'; /* Unicode star */
    font-size: 18px;
    line-height: 1;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .timeline-item {
        width: 100%;
        padding: 1rem 1rem 1rem 2rem;
        left: 0 !important;
        text-align: left;
        margin-bottom: 2rem;
    }
    .timeline-item .timeline-card {
        width: calc(100% - 2.5rem);
    }
    .timeline-dot {
        left: 0;
        transform: translate(-50%, -50%) translateX(1.2rem);
    }
    .timeline-line {
        left: 1rem;
    }
}

/* Pop-up (clicked) effect classes. The JavaScript will toggle these. */
.timeline-card.popup {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(1);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 9999;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    animation: timeline-popup-in 0.3s ease forwards;
}

@keyframes timeline-popup-in {
    from {
        opacity: 0;
        transform: translate(-50%, -60%) scale(0.7);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Overlay for pop‑up. The background colour can be customised from the widget settings. */
.timeline-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}

.timeline-overlay.active {
    display: block;
}