/* ============================================================
 * Button group — static adapter for the proposed axismundi/button-group.
 *
 * No such block exists yet, and this file does not pretend otherwise. What it
 * renders is the contract a block would have to emit, drawn from the two
 * connected groups this repository already ships:
 *
 *   axismundi/theme-switcher   role="group" + button[aria-pressed]   toggle
 *   axismundi-activities       <nav> + a[aria-current="page"]        navigation
 *
 * Both wear connected geometry; neither is the other's semantics. That split is
 * the point: the group owns geometry and selection arrangement, and whatever
 * control uses it owns what selection means.
 *
 * M3: "Button groups have no color properties." Standard groups contain real
 * Button and Icon button children, so their Button styles stay on those
 * children. A connected group uses the Button Filled toggle roles as a fixed
 * default; Figma exposes no connected-group colour property.
 * ============================================================ */

/* --- The group ----------------------------------------------- */

/* Standard hugs its buttons; connected spans its container and stretches the
 * segments to fill it. That is M3's own distinction, and it is why only the
 * connected rule below touches flex-grow on a segment. */
.wp-block-axismundi-button-group {
	/* inline-flex, because M3 says the standard group "hugs the width of the
	 * buttons inside". Connected overrides this below: it is the variant that
	 * spans its container. */
	display: inline-flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: var(--ax-group-padding, var(--md-sys-measurement-space150));
	margin: 0;
	padding: 0;
	border: 0;
	list-style: none;
}

/* --- Size: the one axis a group cannot infer ------------------ */

/* Inner padding is a group measurement that varies by button size, and CSS
 * gives a container no way to read its children. So the group declares the
 * size, and segments inherit it through the same --ax-button-* properties a
 * standalone button reads. */
.wp-block-axismundi-button-group[data-size="xsmall"] {
	/* 18dp, and there is no 18 on the M3 spacing scale - it runs 14, 16, 20.
	 * M3 publishes this as a component measurement, and it is deliberately
	 * generous: XS and S carry the larger between-space so the 48dp target
	 * survives a 32dp container. */
	--ax-group-padding: 18px;
	--ax-group-inner-corner: var(--md-sys-shape-corner-value-small);
	--ax-group-pressed-inner-corner: var(--md-sys-shape-corner-value-extra-small);
	--ax-button-height: 32px;
	--ax-button-space: var(--md-sys-measurement-space150);
	--ax-button-icon-size: 20px;
	--ax-button-icon-gap: var(--md-sys-measurement-space50);
	--ax-button-shape: 16px;
	--ax-button-pressed-shape: var(--md-sys-shape-corner-value-small);
	--ax-button-label-size: 14px;
	--ax-button-label-line-height: 20px;
}

.wp-block-axismundi-button-group[data-size="small"] {
	--ax-group-padding: var(--md-sys-measurement-space150);
	--ax-group-inner-corner: var(--md-sys-shape-corner-value-small);
	--ax-group-pressed-inner-corner: var(--md-sys-shape-corner-value-extra-small);
}

.wp-block-axismundi-button-group[data-size="medium"] {
	--ax-group-padding: var(--md-sys-measurement-space100);
	--ax-group-inner-corner: var(--md-sys-shape-corner-value-small);
	--ax-group-pressed-inner-corner: var(--md-sys-shape-corner-value-extra-small);
	--ax-button-height: 56px;
	--ax-button-space: var(--md-sys-measurement-space300);
	--ax-button-icon-size: 24px;
	--ax-button-icon-gap: var(--md-sys-measurement-space100);
	--ax-button-shape: 28px;
	--ax-button-pressed-shape: var(--md-sys-shape-corner-value-medium);
	--ax-button-label-size: 16px;
	--ax-button-label-line-height: 24px;
}

.wp-block-axismundi-button-group[data-size="large"] {
	--ax-group-padding: var(--md-sys-measurement-space100);
	--ax-group-inner-corner: var(--md-sys-shape-corner-value-large);
	--ax-group-pressed-inner-corner: var(--md-sys-shape-corner-value-medium);
	--ax-button-height: 96px;
	--ax-button-space: var(--md-sys-measurement-space600);
	--ax-button-icon-size: 32px;
	--ax-button-icon-gap: var(--md-sys-measurement-space150);
	--ax-button-shape: 48px;
	--ax-button-pressed-shape: var(--md-sys-shape-corner-value-large);
	--ax-button-label-size: 24px;
	--ax-button-label-weight: 400;
	--ax-button-label-line-height: 32px;
}

.wp-block-axismundi-button-group[data-size="xlarge"] {
	--ax-group-padding: var(--md-sys-measurement-space100);
	--ax-group-inner-corner: var(--md-sys-shape-corner-value-large-increased);
	--ax-group-pressed-inner-corner: var(--md-sys-shape-corner-value-large);
	--ax-button-height: 136px;
	--ax-button-space: var(--md-sys-measurement-space800);
	--ax-button-icon-size: 40px;
	--ax-button-icon-gap: var(--md-sys-measurement-space200);
	--ax-button-shape: 68px;
	--ax-button-pressed-shape: var(--md-sys-shape-corner-value-large);
	--ax-button-label-size: 32px;
	--ax-button-label-weight: 400;
	--ax-button-label-line-height: 40px;
}


/* --- A segment may overrule the group's size -------------------- */

/* Standard only, and the Figma property sets are why. A standard group's
 * children are instances of Button and Icon button - components that exist on
 * their own - and each carries its own Type, Size, Width and State. A connected
 * group's children are Segments, which carry Selected, State, Show icon, Icon,
 * Icon(selected), Show label text and Label text, and no Type, Size or Color at
 * all. The group owns those. So a segment cannot overrule a size it does not
 * have, and this override is scoped to standard.
 *
 * Within standard, M3 says the members follow by default - "all buttons in a
 * standard group should be the same size" - and leaves the exception open:
 * "Only use multiple sizes in a group for hero moments." A custom property set
 * on the element beats one inherited from its parent, which is the whole
 * mechanism; there is no cascade trick in it.
 *
 * The container height needs no rule at all. The group is a flex row with
 * align-items: center, so it is already as tall as its tallest member - which
 * is what M3 means by "Button groups adapt to the height of the buttons
 * inside".
 *
 * Between-space does NOT follow the override. It stays the group's, because it
 * is a group token and because a hero button is an exception inside a group
 * rather than a new group size. That has a cost worth knowing: XS and S carry a
 * larger between-space precisely so their 48dp target survives a 32dp
 * container, and M3 says not to reduce it. Drop an XS segment into a group
 * declared M and it gets M's 8dp neighbours, so the target the larger padding
 * was buying is gone. Mixing down is the case to check; mixing up is free. */

.wp-block-axismundi-button-group[data-variant="standard"] > .wp-block-axismundi-button-group__item[data-size="xsmall"] {
	--ax-button-height: 32px;
	--ax-button-space: var(--md-sys-measurement-space150);
	--ax-button-icon-size: 20px;
	--ax-button-icon-gap: var(--md-sys-measurement-space50);
	--ax-button-shape: 16px;
	--ax-button-pressed-shape: var(--md-sys-shape-corner-value-small);
	--ax-button-label-size: 14px;
	--ax-button-label-weight: 500;
	--ax-button-label-line-height: 20px;
}

.wp-block-axismundi-button-group[data-variant="standard"] > .wp-block-axismundi-button-group__item[data-size="small"] {
	--ax-button-height: 40px;
	--ax-button-space: var(--md-sys-measurement-space200);
	--ax-button-icon-size: 20px;
	--ax-button-icon-gap: var(--md-sys-measurement-space100);
	--ax-button-shape: 20px;
	--ax-button-pressed-shape: var(--md-sys-shape-corner-value-small);
	--ax-button-label-size: 14px;
	--ax-button-label-weight: 500;
	--ax-button-label-line-height: 20px;
}

.wp-block-axismundi-button-group[data-variant="standard"] > .wp-block-axismundi-button-group__item[data-size="medium"] {
	--ax-button-height: 56px;
	--ax-button-space: var(--md-sys-measurement-space300);
	--ax-button-icon-size: 24px;
	--ax-button-icon-gap: var(--md-sys-measurement-space100);
	--ax-button-shape: 28px;
	--ax-button-pressed-shape: var(--md-sys-shape-corner-value-medium);
	--ax-button-label-size: 16px;
	--ax-button-label-weight: 500;
	--ax-button-label-line-height: 24px;
}

.wp-block-axismundi-button-group[data-variant="standard"] > .wp-block-axismundi-button-group__item[data-size="large"] {
	--ax-button-height: 96px;
	--ax-button-space: var(--md-sys-measurement-space600);
	--ax-button-icon-size: 32px;
	--ax-button-icon-gap: var(--md-sys-measurement-space150);
	--ax-button-shape: 48px;
	--ax-button-pressed-shape: var(--md-sys-shape-corner-value-large);
	--ax-button-label-size: 24px;
	--ax-button-label-weight: 400;
	--ax-button-label-line-height: 32px;
}

.wp-block-axismundi-button-group[data-variant="standard"] > .wp-block-axismundi-button-group__item[data-size="xlarge"] {
	--ax-button-height: 136px;
	--ax-button-space: var(--md-sys-measurement-space800);
	--ax-button-icon-size: 40px;
	--ax-button-icon-gap: var(--md-sys-measurement-space200);
	--ax-button-shape: 68px;
	--ax-button-pressed-shape: var(--md-sys-shape-corner-value-large);
	--ax-button-label-size: 32px;
	--ax-button-label-weight: 400;
	--ax-button-label-line-height: 40px;
}

/* --- Icon and label are inverted here -------------------------- */

/* Button and Connected group hold the pair the opposite way round. Button has
 * `Label text` plus a `Show icon` boolean; a Connected Segment owns its icon,
 * label, and `Show label text` independently. Theme Switcher's `showLabels`
 * is a separate Axismundi-wide display preference, not this M3 property.
 *
 * The label element is always rendered. Hiding it moves it out of sight and
 * leaves it in the accessibility tree, which is what makes an icon-only
 * segment safe: its accessible name has one source whether or not you can see
 * it. The plugin adds this class server-side, so the specimens carry it in the
 * markup rather than having the group hide the span with a selector. */
.wp-block-axismundi-button-group__item .screen-reader-text,
.wp-block-button__link .screen-reader-text {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* --- Icon(selected): the FILL axis, not a second icon ---------- */

/* Figma gives a segment two icon properties, `Icon` and `Icon(selected)` -
 * stars and stars_filled. That is Figma describing the result, because a static
 * file has to swap one symbol for another to show a filled one.
 *
 * Material Symbols is a variable font and FILL is one of its axes, so the web
 * changes the axis instead of the glyph. The theme registers it with @property
 * (icons.css), which is what lets it interpolate rather than snap, and
 * axismundi/theme-switcher already drives it exactly this way. One icon name in
 * the markup, two rendered states.
 *
 * Hover fills as well as selected, and only where a pointer hovers. Selected
 * stays ungated: gating both would leave the chosen segment unfilled on a
 * touchscreen, which is the one place the fill is doing real work. */
.wp-block-axismundi-button-group__item[aria-pressed="true"] .material-symbols-outlined,
.wp-block-axismundi-button-group__item[aria-current="page"] .material-symbols-outlined {
	--md-icon-fill: 1;
}

@media (hover: hover) {
	.wp-block-axismundi-button-group__item:hover .material-symbols-outlined {
		--md-icon-fill: 1;
	}
}

/* --- Segment label visibility ---------------------------------- */

/* Figma puts `Show label text` on each segment, and it has no choice: component
 * properties there are per-instance. M3's own layout list shows the mixed case
 * too - "Label buttons and icon buttons" is one group holding both.
 *
 * `data-labels` therefore belongs on each segment. */
.wp-block-axismundi-button-group__item[data-labels="hidden"] {
	padding-inline: 0;
}

.wp-block-axismundi-button-group[data-variant="standard"] > .wp-block-axismundi-button-group__item[data-labels="hidden"] {
	inline-size: var(--ax-button-height, 40px);
}

.wp-block-axismundi-button-group__item[data-labels="visible"] {
	padding-inline: var(--ax-button-space, var(--md-sys-measurement-space200));
	inline-size: auto;
}

/* --- The group declares a colour its members may overrule ------ */

/* Figma's standard group carries Color alongside Type and Size, and its worked
 * example is a group set to Filled holding a tonal icon button - the child
 * overruling the group, exactly as it overrules size. The enum is Filled,
 * Tonal and Outline; Elevated is not offered here, and Text cannot be, having
 * no container to treat.
 *
 * The two variants need different variables, and the reason is what each child
 * is. A standard group holds real Buttons, which read --ax-button-container.
 * A connected group holds Segments, which are toggles and read the published
 * toggle pair - so setting the plain roles there changed a variable nothing
 * was looking at, and the segments kept their default colour. Measured before
 * the split: --ax-button-container resolved to transparent on every segment
 * while the painted background stayed surface-container.
 *
 * Standard: the plain roles, read as a fallback by components/button.css. */
.wp-block-buttons[data-color="tonal"] {
	--ax-group-color-container: var(--md-sys-color-secondary-container);
	--ax-group-color-content: var(--md-sys-color-on-secondary-container);
}

.wp-block-buttons[data-color="outlined"] {
	--ax-group-color-container: transparent;
	--ax-group-color-content: var(--md-sys-color-on-surface-variant);
}

/* Elevated and Text are outside M3's group enum, and the editor would still
 * offer them: the dropdown lists what the theme registers for core/button, not
 * what a group should pick. Implemented so the specimen can show what happens,
 * with the constraint stated beside it rather than hidden by omission - Text in
 * particular has no container, which is the thing a group needs to paint a
 * seam and a selection on. */
.wp-block-buttons[data-color="elevated"] {
	--ax-group-color-container: var(--md-sys-color-surface-container-low);
	--ax-group-color-content: var(--md-sys-color-primary);
}

.wp-block-buttons[data-color="elevated"] > .wp-block-button:not([class*="is-style-"]) > .wp-block-button__link {
	box-shadow: var(--md-sys-elevation-shadow-level1);
}

.wp-block-buttons[data-color="text"] {
	--ax-group-color-container: transparent;
	--ax-group-color-content: var(--md-sys-color-primary);
}

/* Outlined is the one enum value that is not only a pair of roles: it also
 * needs the outline drawn. Scoped to members that have not chosen a style of
 * their own, so a tonal child inside an outlined group does not gain a border
 * it never asked for. */
.wp-block-buttons[data-color="outlined"] > .wp-block-button:not([class*="is-style-"]) > .wp-block-button__link {
	border: var(--ax-button-outline-width, 1px) solid var(--md-sys-color-outline-variant);
}

/* A standard group may also hold Icon buttons, and M3 says so itself when it
 * rules one of them out: "Avoid using standard icon buttons ... as they have
 * no container treatment." Figma's own standard child is an "Icon button
 * togglable - tonal". Two consequences follow.
 *
 * First, a toggle reads M3's published toggle pair rather than the plain
 * roles, so the group has to declare both. Setting only the plain pair left
 * every togglable child filled inside a tonal group - the same mistake the
 * connected split already fixed once, and the reason to state it twice.
 *
 * Second, outlined needs its outline drawn on the child, and the icon button
 * has its own width token: 1px at XS/S, 2px at L, 3px at XL. Scoped to
 * children that have not chosen a style, so a tonal icon button in an outlined
 * group does not gain a border it never asked for. */
.wp-block-buttons[data-color="tonal"] {
	--ax-button-toggle-unselected-container: var(--md-sys-color-secondary-container);
	--ax-button-toggle-unselected-content: var(--md-sys-color-on-secondary-container);
	--ax-button-toggle-selected-container: var(--md-sys-color-secondary);
	--ax-button-toggle-selected-content: var(--md-sys-color-on-secondary);
}

.wp-block-buttons[data-color="outlined"] {
	--ax-button-toggle-unselected-container: transparent;
	--ax-button-toggle-unselected-content: var(--md-sys-color-on-surface-variant);
	--ax-button-toggle-selected-container: var(--md-sys-color-inverse-surface);
	--ax-button-toggle-selected-content: var(--md-sys-color-inverse-on-surface);
}

.wp-block-buttons[data-color="outlined"] > .wp-block-axismundi-icon-button:not([class*="is-style-"]) {
	border: var(--ax-icon-button-outline-width, 1px) solid var(--md-sys-color-outline-variant);
}

/* Connected: the toggle pair, which is M3's own table for a selected and an
 * unselected segment. Filled is the default and needs no rule. */
.wp-block-axismundi-button-group[data-color="tonal"] {
	--ax-button-toggle-unselected-container: var(--md-sys-color-secondary-container);
	--ax-button-toggle-unselected-content: var(--md-sys-color-on-secondary-container);
	--ax-button-toggle-selected-container: var(--md-sys-color-secondary);
	--ax-button-toggle-selected-content: var(--md-sys-color-on-secondary);
}

/* Outlined's unselected container is invisible - M3 names outline-variant for
 * the outline, not for a fill - and its selected pair inverts the surface. */
.wp-block-axismundi-button-group[data-color="outlined"] {
	--ax-button-toggle-unselected-container: transparent;
	--ax-button-toggle-unselected-content: var(--md-sys-color-on-surface-variant);
	--ax-button-toggle-selected-container: var(--md-sys-color-inverse-surface);
	--ax-button-toggle-selected-content: var(--md-sys-color-inverse-on-surface);
}

.wp-block-axismundi-button-group[data-color="outlined"] > .wp-block-axismundi-button-group__item:not([aria-pressed="true"]):not([aria-current="page"]) {
	box-shadow: inset 0 0 0 var(--ax-button-outline-width, 1px) var(--md-sys-color-outline-variant);
}

/* --- The selected child ---------------------------------------- */

/* The demo's selection ring, on whichever kind of child is selected. An icon
 * button is its own flex item and has no `.wp-block-button` wrapper, because a
 * sibling block renders its own root - so the ring cannot key off the wrapper
 * class the way it did while every child was a Button. */
[data-group-child][data-group-selected="true"] {
	outline: 2px solid var(--md-sys-color-primary);
	outline-offset: 3px;
}

/* The radius belongs to the wrapper alone. A `.wp-block-button` is a plain
 * box, so without one the ring is a rectangle around a rounded control. An
 * icon button IS the control, and the same declaration overwrote the shape the
 * component publishes - measured 8px where Small round is 20px, and the
 * selected morph gone with it. A demo affordance must not repaint the
 * specimen it points at. */
.wp-block-button[data-group-selected="true"] {
	border-radius: var(--md-sys-shape-corner-value-small);
}

.sg-button-group-playground__child {
	display: grid;
	gap: var(--md-sys-measurement-space150);
	margin: 0;
	padding: var(--md-sys-measurement-space200);
	border: 1px solid var(--md-sys-color-outline-variant);
	border-radius: var(--md-sys-shape-corner-value-small);
}

.sg-button-group-playground__child legend {
	padding-inline: var(--md-sys-measurement-space100);
	font-size: var(--md-sys-typescale-label-medium-size);
	color: var(--md-sys-color-on-surface-variant);
}

.sg-button-group-playground__inline {
	display: flex;
	gap: var(--md-sys-measurement-space100);
	align-items: center;
}

/* --- Connected: 2dp at every size ----------------------------- */

/* One padding for all five sizes, which M3 gives as a consistency rule rather
 * than a derived value: "For all connected button groups, use 2dp padding.
 * This provides visual consistency at scale." */
.wp-block-axismundi-button-group[data-variant="connected"] {
	--ax-group-padding: var(--md-sys-measurement-space25);
	display: flex;
	inline-size: 100%;
}

.wp-block-axismundi-button-group[data-variant="connected"] > .wp-block-axismundi-button-group__item {
	flex: 1 1 0;
	border-radius: var(--ax-group-inner-corner, var(--md-sys-shape-corner-value-small));
}

/* Standard segments keep the button's own shape; only connected hands its
 * segments a group-owned corner. M3 publishes no shape token for the standard
 * group for exactly that reason. */
.wp-block-axismundi-button-group[data-variant="standard"] > .wp-block-axismundi-button-group__item {
	--ax-group-selected-corner: var(--ax-button-pressed-shape, var(--md-sys-shape-corner-value-small));
}

/* Only the two ends are pills. Logical longhands: a group reverses in RTL and
 * a radius shorthand cannot. */
.wp-block-axismundi-button-group[data-variant="connected"]:not([data-connected-edges]) > .wp-block-axismundi-button-group__item:first-of-type,
.wp-block-axismundi-button-group[data-variant="connected"][data-connected-edges] > .wp-block-axismundi-button-group__item[data-connected-edge="first"] {
	border-start-start-radius: var(--ax-button-shape, 20px);
	border-end-start-radius: var(--ax-button-shape, 20px);
}

.wp-block-axismundi-button-group[data-variant="connected"]:not([data-connected-edges]) > .wp-block-axismundi-button-group__item:last-of-type,
.wp-block-axismundi-button-group[data-variant="connected"][data-connected-edges] > .wp-block-axismundi-button-group__item[data-connected-edge="last"] {
	border-start-end-radius: var(--ax-button-shape, 20px);
	border-end-end-radius: var(--ax-button-shape, 20px);
}

/* Figma's square type changes the group-owned outer corners. The mapping is
 * the same Button contract: XS/S medium, M large, L/XL extra-large. */
.wp-block-axismundi-button-group[data-variant="connected"][data-shape="square"][data-size="xsmall"],
.wp-block-axismundi-button-group[data-variant="connected"][data-shape="square"][data-size="small"] {
	--ax-button-shape: var(--md-sys-shape-corner-value-medium);
}

.wp-block-axismundi-button-group[data-variant="connected"][data-shape="square"][data-size="medium"] {
	--ax-button-shape: var(--md-sys-shape-corner-value-large);
}

.wp-block-axismundi-button-group[data-variant="connected"][data-shape="square"][data-size="large"],
.wp-block-axismundi-button-group[data-variant="connected"][data-shape="square"][data-size="xlarge"] {
	--ax-button-shape: var(--md-sys-shape-corner-value-extra-large);
}

/* Pressed state changes only the inner corners. The outer edge remains a
 * capsule, including when the first or last segment is already selected. */
.wp-block-axismundi-button-group[data-variant="connected"]:not([data-connected-edges]) > .wp-block-axismundi-button-group__item:first-of-type:active,
.wp-block-axismundi-button-group[data-variant="connected"][data-connected-edges] > .wp-block-axismundi-button-group__item[data-connected-edge="first"]:active {
	border-start-start-radius: calc(var(--ax-button-height, 40px) / 2);
	border-end-start-radius: calc(var(--ax-button-height, 40px) / 2);
}

.wp-block-axismundi-button-group[data-variant="connected"]:not([data-connected-edges]) > .wp-block-axismundi-button-group__item:last-of-type:active,
.wp-block-axismundi-button-group[data-variant="connected"][data-connected-edges] > .wp-block-axismundi-button-group__item[data-connected-edge="last"]:active {
	border-start-end-radius: calc(var(--ax-button-height, 40px) / 2);
	border-end-end-radius: calc(var(--ax-button-height, 40px) / 2);
}

/* --- Standard: adjacent buttons respond ----------------------- */

/* M3 gives this to standard only: "Connected button groups don't add any
 * interaction between buttons when selected or activated."
 *
 * What is implemented here is the shape morph. The width half is not, and the
 * reason is worth recording. M3's widen keeps the group's total width and
 * redistributes it - the selected button grows about 15% and its neighbours
 * compress to pay for it. flex-grow cannot express that against a container
 * that hugs its content: measured, `flex-grow: 1.15` on a hugging group handed
 * the selected segment every spare pixel and rendered it 11.3x its neighbours.
 * Doing it faithfully means measuring the rest widths first, which is a
 * script, not a stylesheet. The page says so rather than approximating. */

/* --- The segment --------------------------------------------- */

/* Reads the same --ax-button-* contract components/button.css defines, so a
 * segment and a standalone button cannot drift apart in height, type, spacing,
 * or the fixed Filled-toggle colour roles. A Segment has no independent colour
 * selector; that is part of its contract rather than an omitted feature. */
.wp-block-axismundi-button-group__item {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	gap: var(--ax-button-icon-gap, var(--md-sys-measurement-space100));
	position: relative;
	block-size: var(--ax-button-height, 40px);
	padding-inline: var(--ax-button-space, var(--md-sys-measurement-space200));
	border: 0;
	border-radius: var(--ax-button-shape, 20px);
	background-color: var(--ax-button-toggle-unselected-container);
	color: var(--ax-button-toggle-unselected-content);
	font-family: var(--md-ref-typeface-brand);
	font-size: var(--ax-button-label-size, 14px);
	font-weight: var(--ax-button-label-weight, 500);
	letter-spacing: var(--ax-button-label-tracking, 0.1px);
	line-height: var(--ax-button-label-line-height, 20px);
	white-space: nowrap;
	text-decoration: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition:
		border-radius var(--md-sys-motion-curve-fast-spatial-duration) var(--md-sys-motion-curve-fast-spatial),
		flex-grow var(--md-sys-motion-curve-fast-spatial-duration) var(--md-sys-motion-curve-fast-spatial),
		background-color var(--md-sys-motion-curve-fast-effects-duration) var(--md-sys-motion-curve-fast-effects);
}

/* `hidden` is structural state in the Connected editor model. The component
 * sets display for visible segments, so state must explicitly win over the
 * author rule instead of relying on the user-agent stylesheet. */
.wp-block-axismundi-button-group__item[hidden] {
	display: none !important;
}

/* Pattern A keeps native radio semantics. The visible label is its sibling,
 * never a replacement element: this preserves arrow-key selection, form
 * reset, and the shared name contract without a specimen-only controller. */
.wp-block-axismundi-button-group__input {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-axismundi-button-group__item {
		transition: none;
	}
}

/* XS and S carry a 48dp target whatever the container measures, and a target is
 * not a container: widening the box would contradict the sizes M3 publishes.
 * The same overlay the Icon button page arrived at, for the same reason - it
 * takes no space, so nothing in the row moves, and max() lets one rule serve
 * every size because from Medium up the segment already exceeds 48. */
.wp-block-axismundi-button-group__item::after {
	content: "";
	position: absolute;
	inset-inline-start: 50%;
	inset-block-start: 50%;
	inline-size: max(100%, 48px);
	block-size: max(100%, 48px);
	translate: -50% -50%;
}

.wp-block-axismundi-button-group__item > .wp-block-button__icon {
	flex: 0 0 var(--ax-button-icon-size, 20px);
	inline-size: var(--ax-button-icon-size, 20px);
	block-size: var(--ax-button-icon-size, 20px);
	font-size: var(--ax-button-icon-size, 20px);
	line-height: 1;
}

/* Selected. aria-pressed and aria-current are both read, because the two
 * shipping consumers use different ones and both are correct: a toggle is
 * pressed, a link to the current view is current. */
.wp-block-axismundi-button-group__item[aria-pressed="true"],
.wp-block-axismundi-button-group__item[aria-current="page"],
.wp-block-axismundi-button-group__input:checked + .wp-block-axismundi-button-group__item {
	background-color: var(--ax-button-toggle-selected-container);
	color: var(--ax-button-toggle-selected-content);
}

/* Shape morph, and the three states are three different published values:
 *
 *   rest      inner corner   8 / 8 / 8 / 16 / 20 by size
 *   pressed   pressed inner  4 / 4 / 4 / 12 / 16
 *   selected  50%
 *
 * M3's 50% means half the height - a capsule. CSS's `border-radius: 50%` does
 * not mean that: it takes 50% of the width horizontally and 50% of the height
 * vertically, which on a segment three times wider than it is tall draws an
 * ellipse. Written that way it rendered exactly that.
 *
 * So the capsule is a computed length, half the container height, which is the
 * same translation axismundi-lab arrived at (`--_button-group-pill-radius`,
 * components.css §28.9, whose comment reads "§5.4 inner = 50%"). A length also
 * keeps the morph animatable, which `--md-sys-shape-corner-full` would not:
 * 9999px scales down to fit and reads as an unchanged pill until it snaps.
 *
 * Both selection attributes are read. The two shipping consumers disagree on
 * which one they use and both are right: a toggle is pressed, a link to the
 * view you are on is current. Colour already read both; shape did not, which
 * left the feed density switch with the right colour and the wrong corners. */
.wp-block-axismundi-button-group[data-variant="connected"] > .wp-block-axismundi-button-group__item:active {
	border-radius: var(--ax-group-pressed-inner-corner, var(--md-sys-shape-corner-value-extra-small));
}

.wp-block-axismundi-button-group > .wp-block-axismundi-button-group__item[aria-pressed="true"],
.wp-block-axismundi-button-group > .wp-block-axismundi-button-group__item[aria-current="page"],
.wp-block-axismundi-button-group > .wp-block-axismundi-button-group__input:checked + .wp-block-axismundi-button-group__item {
	border-radius: var(--ax-group-selected-corner, calc(var(--ax-button-height, 40px) / 2));
}

/* Pressing a segment that is already selected: M3 gives the pressed shape
 * precedence, and equal specificity plus source order gave it to selected.
 * The lab hit this too and fixed it the same way, with an explicit rule. */
.wp-block-axismundi-button-group[data-variant="connected"] > .wp-block-axismundi-button-group__item[aria-pressed="true"]:active,
.wp-block-axismundi-button-group[data-variant="connected"] > .wp-block-axismundi-button-group__item[aria-current="page"]:active,
.wp-block-axismundi-button-group[data-variant="connected"] > .wp-block-axismundi-button-group__input:checked + .wp-block-axismundi-button-group__item:active {
	border-radius: var(--ax-group-pressed-inner-corner, var(--md-sys-shape-corner-value-extra-small));
}

.wp-block-axismundi-button-group__item:hover {
	background-color: color-mix(in srgb, var(--ax-button-toggle-unselected-state-role) calc(var(--md-sys-state-hover-state-layer-opacity) * 100%), var(--ax-button-toggle-unselected-container));
}

.wp-block-axismundi-button-group__item[aria-pressed="true"]:hover,
.wp-block-axismundi-button-group__item[aria-current="page"]:hover,
.wp-block-axismundi-button-group__input:checked + .wp-block-axismundi-button-group__item:hover {
	background-color: color-mix(in srgb, var(--ax-button-toggle-selected-state-role) calc(var(--md-sys-state-hover-state-layer-opacity) * 100%), var(--ax-button-toggle-selected-container));
}

.wp-block-axismundi-button-group__item:focus-visible {
	outline: var(--md-focus-ring-width) solid var(--md-sys-color-secondary);
	outline-offset: var(--md-focus-ring-outward-offset);
}

.wp-block-axismundi-button-group__input:focus-visible + .wp-block-axismundi-button-group__item {
	outline: var(--md-focus-ring-width) solid var(--md-sys-color-secondary);
	outline-offset: var(--md-focus-ring-outward-offset);
}

.wp-block-axismundi-button-group__item:disabled,
.wp-block-axismundi-button-group__item[aria-disabled="true"],
.wp-block-axismundi-button-group__input:disabled + .wp-block-axismundi-button-group__item {
	opacity: 0.38;
	cursor: not-allowed;
	pointer-events: none;
}

/* Documentation-only specimen layout. Component measurements above remain
 * independent from the way the reference page arranges its examples. */
.sg-button-group-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
	gap: var(--md-sys-measurement-space300);
	margin-block: var(--md-sys-measurement-space300);
}

.sg-button-group-specimen {
	display: grid;
	gap: var(--md-sys-measurement-space150);
	align-content: start;
	padding: var(--md-sys-measurement-space200);
	border: 1px solid var(--md-sys-color-outline-variant);
	border-radius: var(--md-sys-shape-corner-value-medium);
	background: var(--md-sys-color-surface-container-low);
	overflow-x: auto;
}

.sg-button-group-specimen > :first-child {
	max-inline-size: 100%;
}

.sg-button-group-caption {
	margin: 0;
	color: var(--md-sys-color-on-surface-variant);
	font-size: var(--md-sys-typescale-body-small-size);
	line-height: var(--md-sys-typescale-body-small-line-height);
}

.sg-button-group-mobile-shell {
	inline-size: min(100%, 390px);
	padding: var(--md-sys-measurement-space100);
	border: 1px solid var(--md-sys-color-outline-variant);
	border-radius: var(--md-sys-shape-corner-value-medium);
	overflow-x: auto;
}

.sg-button-group-stack {
	display: grid;
	gap: var(--md-sys-measurement-space200);
}

/* --- Documentation-only interactive demos -------------------- */

/* These panels deliberately mirror the Button page's Result + Controls layout.
 * They are two panels, not a variant switch: Standard contains independently
 * authored Buttons; Connected owns its fixed Segment collection. */
.sg-button-group-playground {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(13rem, 17rem);
	margin-block: var(--md-sys-measurement-space300);
	border: 1px solid var(--md-sys-color-outline-variant);
	border-radius: var(--md-sys-shape-corner-value-medium);
	background: var(--md-sys-color-surface-container-low);
	overflow: hidden;
}

.sg-button-group-playground__stage,
.sg-button-group-playground__controls {
	padding: var(--md-sys-measurement-space300);
}

.sg-button-group-playground__stage {
	display: grid;
	align-content: center;
	gap: var(--md-sys-measurement-space300);
	min-block-size: 18rem;
	min-inline-size: 0;
	overflow-x: auto;
}

.sg-button-group-playground__controls {
	display: grid;
	align-content: start;
	gap: var(--md-sys-measurement-space200);
	border-inline-start: 1px solid var(--md-sys-color-outline-variant);
	background: var(--md-sys-color-surface-container);
}

.sg-button-group-playground__controls label {
	display: grid;
	gap: var(--md-sys-measurement-space50);
	font-size: var(--md-sys-typescale-body-medium-size);
	line-height: var(--md-sys-typescale-body-medium-line-height);
}

.sg-button-group-playground__controls select {
	inline-size: 100%;
	min-block-size: 2.5rem;
	padding-inline: var(--md-sys-measurement-space100);
	border: 1px solid var(--md-sys-color-outline);
	border-radius: var(--md-sys-shape-corner-value-extra-small);
	background: var(--md-sys-color-surface-container-highest);
	color: var(--md-sys-color-on-surface);
	font: inherit;
}

.sg-button-group-playground__controls .sg-button-group-playground__checkbox {
	display: flex;
	align-items: center;
	gap: var(--md-sys-measurement-space100);
	min-block-size: 2.5rem;
}

.sg-button-group-playground__actions {
	display: grid;
	gap: var(--md-sys-measurement-space100);
}

.sg-button-group-playground__actions button {
	min-block-size: 2.5rem;
	padding-inline: var(--md-sys-measurement-space150);
	border: 1px solid var(--md-sys-color-outline);
	border-radius: var(--md-sys-shape-corner-value-extra-small);
	background: transparent;
	color: var(--md-sys-color-primary);
	font: inherit;
	text-align: start;
	cursor: pointer;
}

.sg-button-group-playground__actions button:hover {
	background: color-mix(in srgb, var(--md-sys-color-primary) calc(var(--md-sys-state-hover-state-layer-opacity) * 100%), transparent);
}

.sg-button-group-playground__checkbox input {
	inline-size: 1.125rem;
	block-size: 1.125rem;
	margin: 0;
	accent-color: var(--md-sys-color-primary);
}

.sg-button-group-playground__markup {
	max-inline-size: 100%;
	min-block-size: 4.5rem;
	margin: 0;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

@media (max-width: 599px) {
	.sg-button-group-playground {
		grid-template-columns: minmax(0, 1fr);
	}

	.sg-button-group-playground__stage {
		min-block-size: 14rem;
	}

	.sg-button-group-playground__controls {
		border-block-start: 1px solid var(--md-sys-color-outline-variant);
		border-inline-start: 0;
	}
}
