from __future__ import annotations

from typing import Optional, Tuple

SYSTEM_SAFE = {
    'Arial', 'Helvetica', 'Times New Roman', 'Georgia',
    'Calibri', 'Cambria', 'Trebuchet MS', 'Verdana',
    'Courier New', 'Tahoma', 'Garamond',
}

SUBSTITUTION_MAP = {
    'Freight Text Pro':   ('Georgia',       'serif body substitute'),
    'Minion Pro':         ('Georgia',       'serif body substitute'),
    'Proxima Nova':       ('Calibri',       'sans-serif substitute'),
    'Myriad Pro':         ('Calibri',       'sans-serif substitute'),
    'Futura PT':          ('Trebuchet MS',  'geometric sans substitute'),
    'Neue Haas Grotesk':  ('Arial',         'neutral sans substitute'),
    'Brandon Grotesque':  ('Trebuchet MS',  'geometric sans substitute'),
    'Cormorant Garamond': ('Garamond',      'close serif match'),
    'Acumin Pro':         ('Calibri',       'sans-serif substitute'),
    'Adobe Caslon Pro':   ('Georgia',       'serif body substitute'),
}


def classify_font(name: str) -> str:
    """Returns 'safe', 'professional', or 'unknown'."""
    if name in SYSTEM_SAFE:
        return 'safe'
    if name in SUBSTITUTION_MAP:
        return 'professional'
    return 'unknown'


def get_substitute(name: str) -> Tuple[Optional[str], Optional[str]]:
    """Returns (substitute_name, quality_note) or (None, None)."""
    if name in SUBSTITUTION_MAP:
        return SUBSTITUTION_MAP[name]
    return None, None
