# Stylish affection display in top-left corner
screen affection_display():
    frame:
        xalign 0.5
        yalign 0.05
        background "#000000cc"
        padding (25, 15)
        at affection_float
        
        hbox:
            spacing 10
            text "❤" size 45 color "#ff6b9d"
            text "Power:" size 38 color "#ffffff"
            text "[power]" size 38 color "#ffd700" bold True

# Floating animation for the corner display
transform affection_float:
    ease 2.5 yoffset 5
    ease 2.5 yoffset 0
    repeat

# Big popup notification when affection increases
screen affection_popup():
    zorder 200
    
    frame:
        xalign 0.5
        yalign 0.3
        background "#000000ee"
        padding (50, 40)
        at affection_popup_anim
        
        vbox:
            spacing 15
            xalign 0.5
            
            text "❤ POWER UP! ❤" size 45 color "#ff6b9d" xalign 0.5 bold True
            text "+1" size 60 color "#ffd700" xalign 0.5 bold True at number_pulse
            
            hbox:
                spacing 10
                xalign 0.5
                text "New Power:" size 30 color "#ffffff"
                text "[power]" size 30 color "#ffd700" bold True

# Popup animation - slides in from top with fade
transform affection_popup_anim:
    alpha 0.0 yoffset -100 zoom 0.8
    ease 0.4 alpha 1.0 yoffset 0 zoom 1.0
    pause 1.5
    ease 0.3 alpha 0.0 yoffset -50

# Number pulse effect
transform number_pulse:
    zoom 1.0
    ease 0.15 zoom 1.3
    ease 0.15 zoom 1.0
    ease 0.15 zoom 1.2
    ease 0.15 zoom 1.0

# Corner display pulse when affection increases
transform affection_corner_pulse:
    zoom 1.0
    parallel:
        ease 0.2 zoom 1.3
        ease 0.2 zoom 1.0
    parallel:
        linear 0.1 xoffset 5
        linear 0.1 xoffset -5
        linear 0.1 xoffset 5
        linear 0.1 xoffset 0

# Negative popup notification when affection decreases
screen affection_popup_decrease():
    zorder 200
    
    frame:
        xalign 0.5
        yalign 0.3
        background "#1a0000ee"
        padding (50, 40)
        at affection_popup_anim
        
        vbox:
            spacing 15
            xalign 0.5
            
            text "💔 POWER DOWN! 💔" size 45 color "#ff4444" xalign 0.5 bold True
            text "-1" size 60 color "#ff6666" xalign 0.5 bold True at number_shake
            
            hbox:
                spacing 10
                xalign 0.5
                text "New Power:" size 30 color "#ffffff"
                text "[power]" size 30 color "#ff6666" bold True

# Shake effect for negative number
transform number_shake:
    zoom 1.0
    parallel:
        ease 0.1 zoom 1.2
        ease 0.1 zoom 1.0
    parallel:
        linear 0.05 xoffset -8
        linear 0.05 xoffset 8
        linear 0.05 xoffset -8
        linear 0.05 xoffset 8
        linear 0.05 xoffset -5
        linear 0.05 xoffset 5
        linear 0.05 xoffset 0

# Corner display shake for decrease
transform affection_corner_shake:
    zoom 1.0
    parallel:
        ease 0.15 zoom 0.9
        ease 0.15 zoom 1.0
    parallel:
        linear 0.08 xoffset -8 yoffset 3
        linear 0.08 xoffset 8 yoffset -3
        linear 0.08 xoffset -5 yoffset 2
        linear 0.08 xoffset 5 yoffset -2
        linear 0.08 xoffset 0 yoffset 0

# Reusable label for power increase
label increase_power:
    $ power += 1
    hide screen affection_display
    show screen affection_display
    show screen affection_popup
    $ renpy.pause(0.1, hard=True)
    pause 2.1
    hide screen affection_popup
    return

# Reusable label for power decrease
label decrease_power:
    $ power -= 1
    hide screen affection_display
    show screen affection_display
    show screen affection_popup_decrease
    $ renpy.pause(0.1, hard=True)
    pause 2.1
    hide screen affection_popup_decrease
    return