/*
 * Stratax role editor + visibility matrix (stratax-ext-roles view). Layout only — colours/tokens
 * come from theme.css + the hui-* primitive styles. Linked via rummage.config.mjs `styles`.
 */

/* ── Role list: drag-to-reorder rows (drag-drop extension) ──────────────────── */
.stratax-roles-list {
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.stratax-roles-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 10px;
	border: 1px solid var(--border-color, rgba(128, 128, 128, 0.22));
	border-radius: var(--radius-sm);
	background: var(--surface-1, rgba(128, 128, 128, 0.04));
}
.stratax-roles-row--dragging {
	opacity: 0.45;
}
.stratax-roles-row--drop-above {
	box-shadow: inset 0 2px 0 var(--accent-500, #46a08c);
}
.stratax-roles-row--drop-below {
	box-shadow: inset 0 -2px 0 var(--accent-500, #46a08c);
}
.stratax-roles-grip {
	cursor: grab;
	opacity: 0.5;
	font-size: 1.15em;
	line-height: 1;
	user-select: none;
	flex: 0 0 auto;
}
.stratax-roles-grip:active {
	cursor: grabbing;
}
.stratax-roles-name {
	flex: 1 1 auto;
	min-width: 0;
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.stratax-roles-attr {
	display: flex;
	align-items: center;
	gap: 6px;
	flex: 0 0 auto;
}
.stratax-roles-attr-label {
	font-size: 0.78em;
	opacity: 0.65;
	white-space: nowrap;
}
.stratax-roles-actions {
	display: flex;
	align-items: center;
	gap: 2px;
	flex: 0 0 auto;
}

/* Narrow screens: keep grip + name + actions on one grid line. (The per-row attribute toggles
 * moved into the edit modal, so the old attr1/attr2/attr3 template rows are gone — leaving them
 * declared reserved three empty rows + gaps of dead space after every row.) */
@media (max-width: 620px) {
	.stratax-roles-row {
		display: grid;
		grid-template-columns: auto 1fr auto;
		grid-template-areas: "grip name actions";
		align-items: center;
	}
	.stratax-roles-grip {
		grid-area: grip;
	}
	.stratax-roles-name {
		grid-area: name;
	}
	.stratax-roles-actions {
		grid-area: actions;
	}
}

/* ── Visibility matrix: drag contact-role chips into per-viewer dropzones ────── */
/* Larger screens: the palette sits in a side column and STICKS while the role rows scroll past,
 * so the drag source is always next to the visible drop target — never a screen-length drag.
 * (Phones don't render this layout at all — the view swaps to a multi-select per role.) */
.stratax-roles-matrix {
	display: grid;
	grid-template-columns: 230px 1fr;
	gap: 14px;
	align-items: start;
}
.stratax-roles-matrix-sub {
	opacity: 0.72;
	margin: 0 0 12px;
	font-size: 0.9em;
}
.stratax-roles-palette {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	padding: 10px 12px;
	margin: 0;
	position: sticky;
	top: 8px;
	border: 1px dashed var(--border-color, rgba(128, 128, 128, 0.3));
	border-radius: var(--radius-sm);
}
.stratax-roles-palette-label {
	width: 100%;
	font-size: 0.8em;
	opacity: 0.7;
	margin-bottom: 2px;
}
.stratax-roles-matrix-rows {
	display: flex;
	flex-direction: column;
	gap: 8px;
}
/* Phone rows (role name above its multi-select). Desktop zones carry their own name header. */
.stratax-roles-matrix-row {
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.stratax-roles-matrix-viewer {
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.stratax-roles-zone {
	padding: 8px 10px 10px;
	border: 1px solid var(--border-color, rgba(128, 128, 128, 0.22));
	border-radius: var(--radius-sm);
	transition: border-color 0.12s ease, background 0.12s ease;
}
/* The role name heads its own dropzone; the chips body is padded below so drops never cover it. */
.stratax-roles-zone-title {
	font-weight: 600;
	margin-bottom: 8px;
}
.stratax-roles-zone-body {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	min-height: 30px;
}
.stratax-roles-zone--over {
	border-color: var(--accent-500, #46a08c);
	background: var(--accent-050, rgba(70, 160, 140, 0.08));
}
.stratax-roles-zone-empty {
	opacity: 0.5;
	font-size: 0.85em;
	font-style: italic;
}
.stratax-roles-src {
	cursor: grab;
}
.stratax-roles-src:active {
	cursor: grabbing;
}

/* Phone matrix: each role is a distinct card with its name + multi-select, visually separated.
 * The multi-select's chips can be long (role names); cap their width so they don't push the
 * overflow indicator off-screen. */
.stratax-roles-matrix-rows--phone {
	gap: 16px;
}
.stratax-roles-matrix-row--phone {
	padding: 12px;
	border: 1px solid var(--border-color, rgba(128, 128, 128, 0.22));
	border-radius: var(--radius-sm);
	background: var(--surface-1, rgba(128, 128, 128, 0.04));
	gap: 8px;
}
.stratax-roles-matrix-row--phone .stratax-roles-matrix-viewer {
	font-size: 1.05em;
	padding-bottom: 2px;
	border-bottom: 1px solid var(--border-color, rgba(128, 128, 128, 0.15));
	margin-bottom: 2px;
}
.stratax-roles-matrix-row--phone .hui-chip {
	max-width: 140px;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Narrow screens: the matrix renders as one multi-select per member role (no palette/drag) —
 * stack each viewer label above its control. The 1fr fallback also covers a narrow window where
 * the multi-select extension is unavailable and the drag layout still renders. */
@media (max-width: 620px) {
	.stratax-roles-matrix {
		grid-template-columns: 1fr;
	}
	.stratax-roles-matrix-row {
		grid-template-columns: 1fr;
		gap: 4px;
	}
	.stratax-roles-matrix-viewer {
		padding-top: 0;
	}
}
