/* The customer site's light and dark themes, loaded after MCWS's vendored
   stylesheets (static/mcws/stylesheets/*, never edited) and css/site.css.
   The vendored sheets draw everything from the custom properties on :root
   (mattercad.css), whose values are the light theme; this sheet adds the
   few colours they hard-code as properties of its own and gives every one
   a dark value. Dark applies under data-theme="dark", and under
   data-theme="system" (the header's Match my system, the default) while
   the visitor's system prefers dark; data-theme="light" stays light
   whatever the system prefers (js/site-theme.js; the head script in
   site/_theme_head.html sets the attribute before the first paint). The
   accent colour a visitor picks (site_theme_colors.py) overrides the six
   accent properties from the head's own rules. The two dark
   blocks hold the same values: CSS can't share one block between a media
   query and a plain selector. Pictures and thumbnails keep their own
   colours. */

:root {
	color-scheme: light;
	/* Text on the accent and danger buttons. */
	--mc-on-accent: #FFFFFF;
	/* An accent button held down and the focus ring, as MatterCAD's editor
	   derives them (site_theme_colors.py's accent_pressed and
	   accent_focus), from whichever accent is in force: the head's rules
	   give exact values; these cover a page whose head script didn't run. */
	--mc-accent-pressed: color-mix(in srgb, var(--mc-accent) 82%, black);
	--mc-accent-focus: color-mix(in srgb, var(--mc-accent) 45%, transparent);
	--mc-on-danger: #FFFFFF;
	--mc-spinner-track: rgba(42, 55, 66, 0.2);
	--mc-dialog-shadow: 0 12px 40px rgba(27, 39, 51, 0.25);
	--mc-backdrop: rgba(27, 39, 51, 0.45);
	/* The staff lab panel under the design page (css/lab-panel.css). */
	--mc-lab: #7A5AF5;
	--mc-lab-alert: #B00020;
	--mc-code-bg: #F4F4F4;
}

@media (prefers-color-scheme: dark) {
	:root[data-theme="system"] {
		color-scheme: dark;
		--mc-accent: #2EB8CE;
		--mc-accent-hover: #5CCDDE;
		--mc-accent-soft: #15333A;
		--mc-ink: #EEF2F5;
		--mc-text: #D2D9DF;
		--mc-text-dim: #98A3AD;
		--mc-surface: #1B2127;
		--mc-bg: #12161A;
		--mc-border: #313A43;
		--mc-danger: #F07272;
		--mc-viewer-bg: #22272D;
		--mc-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
		--mc-on-accent: #08161A;
		--mc-on-danger: #2A0808;
		--mc-spinner-track: rgba(210, 217, 223, 0.22);
		--mc-dialog-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
		--mc-backdrop: rgba(0, 0, 0, 0.6);
		--mc-lab: #A994FF;
		--mc-lab-alert: #FF8A9A;
		--mc-code-bg: #232A31;
	}
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--mc-accent: #2EB8CE;
	--mc-accent-hover: #5CCDDE;
	--mc-accent-soft: #15333A;
	--mc-ink: #EEF2F5;
	--mc-text: #D2D9DF;
	--mc-text-dim: #98A3AD;
	--mc-surface: #1B2127;
	--mc-bg: #12161A;
	--mc-border: #313A43;
	--mc-danger: #F07272;
	--mc-viewer-bg: #22272D;
	--mc-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
	--mc-on-accent: #08161A;
	--mc-on-danger: #2A0808;
	--mc-spinner-track: rgba(210, 217, 223, 0.22);
	--mc-dialog-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
	--mc-backdrop: rgba(0, 0, 0, 0.6);
	--mc-lab: #A994FF;
	--mc-lab-alert: #FF8A9A;
	--mc-code-bg: #232A31;
}

/* The page behind everything, overscroll included. */
html,
body {
	background: var(--mc-bg);
}

body {
	color: var(--mc-text);
}

/* ---------- What the vendored sheets hard-code ---------- */

.mc-btn-primary,
.mc-btn-primary:hover {
	color: var(--mc-on-accent);
}

/* Held down, the editor's pressed accent. */
.mc-btn-primary:active {
	background: var(--mc-accent-pressed);
	border-color: var(--mc-accent-pressed);
}

.mc-btn-danger,
.mc-btn-danger:hover {
	color: var(--mc-on-danger);
}

/* Dialogs and fields otherwise take the browser's default white. */
dialog.mc-dialog {
	background: var(--mc-surface);
	box-shadow: var(--mc-dialog-shadow);
}

dialog.mc-dialog::backdrop {
	background: var(--mc-backdrop);
}

.mc-input {
	background-color: var(--mc-surface);
}

.mc-spinner {
	border-color: var(--mc-spinner-track);
	border-top-color: var(--mc-accent);
}

/* ---------- The header's theme menu ---------- */

/* A button showing the theme in force (its icon and name) opens the menu
   below it, right-aligned to it (js/site-theme-menu.js flips it above only
   when there's no room below, and keeps it on a phone's screen): Light,
   Dark and Match my system, then the accent colour's swatches. */

.mc-theme {
	position: relative;
	display: inline-flex;
}

.mc-theme[hidden],
.mc-theme-menu[hidden] {
	display: none;
}

.mc-theme-button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-family: var(--mc-font);
	font-size: 13.5px;
	color: var(--mc-text);
	background-color: var(--mc-surface);
	border: 1px solid var(--mc-border);
	border-radius: 6px;
	padding: 4px 8px;
	cursor: pointer;
	white-space: nowrap;
}

.mc-theme-button:hover,
.mc-theme-button[aria-expanded="true"] {
	border-color: var(--mc-accent);
}

.mc-theme-button:focus-visible,
.mc-theme-item:focus-visible,
.mc-theme-swatch:focus-visible {
	outline: 2px solid var(--mc-accent-focus);
	outline-offset: 2px;
}

.mc-theme-icon {
	display: block;
	flex: none;
	color: var(--mc-text-dim);
}

/* The button shows only the icon of the theme in force (the head script
   put it on <html> before the first paint). */
.mc-theme-button .mc-theme-icon {
	display: none;
}

:root[data-theme="light"] .mc-theme-button .mc-theme-icon[data-mode="light"],
:root[data-theme="dark"] .mc-theme-button .mc-theme-icon[data-mode="dark"],
:root[data-theme="system"] .mc-theme-button .mc-theme-icon[data-mode="system"] {
	display: block;
}

.mc-theme-chevron {
	flex: none;
	color: var(--mc-text-dim);
}

.mc-theme-menu {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	z-index: 60;
	width: max-content;
	max-width: calc(100vw - 16px);
	padding: 6px;
	background: var(--mc-surface);
	border: 1px solid var(--mc-border);
	border-radius: 10px;
	box-shadow: var(--mc-dialog-shadow);
	white-space: normal;
}

.mc-theme-modes {
	display: flex;
	flex-direction: column;
}

.mc-theme-item {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 8px 12px 8px 8px;
	font-family: var(--mc-font);
	font-size: 14px;
	color: var(--mc-text);
	text-align: left;
	background: transparent;
	border: 0;
	border-radius: 6px;
	cursor: pointer;
}

.mc-theme-item:hover,
.mc-theme-item:focus-visible {
	background: var(--mc-accent-soft);
}

.mc-theme-check {
	flex: none;
	visibility: hidden;
}

.mc-theme-item .mc-theme-check {
	color: var(--mc-accent);
}

.mc-theme-item[aria-checked="true"],
.mc-theme-item[aria-checked="true"] .mc-theme-icon {
	color: var(--mc-ink);
}

[aria-checked="true"] > .mc-theme-check {
	visibility: visible;
}

.mc-theme-divider {
	height: 1px;
	margin: 6px 4px;
	background: var(--mc-border);
}

.mc-theme-heading {
	padding: 4px 8px 6px;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--mc-text-dim);
}

.mc-theme-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 0 8px 6px;
}

.mc-theme-swatch {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	color: var(--mc-swatch-on);
	background: var(--mc-swatch);
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

.mc-theme-swatch:hover {
	box-shadow: 0 0 0 2px var(--mc-surface), 0 0 0 4px var(--mc-border);
}

.mc-theme-swatch[aria-checked="true"] {
	box-shadow: 0 0 0 2px var(--mc-surface), 0 0 0 4px var(--mc-swatch);
}

/* A phone: the menu's swatches stay one row of easy targets. */
@media (max-width: 360px) {
	.mc-theme-swatches {
		gap: 4px;
	}
	.mc-theme-swatch {
		width: 26px;
		height: 26px;
	}
}
