import SwiftUI

/// Blocking screen when the ubiquity container can't be obtained. The app
/// deliberately has no local-only fallback — notes written without iCloud
/// would exist nowhere durable and be wiped by the next cache rebuild.
struct ICloudGateView: View {
    @Environment(SyncEngine.self) private var syncEngine

    var body: some View {
        VStack(spacing: 16) {
            Image(systemName: "icloud.slash")
                .font(.system(size: 56))
                .foregroundStyle(.secondary)
            Text("iCloud Required")
                .font(.title2.bold())
            Text("Notes stores everything in your iCloud Drive so it's on all your devices. Sign in to iCloud and enable iCloud Drive for Notes in Settings, then try again.")
                .font(.callout)
                .foregroundStyle(.secondary)
                .multilineTextAlignment(.center)
                .frame(maxWidth: 420)
            Button("Try Again") {
                Task { await syncEngine.connect() }
            }
            .buttonStyle(.borderedProminent)
        }
        .padding(32)
    }
}
