/*
 * Modality icons: input chips -> arrow -> output chips.
 * Shared by the Model page, Models Directory (cards + quick-details modal),
 * the Home cards and the logged-in panel's Models tab.
 * Markup: AIAPI_Modalities::render() / window.AIAPIModalities.build().
 */

.aiapi-mods {
	/* Above the cards' stretched "open page" links so hover/tap reaches the chips. */
	position: relative;
	z-index: 3;
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	vertical-align: middle;
}
.aiapi-mods--sm { gap: 4px; }

/*
 * Always read left -> right: inputs on the LEFT, arrow, outputs on the RIGHT,
 * on LTR and RTL pages alike. Forced with !important so
 * a theme / RTL stylesheet (direction: rtl, row-reverse, scaleX(-1) on svgs)
 * can never mirror the row.
 */
.aiapi-mods,
html[dir] .aiapi-mods,
[dir="rtl"] .aiapi-mods {
	direction: ltr !important;
	unicode-bidi: isolate !important;
	flex-direction: row !important;
	justify-content: flex-start !important;
}
.aiapi-mods-arrow svg,
[dir="rtl"] .aiapi-mods-arrow svg { transform: none !important; }

.aiapi-mods-arrow {
	display: inline-flex;
	flex: none;
	color: var(--aiapih-text-faint, var(--ains-text-muted, #8a8fa8));
}

.aiapi-mod {
	--mod-c: #1d9bf0;
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 30px;
	height: 30px;
	border-radius: 9px;
	color: var(--mod-c);
	background: color-mix(in srgb, var(--mod-c) 14%, transparent);
	cursor: default;
	outline: none;
	-webkit-tap-highlight-color: transparent;
	transition: transform .15s ease, box-shadow .15s ease;
}
.aiapi-mods--sm .aiapi-mod { width: 24px; height: 24px; border-radius: 7px; }

.aiapi-mod svg { display: block; flex: none; }

.aiapi-mod.is-text   { --mod-c: #1d9bf0; }
.aiapi-mod.is-image  { --mod-c: #1fa97e; }
.aiapi-mod.is-audio  { --mod-c: #0d9488; }
.aiapi-mod.is-file   { --mod-c: #e0a21a; }
.aiapi-mod.is-vector { --mod-c: #7c5cff; }

.aiapi-mod:hover,
.aiapi-mod:focus-visible,
.aiapi-mod.is-tip-open {
	transform: translateY(-1px);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--mod-c) 32%, transparent);
}

/* ------------------------------------------------------------------ */
/* Tooltip — one floating element on <body>, positioned by modalities.js */
/* ------------------------------------------------------------------ */

.aiapi-mod-tip {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 2147483000;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1px;
	padding: 6px 12px;
	border-radius: 9px;
	background: #0d0f1f;
	border: 1px solid rgba(255, 255, 255, .12);
	color: #fff;
	text-align: center;
	line-height: 1.4;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	box-shadow: 0 8px 24px rgba(13, 15, 31, .28);
	transition: opacity .14s ease, visibility .14s;
}
.aiapi-mod-tip.is-visible { opacity: 1; visibility: visible; }

.aiapi-mod-tip b { font-size: 13px; font-weight: 800; }
.aiapi-mod-tip small { font-size: 10.5px; font-weight: 600; color: rgba(255, 255, 255, .62); }

.aiapi-mod-tip-arrow {
	position: absolute;
	left: var(--arrow-x, 50%);
	bottom: -5px;
	width: 8px;
	height: 8px;
	margin-left: -4px;
	background: #0d0f1f;
	border-right: 1px solid rgba(255, 255, 255, .12);
	border-bottom: 1px solid rgba(255, 255, 255, .12);
	transform: rotate(45deg);
}
/* Not enough room above the chip: the tooltip sits below it. */
.aiapi-mod-tip.is-below .aiapi-mod-tip-arrow {
	bottom: auto;
	top: -5px;
	border-right: 0;
	border-bottom: 0;
	border-left: 1px solid rgba(255, 255, 255, .12);
	border-top: 1px solid rgba(255, 255, 255, .12);
}

@media (prefers-reduced-motion: reduce) {
	.aiapi-mod, .aiapi-mod-tip { transition: none; }
}
