/* ==========================================================================
   Shared search + filter unit

   Single source of truth for the .etb-filter-unit component (search row,
   filter buttons, dropdown panels, active chips). Loaded on any listing page
   that carries the `.etb-listing` class on its wrapper — currently the Videos
   landing and the Free Tools archive landing. Edit the filter's look here and
   it changes on every page at once.

   Extracted verbatim from videos-landing.css (which held the only copy) so the
   two pages could stop drifting apart. The rules use bare selectors and lean
   on general palette tokens (--etb-orange, --color-text-*, --color-border-*)
   that each landing already defines on its own wrapper; only the tokens unique
   to the filter live here, on `.etb-listing`.
   ========================================================================== */

.etb-listing {
	--etb-active-filter-bg:  rgba(250, 70, 22, 0.08);
	--etb-active-chip-bg:    rgba(250, 70, 22, 0.10);
	--etb-active-chip-bdr:   rgba(250, 70, 22, 0.30);
	--etb-filter-panel-bg:   rgba(0, 0, 0, 0.025);
}

/* ==========================================================================
   Search + Filter unit
   ========================================================================== */

.etb-filter-unit {
	border: 0.5px solid var(--color-border-secondary);
	border-radius: 12px;
	overflow: hidden;
	background: #fff;
}

/* Default state: no bottom margin (chips row absent) */
.etb-filter-unit {
	margin-bottom: 1.75rem;
}

/* When chips are visible JS adds .has-chips to the unit and removes margin
   since .etb-active-chips itself carries the 1.75rem bottom margin */
.etb-filter-unit.has-chips {
	margin-bottom: 0;
}

/* Search row */
.etb-search-row {
	padding: 9px 14px;
	display: flex;
	align-items: center;
	gap: 10px;
}

.etb-search-icon {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	color: var(--color-text-tertiary);
}

.etb-search-input {
	flex: 1;
	border: none;
	outline: none;
	background: transparent;
	font-size: 16px;
	color: var(--color-text-primary);
	min-width: 0;
}

.etb-search-input::placeholder {
	color: var(--color-text-tertiary);
}

.etb-kbd {
	font-size: 10px;
	color: var(--color-text-tertiary);
	background: rgba(0, 0, 0, 0.05);
	border: 0.5px solid var(--color-border-secondary);
	border-radius: 4px;
	padding: 2px 5px;
	flex-shrink: 0;
	font-family: inherit;
	white-space: nowrap;
}

/* Filter row */
.etb-filter-row {
	border-top: 0.5px solid var(--color-border-tertiary);
	padding: 7px 14px;
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

/* Filter funnel icon — own column, aligned with first button row */
.etb-filter-label {
	color: var(--color-text-tertiary);
	flex-shrink: 0;
	display: block;
	/* (button line-height ~22px + top/bottom padding 5px each = 32px; funnel is 18px) → (32-18)/2 = 7px */
	margin-top: 7px;
}

/* Buttons + count — wrap freely; second row stays indented by funnel column */
.etb-filter-buttons {
	flex: 1;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 7px;
	min-width: 0;
}

/* Count stays on the far right of its row */
.etb-filter-buttons .etb-video-count {
	margin-left: auto;
	flex-shrink: 0;
}

/* Filter button — default */
.etb-filter-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 16px;
	font-weight: 400;
	padding: 5px 11px;
	border: 0.5px solid var(--color-border-secondary);
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.05);
	color: var(--color-text-primary);
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
	white-space: nowrap;
	outline: none;
}

.etb-filter-btn:hover,
.etb-filter-btn:focus {
	background: var(--etb-active-filter-bg);
	border-color: var(--etb-orange);
	color: var(--etb-orange);
}

/* Filter button — active (has selections) */
.etb-filter-btn.is-active {
	background: var(--etb-active-filter-bg);
	border: 1px solid var(--etb-orange);
	color: var(--etb-orange);
}

/* Count badge inside active filter button */
.etb-filter-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--etb-orange);
	color: #fff;
	border-radius: 10px;
	padding: 0 5px;
	font-size: 10px;
	min-width: 16px;
	line-height: 1.6;
}

/* Chevron icon — rotate when panel is open */
.etb-chevron {
	width: 10px;
	height: 10px;
	flex-shrink: 0;
	transition: transform 0.2s;
}

.etb-filter-btn[aria-expanded="true"] .etb-chevron {
	transform: rotate(180deg);
}

/* Count — right-aligned */
.etb-video-count {
	margin-left: auto;
	font-size: 13px;
	color: var(--color-text-tertiary);
	white-space: nowrap;
}

/* ==========================================================================
   Filter panel
   ========================================================================== */

.etb-filter-panel {
	border-top: 0.5px solid var(--color-border-tertiary);
	background: var(--etb-filter-panel-bg);
	padding: 12px 14px;
	/* Bounded so a long term list scrolls inside the dropdown instead of
	   pushing the whole page down. */
	max-height: 60vh;
	overflow-y: auto;
}

.etb-filter-panel[hidden] {
	display: none;
}

.etb-panel-search {
	width: 100%;
	padding: 6px 10px;
	font-size: 13px;
	border: 0.5px solid var(--color-border-secondary);
	border-radius: 6px;
	background: #fff;
	color: var(--color-text-primary);
	outline: none;
	margin-bottom: 10px;
	box-sizing: border-box;
}

.etb-panel-search::placeholder {
	color: var(--color-text-tertiary);
}

.etb-filter-checkboxes {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 4px 16px;
}

.etb-check-label {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	cursor: pointer;
	padding: 3px 0;
	color: var(--color-text-primary);
}

.etb-check-label input[type="checkbox"] {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
	accent-color: var(--etb-orange);
	cursor: pointer;
}

.etb-check-label.is-hidden {
	display: none;
}

.etb-hidden-terms {
	display: contents;
}

.etb-hidden-terms[hidden] {
	display: none;
}

.etb-show-more-terms {
	grid-column: 1 / -1;
	background: none;
	border: none;
	color: var(--etb-orange);
	font-size: 13px;
	cursor: pointer;
	padding: 4px 0 0;
	text-align: left;
	outline: none;
}

.etb-show-more-terms:hover,
.etb-show-more-terms:focus {
	background: none;
	color: var(--color-text-primary);
}

/* ==========================================================================
   Active filter chips
   ========================================================================== */

.etb-active-chips {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	margin-bottom: 1.75rem;
	margin-top: 0.75rem;
}

.etb-active-chips[hidden] {
	display: none;
}

.etb-chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	background: var(--etb-active-chip-bg);
	color: var(--etb-orange);
	border: 1px solid var(--etb-active-chip-bdr);
	border-radius: 20px;
	padding: 3px 10px;
	font-size: 13px;
	cursor: pointer;
	line-height: 1.4;
	transition: background 0.15s;
}

.etb-chip:hover {
	background: var(--etb-orange);
	color: #fff;
	border-color: var(--etb-orange);
}

.etb-chip-x {
	font-size: 14px;
	line-height: 1;
	opacity: 0.7;
}

.etb-clear-all {
	font-size: 13px;
	color: var(--color-text-tertiary);
	text-decoration: underline;
	background: none;
	border: none;
	cursor: pointer;
	padding: 0;
	margin-left: 2px;
	transition: color 0.15s;
}

.etb-clear-all:hover {
	background: none;
	color: var(--color-text-primary);
	text-decoration: none;
}

/* ==========================================================================
   Responsive (filter-unit only)
   ========================================================================== */

@media (max-width: 900px) {
	.etb-filter-checkboxes {
		grid-template-columns: 1fr 1fr;
	}
}

@media (max-width: 600px) {
	.etb-filter-checkboxes {
		grid-template-columns: 1fr;
	}

	.etb-filter-buttons {
		gap: 5px;
	}

	.etb-filter-btn {
		font-size: 14px;
		padding: 5px 9px;
	}

	.etb-filter-row {
		gap: 7px;
	}

	.etb-kbd {
		display: none;
	}
}
