/**
 * WooCommerce Price History Tracker – frontend styles.
 * Every rule is scoped to .wcph so themes are not affected.
 * Themes can restyle the section by overriding the custom properties below.
 */

.wcph {
	--wcph-bg: #fbf9f6;
	--wcph-surface: #fffefc;
	--wcph-border: #ebe5dd;
	--wcph-border-strong: #e1d9ce;
	--wcph-text: #1f1a17;
	--wcph-muted: #6b625a;
	--wcph-subtle: #8a8178;
	--wcph-accent: #6b4a32;
	--wcph-accent-contrast: #fff;
	--wcph-low: #3f8f4f;
	--wcph-low-bg: #e7f2e7;
	--wcph-high: #d14343;
	--wcph-high-bg: #fbe5e3;
	--wcph-avg: #6b625a;
	--wcph-avg-bg: #f1eeea;
	--wcph-cur: #8b5e3c;
	--wcph-cur-bg: #f4ece4;
	--wcph-radius: 14px;
	--wcph-card-radius: 10px;
	--wcph-font-heading: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Source Serif Pro", Georgia, "Times New Roman", serif;
	--wcph-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--wcph-chart-height: 300px;

	container-type: inline-size;
	container-name: wcph;
	box-sizing: border-box;
	clear: both;
	width: 100%;
	max-width: 100%;
	margin: 2rem 0;
	padding: 28px 30px 20px;
	background: var(--wcph-bg);
	border: 1px solid var(--wcph-border);
	border-radius: var(--wcph-radius);
	color: var(--wcph-text);
	font-family: var(--wcph-font-body);
	font-size: 16px;
	line-height: 1.45;
	overflow: hidden;
}

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

.wcph [hidden] {
	display: none !important;
}

.wcph .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Header ------------------------------------------------------------------ */

.wcph__header {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px 24px;
	margin-bottom: 18px;
}

.wcph__intro {
	flex: 1 1 320px;
	min-width: 0;
}

.wcph .wcph__title {
	margin: 0 0 6px;
	padding: 0;
	font-family: var(--wcph-font-heading);
	font-size: clamp(1.6rem, 1.1rem + 1.6vw, 2.35rem);
	font-weight: 500;
	line-height: 1.1;
	letter-spacing: -0.01em;
	color: var(--wcph-text);
	text-transform: none;
	border: 0;
}

.wcph .wcph__desc {
	margin: 0;
	font-family: var(--wcph-font-heading);
	font-size: 1.05rem;
	color: var(--wcph-muted);
}

.wcph .wcph__variant {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 10px 0 0;
	padding: 4px 12px;
	font-size: 0.82rem;
	color: var(--wcph-muted);
	background: var(--wcph-surface);
	border: 1px solid var(--wcph-border);
	border-radius: 999px;
}

.wcph__variant-name {
	color: var(--wcph-text);
	font-weight: 600;
}

/* Period switch ----------------------------------------------------------- */

.wcph__periods {
	display: inline-flex;
	flex: 0 0 auto;
	padding: 4px;
	background: #f5f1ec;
	border: 1px solid var(--wcph-border);
	border-radius: 999px;
}

.wcph .wcph__period {
	min-width: 88px;
	margin: 0;
	padding: 9px 18px;
	font-family: var(--wcph-font-body);
	font-size: 0.95rem;
	font-weight: 500;
	line-height: 1.2;
	color: var(--wcph-text);
	background: transparent;
	border: 0;
	border-radius: 999px;
	box-shadow: none;
	cursor: pointer;
	text-transform: none;
	letter-spacing: 0;
	transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.wcph .wcph__period:hover {
	background: rgba(107, 74, 50, 0.08);
	color: var(--wcph-text);
}

.wcph .wcph__period.is-active {
	background: var(--wcph-accent);
	color: var(--wcph-accent-contrast);
	box-shadow: 0 2px 6px rgba(70, 45, 25, 0.22);
}

.wcph .wcph__period:focus-visible {
	outline: 2px solid var(--wcph-accent);
	outline-offset: 2px;
}

/* Statistics cards -------------------------------------------------------- */

.wcph__stats {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 16px;
	margin-bottom: 18px;
}

.wcph-card {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	min-width: 0;
	padding: 18px 18px 16px;
	background: var(--wcph-surface);
	border: 1px solid var(--wcph-border);
	border-radius: var(--wcph-card-radius);
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.wcph-card:hover {
	transform: translateY(-2px);
	border-color: var(--wcph-border-strong);
	box-shadow: 0 8px 22px rgba(60, 40, 20, 0.07);
}

.wcph-card__icon {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
}

.wcph-card--low .wcph-card__icon { color: var(--wcph-low); background: var(--wcph-low-bg); }
.wcph-card--high .wcph-card__icon { color: var(--wcph-high); background: var(--wcph-high-bg); }
.wcph-card--avg .wcph-card__icon { color: var(--wcph-avg); background: var(--wcph-avg-bg); }
.wcph-card--current .wcph-card__icon { color: var(--wcph-cur); background: var(--wcph-cur-bg); }

.wcph-card__body {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.wcph-card__label {
	font-size: 0.92rem;
	color: var(--wcph-text);
}

.wcph-card__value {
	margin-top: 2px;
	font-family: var(--wcph-font-heading);
	font-size: clamp(1.35rem, 1rem + 0.9vw, 1.75rem);
	font-weight: 600;
	line-height: 1.2;
	color: var(--wcph-text);
	font-variant-numeric: lining-nums tabular-nums;
	overflow-wrap: anywhere;
	transition: opacity 0.2s ease;
}

.wcph-card__meta {
	min-height: 1.3em;
	font-size: 0.88rem;
	color: var(--wcph-muted);
}

.wcph.is-loading .wcph-card__value,
.wcph.is-loading .wcph-card__meta {
	opacity: 0.45;
}

/* Notice -------------------------------------------------------------------- */

.wcph__notice {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin: 0 0 14px;
	padding: 10px 14px;
	font-size: 0.88rem;
	color: var(--wcph-muted);
	background: var(--wcph-surface);
	border: 1px dashed var(--wcph-border-strong);
	border-radius: var(--wcph-card-radius);
}

.wcph__notice-icon {
	flex: 0 0 auto;
	margin-top: 2px;
}

/* Chart --------------------------------------------------------------------- */

.wcph__chart {
	position: relative;
	width: 100%;
	height: var(--wcph-chart-height);
}

.wcph__canvas {
	display: block;
	width: 100% !important;
	max-width: 100%;
}

.wcph--select .wcph__chart,
.wcph--empty .wcph__chart,
.wcph--single .wcph__chart {
	display: none;
}

.wcph__loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(251, 249, 246, 0.55);
}

.wcph__spinner {
	width: 28px;
	height: 28px;
	border: 2px solid var(--wcph-border-strong);
	border-top-color: var(--wcph-accent);
	border-radius: 50%;
	animation: wcph-spin 0.8s linear infinite;
}

@keyframes wcph-spin {
	to { transform: rotate(360deg); }
}

/* Footer -------------------------------------------------------------------- */

.wcph__footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 6px 20px;
	margin-top: 14px;
	padding-top: 12px;
	font-size: 0.85rem;
	color: var(--wcph-subtle);
}

.wcph .wcph__footer p {
	margin: 0;
}

.wcph__disclaimer {
	display: inline-flex;
	align-items: center;
	gap: 10px;
}

.wcph__disclaimer svg {
	flex: 0 0 auto;
	color: var(--wcph-subtle);
}

/* Responsive (container-based, so it also works in narrow columns) ---------- */

@container wcph (max-width: 900px) {
	.wcph__stats {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@container wcph (max-width: 600px) {
	.wcph__header {
		flex-direction: column;
		align-items: stretch;
	}

	.wcph__intro {
		flex-basis: auto;
	}

	.wcph__periods {
		display: flex;
		width: 100%;
	}

	.wcph .wcph__period {
		flex: 1 1 0;
		min-width: 0;
		padding: 9px 8px;
	}

	.wcph__stats {
		gap: 10px;
	}

	.wcph-card {
		flex-direction: column;
		gap: 10px;
		padding: 14px;
	}

	.wcph-card__icon {
		width: 36px;
		height: 36px;
	}

	.wcph-card__icon svg {
		width: 18px;
		height: 18px;
	}

	.wcph__chart {
		height: 240px;
	}

	.wcph__footer {
		flex-direction: column;
		align-items: flex-start;
	}
}

@media (max-width: 600px) {
	.wcph {
		padding: 20px 16px 16px;
		border-radius: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wcph *,
	.wcph *::before,
	.wcph *::after {
		transition: none !important;
		animation: none !important;
	}
}
