// this is a common file for everything related to our new sandbox UI design

$ui-blue: #3e83eb;
$ui-blue-soft: rgba( 62, 131, 235, 0.14 );

// a row of a menu under the mouse, a stronger blue than the soft one of the lists
$ui-hover-fill: rgba( 62, 131, 235, 0.35 );
$ui-hover-border: rgba( 62, 131, 235, 0.68 );
$ui-hover-text: #56759e;

// text
$ui-text: #555555;
$ui-text-muted: #777777;
$ui-text-label: #666666;
$ui-text-on-gray: rgba( 255, 255, 255, 0.55 );

// big headings and lines drawn straight on the gray block of the menu
$ui-heading-on-gray: rgba( 255, 255, 255, 0.85 );
$ui-line-on-gray: rgba( 255, 255, 255, 0.24 );
$ui-subtext-on-gray: rgba( 255, 255, 255, 0.75 );

// controls inside a white section
$ui-control-border: #989898;
$ui-control-bg: #f3f3f3;
$ui-control-border-hover: #6f6f6f;
$ui-row-alt: rgba( 0, 0, 0, 0.05 );

// the dark fill behind the picture of a card or a spawn icon
$ui-tile-bg: rgba( 0, 0, 0, 0.16 );

// slider: the line and its ticks, and the thumb while hovered and dragged
$ui-slider-line: #8a8a8a;
$ui-slider-thumb-hover: #b0b0b0;
$ui-slider-thumb-pressed: #7d7d7d;

$ui-mono: "Inconsolata";

// text size in the tool settings and the controls in them
$ui-settings-font: 12px;

// the colors of the gray block and of the white section
$ui-block-top: rgba( 140, 140, 140, 0.66 );
$ui-block-bottom: rgba( 130, 130, 130, 0.66 );
$ui-block-border: rgba( 255, 255, 255, 0.28 );
$ui-section-top: rgba( 255, 255, 255, 0.90 );
$ui-section-bottom: rgba( 245, 245, 245, 0.80 );
$ui-section-border: rgba( 0, 0, 0, 0.51 );

// base gray block, all UI stuff is built on top of them
@mixin ui-block
{
	padding: 8px;
	border: 1px solid $ui-block-border;
	background-image: linear-gradient( to bottom, $ui-block-top, $ui-block-bottom );
	border-radius: 2px;
}

// lists, settings, tool list, etc..
@mixin ui-section
{
	color: $ui-text;
	border: 1px solid $ui-section-border;
	background-image: linear-gradient( to bottom, $ui-section-top, $ui-section-bottom );
	border-radius: 2px;
}

// scrollbar
@mixin ui-scroll
{
	scrollbar-width: 9px;
	scrollbar-color: $ui-blue #d0d0d0;
}

// for search boxes
@mixin ui-input
{
	height: 24px;
	min-width: 0px;
	padding: 0 6px;
	align-items: center;
	background-color: rgba( 255, 255, 255, 0.96 );
	border: 1px solid rgba( 0, 0, 0, 0.51 );
	border-radius: 2px;
	font-size: 12px;
	font-weight: 500;
	color: $ui-text;
}

// buttons
@mixin ui-button-face
{
	color: $ui-text;
	background-image: linear-gradient( to bottom, rgba(248, 248, 248, 0.9) 0%, rgba(248, 248, 248, 0.9) 46%, rgba( 230, 230, 230, 0.9 ) 54%, rgba( 230, 230, 230, 0.9 ) 100% );
	border: 1px solid rgba( 0, 0, 0, 0.33 );
	border-radius: 2px;
	cursor: pointer;

	&:hover
	{
		filter: brightness( 1.10 );
		sound-in: ui.hover;
	}

	&:active
	{
		transform: translateY( 1px );
		sound-in: ui.select;
	}

	&.disabled
	{
		opacity: 0.4;
		background-image: none;
		background-color: rgba( 0, 0, 0, 0.33 );
		pointer-events: none;
	}
}

@mixin ui-button
{
	height: 24px;
	padding: 0 10px;
	gap: 6px;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	font-family: $body-font;
	font-size: 12px;
	font-weight: 500;
	@include ui-button-face;
}

// separator
$ui-separator: rgba( 0, 0, 0, 0.12 );

// text entry
@mixin ui-text-entry
{
	@include ui-input;
	flex-direction: row;
	justify-content: flex-start;
	cursor: text;
	@include ui-focus-ring;

	.placeholder
	{
		opacity: 1;
		color: #a8a8a8;
	}

	.content-label
	{
		color: $ui-text;
	}
}

// the dark box of hints
@mixin ui-hint
{
	padding: 5px 15px;
	background-color: rgba( 46, 46, 46, 0.9 );
	border: 1px solid rgb( 43, 43, 43 );
	border-radius: 2px;
	color: rgb( 221, 221, 221 );
	opacity: 1;
	transition: opacity 0.04s ease;

	&:intro, &:outro
	{
		opacity: 0;
	}

	label
	{
		font-family: "Inter";
		font-size: 12px;
		font-weight: 500;
		max-width: 28vw;
	}
}

// white text on the blue fill, for the picked item of a list, dropdown or segmented control
@mixin ui-selected
{
	color: white;
	background-color: $ui-blue;
}

// rows you can pick, a soft blue under the mouse and the blue fill on the active one
@mixin ui-selectable
{
	cursor: pointer;
	border-radius: 2px;

	&:hover
	{
		background-color: $ui-blue-soft;
		sound-in: ui.hover;
	}

	&:active
	{
		sound-in: ui.select;
	}

	&.active
	{
		@include ui-selected;
	}
}

// blue border on the control that has the keyboard focus
@mixin ui-focus-ring
{
	&:focus
	{
		border-color: $ui-blue;
	}
}

// space above every section header except the first one in a sheet or page
$ui-section-gap: 20px;

// blue bar with a white title, on top of lists and settings panels
@mixin ui-title-bar
{
	flex-direction: row;
	align-items: center;
	flex-shrink: 0;
	height: 23px;
	padding: 0 10px;
	background-color: $ui-blue;
	color: white;
	font-size: 12px;
	font-weight: 800;
	border-radius: 2px 2px 0px 0px;
	text-transform: uppercase;
	white-space: nowrap;
}

// the big heading of a page or of a section, drawn on the gray block of the menu, like the name of a spawnlist
@mixin ui-display-heading
{
	font-size: 32px;
	font-weight: 700;
	color: $ui-heading-on-gray;
	text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.4);
	white-space: nowrap;
	text-overflow: ellipsis;
	overflow: hidden;
}

// grey uppercase text of group and section names
@mixin ui-heading-text
{
	font-size: $ui-settings-font;
	font-weight: 800;
	text-transform: uppercase;
	color: $ui-text-muted;
}

// the same group names in the dark menus
@mixin ui-heading-text-on-dark
{
	text-transform: uppercase;
	color: rgba( 255, 255, 255, 0.35 );
}

// a group name with a line under it, the first one of a sheet or page sits at the top and the others get $ui-section-gap above
@mixin ui-section-header
{
	flex-shrink: 0;
	margin: 4px 0px 6px 0px;
	padding-bottom: 3px;
	border-bottom: 1px solid $ui-separator;
	@include ui-heading-text;
}

// (unselected) menu tabs (buttons for spawnlist/entities/NPCs/etc..)
@mixin ui-tab
{
	flex-direction: row;
	align-items: center;
	justify-content: center;
	gap: 4px;
	height: 24px;
	padding: 0 10px;
	flex-shrink: 0;
	border-radius: 2px 2px 0px 0px;
	font-size: 13px;
	font-weight: 600;
	color: $ui-text-on-gray;
	background-color: #676767;
	border-top: 1px solid #464646;
	border-right: 1px solid #464646;
	cursor: pointer;
	white-space: nowrap;

	&:first-child
	{
		border-left: 1px solid #464646;
	}

	&:hover
	{
		color: white;
		background-color: #707070;
		sound-in: ui.hover;
	}

	&:active
	{
		sound-in: ui.select;
	}

	&.active
	{
		@include ui-tab-active;
	}
}

// selected menu tab
@mixin ui-tab-active
{
	height: 25px;
	padding-top: 1px;
	color: white;
	background-color: #878787;
	border: 1px solid $ui-block-border;
	border-bottom: 0px;
	pointer-events: none;
}

// the description strip that slides down from the top of a card on hover for UICardDescription
@mixin ui-card-description
{
	// description block (if available & hovered), parked above the visible area for animation
	.description
	{
		position: absolute;
		left: 0px;
		right: 0px;
		top: -60px;
		padding: 6px 8px;
		overflow: hidden;
		background-color: rgba( 255, 255, 255, 0.35 );
		color: white;
		font-size: 12px;
		font-weight: 600;
		line-height: 12px;
		pointer-events: none;
		transition: top 0.1s ease;

		.viewport
		{
			position: relative;
			width: 100%;
			height: 0px;
			overflow: hidden;
			mask-size: 100% 100%;
			mask-repeat: no-repeat;
			mask-mode: alpha;
		}

		.text
		{
			position: relative;
			width: 100%;
			flex-shrink: 0;
		}

		.sizer
		{
			position: absolute;
			left: 0px;
			right: 0px;
			top: 0px;
			opacity: 0;
			pointer-events: none;
		}
	}

	&:hover .description
	{
		top: 0px;
	}
}

// a card with a picture filling it, a white border under the mouse and a description that slides down over it
@mixin ui-card
{
	width: 100%;
	height: 100%;
	position: relative;
	overflow: hidden;
	border: 1px solid transparent;
	border-radius: 2px;
	background-color: $ui-tile-bg;
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
	font-family: $body-font;
	cursor: pointer;
	transition: border-color 0.1s ease;

	@include ui-card-description;

	&:hover
	{
		sound-in: ui.hover;
		border-color: white;
	}

	&:active
	{
		sound-in: ui.select;
	}
}

// slots in dupes menu, a card with the name (and the author's avatar) in a footer
@mixin ui-dupe-card
{
	@include ui-card;

	.footer
	{
		position: absolute;
		left: 0px;
		right: 0px;
		bottom: 0px;
		height: 36px;
		padding: 0 8px;
		flex-direction: row;
		align-items: center;
		gap: 6px;
		background-color: rgba( 0, 0, 0, 0.4 );
		transition: background-color 0.1s ease;

		.avatar
		{
			width: 24px;
			height: 24px;
			flex-shrink: 0;
			border-radius: 3px;
			background-position: center;
			background-size: cover;
		}

		.name
		{
			flex-grow: 1;
			flex-shrink: 1;
			min-width: 0px;
			color: white;
			font-size: 12px;
			font-weight: 700;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			transition: color 0.1s ease;
		}
	}

	&:hover .footer
	{
		background-color: white;

		.name
		{
			color: #444444;
		}
	}
}

// the picture of a spawn icon
@mixin ui-tile-thumb
{
	width: 100%;
	height: 100%;
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
}

// the white strip with the name at the bottom of a spawn icon
@mixin ui-tile-title
{
	position: absolute;
	left: 1px;
	right: 1px;
	bottom: 1px;
	height: 28px;
	padding: 0 6px;
	justify-content: center;
	align-items: center;
	background-color: white;
	color: black;
	font-family: $body-font;
	font-size: 11px;
	font-weight: 500;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

// handle for the slider
@mixin ui-slider-thumb
{
	width: 10px;
	height: 16px;
	background-color: #9b9b9b;
	border: 1px solid #6d6d6d;
	border-shape: polygon( 0% 0%, 100% 0%, 100% 62%, 50% 100%, 0% 62% );
}

// the plain number box next to a slider, an outline shows on hover and focus
@mixin ui-number-entry
{
	width: 100%;
	height: 22px;
	min-height: 22px;
	padding: 0px;
	justify-content: center;
	background-color: transparent;
	border: 1px solid transparent;
	border-radius: 0;
	font-family: "Inter";
	font-size: $ui-settings-font;
	font-weight: 500;
	color: $ui-text-label;

	&:hover
	{
		border-color: rgba( 0, 0, 0, 0.15 );
	}

	@include ui-focus-ring;
}

@mixin ui-footer-bar
{
	width: 100%;
	flex-shrink: 0;
	padding: 6px;
	border-top: 1px solid rgba( 0, 0, 0, 0.2 );
}
