/* Jewish Timeline CSS */

/* ============================================
   CSS Custom Properties
   ============================================ */
:root {
    --timeline-primary: #a1b0d8;
    --timeline-primary-dark: #8a9ac4;
    --timeline-accent: #e67e22;
    --timeline-accent-light: rgba(230, 126, 34, 0.15);
    --timeline-text: #333;
    --timeline-text-muted: #666;
    --timeline-bg: #f9f9f9;
    --timeline-card-bg: #ffffff;
    --timeline-border: #e0e0e0;
    --timeline-line: #0e4d92;
    --timeline-transition: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --timeline-transition-fast: 0.2s ease;
    --timeline-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --timeline-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.15);
    --timeline-shadow-active: 0 12px 40px rgba(0, 0, 0, 0.2);
}

/* Break out of WordPress constrained layouts */
#jewish-timeline-container {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    padding: 0 1rem;
    box-sizing: border-box;
}

.jewish-timeline {
    font-family: 'Heebo', sans-serif;
    width: 100%;
    margin: 3rem auto;
    padding: 0;
    color: var(--timeline-text);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

.timeline-header {
    text-align: center;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 700px;
}

.timeline-header h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--timeline-primary);
    font-weight: 600;
    letter-spacing: -0.5px;
}

.timeline-header p {
    font-size: 1.2rem;
    color: var(--timeline-text-muted);
    line-height: 1.5;
}

/* ============================================
   Progress Indicator
   ============================================ */
.timeline-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--timeline-text-muted);
}

.timeline-progress-counter {
    font-weight: 600;
    color: var(--timeline-primary);
    min-width: 60px;
    text-align: center;
}

.timeline-progress-bar {
    width: 200px;
    height: 4px;
    background: var(--timeline-border);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.timeline-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--timeline-primary), var(--timeline-accent));
    border-radius: 2px;
    transition: width var(--timeline-transition);
}

.timeline-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 0.5rem;
}

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--timeline-border);
    cursor: pointer;
    transition: all var(--timeline-transition-fast);
    border: none;
    padding: 0;
}

.timeline-dot:hover {
    background: var(--timeline-primary);
    transform: scale(1.2);
}

.timeline-dot.active {
    background: var(--timeline-accent);
    transform: scale(1.3);
}

.timeline-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    position: relative;
    z-index: 10;
    flex-wrap: wrap;
    width: 100%;
    max-width: 700px;
}

.timeline-navigation > button {
    background: var(--timeline-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--timeline-transition-fast);
    box-shadow: 0 2px 8px rgba(161, 176, 216, 0.3);
}

.timeline-navigation > button:hover:not(:disabled) {
    background: var(--timeline-primary-dark);
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 4px 12px rgba(161, 176, 216, 0.4);
}

.timeline-navigation > button:active:not(:disabled) {
    transform: scale(0.95);
}

.timeline-navigation > button:disabled {
    background: var(--timeline-border);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.timeline-navigation select {
    padding: 0.6rem 1.2rem;
    border: 2px solid var(--timeline-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background-color: white;
    min-width: 220px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all var(--timeline-transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.timeline-navigation select:hover {
    border-color: var(--timeline-primary);
}

.timeline-navigation select:focus {
    outline: none;
    border-color: var(--timeline-primary);
    box-shadow: 0 0 0 3px rgba(161, 176, 216, 0.2);
}

.timeline-wrapper {
    position: relative;
    overflow: hidden;
    margin: 0 auto;
    padding: 0;
    height: 520px; /* Fixed height for consistency */
    width: calc(100% - 2rem);
    max-width: 100%;
    border: 2px solid var(--timeline-primary);
    border-radius: 12px;
    background: linear-gradient(180deg, var(--timeline-bg) 0%, #fff 50%, var(--timeline-bg) 100%);
    box-shadow: var(--timeline-shadow);
    box-sizing: border-box;
}

/* Main horizontal line with enhanced gradient */
.timeline-wrapper::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 4px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--timeline-primary) 10%,
        var(--timeline-line) 50%,
        var(--timeline-primary) 90%,
        transparent 100%
    );
    transform: translateY(-50%);
    z-index: 1;
    border-radius: 2px;
}

/* Subtle glow effect on the timeline line */
.timeline-wrapper::after {
    content: '';
    position: absolute;
    left: 5%;
    right: 5%;
    top: 50%;
    height: 12px;
    background: radial-gradient(ellipse at center, rgba(161, 176, 216, 0.2) 0%, transparent 70%);
    transform: translateY(-50%);
    z-index: 0;
    pointer-events: none;
}

.timeline-track {
    display: flex;
    position: relative;
    min-width: 100%;
    z-index: 1;
    transition: transform 0.5s ease;
    align-items: center;
    height: 100%;
    padding: 0 80px;
}

.timeline-event {
    min-width: 280px;
    width: 280px;
    height: 100%;
    margin: 0 1.5rem;
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.timeline-event.even .timeline-content {
    position: absolute;
    bottom: calc(50% + 25px);
}

.timeline-event.odd .timeline-content {
    position: absolute;
    top: calc(50% + 25px);
}

/* Connecting lines from content to timeline - using pseudo-elements */

.timeline-event:hover .timeline-content {
    transform: scale(1.02);
    box-shadow: var(--timeline-shadow-hover);
}

/* Timeline date marker dot */
.timeline-marker {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--timeline-line);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    box-shadow: 0 0 0 4px white, 0 0 0 6px rgba(14, 77, 146, 0.25);
    transition: all var(--timeline-transition);
    cursor: pointer;
}

.timeline-marker:hover {
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 0 0 4px white, 0 0 0 8px rgba(14, 77, 146, 0.35);
}

.timeline-event.active .timeline-marker {
    background: var(--timeline-accent);
    width: 28px;
    height: 28px;
    box-shadow: 0 0 0 5px white, 0 0 0 9px var(--timeline-accent-light);
}

/* Initial load animation - scoped to main history timeline only */
#jewish-timeline-container .timeline-event {
    opacity: 0;
    transform: translateY(20px);
}

#jewish-timeline-container .timeline-event.loaded {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Staggered load delays */
#jewish-timeline-container .timeline-event:nth-child(1).loaded { transition-delay: 0s; }
#jewish-timeline-container .timeline-event:nth-child(2).loaded { transition-delay: 0.05s; }
#jewish-timeline-container .timeline-event:nth-child(3).loaded { transition-delay: 0.1s; }
#jewish-timeline-container .timeline-event:nth-child(4).loaded { transition-delay: 0.15s; }
#jewish-timeline-container .timeline-event:nth-child(5).loaded { transition-delay: 0.2s; }

.timeline-content {
    padding: 1rem;
    background: var(--timeline-card-bg);
    border-radius: 8px;
    box-shadow: var(--timeline-shadow);
    text-align: left;
    width: 260px;
    height: 200px; /* Fixed height for consistency */
    transition: all var(--timeline-transition);
    position: relative;
    z-index: 3;
    border: 1px solid var(--timeline-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.timeline-content:hover {
    box-shadow: var(--timeline-shadow-hover);
}

/* Add connecting line from content to timeline for even events */
.timeline-event.even .timeline-content::after {
    content: '';
    position: absolute;
    width: 2px;
    background: linear-gradient(to bottom, var(--timeline-primary), var(--timeline-line));
    left: 50%;
    bottom: -25px;
    height: 25px;
    transform: translateX(-50%);
    z-index: 2;
}

/* Add connecting line from content to timeline for odd events */
.timeline-event.odd .timeline-content::before {
    content: '';
    position: absolute;
    width: 2px;
    background: linear-gradient(to top, var(--timeline-primary), var(--timeline-line));
    left: 50%;
    top: -25px;
    height: 25px;
    transform: translateX(-50%);
    z-index: 2;
}

.timeline-event.active .timeline-content {
    transform: translateY(-8px);
    box-shadow: var(--timeline-shadow-active);
    border-left: 4px solid var(--timeline-accent);
    background: linear-gradient(135deg, #fff 0%, var(--timeline-accent-light) 100%);
}

/* Date indicator */
.timeline-date {
    position: absolute;
    top: -40px;
    left: 0;
    background: #a1b0d8;
    padding: 0.4rem 0.9rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.timeline-event.active .timeline-date {
    background: #a1b0d8;
    color: white;
}

.timeline-title {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--timeline-line);
    line-height: 1.3;
    font-weight: 600;
    flex-shrink: 0;
}

.timeline-event.active .timeline-title {
    color: var(--timeline-accent);
}

.timeline-description {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--timeline-text-muted);
    overflow: hidden;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
}

/* Read more link for expandable content */
.timeline-read-more {
    display: inline-block;
    margin-top: 0.75rem;
    color: var(--timeline-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--timeline-transition-fast);
    border-bottom: 1px dashed transparent;
}

.timeline-read-more:hover {
    color: var(--timeline-accent);
    border-bottom-color: var(--timeline-accent);
}

.timeline-image {
    margin: 0 -1rem 0.5rem;
    overflow: hidden;
    border-radius: 4px;
    height: 70px;
    width: calc(100% + 2rem);
    flex-shrink: 0;
}

.timeline-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.timeline-event.active .timeline-image img {
    transform: scale(1.02);
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Star of David decorative element */
.timeline-event.active .timeline-marker::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 16px solid rgba(230, 126, 34, 0.4);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(0deg);
    animation: rotateStar 4s infinite linear;
}

.timeline-event.active .timeline-marker::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 16px solid rgba(230, 126, 34, 0.4);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(0deg);
    animation: rotateStar 4s infinite linear reverse;
}

@keyframes rotateStar {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ============================================
   Modal for Expanded Content
   ============================================ */
.timeline-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.timeline-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.timeline-modal {
    background: white;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 2rem;
    position: relative;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
}

.timeline-modal-overlay.active .timeline-modal {
    transform: scale(1) translateY(0);
}

.timeline-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: var(--timeline-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--timeline-text-muted);
    cursor: pointer;
    transition: all var(--timeline-transition-fast);
    border: none;
}

.timeline-modal-close:hover {
    background: var(--timeline-accent);
    color: white;
    transform: rotate(90deg);
}

.timeline-modal-date {
    display: inline-block;
    background: var(--timeline-primary);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.timeline-modal-title {
    font-size: 1.8rem;
    color: var(--timeline-primary);
    margin-bottom: 1rem;
    line-height: 1.3;
    padding-right: 3rem;
}

.timeline-modal-image {
    margin: 1.5rem -2rem;
    max-height: 300px;
    overflow: hidden;
}

.timeline-modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.timeline-modal-description {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--timeline-text);
}

.timeline-modal-description p {
    margin-bottom: 1rem;
}

/* ============================================
   Autoplay Controls
   ============================================ */
.timeline-autoplay {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.timeline-autoplay-btn {
    background: white !important;
    border: 2px solid var(--timeline-primary) !important;
    border-radius: 20px !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--timeline-primary) !important;
    cursor: pointer;
    transition: all var(--timeline-transition-fast);
    display: flex !important;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    width: auto !important;
    height: auto !important;
}

.timeline-autoplay-btn:hover {
    background: var(--timeline-primary) !important;
    color: white !important;
}

.timeline-autoplay-btn.playing {
    background: var(--timeline-primary) !important;
    border-color: var(--timeline-primary) !important;
    color: white !important;
}

.timeline-autoplay-btn .icon-play::before {
    content: '▶';
    font-size: 0.7rem;
}

.timeline-autoplay-btn.playing .icon-play::before {
    content: '⏸';
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .jewish-timeline {
        max-width: 95%;
    }

    .timeline-header h2 {
        font-size: 1.8rem;
    }

    .timeline-progress {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .timeline-progress-bar {
        width: 150px;
    }

    .timeline-navigation {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .timeline-navigation select {
        min-width: 180px;
    }

    .timeline-autoplay {
        margin-left: 0;
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }

    .timeline-wrapper {
        width: calc(100% - 1rem);
        margin: 0 auto;
        height: 480px;
    }

    /* Modal responsive */
    .timeline-modal {
        width: 95%;
        padding: 1.5rem;
        max-height: 90vh;
    }

    .timeline-modal-title {
        font-size: 1.4rem;
    }

    .timeline-modal-image {
        margin: 1rem -1.5rem;
        max-height: 200px;
    }

    .timeline-modal-description {
        font-size: 0.95rem;
        line-height: 1.7;
    }
    
    .timeline-event {
        min-width: 280px; /* Increased from 260px for better image display */
        width: 280px;
        margin: 0 1.5rem;
    }
    
    .timeline-content {
        padding: 1.2rem;
        width: 260px; /* Increased from 240px */
        min-height: 180px; /* Reduced from default to be more compact */
    }
    
    .timeline-event.even .timeline-content {
        margin-bottom: 35px;
    }
    
    .timeline-event.odd .timeline-content {
        margin-top: 35px;
    }
    
    /* Responsive connecting line heights */
    .timeline-event.even .timeline-content::after {
        height: 35px;
        bottom: -35px;
    }
    
    .timeline-event.odd .timeline-content::before {
        height: 35px;
        top: -35px;
    }
    
    /* Adjust connector heights */
    .timeline-event.even .connector {
        height: 35px;
    }
    
    .timeline-event.odd .connector {
        height: 35px;
    }
    
    .timeline-title {
        font-size: 1.1rem;
        margin-bottom: 0.7rem; /* Reduced from 1rem to make more compact */
    }
    
    .timeline-description {
        font-size: 0.9rem;
        line-height: 1.4; /* Reduced from 1.6 to make more compact */
    }
    
    .timeline-image {
        height: 90px; /* Reduced height to make more compact */
        margin-bottom: 0.7rem; /* Reduced margin */
    }
}

@media (max-width: 576px) {
    .timeline-header h2 {
        font-size: 1.5rem;
    }

    .timeline-header p {
        font-size: 1rem;
    }

    .timeline-progress {
        flex-direction: column;
        gap: 0.3rem;
    }

    .timeline-progress-bar {
        width: 120px;
    }

    .timeline-progress-counter {
        font-size: 0.85rem;
    }

    .timeline-navigation {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .timeline-navigation > button {
        width: 36px;
        height: 36px;
    }

    .timeline-navigation select {
        min-width: 140px;
        font-size: 0.9rem;
    }

    .timeline-autoplay-btn {
        padding: 0.3rem 0.8rem;
        font-size: 0.8rem;
    }

    /* Modal on small screens */
    .timeline-modal {
        padding: 1rem;
        margin: 10px;
    }

    .timeline-modal-title {
        font-size: 1.2rem;
        padding-right: 2.5rem;
    }

    .timeline-modal-date {
        font-size: 0.8rem;
        padding: 0.3rem 0.8rem;
    }

    .timeline-modal-close {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }
    
    .timeline-wrapper {
        height: 440px;
        padding: 0;
    }
    
    .timeline-event {
        min-width: 240px; /* Increased from previous 220px for better image display */
        width: 240px;
        margin: 0 1rem;
    }
    
    .timeline-content {
        padding: 1rem 1rem 0.8rem; /* Reduced bottom padding */
        width: 220px; /* Increased from previous 200px */
        min-height: 160px; /* More compact */
    }
    
    .timeline-event.even .timeline-content {
        margin-bottom: 23px; /* Reduced from 40px to be more compact */
    }
    
    .timeline-event.odd .timeline-content {
        margin-top: 50px; /* Reduced from 40px to be more compact */
    }
    
    /* Mobile connecting line heights */
    .timeline-event.even .timeline-content::after {
        height: 30px;
        bottom: -30px;
    }
    
    .timeline-event.odd .timeline-content::before {
        height: 30px;
        top: -30px;
    }
    
    /* Adjust connector heights for mobile */
    .timeline-event.even .connector {
        height: 30px; 
    }
    
    .timeline-event.odd .connector {
        height: 30px;
    }
    
    .timeline-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .timeline-description {
        font-size: 0.85rem;
        line-height: 1.3;
    }
    
    .timeline-image {
        height: 100px; /* Better proportion for the increased width */
        margin: 0 -1rem 0.7rem; /* Adjusted margins */
        width: calc(100% + 2rem); /* Adjusted width calculation */
    }
    
    /* Optimize the date display */
    .timeline-date {
        top: -35px;
        padding: 0.3rem 0.7rem;
        font-size: 0.8rem;
    }
    
    /* Make the marker slightly smaller on mobile */
    .timeline-marker {
        width: 20px;
        height: 20px;
    }
    
    .timeline-event.active .timeline-marker {
        width: 26px;
        height: 26px;
    }
}