/*
 * PureCSS.com
 * https://purecss.com/squishy-buttons/
 * A button group where the pressed button grows and the others give way, with a spring from linear().
 */

/* a shrink-wrapped card pane would leave the group too narrow to squish */
.card-preview .demo-squishy-buttons {
	width: 280px;
}

.demo-squishy-buttons .sq-group {
	display: flex;
	gap: 6px;
	width: min(100%, 340px);
}

.demo-squishy-buttons .sq-item {
	flex: 1 1 0;
	min-width: 0;
	padding: .85rem .4rem;
	border: 1px solid var(--border);
	border-radius: 14px;
	font: inherit;
	font-size: .85rem;
	font-weight: 600;
	color: var(--text);
	background: var(--bg);
	cursor: pointer;
	transition: flex-grow .55s cubic-bezier(.34, 1.56, .64, 1), border-radius .3s;
	/* a spring written out as points: it passes the target, comes back and settles */
	transition-timing-function: linear(0, .907, 1.284, 1.081, .93, .962, 1.014, 1.014, .998, .996, 1);
}

.demo-squishy-buttons .sq-item:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* flex-grow is the whole trick: the siblings shrink without being told to */
.demo-squishy-buttons .sq-item:active {
	flex-grow: 1.7;
	border-radius: 22px;
	color: var(--bg);
	background: var(--accent);
	border-color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
	.demo-squishy-buttons .sq-item { transition: none; }
}

/* ── Variant: a segmented control that stays open ── */

.demo-squishy-buttons .sq-segmented input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
}

.demo-squishy-buttons .sq-segmented .sq-item {
	text-align: center;
}

/* only the checked item grows here, so a press on another one changes nothing until it lands */
.demo-squishy-buttons .sq-segmented .sq-item:active {
	flex-grow: 1;
	border-radius: 14px;
	color: var(--text);
	background: var(--bg);
	border-color: var(--border);
}

.demo-squishy-buttons .sq-segmented .sq-item:has(input:checked) {
	flex-grow: 1.7;
	border-radius: 22px;
	color: var(--bg);
	background: var(--accent);
	border-color: var(--accent);
}

.demo-squishy-buttons .sq-segmented .sq-item:has(input:focus-visible) {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
