/*
 * state.cpp
 * Global state definitions for the Wikipedia client
 * Copyright (c) 2026 Daniel Hammer
 */

#include "wikipedia.h"

int           TOOLBAR_H    = 42;
int           FONT_SIZE    = 18;
int           TITLE_SIZE   = 32;
int           SECTION_SIZE = 24;

AppPhase      g_phase      = AppPhase::WELCOME;
char          g_query[256] = {};
mtk::TextInputState g_query_input = {};
char          g_status[256] = {};
int           g_scroll_y   = 0;
int           g_line_count = 0;
int           g_line_h     = 24;
int           g_win_w      = INIT_W;
int           g_win_h      = INIT_H;
int           g_mouse_x    = -1;
int           g_mouse_y    = -1;
bool          g_search_focused = true;
bool          g_scroll_dragging = false;
int           g_scroll_drag_offset = 0;
bool          g_display_controls_open = false;
ReaderTextSize g_reader_text_size = ReaderTextSize::MEDIUM;
ReaderFontFace g_reader_font_face = ReaderFontFace::BOOK;
char          g_title[512] = {};
int           g_extract_len = 0;
int           g_base_font_size = 18;
int           g_base_title_size = 32;
int           g_base_section_size = 24;
Color         g_accent = colors::ACCENT;
bool          g_welcome_feature_loaded = false;
char          g_welcome_feature_title[256] = {};
char          g_welcome_feature_extract[1024] = {};
char          g_welcome_status[192] = "Loading today's featured article...";
char          g_welcome_date[16] = {};

WikiLine*     g_lines       = nullptr;
char*         g_resp_buf    = nullptr;
char*         g_extract_buf = nullptr;

TrueTypeFont* g_font        = nullptr;
TrueTypeFont* g_font_serif  = nullptr;
TrueTypeFont* g_body_fonts[READER_FONT_FACE_COUNT] = {};
TrueTypeFont* g_heading_fonts[READER_FONT_FACE_COUNT] = {};
SvgIcon       g_display_icon = {};
SvgIcon       g_display_icon_active = {};

bool          g_tls_ready  = false;
uint32_t      g_server_ip  = 0;
tls::TrustAnchors g_tas    = {nullptr, 0, 0};

const char* g_text_size_labels[READER_TEXT_SIZE_COUNT] = {
    "A-", "A", "A+"
};

const char* g_font_face_labels[READER_FONT_FACE_COUNT] = {
    "Sans", "Serif", "Book"
};
