/* Category chips above the calendar. Colours come from TEC's category colours via --rics-chip-color. */
.rics-chips {
	--rics-chip-color: #646970;
	--rics-chip-on-color: #ffffff;
	--rics-chip-ink: var(--tec-color-text-primary, #141827);
	--rics-chip-border: var(--tec-color-border-default, #d5d5d5);
	--rics-chip-bg: var(--tec-color-background, #ffffff);
	--rics-chip-focus: var(--tec-color-accent-primary, #334aff);
}

/* Specific enough to beat TEC's and the theme's element resets, which zeroed the margin.
   TEC's header is a wrapping flex row: take a full line, and min-width 0 so a long chip row scrolls instead of
   stretching the nav past the screen. */
.tribe-common nav.rics-chips,
nav.rics-chips {
	flex: 0 0 100%;
	margin: var(--tec-spacer-4, 16px) 0 var(--tec-spacer-5, 24px);
	max-width: 100%;
	min-width: 0;
}

/* Scoped under .rics-chips: TEC's reset (.tribe-common ul, li, span { border: 0; padding: 0; margin: 0 }) is
   more specific than a single class and would win otherwise. */
.rics-chips .rics-chips__list,
.rics-chips .rics-chips__menu {
	list-style: none;
	margin: 0;
	padding: 0;
}

.rics-chips .rics-chips__list {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.rics-chips .rics-chips__item {
	margin: 0;
}

.rics-chips a.rics-chip,
.tribe-common .rics-chips a.rics-chip,
.tribe-common .rics-chips a.rics-chip:visited,
.tribe-common .rics-chips a.rics-chip:active,
.tribe-common .rics-chips a.rics-chip:focus,
.rics-chips summary.rics-chip {
	align-items: center;
	background: var(--rics-chip-bg);
	/* Style and colour come through variables, so the chip variants below can't lose to these selectors. */
	border: 2px var(--rics-chip-border-style, solid) var(--rics-chip-color);
	border-radius: 22px;
	box-sizing: border-box;
	color: var(--rics-chip-ink);
	cursor: pointer;
	display: inline-flex;
	font-family: inherit;
	font-size: 16px;
	font-weight: 600;
	gap: 8px;
	line-height: 1.2;
	min-height: 44px;
	min-width: 44px;
	padding: 8px 16px;
	text-decoration: none;
	transition: background-color 0.15s;
}

.rics-chips .rics-chip--all {
	--rics-chip-color: var(--rics-chip-ink);
}

.rics-chips .rics-chip--no-color {
	--rics-chip-border-style: dashed;
}

.rics-chips .rics-chip__dot {
	background: var(--rics-chip-color);
	border: 2px solid var(--rics-chip-bg);
	border-radius: 50%;
	box-shadow: 0 0 0 1px var(--rics-chip-color);
	flex: 0 0 auto;
	height: 12px;
	width: 12px;
}

.tribe-common .rics-chips a.rics-chip:hover,
.rics-chips summary.rics-chip:hover {
	background: color-mix(in srgb, var(--rics-chip-color) 12%, var(--rics-chip-bg));
	color: var(--rics-chip-ink);
	text-decoration: underline;
}

.tribe-common .rics-chips a.rics-chip--all:hover {
	background: color-mix(in srgb, var(--rics-chip-ink) 8%, var(--rics-chip-bg));
}

/* Selected: filled with the category colour, plus a check mark so the state never relies on colour alone. */
.tribe-common .rics-chips a.rics-chip--active,
.tribe-common .rics-chips a.rics-chip--active:visited,
.tribe-common .rics-chips a.rics-chip--active:hover,
.tribe-common .rics-chips a.rics-chip--active:focus,
.rics-chips summary.rics-chip--active {
	background: var(--rics-chip-color);
	color: var(--rics-chip-on-color);
	text-decoration: none;
}

.tribe-common .rics-chips a.rics-chip--all.rics-chip--active,
.tribe-common .rics-chips a.rics-chip--all.rics-chip--active:visited,
.tribe-common .rics-chips a.rics-chip--all.rics-chip--active:hover,
.tribe-common .rics-chips a.rics-chip--all.rics-chip--active:focus {
	background: var(--rics-chip-ink);
	color: var(--rics-chip-bg);
}

.rics-chip--active::before {
	content: "\2713";
	font-weight: 700;
}

.rics-chip--active .rics-chip__dot {
	display: none;
}

.tribe-common .rics-chips a.rics-chip:focus-visible,
.rics-chips a.rics-chip:focus-visible,
.rics-chips .rics-chips__more summary:focus-visible {
	outline: 3px solid var(--rics-chip-focus);
	outline-offset: 2px;
}

/* "More" menu for long category lists. */
.rics-chips__more {
	position: relative;
}

.rics-chips__more summary {
	--rics-chip-color: var(--rics-chip-ink);
	list-style: none;
}

.rics-chips__more summary::-webkit-details-marker {
	display: none;
}

.rics-chips__more summary::after {
	content: "\25BE";
}

.rics-chips__more details[open] summary::after {
	content: "\25B4";
}

.rics-chips .rics-chips__menu {
	background: var(--rics-chip-bg);
	border: 1px solid var(--rics-chip-border);
	border-radius: 8px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
	display: flex;
	flex-direction: column;
	gap: 6px;
	left: 0;
	max-width: calc(100vw - 32px);
	min-width: 220px;
	padding: 8px;
	position: absolute;
	top: calc(100% + 6px);
	z-index: 20;
}

/* Set by chips.js when the menu would cross the right edge of the screen. */
.rics-chips .rics-chips__menu--end {
	left: auto;
	right: 0;
}

.rics-chips .rics-chips__menu .rics-chip {
	width: 100%;
}

/* Phones: one row that scrolls sideways (spec §7), slightly tighter chips (touch targets stay 44px tall). */
@media (max-width: 600px) {
	.rics-chips .rics-chips__list {
		flex-wrap: nowrap;
		gap: 6px;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		/* Room for the focus ring, which the scroll container would otherwise clip. */
		padding: 6px;
		margin: -6px;
		position: relative;
		scroll-padding-inline: 6px;
		scrollbar-width: thin;
		-webkit-overflow-scrolling: touch;
	}

	.rics-chips .rics-chips__item {
		flex: 0 0 auto;
	}

	.rics-chips a.rics-chip,
	.tribe-common .rics-chips a.rics-chip {
		white-space: nowrap;
	}

	/* The scroll row would clip a dropdown, so the "More" chips open inline, to the right of "More". */
	.rics-chips__more details[open] {
		display: flex;
		gap: 6px;
	}

	.rics-chips .rics-chips__menu {
		background: none;
		border: 0;
		box-shadow: none;
		flex-direction: row;
		min-width: 0;
		padding: 0;
		position: static;
	}

	.rics-chips .rics-chips__menu .rics-chip {
		width: auto;
	}

	.rics-chips a.rics-chip,
	.tribe-common .rics-chips a.rics-chip,
	.rics-chips summary.rics-chip {
		font-size: 15px;
		gap: 6px;
		padding: 8px 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.rics-chip {
		transition: none;
	}
}

@media print {
	.rics-chips {
		display: none;
	}
}
