/**
 * WP Amazon Listing — Public Styles
 *
 * Mobile-first, responsive product listing with modern design.
 * Follows WCAG AA guidelines, Google Web Vitals optimized.
 *
 * @package WP_Amazon_Listing
 * @since   1.0.0
 */

/* === CSS Custom Properties === */
:root {
	--wpalp-primary: #ff9900;
	--wpalp-primary-dark: #e68a00;
	--wpalp-primary-light: #fff3e0;
	--wpalp-accent: #232f3e;
	--wpalp-accent-light: #37475a;
	--wpalp-success: #067d62;
	--wpalp-danger: #cc0c39;
	--wpalp-text: #0f1111;
	--wpalp-text-secondary: #565959;
	--wpalp-text-light: #fff;
	--wpalp-bg: #ffffff;
	--wpalp-bg-secondary: #f7f8fa;
	--wpalp-bg-card: #ffffff;
	--wpalp-border: #d5d9d9;
	--wpalp-border-light: #ededed;
	--wpalp-shadow: 0 2px 5px 0 rgba(213, 217, 217, 0.5);
	--wpalp-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
	--wpalp-radius: 12px;
	--wpalp-radius-sm: 8px;
	--wpalp-radius-pill: 100px;
	--wpalp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	--wpalp-transition: 0.2s ease;
	--wpalp-gap: 20px;
}

/* === Reset & Base === */
.wpalp-product-listing {
	font-family: var(--wpalp-font);
	color: var(--wpalp-text);
	line-height: 1.6;
	max-width: 1200px;
	margin: 2rem auto;
	padding: 0 1rem;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.wpalp-product-listing *,
.wpalp-product-listing *::before,
.wpalp-product-listing *::after {
	box-sizing: border-box;
}

/* === Listing Header === */
.wpalp-listing-header {
	text-align: center;
	margin-bottom: 2rem;
	padding-bottom: 1.5rem;
	border-bottom: 2px solid var(--wpalp-primary);
	position: relative;
}

.wpalp-listing-title {
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--wpalp-accent);
	margin: 0 0 0.5rem;
	line-height: 1.3;
}

.wpalp-listing-title-icon {
	margin-right: 0.3em;
}

.wpalp-listing-subtitle {
	font-weight: 400;
	font-size: 0.85em;
	color: var(--wpalp-text-secondary);
}

.wpalp-listing-updated {
	font-size: 0.8rem;
	color: var(--wpalp-text-secondary);
	margin: 0;
}

/* === Demo Notice === */
.wpalp-demo-notice {
	background: linear-gradient(135deg, #fff3cd, #ffeeba);
	border: 1px solid #ffc107;
	border-radius: var(--wpalp-radius-sm);
	padding: 0.75rem 1rem;
	margin-bottom: 1.5rem;
	font-size: 0.85rem;
	text-align: center;
}

.wpalp-demo-notice p {
	margin: 0;
}

/* === Products Grid === */
.wpalp-products-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--wpalp-gap);
	list-style: none;
	padding: 0;
	margin: 0;
}

/* === Product Card === */
.wpalp-product-card {
	background: var(--wpalp-bg-card);
	border: 1px solid var(--wpalp-border);
	border-radius: var(--wpalp-radius);
	box-shadow: var(--wpalp-shadow);
	overflow: hidden;
	transition: box-shadow var(--wpalp-transition), transform var(--wpalp-transition);
	position: relative;
	display: flex;
	flex-direction: column;
}

.wpalp-product-card:hover {
	box-shadow: var(--wpalp-shadow-hover);
	transform: translateY(-2px);
}

/* Top Pick Card */
.wpalp-product-card--top-pick {
	border-color: var(--wpalp-primary);
	border-width: 2px;
	background: linear-gradient(180deg, var(--wpalp-primary-light) 0%, var(--wpalp-bg-card) 120px);
}

/* === Badge === */
.wpalp-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.3em;
	padding: 0.35em 0.9em;
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	border-radius: var(--wpalp-radius-pill);
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 2;
}

.wpalp-badge--top {
	background: linear-gradient(135deg, var(--wpalp-primary), #ffb84d);
	color: var(--wpalp-accent);
}

.wpalp-badge-icon {
	font-size: 0.85em;
}

/* === Rank === */
.wpalp-product-rank {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 2;
}

.wpalp-rank-number {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--wpalp-accent);
	color: var(--wpalp-text-light);
	font-size: 0.75rem;
	font-weight: 700;
	width: 32px;
	height: 32px;
	border-radius: 50%;
}

/* === Product Image === */
.wpalp-product-image-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.25rem;
	background: var(--wpalp-bg-secondary);
	min-height: 200px;
}

.wpalp-product-image {
	max-width: 100%;
	height: auto;
	max-height: 220px;
	object-fit: contain;
	aspect-ratio: 1 / 1;
}

/* === Product Content === */
.wpalp-product-content {
	padding: 1.25rem;
	display: flex;
	flex-direction: column;
	flex: 1;
}

/* === Product Title === */
.wpalp-product-title {
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.4;
	margin: 0 0 0.4rem;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.wpalp-product-link {
	color: var(--wpalp-accent);
	text-decoration: none;
	transition: color var(--wpalp-transition);
}

.wpalp-product-link:hover,
.wpalp-product-link:focus {
	color: var(--wpalp-primary-dark);
	text-decoration: underline;
}

/* === Brand === */
.wpalp-product-brand {
	font-size: 0.8rem;
	color: var(--wpalp-text-secondary);
	margin: 0 0 0.75rem;
}

/* === Pricing === */
.wpalp-product-pricing {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 1rem;
}

.wpalp-price-current {
	font-size: 1.35rem;
	font-weight: 700;
	color: var(--wpalp-danger);
}

.wpalp-price-original {
	font-size: 0.9rem;
	color: var(--wpalp-text-secondary);
}

.wpalp-price-original del {
	text-decoration: line-through;
}

.wpalp-price-savings {
	display: inline-block;
	background: var(--wpalp-success);
	color: var(--wpalp-text-light);
	font-size: 0.7rem;
	font-weight: 700;
	padding: 0.2em 0.6em;
	border-radius: var(--wpalp-radius-pill);
	white-space: nowrap;
}

/* === Features === */
.wpalp-product-features {
	list-style: none;
	padding: 0;
	margin: 0 0 1rem;
	font-size: 0.85rem;
	flex: 1;
}

.wpalp-feature {
	padding: 0.3em 0;
	padding-left: 1.4em;
	position: relative;
	color: var(--wpalp-text-secondary);
	line-height: 1.5;
}

.wpalp-feature-icon {
	position: absolute;
	left: 0;
	top: 0.35em;
	color: var(--wpalp-success);
	font-size: 0.85em;
	font-weight: 700;
}

.wpalp-feature--hidden {
	display: none;
}

.wpalp-feature-toggle {
	padding-left: 0;
}

.wpalp-show-more-btn {
	background: none;
	border: none;
	color: var(--wpalp-primary-dark);
	font-size: 0.8rem;
	font-weight: 600;
	cursor: pointer;
	padding: 0.3em 0;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.wpalp-show-more-btn:hover,
.wpalp-show-more-btn:focus {
	color: var(--wpalp-primary);
}

/* === CTA Button === */
.wpalp-product-actions {
	margin-top: auto;
}

.wpalp-cta-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	width: 100%;
	padding: 0.75em 1.5em;
	background: linear-gradient(180deg, #f7dea0, #f0c14b);
	border: 1px solid #a88734;
	border-radius: var(--wpalp-radius-sm);
	color: var(--wpalp-text);
	font-size: 0.9rem;
	font-weight: 600;
	text-decoration: none;
	text-align: center;
	cursor: pointer;
	transition: background var(--wpalp-transition), box-shadow var(--wpalp-transition);
}

.wpalp-cta-button:hover,
.wpalp-cta-button:focus {
	background: linear-gradient(180deg, #f5d78e, #ddb347);
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
	text-decoration: none;
	color: var(--wpalp-text);
	outline-offset: 2px;
}

.wpalp-cta-icon {
	font-size: 1.1em;
}

/* === Notice === */
.wpalp-notice {
	background: var(--wpalp-bg-secondary);
	border: 1px solid var(--wpalp-border);
	border-radius: var(--wpalp-radius-sm);
	padding: 1.25rem;
	text-align: center;
	color: var(--wpalp-text-secondary);
	font-size: 0.9rem;
}

.wpalp-notice p {
	margin: 0;
}

/* === Screen Reader Text === */
.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

/* === Focus Styles (WCAG) === */
.wpalp-product-link:focus-visible,
.wpalp-cta-button:focus-visible,
.wpalp-show-more-btn:focus-visible {
	outline: 2px solid var(--wpalp-primary);
	outline-offset: 2px;
	border-radius: 2px;
}

/* ========================= */
/* === RESPONSIVE LAYOUT === */
/* ========================= */

/* Tablet: 2 columns */
@media (min-width: 600px) {
	.wpalp-products-grid {
		grid-template-columns: repeat(2, 1fr);
	}

	.wpalp-listing-title {
		font-size: 1.75rem;
	}

	.wpalp-product-image {
		max-height: 240px;
	}
}

/* Desktop: 3 columns */
@media (min-width: 960px) {
	.wpalp-products-grid {
		grid-template-columns: repeat(3, 1fr);
	}

	.wpalp-product-listing {
		padding: 0;
	}

	.wpalp-listing-title {
		font-size: 2rem;
	}
}

/* Large Desktop */
@media (min-width: 1200px) {
	.wpalp-products-grid {
		gap: 24px;
	}
}

/* === Print Styles === */
@media print {
	.wpalp-product-listing {
		max-width: 100%;
	}

	.wpalp-product-card {
		break-inside: avoid;
		box-shadow: none;
		border: 1px solid #ccc;
	}

	.wpalp-product-card:hover {
		transform: none;
		box-shadow: none;
	}

	.wpalp-cta-button {
		background: #f0c14b !important;
		border: 1px solid #a88734;
	}

	.wpalp-demo-notice {
		display: none;
	}
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
	.wpalp-product-card {
		transition: none;
	}

	.wpalp-product-card:hover {
		transform: none;
	}
}

/* === Dark Theme Support (WCAG AAA — 7:1 contrast ratio) === */
@media (prefers-color-scheme: dark) {
	.wpalp-product-listing {
		--wpalp-text: #f0edea;
		--wpalp-text-secondary: #c8c3be;
		--wpalp-bg: #0f172a;
		--wpalp-bg-secondary: #1e293b;
		--wpalp-bg-card: #1e293b;
		--wpalp-border: #334155;
		--wpalp-border-light: #475569;
		--wpalp-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
		--wpalp-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.5);
		--wpalp-accent: #f1f5f9;
		--wpalp-accent-light: #cbd5e1;
		--wpalp-primary: #ffb347;
		--wpalp-primary-dark: #ffb347;
		--wpalp-primary-light: rgba(255, 179, 71, 0.12);
		--wpalp-danger: #ff8a8a;
		--wpalp-success: #34d399;
	}

	/* CTA button needs dark text on gold background */
	.wpalp-product-listing .wpalp-cta-button,
	.wpalp-product-listing .wpalp-cta-button:hover,
	.wpalp-product-listing .wpalp-cta-button:focus {
		color: #1a1a1a;
	}

	/* Rank badge — light text on dark circle */
	.wpalp-product-listing .wpalp-rank-number {
		background: #334155;
		color: #f1f5f9;
	}

	/* Editor's Pick badge — dark text on gold gradient */
	.wpalp-product-listing .wpalp-badge--top {
		color: #1a1a1a;
	}

	/* Image area — slightly lighter than card for definition */
	.wpalp-product-listing .wpalp-product-image-wrap {
		background: #0f172a;
	}

	/* Savings badge */
	.wpalp-product-listing .wpalp-price-savings {
		background: #059669;
		color: #ffffff;
	}

	/* Show more button — high-contrast amber */
	.wpalp-product-listing .wpalp-show-more-btn {
		color: #ffb347;
	}

	.wpalp-product-listing .wpalp-show-more-btn:hover,
	.wpalp-product-listing .wpalp-show-more-btn:focus {
		color: #ffd07a;
	}

	/* Strikethrough price — needs to be readable */
	.wpalp-product-listing .wpalp-price-original {
		color: #94a3b8;
	}

	/* === Scoped Dark Mode === */
	/* Only apply dark mode text colors where we control the background (The Cards) */
	/* The main container and header should inherit from the theme to match the page background */

	.wpalp-product-listing {
		/* Reset main container to inherit theme color */
		color: inherit;
	}

	.wpalp-listing-title,
	.wpalp-listing-subtitle,
	.wpalp-listing-updated {
		/* Let headings inherit from theme */
		color: inherit !important;
	}

	/* Force darker border for header in dark mode if needed, or keep theme's */
	.wpalp-listing-header {
		border-color: var(--wpalp-primary);
	}

	/* === Card Styling (We control the bg, so we set the text) === */
	.wpalp-product-card {
		background: #1e293b;
		/* Ensure dark bg */
		color: #f0edea;
		/* Ensure light text */
	}

	/* Top pick card gradient */
	.wpalp-product-card--top-pick {
		background: linear-gradient(180deg, rgba(255, 179, 71, 0.08) 0%, #1e293b 120px) !important;
	}

	/* Product Title Links (Inside Card) */
	.wpalp-product-card .wpalp-product-title,
	.wpalp-product-card .wpalp-product-link,
	.wpalp-product-card a.wpalp-product-link {
		color: #f1f5f9 !important;
	}

	.wpalp-product-card .wpalp-product-link:hover,
	.wpalp-product-card .wpalp-product-link:focus,
	.wpalp-product-card a.wpalp-product-link:hover,
	.wpalp-product-card a.wpalp-product-link:focus {
		color: #ffb347 !important;
	}

	/* Brand Name (Inside Card) */
	.wpalp-product-card .wpalp-product-brand,
	.wpalp-product-card .wpalp-product-brand span {
		color: #c8c3be !important;
	}

	/* Features (Inside Card) */
	.wpalp-product-card .wpalp-feature {
		color: #c8c3be !important;
	}

	/* Feature Icon */
	.wpalp-product-card .wpalp-feature-icon {
		color: #34d399 !important;
	}

	/* Prices */
	.wpalp-product-card .wpalp-price-current {
		color: #ff8a8a !important;
	}

	.wpalp-product-card .wpalp-price-original,
	.wpalp-product-card .wpalp-price-original del {
		color: #94a3b8 !important;
	}
}