/*
 * Hamo Taxonomy - Select Filter — dropdown personalizado de taxonomia.
 * Ao escolher um termo, navega para o arquivo dele (atualiza a página).
 * Dropdown custom (não o <select> nativo) para ser 100% estilizável.
 * Nunca declarar aqui as CSS vars escritas pelos controles (lição do
 * shadowing) — apenas consumir com var(--x, fallback).
 */

.hamo-ts {
	position: relative;
	width: var(--hamo-ts-width, 100%);
	max-width: 100%;
}

/* Alinhamento quando a largura é menor que a coluna (prefix_class na raiz). */
.hamo-ts-align-left .hamo-ts { margin-left: 0; margin-right: auto; }
.hamo-ts-align-center .hamo-ts { margin-left: auto; margin-right: auto; }
.hamo-ts-align-right .hamo-ts { margin-left: auto; margin-right: 0; }

/* ---------------- Botão (toggle) ---------------- */
.hamo-ts__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	margin: 0;
	text-align: left;
	background: var(--hamo-ts-toggle-bg, #ffffff);
	color: var(--hamo-ts-toggle-color, #1a1a1a);
	border: 1px solid var(--hamo-ts-toggle-border, #e6b800);
	border-radius: var(--hamo-ts-toggle-radius, 8px);
	padding: var(--hamo-ts-toggle-pad, 12px 18px);
	line-height: 1.2;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.hamo-ts__toggle:hover {
	background: var(--hamo-ts-toggle-bg-hover, var(--hamo-ts-toggle-bg, #ffffff));
	color: var(--hamo-ts-toggle-color-hover, var(--hamo-ts-toggle-color, #1a1a1a));
}

.hamo-ts__current {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hamo-ts__arrow {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--hamo-ts-arrow-color, currentColor);
	font-size: var(--hamo-ts-arrow-size, 16px);
	transition: transform 0.25s ease;
}

.hamo-ts__arrow svg {
	width: var(--hamo-ts-arrow-size, 16px);
	height: var(--hamo-ts-arrow-size, 16px);
	fill: currentColor;
}

.hamo-ts.is-open .hamo-ts__arrow {
	transform: rotate(180deg);
}

/* ---------------- Painel (lista) ---------------- */
.hamo-ts__panel {
	position: absolute;
	z-index: 99;
	left: 0;
	right: 0;
	top: calc(100% + var(--hamo-ts-panel-offset, 6px));
	margin: 0;
	padding: var(--hamo-ts-panel-pad, 6px);
	list-style: none;
	background: var(--hamo-ts-panel-bg, #ffffff);
	border: 1px solid var(--hamo-ts-panel-border, #e6b800);
	border-radius: var(--hamo-ts-panel-radius, 8px);
	box-shadow: var(--hamo-ts-panel-shadow, 0 12px 30px rgba(0, 0, 0, 0.12));
	max-height: var(--hamo-ts-panel-maxh, 320px);
	overflow-y: auto;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.hamo-ts.is-open .hamo-ts__panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.hamo-ts__item {
	margin: 0;
}

.hamo-ts__option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	width: 100%;
	text-decoration: none;
	cursor: pointer;
	color: var(--hamo-ts-option-color, inherit);
	background: var(--hamo-ts-option-bg, transparent);
	padding: var(--hamo-ts-option-pad, 10px 14px);
	border-radius: var(--hamo-ts-option-radius, 4px);
	line-height: 1.3;
	transition: background-color 0.15s ease, color 0.15s ease;
}

/* Divisória opcional entre itens (prefix_class hamo-ts-divider-yes na raiz). */
.hamo-ts-divider-yes .hamo-ts__item + .hamo-ts__item .hamo-ts__option {
	border-top: 1px solid var(--hamo-ts-divider-color, rgba(0, 0, 0, 0.08));
	border-radius: 0;
}

/* Sem cor de hover por padrão (só se o usuário definir nos controles). */
.hamo-ts__option:hover {
	background: var(--hamo-ts-option-bg-hover, transparent);
	color: var(--hamo-ts-option-color-hover, inherit);
}

/* Contorno apenas para foco por teclado (acessibilidade), sem cor imposta. */
.hamo-ts__option:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

.hamo-ts__option.is-active {
	background: var(--hamo-ts-option-bg-active, #bfe3ff);
	color: var(--hamo-ts-option-color-active, #1a1a1a);
}

.hamo-ts__label {
	flex: 1 1 auto;
	min-width: 0;
}

.hamo-ts__count {
	flex: 0 0 auto;
	color: var(--hamo-ts-count-color, inherit);
	opacity: var(--hamo-ts-count-opacity, 0.7);
}

/* Estado de carregamento aplicado ao loop-alvo durante o fetch AJAX. */
.hamo-ts-loading {
	opacity: 0.5;
	transition: opacity 0.2s ease;
	pointer-events: none;
}

/* Placeholder de edição no editor quando não há termos. */
.hamo-ts__placeholder {
	padding: 16px;
	text-align: center;
	opacity: 0.6;
	border: 1px dashed currentColor;
	border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
	.hamo-ts__panel,
	.hamo-ts__arrow,
	.hamo-ts__toggle,
	.hamo-ts__option {
		transition: none;
	}
}
