import SwiftUI

struct MainMenuView: View {
    @Binding var selectedVariant: GameVariant
    let onStart: () -> Void

    var body: some View {
        VStack(spacing: 32) {
            Text("SoliCards")
                .font(.largeTitle.bold())

            VStack(spacing: 16) {
                ForEach(GameVariant.allCases) { variant in
                    Button {
                        selectedVariant = variant
                        onStart()
                    } label: {
                        HStack {
                            Image(systemName: iconName(for: variant))
                                .font(.title2)
                                .frame(width: 30)
                            VStack(alignment: .leading) {
                                Text(variant.displayName)
                                    .font(.headline)
                                Text(subtitle(for: variant))
                                    .font(.caption)
                                    .foregroundStyle(.secondary)
                            }
                            Spacer()
                            Image(systemName: "chevron.right")
                                .foregroundStyle(.tertiary)
                        }
                        .padding()
                        .background(.regularMaterial, in: RoundedRectangle(cornerRadius: 12))
                    }
                    .buttonStyle(.plain)
                }
            }
            .frame(maxWidth: 400)
        }
        .padding()
    }

    private func iconName(for variant: GameVariant) -> String {
        switch variant {
        case .klondike: "suit.spade.fill"
        case .spider: "suit.club.fill"
        case .freeCell: "suit.diamond.fill"
        }
    }

    private func subtitle(for variant: GameVariant) -> String {
        switch variant {
        case .klondike: "Classic solitaire with stock and waste"
        case .spider: "Build same-suit sequences with two decks"
        case .freeCell: "Strategic play with four free cells"
        }
    }
}
