@use "sass:map";
@use "@angular/material" as mat;
@use "reset";
@use "themes";
@use "components";
@use "global";
// Import scss lib components
@use "../lib";

// TODO(v15): As of v15 mat.legacy-core no longer includes default typography styles.
//  The following line adds:
//    1. Default typography styles for all components
//    2. Styles for typography hierarchy classes (e.g. .mat-headline-1)
//  If you specify typography styles for the components you use elsewhere, you should delete this line.
//  If you don't need the default component typographies but still want the hierarchy styles,
//  you can delete this line and instead use:
//    `@include mat.legacy-typography-hierarchy(mat.define-legacy-typography-config());`
@include mat.all-legacy-component-typographies();
@include mat.legacy-core();

$themeDefinitions: themes.define();
/*****************************
 * Get the different themes *
 *****************************/
$dark-theme: map.get($themeDefinitions, dark-theme);
$light-theme: map.get($themeDefinitions, light-theme);
/**********************************************************************************************
 * Get the corresponding color configuration (foreground here because we need the font colors)*
 **********************************************************************************************/
// Dark color config
$dark-color-config: mat.get-color-config($dark-theme);
$dark-foreground: map.get($dark-color-config, foreground);
// Light color config
$light-color-config: mat.get-color-config($light-theme);
$light-foreground: map.get($light-color-config, foreground);
// Body color
$dark-body-color: map.get($dark-foreground, text);
$light-body-color: map.get($light-foreground, text);

body {
	@include components.all-component-themes($dark-theme);
	@include components.all-component-typographies($dark-theme);
	@include lib.all-override-colors($dark-theme);

	background: map.get(map.get($dark-theme, background), background);
	color: $dark-body-color;

	&.light-theme {
		@include components.all-component-colors($light-theme);
		@include lib.all-override-colors($light-theme);

		background: map.get(map.get($light-theme, background), background);
		color: $light-body-color;
	}
}

// /!\ All SCSS files that need to access to themes' variables must be IMPORTED after the themes.define() call.
@import "classes";
