import SwiftUI

/// Marianum-M peeking out of the bottom-right corner. Sized to the longer
/// widget edge so it scales with the picked WidgetFamily; offset nudges a
/// sliver behind the edge. Opacity comes from the widget palette so the
/// watermark matches Android's `watermarkAlpha` at the same brightness.
struct MarianumWatermark: View {
  @Environment(\.widgetPalette) private var palette

  var body: some View {
    GeometryReader { geo in
      let markSize = min(400, max(160, max(geo.size.width, geo.size.height) * 0.8))
      let offsetX = markSize * 0.18
      let offsetY = markSize * 0.18
      ZStack(alignment: .bottomTrailing) {
        Color.clear
        Image("marianum_m")
          .resizable()
          .renderingMode(.template)
          .aspectRatio(contentMode: .fit)
          .foregroundStyle(palette.textPrimary)
          .frame(width: markSize, height: markSize)
          .opacity(palette.watermarkOpacity)
          .offset(x: offsetX, y: offsetY)
      }
    }
    .clipped()
  }
}
