/* Accordion and FAQ (docs/widgets/accordion.md), in the design language (spec §3.7). This is Soft,
   the default: separate white cards with a thin border and a soft shadow, the icon on a pale accent
   circle. Fonts come from the theme. accordion-outline.css and accordion-solid.css change only the
   --hafe-acc-d-* tokens below, so a Style control's own property always wins.

   Each item is a <details>: the browser opens and closes it, with no script. */
.hafe-acc {
	--hafe-acc-d-bg: var(--hafe-surface);
	--hafe-acc-d-open-bg: var(--hafe-surface);
	--hafe-acc-d-line: var(--hafe-line);
	--hafe-acc-d-shadow: var(--hafe-shadow);
	--hafe-acc-d-radius: var(--hafe-radius-sm);
	--hafe-acc-d-inner-radius: var(--hafe-acc-radius, var(--hafe-acc-d-radius));
	--hafe-acc-d-gap: 0.75rem;
	--hafe-acc-d-overlap: 0px;
	--hafe-acc-d-hover: var(--hafe-tint);
	--hafe-acc-d-open-ink: var(--hafe-ink);
	--hafe-acc-d-icon-bg: var(--hafe-tint);
	--hafe-acc-d-icon-ink: var(--hafe-accent-ink);
	--hafe-acc-d-icon-ring: 0px;
	--hafe-acc-d-icon-hover: color-mix(in srgb, var(--hafe-acc-icon-bg, var(--hafe-acc-d-icon-bg)) 82%, currentColor);
	--hafe-acc-d-indent: 1.25em;
	display: flex;
	flex-direction: column;
	gap: var(--hafe-acc-gap, var(--hafe-acc-d-gap));
	color: var(--hafe-ink);
	interpolate-size: allow-keywords;
}

.hafe-acc--icon-start {
	--hafe-acc-d-indent: calc(2em + var(--hafe-acc-icon-size, 1.75em));
}

.hafe-acc__item {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	overflow: clip;
	border: var(--hafe-acc-line-width, 1px) solid var(--hafe-acc-line, var(--hafe-acc-d-line));
	border-radius: var(--hafe-acc-d-inner-radius);
	background: var(--hafe-acc-bg, var(--hafe-acc-d-bg));
	box-shadow: var(--hafe-acc-d-shadow);
}

/* Joined items (Outline) share their borders and round only the outer corners. The schema's
   script element may follow the last item, so these count items by type. */
.hafe-acc__item + .hafe-acc__item {
	margin-block-start: calc(-1 * var(--hafe-acc-d-overlap));
}

.hafe-acc__item:first-of-type {
	border-start-start-radius: var(--hafe-acc-radius, var(--hafe-acc-d-radius));
	border-start-end-radius: var(--hafe-acc-radius, var(--hafe-acc-d-radius));
}

.hafe-acc__item:last-of-type {
	border-end-start-radius: var(--hafe-acc-radius, var(--hafe-acc-d-radius));
	border-end-end-radius: var(--hafe-acc-radius, var(--hafe-acc-d-radius));
}

.hafe-acc__item[open] {
	background: var(--hafe-acc-open-bg, var(--hafe-acc-bg, var(--hafe-acc-d-open-bg)));
}

.hafe-acc .hafe-acc__title {
	display: flex;
	align-items: center;
	gap: 0.75em;
	margin: 0;
	padding: var(--hafe-acc-title-padding, 1em 1.25em);
	color: var(--hafe-acc-title-ink, var(--hafe-ink));
	list-style: none;
	cursor: pointer;
	transition: background-color 0.2s;
}

.hafe-acc__title::-webkit-details-marker {
	display: none;
}

/* A closed item is only its title, so the hover tint fills the card with even space around the
   text. On an open item it would be a band sitting right on the answer, so there only the icon
   answers the pointer. It does so on every item, so it never fades into the tint: its circle
   deepens by a share of its own ink (Solid: of black), whatever colours are chosen. */
.hafe-acc .hafe-acc__item:not([open]) > .hafe-acc__title:hover {
	background: var(--hafe-acc-hover-bg, var(--hafe-acc-d-hover));
}

.hafe-acc .hafe-acc__title:hover .hafe-acc__icon {
	background: var(--hafe-acc-d-icon-hover);
}

/* Inside the item, which clips, so the ring is drawn within the title. Stated here too: some packs
   take the outline off every focused control, site-wide. */
.hafe-acc .hafe-acc__item > .hafe-acc__title:focus-visible {
	outline: 2px solid var(--hafe-accent);
	outline-offset: -4px;
	border-radius: inherit;
}

.hafe-acc .hafe-acc__heading {
	flex: 1;
	min-inline-size: 0;
	margin: 0;
	padding: 0;
	color: inherit;
	font-size: 1.0625em;
	font-weight: 600;
	line-height: 1.4;
	overflow-wrap: break-word;
}

.hafe-acc__item[open] > .hafe-acc__title {
	color: var(--hafe-acc-title-open-ink, var(--hafe-acc-title-ink, var(--hafe-acc-d-open-ink)));
}

/* The icon: a circle with an arrow or a plus drawn in it, which turns as the item opens. */
.hafe-acc__icon {
	position: relative;
	box-sizing: border-box;
	flex: none;
	inline-size: var(--hafe-acc-icon-size, 1.75em);
	block-size: var(--hafe-acc-icon-size, 1.75em);
	border: var(--hafe-acc-d-icon-ring) solid;
	border-radius: 50%;
	background: var(--hafe-acc-icon-bg, var(--hafe-acc-d-icon-bg));
	color: var(--hafe-acc-icon-ink, var(--hafe-acc-d-icon-ink));
	transition: background-color 0.2s;
}

.hafe-acc--icon-start .hafe-acc__icon {
	order: -1;
}

.hafe-acc__icon::before,
.hafe-acc__icon::after {
	position: absolute;
	inset: 0;
	margin: auto;
	content: "";
	transition: transform var(--hafe-acc-speed, 0.25s);
}

.hafe-acc--icon-chevron .hafe-acc__icon::before {
	inline-size: 32%;
	block-size: 32%;
	border-block-end: 2px solid;
	border-inline-end: 2px solid;
	transform: translateY(-18%) rotate(45deg);
}

.hafe-acc--icon-chevron [open] .hafe-acc__icon::before {
	transform: translateY(18%) rotate(225deg);
}

.hafe-acc--icon-plus .hafe-acc__icon::before,
.hafe-acc--icon-plus .hafe-acc__icon::after {
	inline-size: 46%;
	block-size: 2px;
	border-radius: 1px;
	background: currentColor;
}

.hafe-acc--icon-plus .hafe-acc__icon::after {
	transform: rotate(90deg);
}

.hafe-acc--icon-plus [open] .hafe-acc__icon::after {
	transform: rotate(90deg) scaleX(0);
}

.hafe-acc .hafe-acc__content {
	padding: var(--hafe-acc-content-padding, 0 1.25em 1.25em var(--hafe-acc-d-indent));
	color: var(--hafe-acc-content-ink, var(--hafe-ink));
}

/* Right to left, the answer lines up with the title past the icon on the right. A padding set in the
   Style tab is the same on both sides, as Elementor's own are. */
.hafe-acc .hafe-acc__content:dir(rtl) {
	padding: var(--hafe-acc-content-padding, 0 var(--hafe-acc-d-indent) 1.25em 1.25em);
}

.hafe-acc__content > :first-child {
	margin-block-start: 0;
}

.hafe-acc__content > :last-child {
	margin-block-end: 0;
}

/* Opening and closing slide where the browser can animate to a height of auto. */
.hafe-acc__item::details-content {
	block-size: 0;
	overflow-y: clip;
	transition: block-size var(--hafe-acc-speed, 0.25s) ease, content-visibility var(--hafe-acc-speed, 0.25s) allow-discrete;
}

.hafe-acc__item[open]::details-content {
	block-size: auto;
}

@media (prefers-reduced-motion: reduce) {
	.hafe-acc .hafe-acc__title,
	.hafe-acc__icon,
	.hafe-acc__icon::before,
	.hafe-acc__icon::after,
	.hafe-acc__item::details-content {
		transition: none;
	}
}

@media print {
	.hafe-acc__icon {
		display: none;
	}
}

/* The search box (shown by accordion.js), and how many items match. */
.hafe-acc__search {
	display: flex;
	flex-direction: column;
	gap: 0.5em;
}

.hafe-acc__search[hidden],
.hafe-acc__item[hidden] {
	display: none;
}

/* Themes space, colour and weigh labels: this one follows the search box, like the text round it. */
.hafe-acc .hafe-acc__search-box {
	margin: 0;
	color: inherit;
	font-weight: inherit;
}

/* :not(#hafe-never): spec §4. */
.hafe-acc .hafe-acc__search-input:not(#hafe-never) {
	box-sizing: border-box;
	inline-size: 100%;
	margin: 0;
	padding: 0.75em 1em;
	border: 1px solid var(--hafe-line);
	border-radius: var(--hafe-acc-radius, var(--hafe-acc-d-radius));
	background: var(--hafe-surface);
	box-shadow: none;
	color: var(--hafe-ink);
	font: inherit;
}

.hafe-acc .hafe-acc__search-input:focus-visible {
	outline: 2px solid var(--hafe-accent);
	outline-offset: 2px;
}

.hafe-acc .hafe-acc__found {
	margin: 0;
	color: var(--hafe-ink-soft);
	font-size: 0.875em;
}

.hafe-acc .hafe-acc__found:empty {
	display: none;
}

.hafe-acc__sr {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}
