/*
 * Features — Accordion + Preview
 * Port of 21st.dev "accordion-feature-section".
 */

.cw-acc {
	--cw-fg: #18181b;
	--cw-muted: #71717a;
	--cw-border: rgba(0, 0, 0, 0.1);

	--cw-list-width: 50%;
	--cw-columns-gap: 3rem;
	--cw-row-padding: 1.25rem;
	--cw-fade: 350ms;

	position: relative;
	width: 100%;
	color: var(--cw-fg);
}

.cw-acc[data-cw-theme='dark'] {
	--cw-fg: #fafafa;
	--cw-muted: #a1a1aa;
	--cw-border: rgba(255, 255, 255, 0.12);
}

/* --------------------------------------------------------------------- Title block */

.cw-acc__header {
	margin-bottom: 3rem;
}

.cw-acc__eyebrow {
	display: block;
	margin-bottom: 0.75rem;
	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.08em;
	color: #2f5fbf;
}

.cw-acc__heading {
	display: block;
}

.cw-acc__title {
	display: block;
	font-size: clamp(1.75rem, 1.2rem + 2vw, 2.75rem);
	font-weight: 600;
	line-height: 1.15;
	letter-spacing: -0.02em;
	color: var(--cw-fg);
	text-wrap: balance;
}

.cw-w .cw-acc__description {
	/* inline-block so a max-width box follows the header's text-align
	   instead of staying pinned to the left. */
	display: inline-block;
	margin-top: 0.875rem;
	font-size: 1.0625rem;
	line-height: 1.65;
	color: var(--cw-muted);
	text-wrap: pretty;
}

/* ------------------------------------------------------------------------ Columns */

.cw-acc__inner {
	display: flex;
	align-items: flex-start;
	gap: var(--cw-columns-gap);
}

.cw-acc__list {
	flex: 1 1 auto;
	min-width: 0;
}

.cw-acc--has-preview .cw-acc__list {
	flex: 0 0 var(--cw-list-width);
	max-width: var(--cw-list-width);
}

.cw-acc--preview-left .cw-acc__inner {
	flex-direction: row-reverse;
}

/* -------------------------------------------------------------------------- Items */

.cw-acc--dividers .cw-acc__item {
	border-bottom-width: 1px;
	border-bottom-color: var(--cw-border);
}

.cw-acc__item-heading {
	display: flex;
}

.cw-w .cw-acc__trigger {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	width: 100%;
	padding: var(--cw-row-padding) 0;
	text-align: left;
	cursor: pointer;
	background: transparent;
	transition: color 150ms ease;
}

.cw-acc__item-title {
	font-size: 1.25rem;
	font-weight: 600;
	line-height: 1.35;
	/* Closed items are dimmed; the open one lifts to full contrast. */
	color: var(--cw-muted);
	transition: color 150ms ease;
}

.cw-acc__item.is-open .cw-acc__item-title,
.cw-w .cw-acc__trigger:hover .cw-acc__item-title {
	color: var(--cw-fg);
}

.cw-acc__chevron {
	display: inline-flex;
	flex: 0 0 auto;
	color: var(--cw-muted);
	transform: rotate(90deg);
	transition: transform 200ms ease;
}

.cw-acc__item.is-open .cw-acc__chevron {
	transform: rotate(-90deg);
}

.cw-acc__chevron .cw-icon {
	width: 16px;
	height: 16px;
}

/* Stated explicitly so a theme's button:hover cannot paint the row. */
.cw-w .cw-acc__trigger:hover,
.cw-w .cw-acc__trigger:focus {
	background: transparent;
	color: inherit;
}

.cw-w .cw-acc__trigger:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

/* The 0fr/1fr grid trick animates to the panel's natural height without JS measuring
   it. Browsers without interpolation support still collapse and expand — just instantly. */
.cw-acc__panel {
	display: grid;
	grid-template-rows: 0fr;
	transition: grid-template-rows var(--cw-fade) ease;
}

.cw-acc__item.is-open .cw-acc__panel {
	grid-template-rows: 1fr;
}

.cw-acc__panel-inner {
	overflow: hidden;
	min-height: 0;
}

.cw-w .cw-acc__item-desc {
	padding-bottom: var(--cw-desc-bottom, 1rem);
	font-size: 1rem;
	line-height: 1.65;
	color: var(--cw-muted);
	text-wrap: pretty;
}

.cw-acc__item-media {
	display: none;
	padding-bottom: var(--cw-desc-bottom, 1rem);
}

.cw-acc .cw-acc__item-media img {
	width: 100%;
	height: 20rem;
	max-height: 60vh;
	object-fit: cover;
	border-radius: 0.75rem;
}

/* ------------------------------------------------------------------------ Preview */

.cw-acc__preview {
	position: relative;
	display: block;
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	border-radius: 0.75rem;
	background-color: rgba(0, 0, 0, 0.04);
}

/* One image, src swapped by the script. width/height are also set inline in PHP so the
   panel is filled even if this stylesheet is stale or overridden. */
.cw-acc .cw-acc__preview-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: opacity var(--cw-fade) ease;
}

.cw-acc .cw-acc__preview-img.is-swapping {
	opacity: 0;
}

/* ------------------------------------------------------------------------- Mobile */

@media (max-width: 767px) {
	.cw-acc__inner,
	.cw-acc--preview-left .cw-acc__inner {
		flex-direction: column;
	}

	.cw-acc--has-preview .cw-acc__list {
		flex: 1 1 auto;
		max-width: 100%;
		width: 100%;
	}

	/* With images shown inside each item, the side panel is redundant. */
	.cw-acc--inline-media .cw-acc__preview {
		display: none;
	}

	.cw-acc--inline-media .cw-acc__item-media {
		display: block;
	}

	.cw-acc__header {
		margin-bottom: 2rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cw-acc__panel,
	.cw-acc__preview-img,
	.cw-acc__chevron {
		transition: none;
	}
}
