/**
 * Advanced Post FAQ — Frontend Styles
 * All selectors are namespaced under .apf-accordion to avoid theme collisions.
 * No WordPress default UI components are used here by design.
 */

.apf-accordion {
	--apf-icon-color: #9CA3AF;
	max-width: 800px;
	margin: 20px auto;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
	display: flex;
	flex-direction: column;
	gap: var(--apf-spacing, 16px);
	box-sizing: border-box;
}

.apf-accordion *,
.apf-accordion *::before,
.apf-accordion *::after {
	box-sizing: border-box;
}

/* Card */
.apf-item {
	border: 1px solid var(--apf-border-color, #ECECEC);
	border-radius: var(--apf-border-radius, 12px);
	background-color: #ffffff;
	box-shadow: var(--apf-card-shadow, 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03));
	overflow: hidden;
	margin: 0;
	transition: none; /* explicitly no visual change on interaction/hover */
}

/* Explicitly neutralise any theme hover styling on the card itself */
.apf-item:hover {
	background-color: #ffffff;
	border-color: var(--apf-border-color, #ECECEC);
	box-shadow: var(--apf-card-shadow, 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03));
}

.apf-question {
	margin: 0;
	padding: 0;
	font-size: inherit;
	font-weight: inherit;
	line-height: inherit;
}

.apf-question-btn {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	width: 100%;
	padding: 26px 30px;
	margin: 0;
	background: transparent;
	border: none;
	border-radius: 0;
	text-align: left;
	font-family: inherit;
	font-size: 1.125rem; /* 18px */
	line-height: 1.4;
	font-weight: 700;
	color: var(--apf-primary-color, #111827);
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	text-decoration: none;
}

.apf-question-text {
	flex: 1 1 auto;
}

/* Explicit resets so theme button/link hover & focus styles never alter appearance */
.apf-question-btn:hover,
.apf-question-btn:focus,
.apf-question-btn:active,
.apf-question-btn:visited {
	background-color: transparent !important;
	color: var(--apf-primary-color, #111827) !important;
	border: none !important;
	text-decoration: none !important;
	box-shadow: none !important;
	outline: none;
}

/* Accessible keyboard focus indicator only (not a hover effect) */
.apf-question-btn:focus-visible {
	outline: 2px solid var(--apf-primary-color, #111827);
	outline-offset: -4px;
	border-radius: 6px;
}

/* Answer */
.apf-answer {
	color: #4B5563;
	font-size: 1rem;
	line-height: 1.75;
}

.apf-answer-inner {
	padding: 0 30px 26px;
}

.apf-answer-content p {
	margin: 0 0 12px;
}

.apf-answer-content p:last-child {
	margin-bottom: 0;
}

/* Default (no-animation) toggle behaviour */
.apf-answer[hidden] {
	display: none;
}

/* Smooth, flicker-free height animation using animated grid rows.
   No JS height measurement needed, so there is nothing to jump/flicker. */
.apf-has-animation .apf-answer {
	display: grid;
	grid-template-rows: 0fr;
	opacity: 0;
	visibility: hidden;
	transition: grid-template-rows 0.35s cubic-bezier(0.4, 0, 0.2, 1),
	            opacity 0.28s ease,
	            visibility 0s linear 0.35s;
}

.apf-has-animation .apf-answer-inner {
	overflow: hidden;
	min-height: 0;
}

.apf-has-animation .apf-item--open > .apf-answer {
	grid-template-rows: 1fr;
	opacity: 1;
	visibility: visible;
	transition: grid-template-rows 0.35s cubic-bezier(0.4, 0, 0.2, 1),
	            opacity 0.28s ease 0.05s,
	            visibility 0s linear 0s;
}

/* When animation is enabled, [hidden] is replaced by the grid technique above */
.apf-has-animation .apf-answer[hidden] {
	display: none !important;
}

/* Icon (+ / ×) — real characters that crossfade, no rotation */
.apf-icon {
	position: relative;
	width: var(--apf-icon-size, 28px);
	height: var(--apf-icon-size, 28px);
	flex-shrink: 0;
	margin-left: auto;
}

.apf-icon::before,
.apf-icon::after {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: calc(var(--apf-icon-size, 28px) * 0.75);
	font-weight: 400;
	line-height: 1;
	color: var(--apf-icon-color, #9CA3AF);
	transition: opacity 0.25s ease;
}

/* Closed state: a real "+" character */
.apf-icon::before {
	content: "+";
	opacity: 1;
}

/* Open state: a real "×" character, cross-faded in — never rotated */
.apf-icon::after {
	content: "\00D7";
	opacity: 0;
}

.apf-item--open .apf-icon::before {
	opacity: 0;
}

.apf-item--open .apf-icon::after {
	opacity: 1;
}

/* Responsive tweaks */
@media (max-width: 600px) {
	.apf-question-btn {
		padding: 20px 20px;
		font-size: 1rem;
		gap: 12px;
	}

	.apf-answer-inner {
		padding: 0 20px 20px;
	}

	.apf-icon {
		width: calc(var(--apf-icon-size, 28px) * 0.85);
		height: calc(var(--apf-icon-size, 28px) * 0.85);
	}
}