/**
 * PersonaFlow Frontend Styles (SLAI-12 design system).
 *
 * Recommendation cards, feedback buttons, and display layouts. Follows the
 * theme by default; the --atlas-ai-pf-* custom properties are the public
 * styling API (set from the Appearance settings; safe to override).
 *
 * @package Smart_Local_AI
 * @subpackage PersonaFlow
 */

/* ── Container ── */
.atlas-ai-pf-container {
	margin: 2em 0;
	background: var(--atlas-ai-pf-bg, transparent);
	color: var(--atlas-ai-pf-text, inherit);
}

.atlas-ai-pf-container h3 {
	font-size: 1.25em;
	font-weight: 600;
	line-height: 1.3;
	margin: 0 0 1em;
	color: var(--atlas-ai-pf-heading, inherit);
}

/* ── Cards Layout (Default) ── */
.atlas-ai-pf-cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 1.25em;
}

.atlas-ai-pf-card {
	display: flex;
	flex-direction: column;
	background: var(--atlas-ai-pf-card-bg, rgba(127, 127, 127, 0.06));
	border: 1px solid var(--atlas-ai-pf-border, rgba(127, 127, 127, 0.3));
	border-radius: var(--atlas-ai-pf-border-radius, 12px);
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.atlas-ai-pf-card:hover {
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
	transform: translateY(-2px);
}

.atlas-ai-pf-card a {
	text-decoration: none;
	color: var(--atlas-ai-pf-text, inherit);
	display: block;
}

.atlas-ai-pf-card a:focus-visible {
	outline: 2px solid var(--atlas-ai-pf-accent, currentColor);
	outline-offset: 2px;
	border-radius: 4px;
}

/* ── Card Thumbnail ── */
.atlas-ai-pf-card-thumb {
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 9;
	object-fit: cover;
	display: block;
}

.atlas-ai-pf-card-thumb-placeholder {
	width: 100%;
	aspect-ratio: 16 / 9;
	background: rgba(127, 127, 127, 0.15);
	display: flex;
	align-items: center;
	justify-content: center;
}

/* ── Card Body ── */
.atlas-ai-pf-card-body {
	flex: 1;
	padding: 1em;
}

.atlas-ai-pf-card-title {
	font-size: 1em;
	font-weight: 600;
	line-height: 1.4;
	margin: 0 0 0.5em;
	color: var(--atlas-ai-pf-heading, inherit);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.atlas-ai-pf-card a:hover .atlas-ai-pf-card-title {
	color: var(--atlas-ai-pf-accent, inherit);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.atlas-ai-pf-card-excerpt {
	font-size: 0.875em;
	line-height: 1.5;
	color: var(--atlas-ai-pf-excerpt-color, inherit);
	opacity: 0.85;
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ── Feedback Buttons ── */
.atlas-ai-pf-card-feedback {
	display: flex;
	gap: 0.375em;
	padding: 0.5em 1em 1em;
	border-top: 1px solid var(--atlas-ai-pf-border, rgba(127, 127, 127, 0.2));
}

.atlas-ai-pf-feedback-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	min-height: 36px;
	padding: 0.35em;
	background: none;
	border: 1px solid var(--atlas-ai-pf-border, rgba(127, 127, 127, 0.3));
	border-radius: 8px;
	cursor: pointer;
	line-height: 1;
	color: inherit;
	opacity: 0.75;
	transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.atlas-ai-pf-feedback-btn svg {
	display: block;
	width: 18px;
	height: 18px;
}

.atlas-ai-pf-feedback-btn:hover {
	opacity: 1;
	background: rgba(127, 127, 127, 0.1);
}

.atlas-ai-pf-feedback-btn:focus-visible {
	opacity: 1;
	outline: 2px solid var(--atlas-ai-pf-accent, currentColor);
	outline-offset: 2px;
}

/* Pressed: aria-pressed is the state; .active is kept for existing custom CSS. */
.atlas-ai-pf-feedback-btn[aria-pressed="true"],
.atlas-ai-pf-feedback-btn.active {
	opacity: 1;
	color: var(--atlas-ai-pf-accent, #0d6b63);
	border-color: currentcolor;
	background: rgba(127, 127, 127, 0.1);
}

.atlas-ai-pf-feedback-btn[aria-pressed="true"] svg,
.atlas-ai-pf-feedback-btn.active svg {
	fill: currentcolor;
	fill-opacity: 0.2;
}

.atlas-ai-pf-feedback-btn[data-action="dislike"][aria-pressed="true"],
.atlas-ai-pf-feedback-btn[data-action="dislike"].active {
	color: #cf2d24;
}

.atlas-ai-pf-feedback-btn[data-action="bookmark"][aria-pressed="true"],
.atlas-ai-pf-feedback-btn[data-action="bookmark"].active {
	color: #b45309;
}

/* ── List Layout ── */
.atlas-ai-pf-list {
	display: flex;
	flex-direction: column;
	gap: 0.75em;
}

.atlas-ai-pf-list .atlas-ai-pf-card {
	flex-direction: row;
	align-items: stretch;
}

.atlas-ai-pf-list .atlas-ai-pf-card a {
	display: flex;
	flex-direction: row;
}

.atlas-ai-pf-list .atlas-ai-pf-card-thumb,
.atlas-ai-pf-list .atlas-ai-pf-card-thumb-placeholder {
	width: 120px;
	min-width: 120px;
	aspect-ratio: auto;
	height: 100%;
}

.atlas-ai-pf-list .atlas-ai-pf-card-body {
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 0.75em 1em;
}

.atlas-ai-pf-list .atlas-ai-pf-card-feedback {
	flex-direction: column;
	border-top: none;
	border-left: 1px solid var(--atlas-ai-pf-border, rgba(127, 127, 127, 0.2));
	padding: 0.5em;
	justify-content: center;
}

/* ── Grid Layout ── */
.atlas-ai-pf-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 1em;
}

.atlas-ai-pf-grid .atlas-ai-pf-card-thumb,
.atlas-ai-pf-grid .atlas-ai-pf-card-thumb-placeholder {
	aspect-ratio: 1;
}

.atlas-ai-pf-grid .atlas-ai-pf-card-body {
	padding: 0.75em;
}

.atlas-ai-pf-grid .atlas-ai-pf-card-title {
	font-size: 0.875em;
	-webkit-line-clamp: 2;
}

.atlas-ai-pf-grid .atlas-ai-pf-card-excerpt {
	display: none;
}

.atlas-ai-pf-grid .atlas-ai-pf-card-feedback {
	padding: 0.35em 0.75em 0.75em;
}

/* ── Loading State ── */
.atlas-ai-pf-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 200px;
	opacity: 0.7;
	font-size: 0.875em;
}

.atlas-ai-pf-loading::before {
	content: "";
	width: 1.25em;
	height: 1.25em;
	border: 2px solid var(--atlas-ai-pf-border, rgba(127, 127, 127, 0.3));
	border-top-color: var(--atlas-ai-pf-accent, currentColor);
	border-radius: 50%;
	animation: atlas-ai-pf-spin 0.6s linear infinite;
	margin-right: 0.5em;
}

@keyframes atlas-ai-pf-spin {

	to {
		transform: rotate(360deg);
	}
}

/* ── Empty State ── */
.atlas-ai-pf-empty {
	text-align: center;
	padding: 2em;
	opacity: 0.7;
	font-size: 0.875em;
}

/* ── Responsive ── */
@media ( max-width: 640px ) {

	.atlas-ai-pf-cards {
		grid-template-columns: 1fr;
	}

	.atlas-ai-pf-grid {
		grid-template-columns: repeat(2, 1fr);
	}

	.atlas-ai-pf-list .atlas-ai-pf-card-thumb,
	.atlas-ai-pf-list .atlas-ai-pf-card-thumb-placeholder {
		width: 80px;
		min-width: 80px;
	}
}

@media ( max-width: 400px ) {

	.atlas-ai-pf-grid {
		grid-template-columns: 1fr;
	}
}

@media ( prefers-reduced-motion: reduce ) {

	.atlas-ai-pf-card,
	.atlas-ai-pf-card:hover,
	.atlas-ai-pf-feedback-btn {
		transition: none;
		transform: none;
	}

	.atlas-ai-pf-loading::before {
		animation-duration: 1.5s;
	}
}

/* Reserve space while the list loads (was an inline style). */
.atlas-ai-pf-container:empty {
	min-height: 200px;
}
