"""
deckforge - Brand-first slide deck library.

Create beautiful, brand-consistent slide decks with full creative control.

Example:
    from deckforge import Brand, export, base_html

    # Extract brand from website
    brand = Brand.from_domain("scaile.tech")

    # Or define manually
    brand = Brand(
        primary="#054dfe",
        background="#fdfbf5",
        text="#191919",
        font_headline="Syne",
        font_body="Inter",
    )

    # Create slides using brand values
    def slide_hero():
        return f'''
        {base_html(brand)}
        <body style="background:{brand.background};">
            <h1 style="color:{brand.primary};">Hello World</h1>
        </body></html>
        '''

    # Export to PNG
    export([slide_hero()], "/tmp/my-deck/")
"""

from .brand import Brand
from .export import export, export_async, export_pdf

__version__ = "1.0.0"
__all__ = ["Brand", "export", "export_async", "export_pdf", "base_html", "base_styles", "clearbit_logo"]


def clearbit_logo(domain: str, size: int = 40) -> str:
    """
    Generate an img tag for a company logo using Clearbit.

    Args:
        domain: Company domain (e.g., "stripe.com")
        size: Logo height in pixels

    Returns:
        HTML img tag
    """
    if domain.startswith("www."):
        domain = domain[4:]
    return f'<img src="https://logo.clearbit.com/{domain}" alt="logo" style="height:{size}px;" />'


def base_html(brand: Brand) -> str:
    """
    Generate HTML boilerplate with brand fonts loaded.

    Returns everything up to (but not including) <body>.
    You add <body>...</body></html> yourself.

    Example:
        def slide():
            return f'''
            {base_html(brand)}
            <body style="background:{brand.background};">
                <h1>Hello</h1>
            </body></html>
            '''
    """
    return f'''<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="{brand.google_fonts_url}" rel="stylesheet">
<style>
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
body {{
    font-family: '{brand.font_body}', -apple-system, sans-serif;
    width: 1920px;
    height: 1080px;
    overflow: hidden;
}}
</style>
</head>'''


def base_styles(brand: Brand) -> str:
    """
    Generate common CSS styles using brand values.

    Use inside a <style> tag for common patterns.

    Example:
        <style>
        {base_styles(brand)}
        .my-custom-class {{ ... }}
        </style>
    """
    return f'''
.headline {{
    font-family: '{brand.font_headline}', sans-serif;
    color: {brand.text};
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}}
.body-text {{
    font-family: '{brand.font_body}', sans-serif;
    color: {brand.text};
    font-size: 18px;
    line-height: 1.6;
}}
.muted {{
    color: {brand.muted};
}}
.accent {{
    color: {brand.primary};
}}
.card {{
    background: {brand.surface};
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}}
.label {{
    font-size: 12px;
    color: {brand.primary};
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
}}
.btn {{
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: {brand.primary};
    color: white;
    padding: 16px 32px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
}}
'''
