/*
 * vendored from dPanel (dev.dsub.net/dPanel), css/buttons.css verbatim.
 * TODO: once dPanel is consumable as a shared dependency, drop this copy.
 *
 * .group — a grid of .button elements.
 *
 * Column count: defaults to a responsive auto-fit (as many columns as
 * fit, each at least --button-min wide, with existing buttons stretching
 * to fill the row rather than leaving dangling empty tracks). For a grid
 * that needs an exact column count regardless of container width (e.g.
 * an 8-in/8-out device grid), set --cols directly, or use one of the
 * .cols3/.cols4/.cols8 shorthands below.
 *
 * Aspect ratio: set --ar on a .group (inherited by every .button inside)
 * or on an individual .button to override just that one. Defaults to 1
 * (square). e.g. style="--ar: 21/9"
 */
.group {
	--button-min: 2.5em;

	display: grid;
	grid-template-columns: repeat(var(--cols, auto-fit), minmax(var(--button-min), 1fr));
	align-items: start; /* let each button's own --ar set its height, instead of stretching to match the tallest item in its row */
	gap: 1px;
	border-radius: 6px;
	background-color: rgba(255, 255, 255, 0.21);

	/* buttons sit flush against this edge (no padding) so overflow clips
	   whichever button lands in a corner to match this radius — the
	   only "corner rounding" buttons need is this, nothing per-button */
	overflow: hidden;
	box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.21);
}

.group.cols3 { --cols: 3; }
.group.cols4 { --cols: 4; }
.group.cols8 { --cols: 8; }

/* how many grid columns a single button spans within its .group.
   Set --ar explicitly on a spanning button to approximate matching
   row siblings (e.g. --ar: 2 for a span2 beside 1-column --ar:1
   siblings). This is NOT pixel-exact — a spanning button's box
   includes the gap between the columns it covers, and grid track
   width itself isn't guaranteed to divide evenly across columns
   (both browser-dependent), so a small mismatch can show up,
   worse in some engines than others. align-self: stretch looks
   like the fix, but confirmed collapses a spanning button to
   near-zero height in Safari when it ends up alone in its row
   (aspect-ratio + stretch + nothing to stretch against) — avoid it.
   Unresolved: a real fix needs testing against actual Safari, which
   wasn't available when this was last touched. */
.button.span2 { grid-column: span 2; }
.button.span3 { grid-column: span 3; }
.button.span4 { grid-column: span 4; }


.button {
	position: relative;
	aspect-ratio: var(--ar, 1); /* --ar is intentionally not declared here — that would shadow inheritance from an ancestor .group; this fallback only kicks in when nothing set --ar at all */
	height: var(--button-height, auto); /* an explicit alternative to sizing height off --ar/width — e.g. a fixed row height that should stay constant no matter how many columns (and thus how wide each button is) share the row. When set, also set --ar: auto on the same scope (.group or .button): aspect-ratio doesn't just quietly step aside once height is otherwise definite — it still resolves the *other* dimension (width) to match, fighting the grid's own stretch sizing and collapsing every button to a fixed square with gaps between them, confirmed in dsub_3d_logo's palette. --ar: auto is the explicit "don't do that" the spec asks for. */

	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;

	font-family: Montserrat, sans-serif;
	font-size: 10px;
	line-height: 1.3em;
	color: rgba(0, 0, 0, 0.65);

	border: 2px solid rgba(255, 255, 255, 0.35);
	/* no border-radius here on purpose — .group's overflow:hidden clips
	   whichever button lands in a corner to its own radius instead */

	background: radial-gradient(ellipse at center, rgba(201, 199, 195, 0) 0%, rgba(201, 199, 195, 0.75) 100%), rgba(255, 255, 255, 0.85);

	cursor: pointer;

	-webkit-touch-callout: none;
	-webkit-user-select: none;
	user-select: none;

	--animate-before-opacity: 1;
	--animate-before-transition-duration: 1200ms;
}

.button.disabled {
	cursor: default;
	opacity: 0.4;
	pointer-events: none;
}

/* the visible label — rendered from data-label, no markup needed inside .button.
   Keep labels short: text-overflow:ellipsis does not reliably apply here (the
   label is centered, generated content inside a flex box, not a block's own
   inline overflow) — tried it, confirmed it clips to a confusing centered
   fragment ("eryLo" from "ThisIsAVeryLongLabel") instead of a clean ellipsis. */
.button::after {
	content: attr(data-label);
}


@keyframes fadeOutOpacity {
	0% { opacity: 1; }
	100% { opacity: 0; }
}
.fadeOutOpacity::before {
	animation: fadeOutOpacity 2s ease-out;
}


.button::before,
.button::after {
	position: absolute;
	width: 100%;
	height: 100%;

	display: flex;
	align-items: center;
	justify-content: center;
}
.button::before {
	content: '';

	opacity: var(--animate-before-opacity);
	transition-property: opacity;
	transition-duration: var(--animate-before-transition-duration);
	transition-timing-function: ease-out;
}

/* state color washes, on the ::before layer so the label stays crisp on top */
.button.on::before,
.button.orange::before,
.button.red::before,
.button.green::before,
.button.blue::before,
.button.white::before {
	top: -2px;
	left: -2px;
	border-style: solid;
	border-width: 2px;
}

.button.on::before {
	border-color: rgba(0, 0, 0, 0.1);
	box-shadow: 0 0 4px #FFE68E;
	background: radial-gradient(ellipse at center, rgba(255, 230, 142, 0.1) 0%, rgba(255, 230, 142, 0.6) 100%), rgba(255, 255, 255, 0.85);
}

.button.white::before {
	border-color: rgba(0, 0, 0, 0.1);
	box-shadow: 0 0 4px #FFFFFF;
	background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.6) 100%), rgba(255, 255, 255, 0.85);
}

.button.red::before {
	border-color: rgba(255, 255, 255, 0.3);
	box-shadow: 0 0 7px #F20000;
	background: radial-gradient(ellipse at center, rgba(242, 0, 0, 0.2) 0%, rgba(242, 0, 0, 0.66) 100%), rgba(255, 255, 255, 0.85);
}

.button.green::before {
	border-color: rgba(255, 255, 255, 0.3);
	box-shadow: 0 0 7px #00F200;
	background: radial-gradient(ellipse at center, rgba(0, 239, 19, 0.2) 0%, rgba(0, 239, 19, 0.66) 100%), rgba(255, 255, 255, 0.85);
}

.button.blue::before {
	border-color: rgba(255, 255, 255, 0.3);
	box-shadow: 0 0 7px #00b2f2;
	background: radial-gradient(ellipse at center, rgba(0, 177, 242, 0.2), rgba(0, 111, 242, 0.66)), rgba(255, 255, 255, 0.85);
}

.button.orange::before {
	border-color: rgba(255, 255, 255, 0.3);
	box-shadow: 0 0 7px #ED9200;
	background: radial-gradient(ellipse at center, rgba(237, 146, 0, 0.2) 0%, rgba(237, 146, 0, 0.66) 100%), rgba(255, 255, 255, 0.85);
}


/*
 * .led — a small round indicator light, not clickable.
 * Colors match .vfd's palette: red/green/blue/orange/white.
 * Toggle the .on class to light it up.
 */
.led {
	--led-color: 250, 47, 22; /* red, default */

	display: inline-block;
	margin: 0.3em 0 0.6em;
	width: 1em;
	height: 1em;
	border-radius: 50%;

	background: radial-gradient(rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.75) 56%, #000000 72%);
	box-shadow: 1px 1px 2px -1px rgba(255, 255, 255, 0.5);
}
.led.on {
	background: radial-gradient(rgba(var(--led-color), 1) 0%, rgba(var(--led-color), 0.85) 33%, rgba(var(--led-color), 0.35) 56%, #000000 72%);
	box-shadow: 0 0 10px 5px rgba(var(--led-color), 0.6), 1px 1px 2px -1px rgba(255, 255, 255, 0.5);
}

.led.red    { --led-color: 250, 47, 22; }
.led.green  { --led-color: 4, 245, 151; }
.led.blue   { --led-color: 98, 215, 234; }
.led.orange { --led-color: 237, 146, 0; }
.led.white  { --led-color: 255, 255, 255; }

.led::after {
	margin-left: 1.35em;
	color: rgb(255, 255, 255);
	content: attr(data-label);
}
.led + .label {
	margin-left: 0.5em;
}
