/* style-histoire.css (Updated for Mobile & Touch) */

.history-container {
    max-width: 2000px;
    /* Increased from 1200px for better visibility */
    margin: 0 auto;
    padding: 20px;
    /* Prevent default touch actions like scroll when dragging */
    touch-action: pan-y;
}

/* Override default game container width for History game */
.game-container {
    max-width: 1600px !important;
}

/* Zone de la frise */
.timeline-area {
    background-color: #f5f5f5;
    border-radius: 15px;
    padding: 20px;
    min-height: 280px;
    display: flex;
    align-items: center;
    overflow-x: auto;
    gap: 15px;
    margin-bottom: 30px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    border: 3px dashed #bbb;
    transition: background-color 0.3s, border-color 0.3s;
    position: relative;
    /* For scroll calculation */
}

.timeline-area.drag-over {
    background-color: #e3f2fd;
    border-color: #2196F3;
}

.empty-message {
    width: 100%;
    text-align: center;
    color: #999;
    font-size: 1.5rem;
    font-style: italic;
    pointer-events: none;
}

/* Carte placée dans la frise */
.timeline-card {
    background: white;
    border-radius: 10px;
    padding: 10px;
    width: 200px;
    min-width: 200px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative;
    display: inline-block;
    vertical-align: top;
    white-space: normal;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    touch-action: none;
    /* Important for custom drag */
}

.timeline-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    cursor: grabbing;
}

.timeline-card.correct {
    border: 3px solid #4CAF50;
    background-color: #e8f5e9;
}

.timeline-card.incorrect {
    border: 3px solid #F44336;
    background-color: #ffebee;
}

.timeline-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 8px;
    background-color: #eee;
    pointer-events: none;
}

.card-title {
    font-weight: bold;
    color: #5a4e49;
    font-size: 1rem;
    margin-bottom: 5px;
}

.card-date {
    font-family: 'Dancing Script', cursive;
    font-size: 1.3rem;
    color: #E91E63;
    font-weight: bold;
    margin-top: 5px;
    display: none;
}

.timeline-card.revealed .card-date {
    display: block;
}

/* Zone "Carte à placer" */
.current-card-area {
    text-align: center;
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
    margin-bottom: 20px;
    min-height: 350px;
}

/* La carte en main draggable */
.card-to-place {
    width: 300px;
    margin: 0 auto;
    background: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    cursor: grab;
    transition: transform 0.2s;
    touch-action: none;
    /* Important for custom drag */
}

.card-to-place img {
    width: 100%;
    height: auto;
    max-height: 300px;
    /* Prevent overly tall images */
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
    pointer-events: none;
}

/* Ghost Card style for Touch Drag */
.ghost-card {
    position: fixed;
    top: 0;
    left: 0;
    width: 200px;
    /* Taille réduite pendant le drag */
    background: white;
    border-radius: 10px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    /* Click-through */
    z-index: 9999;
    opacity: 0.9;
    transform: translate(-50%, -50%) rotate(5deg);
    padding: 10px;
}

.ghost-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 5px;
}

.ghost-card .card-title {
    font-size: 0.9rem;
}

.ghost-card .card-description {
    display: none;
    /* Hide details while dragging */
}

/* Validation */
.validate-container {
    text-align: center;
    margin-top: 20px;
    display: none;
}

#validate-timeline-btn {
    background: linear-gradient(45deg, #4CAF50, #81C784);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
    transition: transform 0.2s;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .history-container {
        padding: 10px;
    }

    .timeline-area {
        min-height: 400px;
        /* Increased height for vertical stack */
        padding: 10px;
        margin-bottom: 20px;
        flex-direction: column;
        /* Vertical stack */
        align-items: center;
        /* Center cards */
        overflow-x: hidden;
        /* Disable horizontal scroll */
        overflow-y: auto;
        /* Enable vertical scroll */
        white-space: normal;
        /* Allow wrapping */
        gap: 10px;
    }

    .timeline-card {
        width: 90%;
        /* Full width cards */
        min-width: unset;
        /* Remove min-width constraint */
        padding: 10px;
        display: block;
        /* Block display for stacking */
        margin-bottom: 10px;
        /* Spacing between cards */
    }

    .timeline-card img {
        height: 120px;
        /* Slightly larger image */
        width: 100%;
        object-fit: cover;
    }

    .timeline-card .card-title {
        font-size: 0.85rem;
    }

    .current-card-area {
        min-height: auto;
        /* Allow shrink */
    }

    .card-to-place {
        width: 240px;
        padding: 10px;
    }

    .card-to-place img {
        height: 150px;
    }

    .card-to-place .card-title {
        font-size: 1rem !important;
    }

    .card-to-place .card-description {
        font-size: 0.9rem;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* Insert Button Styles */
.insert-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #4CAF50;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
    flex-shrink: 0;
    margin: 0 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.insert-btn:hover {
    transform: scale(1.1);
    background: #43A047;
}

.insert-btn:active {
    transform: scale(0.9);
}

@media (max-width: 768px) {
    .insert-btn {
        margin: 5px 0;
        width: 50px;
        /* Larger touch target */
        height: 50px;
        font-size: 28px;
    }
}