/**
 * HiaTags Tag Index — scoped styles.
 *
 * Everything is namespaced under .hiatags-wrap, and chips are qualified with the
 * element (a.hiatags-chip) so the rules out-specify bare-element styling from block
 * themes such as Twenty Twenty-Five without resorting to !important.
 *
 * Custom-property defaults live here so the plugin looks right before any settings
 * are saved; the admin settings page emits an inline <style> that overrides them.
 */

.hiatags-wrap {
	--hiatags-font-size: 14px;
	--hiatags-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--hiatags-chip-pad-x: 10px;
	--hiatags-chip-pad-y: 4px;
	--hiatags-chip-radius: 4px;
	--hiatags-chip-gap: 6px;

	/* Dark theme with #ff2fb2 accent. The chip/header colors below are also exposed
	   on the Settings → Tag Index screen; the rest are CSS-variable-only "chrome". */
	--hiatags-chip-bg: #242424;
	--hiatags-chip-color: #f2f2f2;
	--hiatags-chip-hover-bg: #ff2fb2;
	--hiatags-chip-hover-color: #111111;
	--hiatags-header-color: #ff2fb2;

	/* Surrounding chrome (not in the settings UI — override here if needed). */
	--hiatags-bg: #111111;
	--hiatags-input-bg: #1a1a1a;
	--hiatags-input-border: #333333;
	--hiatags-input-color: #f2f2f2;
	--hiatags-muted: #999999;

	font-family: var(--hiatags-font-family);
	font-size: var(--hiatags-font-size);
	line-height: 1.4;
	box-sizing: border-box;
}

.hiatags-wrap *,
.hiatags-wrap *::before,
.hiatags-wrap *::after {
	box-sizing: border-box;
}

/* Sticky search bar. */
.hiatags-wrap .hiatags-controls {
	position: sticky;
	top: 0;
	z-index: 2;
	background: var(--hiatags-bg);
	padding: 8px 0;
	margin-bottom: 8px;
}

.hiatags-wrap .hiatags-search {
	width: 100%;
	max-width: 420px;
	font-family: inherit;
	font-size: calc(var(--hiatags-font-size) + 2px);
	padding: 8px 12px !important;
	border: 1px solid var(--hiatags-input-border) !important;
	border-radius: var(--hiatags-chip-radius) !important;
	background: var(--hiatags-input-bg) !important;
	color: var(--hiatags-input-color) !important;
}

.hiatags-wrap .hiatags-search:focus {
	outline: none;
	border-color: var(--hiatags-chip-hover-bg);
}

.hiatags-wrap .hiatags-search::placeholder {
	color: var(--hiatags-muted);
	opacity: 1;
}

/* A–Z jump bar. */
.hiatags-wrap .hiatags-jump {
	display: flex !important;
	flex-wrap: wrap !important;
	gap: 4px !important;
	margin-top: 8px;
}

/* The A–Z jump buttons reuse the tag-chip colors so the bar matches the chips.
   !important keeps them safe from theme <button> styling, same as the chips. */
.hiatags-wrap .hiatags-jump-letter {
	display: inline-block !important;
	min-width: 1.9em;
	box-sizing: border-box;
	text-align: center;
	font-family: inherit;
	font-size: var(--hiatags-font-size) !important;
	line-height: 1.4 !important;
	padding: 2px 6px !important;
	border: 0 !important;
	border-radius: var(--hiatags-chip-radius) !important;
	background: var(--hiatags-chip-bg) !important;
	color: var(--hiatags-chip-color) !important;
	text-decoration: none !important;
}

.hiatags-wrap button.hiatags-jump-letter {
	cursor: pointer;
}

.hiatags-wrap button.hiatags-jump-letter:hover,
.hiatags-wrap button.hiatags-jump-letter:focus {
	background: var(--hiatags-chip-hover-bg) !important;
	color: var(--hiatags-chip-hover-color) !important;
	outline: none;
}

.hiatags-wrap button.hiatags-jump-letter:focus-visible {
	outline: 2px solid var(--hiatags-chip-hover-bg);
	outline-offset: 2px;
}

/* Letters with no (visible) tags — dimmed and inert. */
.hiatags-wrap .hiatags-jump-empty,
.hiatags-wrap button.hiatags-jump-letter:disabled {
	opacity: 0.3;
	cursor: default;
	pointer-events: none;
	background: transparent !important;
	color: var(--hiatags-chip-color) !important;
}

/* Letter sections. scroll-margin keeps the heading clear of the sticky bar on jump. */
.hiatags-wrap .hiatags-section {
	margin: 0 0 1.25em;
	padding: 0;
	border: 0;
	scroll-margin-top: 96px;
}

.hiatags-wrap .hiatags-letter {
	font-family: inherit;
	font-size: calc(var(--hiatags-font-size) + 8px);
	font-weight: 700;
	color: var(--hiatags-header-color) !important;
	margin: 0 0 0.4em;
	padding: 0 0 0.2em;
	border-bottom: 2px solid currentColor;
	line-height: 1.2;
}

/* Chip grid — uniform chips, no size variation by post count (booru style).
   The layout + gap are forced so a theme can't flatten the flex container or
   override the spacing (which would make "Space between chips" do nothing). */
.hiatags-wrap .hiatags-chips {
	display: flex !important;
	flex-wrap: wrap !important;
	gap: var(--hiatags-chip-gap) !important;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Tag chips are <a> links, so themes love to style them (background, padding,
   color, underline). The !important flags below guarantee the plugin's settings win
   over the active theme — they still resolve the CSS variables, so the Settings page
   and Additional CSS variable overrides keep working. */
.hiatags-wrap a.hiatags-chip {
	display: inline-flex !important;
	align-items: baseline;
	gap: 6px;
	width: auto !important;
	font-family: inherit;
	font-size: var(--hiatags-font-size) !important;
	line-height: 1.3 !important;
	padding: var(--hiatags-chip-pad-y) var(--hiatags-chip-pad-x) !important;
	border-radius: var(--hiatags-chip-radius) !important;
	background: var(--hiatags-chip-bg) !important;
	color: var(--hiatags-chip-color) !important;
	text-decoration: none !important;
	box-shadow: none !important;
	border: 0 !important;
	margin: 0 !important; /* let the container's gap be the only spacing between chips */
	float: none !important;
	transition: background-color 0.12s ease, color 0.12s ease;
}

.hiatags-wrap a.hiatags-chip:hover,
.hiatags-wrap a.hiatags-chip:focus {
	background: var(--hiatags-chip-hover-bg) !important;
	color: var(--hiatags-chip-hover-color) !important;
	text-decoration: none !important;
	outline: none;
}

.hiatags-wrap a.hiatags-chip:focus-visible {
	outline: 2px solid var(--hiatags-chip-hover-bg);
	outline-offset: 2px;
}

.hiatags-wrap .hiatags-count {
	font-size: 0.82em;
	opacity: 0.7;
}

/* States. */
.hiatags-wrap .hiatags-hidden {
	display: none !important; /* Beat any theme rule that forces display on these nodes. */
}

.hiatags-wrap .hiatags-noresults,
.hiatags-wrap .hiatags-empty {
	color: var(--hiatags-muted);
	font-style: italic;
	margin: 0.5em 0;
}

.hiatags-wrap .hiatags-noresults[hidden] {
	display: none;
}

/* Accessible visually-hidden label. */
.hiatags-wrap .hiatags-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
