//! Theming for bos-settings.
//!
//! bos-settings deliberately owns almost no styling: it loads the ecosystem's
//! shared stylesheet (the same one breadbar/breadbox/breadpad use, generated by
//! `bread-theme` from the pywal palette) and adds only the few layout rules
//! specific to this app's sidebar + content shell. This keeps it visually
//! identical to the rest of the bread desktop and live-recolouring for free.

use gtk4::CssProvider;
use std::cell::RefCell;

// App-specific layout only — everything visual (colours, buttons, entries,
// switches, sidebar/row styling, cards, scrollbars) comes from the shared sheet.
const APP_CSS: &str = "\
.view-content { padding: 24px; }\n\
.view-content > label.title { margin-bottom: 16px; }\n\
";

thread_local! {
    static APP_PROVIDER: RefCell<Option<CssProvider>> = const { RefCell::new(None) };
}

pub fn load(_display: &gtk4::gdk::Display) {
    // Shared ecosystem stylesheet (loads the generated file or a rendered
    // fallback, and live-reloads when the palette changes).
    bread_theme::gtk::apply_shared();

    // bos-settings layout, layered on top at APPLICATION priority.
    APP_PROVIDER.with(|cell| bread_theme::gtk::apply_css(APP_CSS, cell));
}
