/*
 * Applet sizing + control styling.
 *
 * .applet-fit  — responsive wrapper. Set --applet-w and --applet-h on the
 *                element to its native pixel dimensions; the wrapper scales
 *                to 100% container width and preserves the aspect ratio.
 *
 * .applet-controls — overlay panel (slider + labels + buttons) positioned at
 *                    the bottom-center of an applet, dark background, orange-
 *                    bordered slider, small Reset-style button.
 */

.applet-fit {
	display: block;
	width: 100%;
	aspect-ratio: var(--applet-w) / var(--applet-h);
	margin: 0 auto 2em;
}
.applet-fit > * {
	display: block;
	width: 100%;
	height: 100%;
}
.applet-fit canvas {
	width: 100% !important;
	height: 100% !important;
	display: block;
}

.applet-controls {
	position: absolute;
	left: 50%;
	bottom: 14px;
	transform: translateX(-50%);
	width: auto !important;
	height: auto !important;
	display: flex;
	align-items: center;
	gap: 10px;
	z-index: 10;
	color: #fff;
	font-size: 12px;
	padding: 6px 12px;
	background: #000;
	border-radius: 6px;
}
.applet-controls b {
	color: #fff;
	font-weight: 700;
}
.applet-controls input[type=range] {
	-webkit-appearance: none;
	appearance: none;
	width: 200px;
	height: 10px;
	background: #1a1a1a;
	border: 2px solid #ff9600;
	border-radius: 0;
	margin: 0;
	padding: 0;
	outline: none;
}
.applet-controls input[type=range]::-webkit-slider-runnable-track {
	background: #1a1a1a;
	height: 100%;
	border: none;
}
.applet-controls input[type=range]::-moz-range-track {
	background: #1a1a1a;
	height: 100%;
	border: none;
}
.applet-controls input[type=range]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 8px;
	height: 14px;
	background: #ccc;
	border: 1px solid #555;
	border-radius: 2px;
	cursor: pointer;
	margin-top: -3px;
}
.applet-controls input[type=range]::-moz-range-thumb {
	width: 8px;
	height: 14px;
	background: #ccc;
	border: 1px solid #555;
	border-radius: 2px;
	cursor: pointer;
}
.applet-controls button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: #1a1a1a;
	color: #fff;
	border: 1px solid #ff9600;
	border-radius: 4px;
	padding: 3px 10px;
	height: 18px;
	font-size: 11px;
	font-weight: 600;
	font-family: inherit;
	line-height: 1;
	cursor: pointer;
	margin-left: 6px;
}
.applet-controls button:hover { background: #333; }

/* Controls pinned to the top instead of the bottom. Add the `top` class to the
   .applet-controls element. */
.applet-controls.top {
	top: 14px;
	bottom: auto;
}

/* Number input (matches the slider/button border style). */
.applet-controls input[type=number] {
	width: 56px;
	background: #1a1a1a;
	color: #fff;
	border: 1px solid #ff9600;
	border-radius: 3px;
	padding: 1px 3px;
	font: inherit;
	font-size: 11px;
}

/* Prevent labels and label bolds from wrapping mid-text. */
.applet-controls b {
	white-space: nowrap;
}
.applet-controls label {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	cursor: pointer;
	margin: 0;
	padding: 0;
	line-height: 1;
	font-weight: inherit;
	color: inherit;
	white-space: nowrap;
}
.applet-controls label b {
	line-height: 1;
	white-space: nowrap;
}

/* Custom checkbox styling — overrides the site-wide hidden-checkbox pattern in
   main.css (opacity:0 + z-index:-1) that relies on a sibling label's :before. */
.applet-controls input[type=checkbox] {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	display: inline-block;
	float: none;
	opacity: 1;
	z-index: auto;
	width: 16px;
	height: 16px;
	background: #1a1a1a;
	border: 1px solid #ff9600;
	border-radius: 3px;
	cursor: pointer;
	margin: 0;
	padding: 0;
	position: relative;
	flex: none;
	vertical-align: middle;
}
.applet-controls input[type=checkbox] + label,
.applet-controls label > input[type=checkbox] + b {
	padding: 0 !important;
}
.applet-controls input[type=checkbox] + label:before,
.applet-controls input[type=checkbox] + b:before {
	display: none !important;
	content: none !important;
}
.applet-controls input[type=checkbox]:checked {
	background: #ff9600;
}
.applet-controls input[type=checkbox]:checked::after {
	content: '';
	position: absolute;
	left: 4px;
	top: 0px;
	width: 4px;
	height: 9px;
	border: solid #1a1a1a;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

/* Parameter description table rendered below an applet. */
.applet-params {
	width: 100%;
	border-collapse: collapse;
	margin: 0 0 2em;
	font-size: 0.95em;
}
.applet-params th, .applet-params td {
	border: 1px solid #ddd;
	padding: 0.5em 0.75em;
	vertical-align: top;
	text-align: left;
}
.applet-params th {
	background: #f4f4f4;
	white-space: nowrap;
}
.applet-params td:first-child {
	font-weight: 600;
	white-space: nowrap;
	width: 1%;
}
