/**
 * Justread – Product box ("Top pick" card).
 * Works in LTR and RTL. Layout responds to the width of its container, not the screen.
 */

.jr-product-wrap {
	container-type: inline-size;
	margin: 3.5em 0 2.5em;
}

.jr-product {
	--jr-accent: #5b6cf0;
	--jr-frame: 2px;
	--jr-frame-color: #e3e3e3;
	--jr-text: #111;
	--jr-muted: #333;
	--jr-soft: #efefef;
	--jr-radius: 8px;
	--jr-pad: clamp(1.25rem, 4cqi, 2.5rem);

	position: relative;
	box-sizing: border-box;
	display: grid;
	grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr) auto;
	grid-template-areas: "media body actions";
	align-items: center;
	gap: clamp(1rem, 3cqi, 2.25rem);
	padding: var(--jr-pad);
	background: #fff;
	color: var(--jr-text);
	border: var(--jr-frame) solid var(--jr-frame-color);
	line-height: 1.5;
}

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

/* ---------- Frame variants ---------- */

.jr-product--special {
	--jr-frame: 6px;
	--jr-frame-color: var(--jr-accent);
}

.jr-product--border-top,
.jr-product--border-bottom {
	border-color: transparent;
	border-left-width: 0;
	border-right-width: 0;
	padding-left: 0;
	padding-right: 0;
}

.jr-product--border-top {
	border-top-color: var(--jr-frame-color);
}

.jr-product--border-bottom {
	border-bottom-color: var(--jr-frame-color);
}

.jr-product--border-top.jr-product--border-bottom {
	border-top-color: var(--jr-frame-color);
	border-bottom-color: var(--jr-frame-color);
}

.jr-product--no-border {
	border: 0;
	padding-left: 0;
	padding-right: 0;
}

.jr-product--has-badge {
	padding-top: calc(var(--jr-pad) + 0.75rem);
}

/* ---------- Badge (ribbon with notched end) ---------- */

.jr-product__badge {
	position: absolute;
	top: calc(var(--jr-frame) * -1);
	inset-inline-start: clamp(1rem, 4cqi, 2.75rem);
	transform: translateY(-55%);
	z-index: 1;
	display: inline-block;
	padding: 0.3em 1.15em 0.35em 0.75em;
	background: var(--jr-accent);
	color: #fff;
	font-size: clamp(1.1rem, 2.6cqi, 1.75rem);
	font-weight: 800;
	line-height: 1.15;
	letter-spacing: -0.01em;
	white-space: nowrap;
	border-radius: 4px 0 0 4px;
	clip-path: polygon(0 0, 100% 0, calc(100% - 0.55em) 50%, 100% 100%, 0 100%);
}

.rtl .jr-product__badge,
[dir="rtl"] .jr-product__badge {
	padding: 0.3em 0.75em 0.35em 1.15em;
	border-radius: 0 4px 4px 0;
	clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 0.55em 50%);
}

/* ---------- Media ---------- */

.jr-product__media {
	grid-area: media;
	text-align: center;
}

.jr-product__media a {
	display: block;
}

.jr-product__img {
	display: inline-block;
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: 340px;
	object-fit: contain;
	margin: 0;
}

/* ---------- Body ---------- */

.jr-product__body {
	grid-area: body;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	min-width: 0;
}

.jr-product .jr-product__headline {
	margin: 0;
	color: var(--jr-text);
	font-size: clamp(1.4rem, 3.4cqi, 2.1rem);
	font-weight: 800;
	line-height: 1.12;
	letter-spacing: -0.015em;
}

.jr-product .jr-product__name {
	align-self: flex-start;
	color: var(--jr-text);
	font-size: clamp(1rem, 2.2cqi, 1.35rem);
	line-height: 1.35;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

.jr-product a.jr-product__name:hover,
.jr-product a.jr-product__name:focus-visible {
	color: var(--jr-accent);
	text-decoration-thickness: 2px;
}

.jr-product__desc {
	color: var(--jr-muted);
	font-size: clamp(0.98rem, 2cqi, 1.2rem);
	line-height: 1.65;
}

.jr-product__desc p {
	margin: 0 0 0.6em;
}

.jr-product__desc > :last-child {
	margin-bottom: 0;
}

.jr-product__list {
	margin: 0;
	padding-inline-start: 1.2em;
	text-align: start;
}

.jr-product__list li {
	margin: 0.2em 0;
}

/* ---------- Buttons ---------- */

.jr-product__buttons {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	margin-top: 0.75rem;
}

.jr-product .jr-product__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 3.6rem;
	padding: 0.8em 1.25em;
	border: 2px solid #000;
	border-radius: var(--jr-radius);
	font-size: clamp(1rem, 2cqi, 1.2rem);
	font-weight: 700;
	line-height: 1.25;
	text-align: center;
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.jr-product .jr-product__btn--primary {
	background: #000;
	color: #fff;
}

.jr-product .jr-product__btn--primary:hover,
.jr-product .jr-product__btn--primary:focus-visible {
	background: #2b2b2b;
	border-color: #2b2b2b;
	color: #fff;
}

.jr-product .jr-product__btn--secondary {
	background: #fff;
	color: #000;
}

.jr-product .jr-product__btn--secondary:hover,
.jr-product .jr-product__btn--secondary:focus-visible {
	background: #000;
	color: #fff;
}

.jr-product .jr-product__btn:focus-visible,
.jr-product .jr-product__icon:focus-visible,
.jr-product a.jr-product__name:focus-visible {
	outline: 3px solid var(--jr-accent);
	outline-offset: 3px;
}

/* ---------- Round icon actions ---------- */

.jr-product__actions {
	grid-area: actions;
	align-self: start;
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.jr-product .jr-product__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 3.5rem;
	height: 3.5rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--jr-soft);
	color: #222;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.jr-product .jr-product__icon:hover {
	background: #e0e0e0;
}

.jr-product .jr-product__icon.is-copied {
	background: var(--jr-accent);
	color: #fff;
}

.jr-product__toast {
	position: absolute;
	top: 50%;
	inset-inline-end: calc(100% + 0.5rem);
	transform: translateY(-50%);
	padding: 0.3em 0.7em;
	border-radius: 4px;
	background: #111;
	color: #fff;
	font-size: 0.8rem;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.15s ease;
}

.jr-product__toast:not(:empty) {
	opacity: 1;
}

/* ---------- Stacked layouts (col-one-*) ---------- */

.jr-product--stack {
	grid-template-columns: minmax(0, 1fr);
	grid-template-areas:
		"media"
		"body";
	text-align: center;
}

.jr-product--stack .jr-product__body {
	align-items: center;
}

.jr-product--stack .jr-product__name {
	align-self: center;
}

.jr-product--stack .jr-product__buttons {
	width: min(100%, 26rem);
}

.jr-product--stack .jr-product__actions {
	position: absolute;
	top: var(--jr-pad);
	inset-inline-end: var(--jr-pad);
}

.jr-product--stack.jr-product--has-badge .jr-product__actions {
	top: calc(var(--jr-pad) + 0.75rem);
}

/* ---------- Compact sizes ---------- */

.jr-product--col-two-small,
.jr-product--col-one-small,
.jr-product--col-one-xsmall {
	--jr-pad: clamp(1rem, 3cqi, 1.5rem);
	font-size: 0.9em;
}

.jr-product--col-two-small .jr-product__img,
.jr-product--col-one-small .jr-product__img {
	max-height: 220px;
}

.jr-product--col-one-xsmall {
	font-size: 0.82em;
}

.jr-product--col-one-xsmall .jr-product__img {
	max-height: 150px;
}

.jr-product--col-two-small .jr-product__icon,
.jr-product--col-one-small .jr-product__icon,
.jr-product--col-one-xsmall .jr-product__icon {
	width: 2.75rem;
	height: 2.75rem;
}

.jr-product--col-two-small .jr-product__btn,
.jr-product--col-one-small .jr-product__btn,
.jr-product--col-one-xsmall .jr-product__btn {
	min-height: 3rem;
}

/* ---------- Narrow containers: side-by-side becomes stacked ---------- */

@container (max-width: 560px) {
	.jr-product--row {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas:
			"media"
			"body";
	}

	.jr-product--row .jr-product__actions {
		position: absolute;
		top: var(--jr-pad);
		inset-inline-end: var(--jr-pad);
	}

	.jr-product--row.jr-product--has-badge .jr-product__actions {
		top: calc(var(--jr-pad) + 0.75rem);
	}

	.jr-product .jr-product__img {
		max-height: 260px;
	}

	.jr-product .jr-product__icon {
		width: 2.75rem;
		height: 2.75rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jr-product * {
		transition: none !important;
	}
}

@media print {
	.jr-product__actions {
		display: none;
	}
}
