/* ShapeBlock — Menu block (front-end + editor shared styles). */
.shapeblock-menu {
	position: relative;
}

.shapeblock-menu .shapeblock-menu-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 24px;
	align-items: center;
}

.shapeblock-menu--vertical .shapeblock-menu-list {
	flex-direction: column;
	align-items: stretch;
}

.shapeblock-menu-align-center .shapeblock-menu-list {
	justify-content: center;
}

.shapeblock-menu-align-right .shapeblock-menu-list {
	justify-content: flex-end;
}

/* Vertical menu: the items run down the page, so Justification aligns them across. */
.shapeblock-menu--vertical.shapeblock-menu-align-center .shapeblock-menu-list {
	align-items: center;
}

.shapeblock-menu--vertical.shapeblock-menu-align-right .shapeblock-menu-list {
	align-items: flex-end;
}

.shapeblock-menu .shapeblock-menu-list li {
	margin: 0;
	position: relative;
}

.shapeblock-menu .shapeblock-menu-list a {
	display: inline-flex;
	flex-direction: row;
	align-items: center;
	gap: 4px;
	text-decoration: none;
	line-height: 1.35;
	transition: color 0.2s ease;
}

/* Room above and below the top-level links, so a dropdown opens clear of its item.
   Kept low in specificity: the drawer and the item-background pills set their own. */
.shapeblock-menu--horizontal :where(.shapeblock-menu-list > li > a) {
	padding-top: 20px;
	padding-bottom: 20px;
}

/* Label + description stack together; icons sit beside this text block. */
.shapeblock-menu .shapeblock-menu-text {
	display: inline-flex;
	flex-direction: column;
}

.shapeblock-menu .shapeblock-menu-label {
	display: block;
}

/* Per-item icon ( left / right of the text ). */
.shapeblock-menu .shapeblock-menu-item-icon {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
	color: inherit;
}

.shapeblock-menu .shapeblock-menu-svg {
	width: 1em;
	height: 1em;
	display: block;
}

/* User-uploaded item icon image. */
.shapeblock-menu .shapeblock-menu-item-img {
	width: 1.15em;
	height: 1.15em;
	object-fit: contain;
	display: block;
}

.shapeblock-menu .shapeblock-menu-desc {
	display: block;
	font-size: 0.78em;
	opacity: 0.7;
	margin-top: 2px;
	font-weight: 400;
}

/* Dropdown indicator ( SVG ) / mobile toggle. */
.shapeblock-menu .shapeblock-menu-sub-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: inherit;
	cursor: pointer;
	transition: transform 0.25s ease;
}

.shapeblock-menu .menu-item-has-children.is-sub-open > .shapeblock-menu-sub-toggle,
.shapeblock-menu .menu-item-has-children.is-sub-open > a > .shapeblock-menu-sub-toggle {
	transform: rotate( 180deg );
}

/* Editor: the caret is a button that opens the "add sub-menu" popover. */
.shapeblock-menu .shapeblock-menu-sub-trigger {
	background: transparent;
	border: none;
	padding: 0;
	font: inherit;
}

.shapeblock-menu-subadd {
	display: inline-flex;
}

/* Editor only: a leaf item inside a dropdown lays out as a row so its "+" ( add next level ) sits
   on the right. These classes are emitted by the editor preview, never on the front end. */
.shapeblock-menu .shapeblock-menu-list .sub-menu li.shapeblock-menu-has-add {
	display: flex;
	align-items: center;
}

.shapeblock-menu .shapeblock-menu-list .sub-menu li.shapeblock-menu-has-add > a {
	flex: 1 1 auto;
}

.shapeblock-menu .shapeblock-menu-sub-plus.components-button {
	flex: 0 0 auto;
	min-width: 16px;
	width: 16px;
	height: 16px;
	padding: 0;
	border-radius: 4px;
	color: #7a3fd0;
	opacity: 0.4;
	transition: opacity 0.15s ease, background 0.15s ease;
}

/* Keep the "+" glyph itself compact inside the small button. */
.shapeblock-menu .shapeblock-menu-sub-plus.components-button svg {
	width: 12px;
	height: 12px;
}

.shapeblock-menu .shapeblock-menu-list .sub-menu li.shapeblock-menu-has-add:hover .shapeblock-menu-sub-plus.components-button,
.shapeblock-menu .shapeblock-menu-sub-plus.components-button:focus {
	opacity: 1;
	background: #f3ecfc;
}

/* Plus indicator becomes a "×" when open instead of a meaningless 180° flip. */
.shapeblock-menu .menu-item-has-children.is-sub-open > .shapeblock-menu-sub-toggle--plus,
.shapeblock-menu .menu-item-has-children.is-sub-open > a > .shapeblock-menu-sub-toggle--plus {
	transform: rotate( 45deg );
}

/* ---- Dropdown (sub-menu) — smooth fade + slide ---- */
.shapeblock-menu .shapeblock-menu-list .sub-menu {
	list-style: none;
	margin: 0;
	padding: 0;
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 210px;
	background: #ffffff;
	box-shadow: 0 12px 30px rgba( 0, 0, 0, 0.12 );
	border-radius: 8px;
	display: flex;
	flex-direction: column;
	gap: 0;
	z-index: 99;
	opacity: 0;
	visibility: hidden;
	transform: translateY( 12px );
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
	overflow: hidden; /* Clip item hover backgrounds to the rounded corners. */
}

/* A horizontal dropdown that opens a nested ( side ) flyout must NOT clip — that would hide the
   flyout. Those keep overflow visible and round their first / last items so corners still look clean.
   ( Vertical menus use a static accordion that relies on overflow:hidden, so they are excluded. ) */
.shapeblock-menu:not( .shapeblock-menu--vertical ) .shapeblock-menu-list .sub-menu:has( .sub-menu ) {
	overflow: visible;
}

.shapeblock-menu:not( .shapeblock-menu--vertical ) .shapeblock-menu-list .sub-menu:has( .sub-menu ) > li:first-child > a {
	border-top-left-radius: 8px;
	border-top-right-radius: 8px;
}

.shapeblock-menu:not( .shapeblock-menu--vertical ) .shapeblock-menu-list .sub-menu:has( .sub-menu ) > li:last-child > a {
	border-bottom-left-radius: 8px;
	border-bottom-right-radius: 8px;
}

.shapeblock-menu .shapeblock-menu-list li:hover > .sub-menu,
.shapeblock-menu .shapeblock-menu-list li:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY( 0 );
	pointer-events: auto;
}

/* Click mode: hover does NOT open; the sub-menu opens only when JS adds .is-sub-open. */
.shapeblock-menu-click .shapeblock-menu-list li:hover > .sub-menu,
.shapeblock-menu-click .shapeblock-menu-list li:focus-within > .sub-menu {
	opacity: 0;
	visibility: hidden;
	transform: translateY( 12px );
	pointer-events: none;
}

.shapeblock-menu .shapeblock-menu-list li.is-sub-open > .sub-menu,
.shapeblock-menu-click .shapeblock-menu-list li.is-sub-open > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY( 0 );
	pointer-events: auto;
}

/* Nested dropdowns ( 3rd level and deeper ) fly out to the side instead of stacking on top.
   Scoped away from the vertical layout, which uses a static accordion instead. */
.shapeblock-menu:not( .shapeblock-menu--vertical ) .shapeblock-menu-list .sub-menu .sub-menu {
	top: 0;
	left: 100%;
	transform: translateX( 12px );
}

.shapeblock-menu:not( .shapeblock-menu--vertical ) .shapeblock-menu-list .sub-menu li:hover > .sub-menu,
.shapeblock-menu:not( .shapeblock-menu--vertical ) .shapeblock-menu-list .sub-menu li:focus-within > .sub-menu {
	transform: translateX( 0 );
}

/* Invisible hover "bridge" that fills the gap between a parent item and its dropdown, so moving the
   pointer from the item into the dropdown ( or between levels ) never loses hover and closes it.
   It is part of the sub-menu, so hovering it keeps the parent's :hover active. Only active while the
   dropdown is open ( the sub-menu is pointer-events:none while hidden ). */
.shapeblock-menu:not( .shapeblock-menu--vertical ) .shapeblock-menu-list .sub-menu::before {
	content: '';
	position: absolute;
	top: -14px;
	left: 0;
	right: 0;
	height: 14px;
	background: transparent;
}

/* Nested ( side ) flyouts: the gap is on the left instead of the top. */
.shapeblock-menu:not( .shapeblock-menu--vertical ) .shapeblock-menu-list .sub-menu .sub-menu::before {
	top: 0;
	left: -14px;
	right: auto;
	width: 14px;
	height: 100%;
}

.shapeblock-menu-click:not( .shapeblock-menu--vertical ) .shapeblock-menu-list .sub-menu li:hover > .sub-menu,
.shapeblock-menu-click:not( .shapeblock-menu--vertical ) .shapeblock-menu-list .sub-menu li:focus-within > .sub-menu {
	transform: translateX( 12px );
}

.shapeblock-menu-click:not( .shapeblock-menu--vertical ) .shapeblock-menu-list .sub-menu li.is-sub-open > .sub-menu {
	transform: translateX( 0 );
}

.shapeblock-menu .shapeblock-menu-list .sub-menu > li > a {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 9px 18px;
	white-space: nowrap;
	/* Stay transparent so the panel's own background ( solid or gradient ) shows through the items;
	   only the item :hover rule paints a background. */
	background-color: transparent;
}

.shapeblock-menu .shapeblock-menu-list .sub-menu li {
	background-color: transparent;
}

/* In a dropdown the arrow ( and the editor's leaf "+" ) is pushed to the far right, while any
   icon + label stay grouped on the left. On the front end the arrow is a direct child of the link;
   in the editor the caret / "+" is wrapped in a Dropdown ( .shapeblock-menu-subadd ), so target that too. */
.shapeblock-menu .shapeblock-menu-list .sub-menu > li > a > .shapeblock-menu-sub-toggle,
.shapeblock-menu .shapeblock-menu-list .sub-menu > li > a > .shapeblock-menu-sub-plus,
.shapeblock-menu .shapeblock-menu-list .sub-menu > li > a > .shapeblock-menu-subadd {
	margin-left: auto;
}

/* Make a dropdown parent's link fill the row so the arrow reaches the dropdown's right edge.
   ( Front end: arrow is inside the link. Editor: the caret button is a sibling — both land right. ) */
.shapeblock-menu .shapeblock-menu-list .sub-menu li.menu-item-has-children > a {
	flex: 1 1 auto;
}

.shapeblock-menu--vertical .shapeblock-menu-list .sub-menu {
	position: static;
	box-shadow: none;
	border-radius: 0;
	min-width: 0;
	padding: 0 0 0 16px;
	opacity: 1;
	visibility: visible;
	transform: none;
	pointer-events: auto;
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.35s ease;
}

.shapeblock-menu--vertical .shapeblock-menu-list li:hover > .sub-menu,
.shapeblock-menu--vertical .shapeblock-menu-list li:focus-within > .sub-menu {
	max-height: 600px;
}

/* ---- Off-canvas drawer primitives (desktop: transparent; mobile switched on via inline CSS) ---- */
.shapeblock-menu-panel {
	display: contents; /* On desktop the list flows in place; on mobile it becomes the sliding drawer. */
}

.shapeblock-menu-overlay {
	display: none;
}

/* While the window is being resized, kill the drawer transition so it doesn't
   visibly slide across the screen when crossing the breakpoint. */
.shapeblock-menu-no-anim .shapeblock-menu-panel,
.shapeblock-menu-no-anim .shapeblock-menu-overlay {
	transition: none !important;
}

.shapeblock-menu-close {
	display: none;
	align-items: center;
	justify-content: center;
	position: absolute;
	top: 12px;
	right: 12px;
	width: 36px;
	height: 36px;
	padding: 0;
	background: transparent;
	border: none;
	line-height: 0;
	cursor: pointer;
	color: inherit;
}

/* Cross ( X ) icon, centered inside the close button. */
.shapeblock-menu-close .shapeblock-menu-svg {
	width: 20px;
	height: 20px;
	display: block;
}

/* ---- Responsive hamburger toggle (shown below the breakpoint via inline CSS) ---- */
.shapeblock-menu-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	gap: 4px;
	width: 42px;
	height: 42px;
	padding: 9px;
	background: transparent;
	border: 1px solid currentColor;
	border-radius: 6px;
	cursor: pointer;
	color: inherit;
}

.shapeblock-menu-toggle-bar {
	display: block;
	width: 20px;
	height: 2px;
	background: currentColor;
	transition: transform 0.25s ease, opacity 0.25s ease;
}

.shapeblock-menu.is-open .shapeblock-menu-toggle-bar:nth-child( 1 ) {
	transform: translateY( 6px ) rotate( 45deg );
}

.shapeblock-menu.is-open .shapeblock-menu-toggle-bar:nth-child( 2 ) {
	opacity: 0;
}

.shapeblock-menu.is-open .shapeblock-menu-toggle-bar:nth-child( 3 ) {
	transform: translateY( -6px ) rotate( -45deg );
}

/* ---- Editor: inline "add item" (+) button ---- */
.shapeblock-menu-add-item {
	display: inline-flex;
	align-items: center;
	list-style: none;
}

.shapeblock-menu-add-btn.components-button {
	min-width: 22px;
	width: 22px;
	height: 22px;
	padding: 0;
	justify-content: center;
	border: 1px dashed #a216ff;
	color: #a216ff;
	border-radius: 5px;
	background: rgba( 162, 22, 255, 0.06 );
}

/* Keep the "+" glyph compact inside the smaller button. */
.shapeblock-menu-add-btn.components-button svg {
	width: 14px;
	height: 14px;
}

.shapeblock-menu-add-btn.components-button:hover {
	background: rgba( 162, 22, 255, 0.14 );
	color: #a216ff;
	border-color: #a216ff;
}

.shapeblock-menu-is-empty .shapeblock-menu-list {
	min-height: 32px;
}

/* ---- Editor: the search popover ( width lives on .components-popover__content ) ---- */
.shapeblock-menu-add-pop .components-popover__content {
	width: 340px;
	max-width: 92vw;
}

/* "Create page" sub-panel ( title + publish toggle ). */
.shapeblock-menu-add-createview {
	padding: 12px;
}

.shapeblock-menu-add-back.components-button {
	height: auto;
	padding: 2px 0;
	margin-bottom: 10px;
	color: #1e1e1e;
	font-weight: 600;
}

.shapeblock-menu-add-actions {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 8px;
	margin-top: 14px;
}

.shapeblock-menu-add-search {
	padding: 8px;
}

.shapeblock-menu-add-search,
.shapeblock-menu-add-search .components-base-control,
.shapeblock-menu-add-search .components-text-control__input {
	width: 100%;
}

.shapeblock-menu-add-results {
	list-style: none;
	margin: 6px 0 0;
	padding: 0;
	max-height: 260px;
	overflow-y: auto;
}

.shapeblock-menu-add-row {
	margin: 0;
}

.shapeblock-menu-add-result.components-button {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	height: auto;
	min-height: 36px;
	padding: 6px 8px;
	justify-content: flex-start;
	text-align: left;
	border-radius: 4px;
	color: #1e1e1e;
}

.shapeblock-menu-add-result.components-button:hover {
	background: #f0f0f1;
}

.shapeblock-menu-add-result .dashicons {
	color: #757575;
	flex: 0 0 auto;
}

.shapeblock-menu-add-loading,
.shapeblock-menu-add-empty {
	padding: 10px 8px;
	color: #757575;
	font-size: 12px;
}

/* ---- Editor: three Inspector tabs ( Menu Items / Settings / Style ) ---- */
.shapeblock-menu-tabs .components-tab-panel__tabs {
	display: flex;
}

.shapeblock-menu-tabs .components-tab-panel__tabs-item {
	flex: 1;
	justify-content: center;
}

/* ---- Editor: item editors in the Inspector ( default Gutenberg look — no custom boxes ) ---- */
/* Top-level items are their own collapsible PanelBody ( titled with the item name ). */
.shapeblock-menu-additem-row {
	padding: 12px 16px 16px;
}

/* Sub-item ( dropdown ) editors sit inside their parent's panel, separated by a light rule. */
.shapeblock-menu-item-editor.is-child {
	margin: 10px 0 14px;
	padding: 10px 0 14px 12px;
	border-bottom: 1px solid #e0e0e0;
	/* Left accent + indent makes the nesting depth easy to read at a glance. */
	border-left: 2px solid #d5c2ef;
}

/* Small "Level N sub-item" badge that heads every nested editor. */
.shapeblock-menu-level-badge {
	display: inline-block;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #7a3fd0;
	background: #f3ecfc;
	border-radius: 3px;
	padding: 2px 7px;
	margin-bottom: 8px;
}

.shapeblock-menu-subsection {
	margin-top: 8px;
}

.shapeblock-menu-section-label {
	font-size: 11px;
	text-transform: uppercase;
	font-weight: 500;
	color: #757575;
	margin-bottom: 8px;
}

/* Icon upload row. */
.shapeblock-menu-icon-picker {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 8px;
}

.shapeblock-menu-icon-thumb img {
	width: 24px;
	height: 24px;
	object-fit: contain;
	display: block;
}

.shapeblock-menu-icon-preview svg {
	width: 22px;
	height: 22px;
	display: block;
	color: #1e1e1e;
}

/* Responsive spacing controls. */
.shapeblock-menu-devices {
	display: flex;
	gap: 4px;
	margin-bottom: 12px;
}

.shapeblock-menu-devices .components-button {
	flex: 1;
	justify-content: center;
}

.shapeblock-menu-field {
	margin-bottom: 12px;
}

.shapeblock-menu-linkfield-label {
	font-size: 11px;
	text-transform: uppercase;
	font-weight: 500;
	margin-bottom: 4px;
	color: #1e1e1e;
}

/* The Dropdown wrapper must be full-width, else its button shrinks to the link text ( e.g. "#" ). */
.shapeblock-menu-linkpicker {
	display: block;
	width: 100%;
}

.shapeblock-menu-linkpicker-btn.components-button {
	width: 100%;
	justify-content: flex-start;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	display: block;
	text-align: left;
}

.shapeblock-menu-item-actions {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
	align-items: center;
	margin-top: 6px;
}

/* ---- Notices ---- */
.shapeblock-menu-notice {
	margin: 0;
	padding: 14px 16px;
	background: #f6f7f7;
	border: 1px dashed #c3c4c7;
	border-radius: 6px;
	color: #50575e;
	font-size: 13px;
}

/* ---- Editor: search input row + result text (title + slug) ---- */
.shapeblock-menu-add-input {
	display: flex;
	align-items: flex-start;
	gap: 4px;
}
.shapeblock-menu-add-input .components-base-control {
	flex: 1 1 auto;
}
.shapeblock-menu-add-go.components-button {
	margin-top: 2px;
	flex: 0 0 auto;
}
.shapeblock-menu-add-result-text {
	display: flex;
	flex-direction: column;
	line-height: 1.3;
	overflow: hidden;
}
.shapeblock-menu-add-result-title {
	color: #1e1e1e;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.shapeblock-menu-add-result-sub {
	font-size: 11px;
	color: #757575;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.shapeblock-menu-add-create .dashicons {
	color: #a216ff;
}

/* ---- Editor: inline-editable menu label (preview) ---- */
.shapeblock-menu-label[contenteditable] {
	outline: none;
	cursor: text;
	border-radius: 2px;
}
.shapeblock-menu-label[contenteditable]:hover {
	outline: 1px dashed rgba( 162, 22, 255, 0.45 );
	outline-offset: 2px;
}
.shapeblock-menu-label[contenteditable]:focus {
	outline: 2px solid #a216ff;
	outline-offset: 2px;
}
.shapeblock-menu-label[contenteditable]:empty {
	min-width: 46px;
	display: inline-block;
}
.shapeblock-menu-label[contenteditable]:empty::before {
	content: attr( data-shapeblock-placeholder );
	opacity: 0.5;
}
