"""
ANSI escape codes and terminal control constants.

Provides standard ANSI escape sequences for terminal manipulation.
This module belongs in Sideline as it's a framework-level concern.
"""

# ─── ANSI RESET ──────────────────────────────────────────
RST = "\033[0m"

# ─── TEXT STYLES ─────────────────────────────────────────
BOLD = "\033[1m"
DIM = "\033[2m"
UNDERLINE = "\033[4m"
REVERSE = "\033[7m"

# ─── MATRIX GREENS (Sideline default theme) ─────────────
G_HI = "\033[38;5;46m"  # Bright green
G_MID = "\033[38;5;34m"  # Medium green
G_LO = "\033[38;5;22m"  # Dark green
G_DIM = "\033[2;38;5;34m"  # Dim green

# ─── COOL TONES ──────────────────────────────────────────
W_COOL = "\033[38;5;250m"  # Cool white
W_DIM = "\033[2;38;5;245m"  # Dim white
W_GHOST = "\033[2;38;5;238m"  # Ghost white
C_DIM = "\033[2;38;5;37m"  # Dim cyan

# ─── TERMINAL CONTROL ────────────────────────────────────
CLR = "\033[2J\033[H"  # Clear screen and home cursor
CURSOR_OFF = "\033[?25l"  # Hide cursor
CURSOR_ON = "\033[?25h"  # Show cursor


# ─── CURSOR POSITIONING ──────────────────────────────────
def cursor_pos(row: int, col: int) -> str:
    """Move cursor to position (row, col)."""
    return f"\033[{row};{col}H"


# ─── COLOR UTILITIES ─────────────────────────────────────
def fg_color(code: int) -> str:
    """Set foreground color (0-255)."""
    return f"\033[38;5;{code}m"


def bg_color(code: int) -> str:
    """Set background color (0-255)."""
    return f"\033[48;5;{code}m"


# ─── COMMON COLORS ───────────────────────────────────────
BLACK = "\033[30m"
RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
BLUE = "\033[34m"
MAGENTA = "\033[35m"
CYAN = "\033[36m"
WHITE = "\033[37m"

# ─── BRIGHT COLORS ───────────────────────────────────────
BRIGHT_BLACK = "\033[90m"
BRIGHT_RED = "\033[91m"
BRIGHT_GREEN = "\033[92m"
BRIGHT_YELLOW = "\033[93m"
BRIGHT_BLUE = "\033[94m"
BRIGHT_MAGENTA = "\033[95m"
BRIGHT_CYAN = "\033[96m"
BRIGHT_WHITE = "\033[97m"

__all__ = [
    "RST",
    "BOLD",
    "DIM",
    "UNDERLINE",
    "REVERSE",
    "G_HI",
    "G_MID",
    "G_LO",
    "G_DIM",
    "W_COOL",
    "W_DIM",
    "W_GHOST",
    "C_DIM",
    "CLR",
    "CURSOR_OFF",
    "CURSOR_ON",
    "cursor_pos",
    "fg_color",
    "bg_color",
    "BLACK",
    "RED",
    "GREEN",
    "YELLOW",
    "BLUE",
    "MAGENTA",
    "CYAN",
    "WHITE",
    "BRIGHT_BLACK",
    "BRIGHT_RED",
    "BRIGHT_GREEN",
    "BRIGHT_YELLOW",
    "BRIGHT_BLUE",
    "BRIGHT_MAGENTA",
    "BRIGHT_CYAN",
    "BRIGHT_WHITE",
]
