import SwiftUI

/// Constrains content to a max readable width and centers it.
/// On iPhone this has no effect (content is already narrow).
/// On iPad this prevents content from stretching edge-to-edge.
struct AdaptiveContainer: ViewModifier {
    var maxWidth: CGFloat = 700

    func body(content: Content) -> some View {
        content
            .frame(maxWidth: maxWidth)
            .frame(maxWidth: .infinity)
    }
}

extension View {
    func adaptiveContainer(maxWidth: CGFloat = 700) -> some View {
        modifier(AdaptiveContainer(maxWidth: maxWidth))
    }
}
