import SwiftUI

struct DraggedCardsOverlay: View {
    @Bindable var viewModel: GameViewModel
    let layout: CardLayout
    let cardFaceStyle: CardFaceStyle
    let cardBackDesign: CardBackDesign

    var body: some View {
        if !viewModel.draggedCards.isEmpty {
            ZStack(alignment: .top) {
                ForEach(Array(viewModel.draggedCards.enumerated()), id: \.element.id) { index, card in
                    CardView(card: card, cardFaceStyle: cardFaceStyle,
                             cardBackDesign: cardBackDesign, size: layout.cardSize())
                        .offset(y: CGFloat(index) * layout.verticalOverlapFaceUp)
                }
            }
            .frame(width: layout.cardWidth)
            .position(viewModel.dragPosition)
            .allowsHitTesting(false)
        }
    }
}
