/**
 * The Save / load button in the site header, and the dialog it opens.
 *
 * Its own file because it is the one piece of this plugin that belongs to neither engine.
 * The button is printed on every page that has a wheel OR dice on it - both remember what
 * the visitor changed, and both are worth being able to carry to another device - so
 * styling it inside wheel.css meant an unstyled button in the header of every dice page.
 *
 * Loaded alongside whichever engine the page needs. See MrWin_Wheel_Assets::enqueue().
 *
 * The class names keep the mrwin-wheel- prefix even on a dice page. They name the plugin
 * rather than the wheel, the markup that carries them is printed by one class for both, and
 * renaming them would be a rename in three files to say the same thing.
 */

/* ---------------------------------------------------------------- save and load */

.mrwin-wheel-tools-open {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border: 1px solid var( --border-color, #e2e2e2 );
	border-radius: var( --control-radius, 8px );
	background: transparent;
	color: var( --header-text, var( --text-color, #111111 ) );
	font: inherit;
	font-size: 0.85rem;
	cursor: pointer;
}

.mrwin-wheel-tools-open:hover {
	background: var( --header-hover-bg, rgba( 0, 0, 0, 0.06 ) );
	color: var( --header-hover-text, inherit );
}

/*
 * The header is tight and this is not the most important thing in it, so below the tablet
 * breakpoint the label goes and the arrows carry it alone.
 */
@media ( max-width: 782px ) {
	.mrwin-wheel-tools-label {
		display: none;
	}
}

.mrwin-wheel-tools {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba( 0, 0, 0, 0.55 );
}

.mrwin-wheel-tools[hidden] {
	display: none !important;
}

.mrwin-wheel-tools-box {
	position: relative;
	max-width: 460px;
	width: 100%;
	padding: 28px 24px;
	border-radius: var( --card-radius, 12px );
	background: var( --content-bg, #ffffff );
	color: var( --text-color, #111111 );
	box-shadow: 0 20px 60px rgba( 0, 0, 0, 0.35 );
}

.mrwin-wheel-tools-box h2 {
	margin: 0 0 8px;
	font-size: 1.15rem;
}

.mrwin-wheel-tools-close {
	position: absolute;
	top: 8px;
	right: 12px;
	border: 0;
	background: transparent;
	color: var( --text-color-light, #888888 );
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

.mrwin-wheel-tools-intro {
	margin: 0 0 18px;
	font-size: 0.9rem;
	color: var( --text-color-light, #666666 );
}

.mrwin-wheel-tools-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 12px;
}

.mrwin-wheel-tools-row input[ type='file' ] {
	flex: 1 1 180px;
	min-width: 0;
	font-size: 0.85rem;
}

.mrwin-wheel-tools-status {
	margin: 4px 0 0;
	min-height: 1.4em;
	font-size: 0.9rem;
	color: var( --text-color-light, #666666 );
}

/*
 * A failed import is the one message here that must not be missed - it is the difference
 * between "loaded" and "nothing happened".
 */
.mrwin-wheel-tools-status.is-bad {
	color: #c62828;
	font-weight: 600;
}

/* ---------------------------------------------------------------- demos in the article */

/*
 * The Save / load dialog, drawn open in the article by [wheel_demo show="tools"].
 *
 * The box without the page behind it: a shadow meant to lift a dialog off a dimmed page is
 * too heavy for a picture between two paragraphs, so it gets the border the wheel's panel
 * has instead.
 */
.mrwin-demo-tools {
	max-width: calc( 460px + 36px );
	margin: 16px auto 28px;
	pointer-events: none;
	user-select: none;
	/*
	 * A frame of its own, so a demo reads as a picture of the wheel rather than as a control
	 * that belongs to the article. The max-width grows by the padding, so what is inside stays
	 * the size the visitor knows it at.
	 */
	box-sizing: border-box;
	padding: 18px;
	border: 1px solid var( --border-color, #e0e0e0 );
	border-radius: var(--card-radius, 14px);
	background: var( --tint-panel, rgba( 0, 0, 0, 0.03 ) );
	box-shadow: var( --shadow-md, 0 2px 4px rgba( 0, 0, 0, 0.04 ), 0 6px 16px rgba( 0, 0, 0, 0.06 ) );
}

.mrwin-demo-tools .mrwin-wheel-tools-box {
	border: 1px solid var( --border-color, #e2e2e2 );
	box-shadow: none;
}

/*
 * Inside an article the theme styles every h2 and p, and those rules outrank the ones above
 * (one class and one element against one class). Put back what the dialog sets for itself.
 */
.entry-content .mrwin-demo-tools .mrwin-wheel-tools-box h2 {
	margin: 0 0 8px;
	padding: 0;
	border: 0;
	font-size: 1.15rem;
	font-weight: 700;
	line-height: 1.3;
}

.entry-content .mrwin-demo-tools .mrwin-wheel-tools-intro {
	margin: 0 0 18px;
}

.entry-content .mrwin-demo-tools .mrwin-wheel-tools-status {
	margin: 4px 0 0;
}

/*
 * The theme's Tiles layout: a demo in an article is an inset in the article's tile - no
 * outline, no shadow, the inset colour (--outer-bg inside a tile). Its corners already
 * follow the theme's Rounded Elements.
 */
body.site-layout-tiles .mrwin-demo-tools {
	border-color: transparent;
	box-shadow: none;
	background: var( --outer-bg, #f5f5f5 );
}
