/* Project History Section */
#project-history {
    background-color: var(--white);
    padding: 80px 0;
}

.history-wrapper {
    margin-top: 40px;
}

/* Timeline Years Navigation */
.timeline-years-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 50px;
    padding: 0 40px;
}

.timeline-years {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 10px 5px;
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
    max-width: 800px;
    margin: 0 auto;
}

.timeline-years::-webkit-scrollbar {
    display: none;
}

.year-item {
    font-size: 1.1rem;
    font-weight: 600;
    color: #999;
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    white-space: nowrap;
    user-select: none;
}

.year-item:hover {
    color: var(--primary-color);
    background: rgba(16, 103, 178, 0.05);
}

.year-item.active {
    color: var(--white);
    background: var(--primary-color);
    box-shadow: 0 4px 15px rgba(16, 103, 178, 0.3);
    transform: scale(1.05);
}

/* Snap scrolling enhancement */
.timeline-years {
    scroll-snap-type: x mandatory;
}

.year-item {
    scroll-snap-align: center;
}

.nav-btn {
    background: var(--white);
    border: 1px solid #eee;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary-color);
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.nav-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: scale(1.1);
}

/* RTL Adjustments for Navigation Buttons */
html[dir="rtl"] .nav-btn svg {
    transform: scaleX(-1);
}

/* Projects Grid */
.timeline-projects {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    min-height: 200px;
}

.project-history-card {
    background: transparent; /* Changed to transparent as inner faces will have background */
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    opacity: 0;
    animation: fadeInUpHistory 0.6s ease forwards;
    perspective: 1000px;
    transform-style: preserve-3d;
}

@keyframes fadeInUpHistory {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

.project-history-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

/* Card Content Standard View */
.project-card-content {
    padding: 25px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    z-index: 1;
    background: var(--white);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    backface-visibility: hidden;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.project-client-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 8px;
    display: block;
}

.project-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--black);
    margin: 0 0 15px 0;
    line-height: 1.4;
}

.project-contractor {
    font-size: 0.9rem;
    color: #555;
    background: #f4f6f9;
    padding: 8px 12px;
    border-radius: 6px;
    align-self: flex-start;
    margin-top: auto;
    /* Push to bottom of content area */
}

/* Hover Details Overlay (Now Back Side) */
.project-card-details {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    color: var(--white);
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    backface-visibility: hidden;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform: rotateY(180deg);
    z-index: 2;
    border-radius: 16px;
}

/* Active toggles details for flip effect */
.project-history-card.active .project-card-content {
    transform: rotateY(180deg);
}

.project-history-card.active .project-card-details {
    transform: rotateY(0deg);
}

/* Hover effect on desktop can still show details by flipping */
@media (min-width: 769px) {
    .project-history-card:hover .project-card-content {
        transform: rotateY(180deg);
    }
    .project-history-card:hover .project-card-details {
        transform: rotateY(0deg);
    }
}

.detail-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
    margin-bottom: 10px;
    display: block;
}

.detail-desc {
    font-size: 1.05rem;
    line-height: 1.6;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .timeline-projects {
        grid-template-columns: 1fr;
    }

    .timeline-years-wrapper {
        padding: 0;
        /* create fade effect on sides to indicate scrolling */
        mask-image: linear-gradient(to right, transparent 0%, black 15%, black 85%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, transparent 0%, black 15%, black 85%, transparent 100%);
    }

    .timeline-years {
        padding: 15px 35%;
        /* Large padding centers the active item effectively */
    }

    .year-item {
        /* Mobile Specific Style: smaller but clearer */
        padding: 8px 16px;
        font-size: 1rem;
        background: #f8f9fa;
        /* Slight bg for context */
        border: 1px solid #eee;
    }

    .year-item.active {
        transform: scale(1.15);
        /* More pop on mobile */
        box-shadow: 0 4px 20px rgba(16, 103, 178, 0.4);
    }

    .nav-btn {
        display: none;
        /* Hide arrows on mobile, rely on swipe */
    }

    .project-history-card {
        cursor: pointer;
        /* Indication it's clickable */
    }

    /* Scroll Hint Animation */
    .mobile-scroll-hint {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: 10;
        pointer-events: none;
        opacity: 0;
        /* Hidden by default, JS triggers it via class */
        transition: opacity 0.5s ease;
    }

    .mobile-scroll-hint.show {
        opacity: 1;
        animation: fadeOutHint 3s forwards;
        /* Auto hide after animation */
        animation-delay: 2s;
        /* Wait for user to see it */
    }

    .hint-hand {
        font-size: 2rem;
        animation: swipeAnim 2s infinite ease-in-out;
        filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.2));
    }

    @keyframes swipeAnim {

        0%,
        100% {
            transform: translateX(0) scale(1);
        }

        50% {
            transform: translateX(-40px) scale(0.9);
        }

        /* Swipe Left motion */
    }

    @keyframes fadeOutHint {
        to {
            opacity: 0;
            visibility: hidden;
        }
    }
}

/* RTL Adjustments for animation */
html[dir="rtl"] .hint-hand {
    animation-name: swipeAnimRTL;
}

@keyframes swipeAnimRTL {

    0%,
    100% {
        transform: translateX(0) scale(1);
    }

    50% {
        transform: translateX(40px) scale(0.9);
    }

    /* Swipe Right motion */
}