<?php
/**
 * CSS vars logic - Scrollbar
 *
 * @package Multi
 */

if ( ! defined( 'ABSPATH' ) ) {
	die;
}
/**
 * Prepares css variables holding scrollbar properties
 */
function multimagazine_css_vars_scrollbar() {
	$css = '';

	$scrollbar_bg_color = get_theme_mod( 'multi_scrollbar_background_color', MULTIMAGAZINE_SCROLLBAR_BACKGROUND_COLOR );
	$css               .= '--scrollbar-background-color: ' . $scrollbar_bg_color . ";\n";

	$scrollbar_handle_color = get_theme_mod( 'multi_scrollbar_handle_color', MULTIMAGAZINE_SCROLLBAR_HANDLE_COLOR );
	if ( empty( $scrollbar_handle_color ) ) {
		$scrollbar_handle_color = 'var(--main-color)';
	}
	$css .= '--scrollbar-handle-color: ' . $scrollbar_handle_color . ";\n";

	$scrollbar_width = get_theme_mod( 'multi_scrollbar_width', MULTIMAGAZINE_SCROLLBAR_WIDTH );
	switch ( true ) {
		case absint( $scrollbar_width ) < 3:
			$scrollbar_width_name = 'none';
			break;
		case absint( $scrollbar_width ) >= 3 && absint( $scrollbar_width ) < 10:
			$scrollbar_width_name = 'thin';
			break;
		default:
			$scrollbar_width_name = 'auto';
	}
	if ( empty( $scrollbar_width ) ) {
		$scrollbar_width = '';
	} else {
		$scrollbar_width .= 'px';
	}
	$css .= '--scrollbar-width: ' . $scrollbar_width . ";\n";
	$css .= '--scrollbar-width-name: ' . $scrollbar_width_name . ";\n";
	return $css;
}
