//
//  ClockDisplayContainer.swift
//  TheNoiseClock
//
//  Created by Matt Bruce on 9/8/25.
//

import SwiftUI
import Bedrock

/// Container component that handles the main clock display layout and scaling
struct ClockDisplayContainer: View {
    
    // MARK: - Properties
    let currentTime: Date
    let style: ClockStyle
    let isDisplayMode: Bool
    
    // MARK: - Body
    var body: some View {
        GeometryReader { geometry in
            let isPortrait = geometry.size.height >= geometry.size.width
            let hasOverlay = style.showBattery || style.showDate
            let topSpacing = hasOverlay ? (isPortrait ? Design.Spacing.xxLarge : Design.Spacing.large) : 0
            
            // Time display - fills all available space
            TimeDisplayView(
                date: currentTime,
                use24Hour: style.use24Hour,
                showSeconds: style.showSeconds,
                showAmPm: style.showAmPm,
                digitColor: style.effectiveDigitColor,
                glowIntensity: style.glowIntensity,
                clockOpacity: style.clockOpacity,
                fontFamily: style.fontFamily,
                fontWeight: style.fontWeight,
                fontDesign: style.fontDesign,
                forceHorizontalMode: style.forceHorizontalMode,
                isDisplayMode: isDisplayMode,
                animationStyle: style.digitAnimationStyle
            )
            .padding(.top, topSpacing)
            .frame(width: geometry.size.width, height: geometry.size.height)
            .transition(.opacity)
            .animation(.smooth(duration: Design.Animation.standard), value: isDisplayMode)
        }
    }
}

// MARK: - Preview
#Preview {
    ClockDisplayContainer(
        currentTime: Date(),
        style: ClockStyle(),
        isDisplayMode: false
    )
    .frame(width: 400, height: 600)
    .background(Color.black)
}
