/**
 * Decorations (shared block module): shapes layered behind / in front of a
 * block's content (init.php, editor.js).
 *
 * The block becomes the positioning box and its own stacking context, so
 * "behind" shapes (z-index -1) paint above the block's background but under
 * its content, and "front" shapes (z-index 1) over it. Positions are the
 * shape's centre in % of the block; width is % of the block's width so the
 * layout scales with the container. --cm-decor-mscale (set on the wrapper
 * from the block's "Size on mobile" control) multiplies the width at
 * <= 600px.
 */
.cm-has-decor {
	position: relative;
	isolation: isolate;
}
.cm-decor-clip {
	overflow: hidden;
}
.cm-decor {
	position: absolute;
	left: var(--cm-x, 50%);
	top: var(--cm-y, 50%);
	/* Zones whose CSS sets the width of their children (e.g. a flex panel
	   with "> * { width: 100% }") should use width: var(--cm-decor-width)
	   so the mobile multiplier still applies. */
	--cm-decor-width: var(--cm-w, 20%);
	width: var(--cm-decor-width);
	aspect-ratio: 1 / 1;
	transform: translate(-50%, -50%) rotate(var(--cm-r, 0deg));
	pointer-events: none;
	user-select: none;
	line-height: 0;
}
.cm-decor--behind { z-index: -1; }
.cm-decor--front { z-index: 1; }
.cm-decor > svg,
.cm-decor > img {
	display: block;
	width: 100%;
	height: 100%;
}
/* Palette-coloured: the file's alpha as a mask over the chosen colour. */
.cm-decor--mask {
	background: currentColor;
	-webkit-mask: no-repeat center / contain;
	mask: no-repeat center / contain;
}
@media (max-width: 600px) {
	.cm-decor { --cm-decor-width: calc(var(--cm-w, 20%) * var(--cm-decor-mscale, 1)); }
	.cm-decor--hide-mobile { display: none; }
}
/* Cover: core stacks its image (0) and colour overlay (1) under the content,
   so "behind" shapes go above the overlay and the content above them. The
   repeated class outranks core's body:not(...) rule for the inner container. */
.wp-block-cover.cm-has-decor > .cm-decor--behind { z-index: 2; }
.wp-block-cover.cm-has-decor.cm-has-decor.cm-has-decor.cm-has-decor.cm-has-decor .wp-block-cover__inner-container { z-index: 3; }
.wp-block-cover.cm-has-decor > .cm-decor--front { z-index: 4; }

/* Editor only: hidden shapes are faded; while a shape is open the others
   are clickable (opens them) and the open one has a drag handle: the same
   box as the shape, above the block's content, with a corner grip. */
.editor-styles-wrapper .cm-decor--off {
	opacity: 0.25;
}
.editor-styles-wrapper .cm-decor--pick {
	pointer-events: auto;
	cursor: pointer;
}
.editor-styles-wrapper .cm-decor-handle {
	position: absolute;
	left: var(--cm-x, 50%);
	top: var(--cm-y, 50%);
	--cm-decor-width: var(--cm-w, 20%);
	width: var(--cm-decor-width);
	aspect-ratio: 1 / 1;
	transform: translate(-50%, -50%) rotate(var(--cm-r, 0deg));
	z-index: 100;
	box-sizing: border-box;
	outline: 2px dashed var(--wp-admin-theme-color, #3858e9);
	outline-offset: 3px;
	cursor: move;
	touch-action: none;
	user-select: none;
}
.editor-styles-wrapper .cm-decor-handle:focus-visible {
	outline-style: solid;
}
.editor-styles-wrapper .cm-decor-handle.is-dragging {
	outline-style: solid;
	background: rgba(56, 88, 233, 0.06);
}
.editor-styles-wrapper .cm-decor-handle__size {
	position: absolute;
	right: -9px;
	bottom: -9px;
	width: 14px;
	height: 14px;
	box-sizing: border-box;
	border: 2px solid var(--wp-admin-theme-color, #3858e9);
	border-radius: 2px;
	background: #fff;
	cursor: nwse-resize;
}
.editor-styles-wrapper .cm-decor-handle.is-size {
	cursor: nwse-resize;
}
@media (max-width: 600px) {
	.editor-styles-wrapper .cm-decor-handle { --cm-decor-width: calc(var(--cm-w, 20%) * var(--cm-decor-mscale, 1)); }
}

/* Editor sidebar panel: accordion list, one shape open at a time. */
.orbit-decor-list {
	margin: 12px 0;
	border: 1px solid #ddd;
	border-radius: 4px;
}
.orbit-decor-item + .orbit-decor-item {
	border-top: 1px solid #ddd;
}
.orbit-decor-item.is-hidden .orbit-decor-item__toggle {
	opacity: 0.55;
}
.orbit-decor-item__head {
	display: flex;
	align-items: center;
	gap: 2px;
	padding-right: 4px;
}
.orbit-decor-item__toggle {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px;
	background: none;
	border: 0;
	text-align: left;
	cursor: pointer;
	color: inherit;
	font: inherit;
}
.orbit-decor-item__toggle:hover,
.orbit-decor-item.is-open .orbit-decor-item__toggle {
	background: #f6f7f7;
}
.orbit-decor-item__toggle:focus-visible {
	outline: 2px solid var(--wp-admin-theme-color, #3858e9);
	outline-offset: -2px;
}
.orbit-decor-item__text {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	line-height: 1.3;
}
.orbit-decor-item__name {
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.orbit-decor-item__meta {
	font-size: 11px;
	color: #757575;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.orbit-decor-item__body {
	padding: 4px 12px 12px;
	border-top: 1px solid #eee;
}
.orbit-decor-item__body > * + * {
	margin-top: 12px;
}
.orbit-decor-item__foot {
	display: flex;
	gap: 4px;
	justify-content: flex-end;
	padding-top: 4px;
}
.orbit-decor-actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}
.orbit-decor-mobile {
	margin-top: 16px;
}
.orbit-decor-hint {
	margin: 0;
	font-size: 12px;
	color: #757575;
}

/* Thumbnails: coloured shapes as a mask, others as the file. */
.orbit-decor-thumb {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	display: block;
}
.orbit-decor-thumb img {
	width: 100%;
	height: 100%;
	display: block;
}
.orbit-decor-thumb--mask {
	-webkit-mask: no-repeat center / contain;
	mask: no-repeat center / contain;
}

/* Shape picker: current shape as a button, the grid in a popover. */
.orbit-decor-picker__toggle.components-button {
	width: 100%;
	height: auto;
	padding: 6px 10px;
	justify-content: flex-start;
	gap: 8px;
}
.orbit-decor-picker__name {
	flex: 1 1 auto;
	text-align: left;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.orbit-decor-picker__hint {
	font-size: 11px;
	opacity: 0.7;
}
.orbit-decor-picker__panel {
	padding: 12px;
	width: 292px;
	box-sizing: border-box;
}
.orbit-decor-picker__set {
	margin: 8px 0 4px;
	font-size: 11px;
	font-weight: 500;
	text-transform: uppercase;
	color: #757575;
}
.orbit-decor-picker__set:first-child {
	margin-top: 0;
}
.orbit-decor-shapes {
	display: grid;
	grid-template-columns: repeat(auto-fill, 40px);
	gap: 4px;
}
.orbit-decor-shapes .components-button {
	width: 40px;
	height: 40px;
	padding: 3px;
	min-width: 0;
	justify-content: center;
}
.orbit-decor-shapes img {
	width: 32px;
	height: 32px;
	display: block;
}
/* Label on its own line, buttons share the row: the sidebar is only ~230px
   wide inside the item, so "Whole banner / Collage panel" can't sit inline. */
.orbit-decor-row {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	align-items: center;
	margin-bottom: 12px;
}
.orbit-decor-row__label {
	flex: 0 0 100%;
	font-size: 11px;
	font-weight: 500;
	text-transform: uppercase;
	margin-bottom: 2px;
}
.orbit-decor-row .components-button {
	flex: 1 1 0;
	min-width: 0;
	justify-content: center;
	padding-left: 8px;
	padding-right: 8px;
}
