"""
s02 - The threat numbers. 30s.

Four big stat cards: 200 victims, 0 clicks, 2 CVEs chained, CVSS 8.8.
Subtitle: 90 days in the wild before patch.
"""

import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent.parent))

from manim import (
    Text, Rectangle, VGroup, FadeIn, Write,
    UP, DOWN, LEFT, RIGHT, ORIGIN,
)
from src.slides._core import SceneSlide
from src.slides._theme import SecurityPalette, Fonts, Sizes, Layout
from src.slides._layout import slide_title


class S02Threat(SceneSlide):
    SECTION = None
    WITH_FOOTER = True
    ON_DARK = True

    def construct_content(self):
        title = slide_title(
            "No click required.  No user error.",
            font_size=Sizes.TITLE - 6,
            color=SecurityPalette.FG,
            with_accent_rule=True,
        )
        title.move_to((0.0, 2.5, 0.0))

        subtitle = Text(
            "August 2025  -  WhatsApp + Apple ImageIO  -  in the wild for 90 days",
            font=Fonts.SERIF, font_size=Sizes.SUBTITLE - 6,
            color=SecurityPalette.FG_MUTED,
        )
        subtitle.next_to(title, DOWN, buff=0.6)

        def stat_card(big: str, small: str, color):
            big_t = Text(big, font=Fonts.SERIF_DISPLAY, font_size=64,
                         color=color, weight="BOLD")
            small_t = Text(small, font=Fonts.SANS, font_size=Sizes.SMALL,
                           color=SecurityPalette.FG_MUTED, weight="MEDIUM")
            small_t.next_to(big_t, DOWN, buff=0.15)
            return VGroup(big_t, small_t)

        c1 = stat_card("~200",    "VICTIMS",         SecurityPalette.WARN)
        c2 = stat_card("0",       "CLICKS REQUIRED", SecurityPalette.DANGER)
        c3 = stat_card("2",       "CVEs CHAINED",    SecurityPalette.INFO)
        c4 = stat_card("8.8",     "CVSS HIGH",       SecurityPalette.ACCENT)

        cards = VGroup(c1, c2, c3, c4).arrange(RIGHT, buff=1.0)
        cards.move_to((0.0, -0.6, 0.0))

        self.play(FadeIn(title, shift=0.2 * UP), run_time=0.6)
        self.play(FadeIn(subtitle), run_time=0.4)
        self.next_slide()

        self.play(FadeIn(c1, shift=0.2 * UP), run_time=0.4)
        self.play(FadeIn(c2, shift=0.2 * UP), run_time=0.4)
        self.play(FadeIn(c3, shift=0.2 * UP), run_time=0.4)
        self.play(FadeIn(c4, shift=0.2 * UP), run_time=0.4)
        self.wait(0.8)
        self.next_slide()
