/* AI Remix Photo — public embed (theme-agnostic, a11y-aware). */

.hre-app {
	--hre-accent: #2563eb;
	--hre-bg: #ffffff;
	--hre-border: #e5e7eb;
	--hre-muted: #6b7280;
	--hre-danger: #b91c1c;
	--hre-radius: 10px;
	font-family: inherit;
	font-size: 16px;
	line-height: 1.5;
	color: inherit;
	width: 100%;
	box-sizing: border-box;
}

.hre-app *,
.hre-app *::before,
.hre-app *::after {
	box-sizing: inherit;
}

/* Author display rules (inline-block on buttons/links) must not defeat the
   `hidden` attribute — UA's [hidden]{display:none} loses to class rules. */
.hre-app [hidden] {
	display: none !important;
}

.hre-layout {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.hre-workspace {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* Step 1 (27%) + Step 2 (73%) share one row. */
.hre-steps-row {
	display: flex;
	gap: 16px;
	align-items: flex-start;
}

.hre-intro {
	max-width: 720px;
	margin: 0 0 2px;
}

.hre-intro-title {
	margin: 0;
	font-size: clamp( 1.6rem, 2.5vw, 2.2rem );
	line-height: 1.15;
}

.hre-intro-subtitle {
	max-width: 720px;
	margin: 8px 0 0;
	color: var(--hre-muted);
	font-size: 1rem;
}

.hre-steps-row .hre-card {
	min-width: 0;
}

.hre-step1-card {
	flex: 1 1 27%;
}

.hre-step2-card {
	flex: 3 1 73%;
}

.hre-card {
	background: var(--hre-bg);
	border: 1px solid var(--hre-border);
	border-radius: var(--hre-radius);
	padding: 16px;
}

.hre-card h2 {
	margin: 0 0 12px;
	font-size: 1.05rem;
}

.hre-hint,
.hre-share-expl,
.hre-privacy,
.hre-disclaimer {
	color: var(--hre-muted);
	font-size: 0.85rem;
	margin: 4px 0 8px;
}

/* ---------- Step 1: empty image placeholder dropzone ---------- */

.hre-dropzone {
	border: 2px dashed var(--hre-border);
	border-radius: var(--hre-radius);
	overflow: hidden;
	position: relative;
	cursor: pointer;
	transition: border-color 0.15s ease;
	background: var(--hre-bg);
}

.hre-dropzone:hover,
.hre-dropzone:focus-visible,
.hre-dropzone.hre-dragging {
	border-color: var(--hre-accent);
	outline: none;
}

/* Empty state: icon + text + faux upload button. */
.hre-drop-empty {
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 28px 16px;
	min-height: 220px;
	width: 100%;
}

.hre-drop-icon {
	width: 44px;
	height: 44px;
	border: 2px solid var(--hre-muted);
	border-radius: 8px;
	position: relative;
	opacity: 0.6;
}

.hre-drop-icon::before {
	/* Mountain + sun glyph inside the image frame. */
	content: "";
	position: absolute;
	left: 50%;
	top: 54%;
	width: 18px;
	height: 12px;
	transform: translate( -50%, -50% );
	border: 2px solid var(--hre-muted);
	border-top: none;
	border-radius: 0 0 10px 10px;
}

.hre-drop-icon::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 32%;
	width: 7px;
	height: 7px;
	transform: translate( -50%, -50% );
	border-radius: 50%;
	background: var(--hre-muted);
}

.hre-drop-text {
	color: var(--hre-muted);
	font-size: 0.9rem;
}

.hre-drop-browse,
.hre-file-label,
.hre-camera-label,
.hre-generate,
.hre-retry,
.hre-change {
	display: inline-block;
	border: 1px solid var(--hre-accent);
	background: var(--hre-accent);
	color: #ffffff;
	border-radius: 6px;
	padding: 8px 14px;
	font-size: 0.92rem;
	cursor: pointer;
	text-decoration: none;
	font-weight: 600;
}

.hre-camera-label,
.hre-change {
	background: transparent;
	color: var(--hre-accent);
}

/* Filled state: the photo fills the placeholder frame. */
.hre-dropzone.hre-has-image {
	border-style: solid;
	border-width: 2px;
}

/* The Step 1 photo frame is ratio 1.1 (1.1:1) — the empty placeholder and the
   preview share it, so the frame shape never jumps when a photo is picked.
   Uploaded room photos keep object-fit: contain, so any ratio is shown fully
   inside the 1.1 frame. */
.hre-drop-empty {
	aspect-ratio: 1.1 / 1;
}

.hre-input-preview {
	display: block;
	width: 100%;
	aspect-ratio: 1.1 / 1;
	height: auto;
	object-fit: contain;
	background: var(--hre-bg);
}

.hre-step1-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 10px;
	align-items: center;
}

.hre-upload-status,
.hre-style-status,
.hre-result-status {
	margin-top: 8px;
	color: var(--hre-muted);
	font-size: 0.9rem;
}

/* The AI-visualisation disclosure and progress lines read as captions of
   the (already centered) result card. */
.hre-result-status {
	text-align: center;
}

/* ---------- Step 2: furniture catalogue (3/row desktop, 2/mobile) ---------- */

.hre-cat {
	margin-bottom: 16px;
}

.hre-cat:last-child {
	margin-bottom: 0;
}

.hre-cat-name {
	margin: 0 0 8px;
	font-size: 0.95rem;
	font-weight: 700;
}

.hre-cat-grid {
	display: grid;
	grid-template-columns: repeat( 3, 1fr );
	gap: 12px;
}

/* Step 2 keeps roughly four photo rows visible; extra catalogue content
   scrolls inside the Step 2 card. Rows are ratio-driven now: photo height =
   cell width / 1.1. At a 1140px embed the 3-up desktop cell is ~249px wide,
   so one row ≈ 226px photo + caption (~24px) + Select (~45px) ≈ 300px;
   4 rows + 3 gaps ≈ 1230px. */
[data-hre-catalogue] {
	max-height: 1230px;
	overflow-y: auto;
	padding-right: 8px;
}

.hre-cat-item {
	border: 1px solid var(--hre-border);
	border-radius: 8px;
	background: transparent;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	gap: 0;
	align-items: stretch;
	width: 100%;
	font-family: inherit;
	font-size: 0.75rem;
	color: inherit;
	text-align: left;
	appearance: none;
	transition: border-color 0.15s ease, background-color 0.15s ease;
	padding: 0;
	position: relative;
	overflow: hidden;
	margin: 0;
}

.hre-cat-photo {
	position: relative;
	display: block;
}

/* Step 2 photo frames are ratio 1.1 (1.1:1) with object-fit: contain, so a
   photo of any ratio is always shown fully inside the frame (letterboxed,
   never cropped). */
.hre-cat-item img {
	width: 100%;
	aspect-ratio: 1.1 / 1;
	height: auto;
	object-fit: contain;
	display: block;
	background: var(--hre-bg);
}

.hre-cat-name-sm {
	min-height: 2.7em;
	padding: 6px 8px 0;
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	color: var(--hre-muted);
}

/* Select action displayed inside the single, accessible card button. */
.hre-cat-select {
	display: block;
	margin: 6px 8px 8px;
	border: 1px solid var(--hre-accent);
	background: transparent;
	color: var(--hre-accent);
	border-radius: 6px;
	padding: 8px 10px;
	font-size: 0.85rem;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	pointer-events: none;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.hre-cat-item:hover,
.hre-cat-item:focus-visible {
	border-color: var(--hre-accent);
	outline: none;
}

/* Selected card: 1px accent border + 2px accent ring drawn by a
   ::after OVERLAY so the opaque photo can never cover it (an inset
   box-shadow paints under the image and disappears). The ::after is the
   last child, so it sits above the whole card; pointer-events: none
   keeps the card clickable. */
.hre-cat-item.hre-selected,
.hre-cat-item[aria-pressed="true"] {
	border-color: var(--hre-accent);
}

.hre-cat-item.hre-selected::after,
.hre-cat-item[aria-pressed="true"]::after {
	content: "";
	position: absolute;
	inset: 0;
	border: 2px solid var(--hre-accent);
	border-radius: 8px;
	pointer-events: none;
}

.hre-cat-item.hre-selected .hre-cat-select,
.hre-cat-item[aria-pressed="true"] .hre-cat-select {
	background: var(--hre-accent);
	color: #ffffff;
}

.hre-cat-check {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--hre-accent);
	color: #ffffff;
	display: none;
	align-items: center;
	justify-content: center;
}

.hre-cat-check::after {
	content: "";
	width: 10px;
	height: 5px;
	border-left: 2px solid #ffffff;
	border-bottom: 2px solid #ffffff;
	transform: rotate( -45deg ) translate( 1px, -1px );
}

.hre-cat-item.hre-selected .hre-cat-check,
.hre-cat-item[aria-pressed="true"] .hre-cat-check {
	display: flex;
}

/* ---------- Step 3: confirm style ---------- */

.hre-confirm-card {
	text-align: center;
}

.hre-confirm-preview {
	display: flex;
	gap: 14px;
	align-items: stretch;
	justify-content: center;
	margin-bottom: 16px;
}

.hre-confirm-side {
	flex: 1 1 33%;
	max-width: 33%;
	min-width: 0;
	margin: 0;
	text-align: center;
}

.hre-confirm-side img {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	background: var(--hre-bg);
	border: 1px solid var(--hre-border);
	border-radius: var(--hre-radius);
	box-shadow: 0 6px 18px rgba( 17, 24, 39, 0.1 );
	display: block;
	margin: 0 auto;
}

.hre-confirm-side figcaption {
	margin-top: 6px;
	color: var(--hre-muted);
	font-size: 0.85rem;
}

/* Style pills */
.hre-styles {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: center;
}

.hre-style-btn {
	border: 1px solid var(--hre-border);
	background: var(--hre-bg);
	color: inherit;
	border-radius: 999px;
	padding: 8px 18px;
	font-size: 0.92rem;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.hre-style-btn:hover,
.hre-style-btn:focus-visible {
	border-color: var(--hre-accent);
	outline: none;
}

.hre-style-btn[aria-checked="true"] {
	background: var(--hre-accent);
	border-color: var(--hre-accent);
	color: #ffffff;
}

.hre-generate-row {
	margin: 16px 0 0;
}

.hre-generate:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* Admin-set "generation disabled" notice shown under the generate button. */
.hre-provider-notice {
	margin: 12px 0 0;
	padding: 10px 14px;
	border-radius: 8px;
	background: #fef3c7;
	border: 1px solid #f59e0b;
	color: #92400e;
	font-size: 0.9rem;
	text-align: center;
}
.hre-provider-notice[hidden] {
	display: none;
}

/* Share row: smaller, grey, clearly subordinate to the generate action. */
.hre-share-row {
	margin-top: 12px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
}

.hre-share {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 0.85rem;
	color: var(--hre-muted);
	cursor: pointer;
}

.hre-share input[type="checkbox"] {
	accent-color: var(--hre-accent);
}

.hre-share-row .hre-share-expl,
.hre-share-row .hre-privacy {
	margin: 0;
	font-size: 0.78rem;
	color: var(--hre-muted);
	text-align: center;
}

/* ---------- Result ---------- */

.hre-result-card h2 {
	text-align: center;
}

.hre-result-holder {
	position: relative;
	margin: 12px 0;
}

.hre-result-card .hre-result-img {
	width: 100%;
	max-width: 100%;
	height: auto;
	border-radius: var(--hre-radius);
	display: block;
	margin: 0 auto;
}

/* Clickable wrapper: clicking the generated photo opens the lightbox. */
.hre-result-view {
	display: block;
	margin: 0;
	text-decoration: none;
}

/* Pop-in reveal once the generated photo has loaded. */
@keyframes hre-reveal {
	from {
		transform: scale( 0.94 );
		opacity: 0.4;
	}

	to {
		transform: scale( 1 );
		opacity: 1;
	}
}

.hre-result-img.hre-reveal {
	animation: hre-reveal 0.45s cubic-bezier( 0.22, 1, 0.36, 1 );
}

/* Confetti overlay for the 2s celebration (sized by the result holder). */
.hre-confetti {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 3;
}

.hre-loading {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 12px 0;
	color: var(--hre-muted);
	font-size: 0.92rem;
}

.hre-spinner {
	width: 20px;
	height: 20px;
	flex: 0 0 auto;
	border: 3px solid var(--hre-border);
	border-top-color: var(--hre-accent);
	border-radius: 50%;
	animation: hre-spin 0.8s linear infinite;
}

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

.hre-elapsed {
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	color: inherit;
}

.hre-result-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	justify-content: center;
	margin-top: 12px;
}

.hre-download {
	display: inline-block;
	border: 1px solid var(--hre-accent);
	background: var(--hre-accent);
	color: #ffffff;
	border-radius: 6px;
	padding: 8px 14px;
	font-size: 0.92rem;
	cursor: pointer;
	text-decoration: none;
	font-weight: 600;
}

/* ---------- Gallery ---------- */

.hre-gallery-section {
	margin-top: 24px;
}

.hre-gallery-section h2 {
	font-size: 1.05rem;
}

.hre-disclaimer {
	margin-top: 12px;
	text-align: center;
}

.hre-gallery {
	list-style: none;
	margin: 12px 0 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat( 5, 1fr );
	gap: 10px;
}

.hre-gallery-link {
	display: block;
	border-radius: 8px;
}

.hre-gallery img {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border-radius: 8px;
	border: 1px solid var(--hre-border);
	display: block;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.hre-gallery-link:hover img {
	transform: translateY( -2px );
	box-shadow: 0 8px 18px rgba( 17, 24, 39, 0.14 );
}

.hre-gallery-empty {
	color: var(--hre-muted);
	font-size: 0.85rem;
}

/* End-of-list reminder under the gallery grid. */
.hre-gallery-end {
	margin: 12px 0 0;
	color: var(--hre-muted);
	font-size: 0.85rem;
	text-align: center;
}

/* Lazy-load sentinel under the gallery grid. */
.hre-gallery-sentinel {
	height: 1px;
}

.hre-disclaimer {
	margin-top: 12px;
}

.hre-nojs,
.hre-error {
	border: 1px solid var(--hre-border);
	border-radius: var(--hre-radius);
	padding: 12px;
	color: var(--hre-muted);
}

/* ---------- A11y ---------- */

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

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect( 1px, 1px, 1px, 1px );
	white-space: nowrap;
}

@media ( prefers-reduced-motion: reduce ) {
	.hre-app * {
		transition: none !important;
		scroll-behavior: auto !important;
		animation: none !important;
	}
}

/* Tablet: furniture grid drops to 2 per row before the steps stack;
   gallery drops to 3 per row. */
@media ( max-width: 1024px ) {
	.hre-cat-grid {
		grid-template-columns: repeat( 2, 1fr );
	}

	.hre-gallery {
		grid-template-columns: repeat( 3, 1fr );
	}
}

/* Mobile: steps stack (Step 1 first), furniture grid stays 2 per row,
   gallery drops to 2 per row. Catalogue photos keep the 1.1 ratio
   (height follows cell width); the scroll cap shrinks to two rows. */
@media ( max-width: 860px ) {
	.hre-steps-row {
		flex-direction: column;
	}

	.hre-confirm-preview {
		flex-direction: column;
		align-items: center;
	}

	.hre-confirm-side {
		flex: 1 1 auto;
		width: 100%;
		max-width: 360px;
		margin: 0 auto;
	}

	.hre-gallery {
		grid-template-columns: repeat( 2, 1fr );
	}

	[data-hre-catalogue] {
		max-height: 900px;
	}
}

/* Tablet portrait: keep the catalogue and gallery compact without making
   each tile unnecessarily wide. Phones remain two columns below 600px. */
@media ( min-width: 601px ) and ( max-width: 860px ) {
	.hre-cat-grid {
		grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
	}

	.hre-gallery {
		grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
	}
}

/* Desktop: cap the result photo at 66% of the card width, centred. */
@media ( min-width: 861px ) {
	.hre-result-card .hre-result-img {
		max-width: 66%;
	}
}
/* Lead capture form (inside the Step 3 confirm card). */
.hre-lead {
	margin-top: 18px;
	padding: 16px;
	border: 1px solid var(--hre-border, rgba(128, 128, 128, 0.35));
	border-radius: 10px;
	background: rgba(128, 128, 128, 0.06);
}
.hre-lead-title {
	margin: 0 0 4px;
	font-size: 1.05em;
}
.hre-lead-hint {
	margin: 0 0 12px;
	font-size: 0.9em;
	opacity: 0.75;
}
.hre-lead-field-row {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-bottom: 12px;
}
.hre-lead-label {
	font-size: 0.9em;
	font-weight: 600;
}
.hre-lead-field-row input[type="text"],
.hre-lead-field-row input[type="tel"],
.hre-lead-field-row input[type="email"],
.hre-lead-field-row input[type="number"],
.hre-lead-field-row select,
.hre-lead-field-row textarea {
	width: 100% !important;
	max-width: none !important;
	padding: 8px 10px;
	border: 1px solid rgba(128, 128, 128, 0.5);
	border-radius: 6px;
	font: inherit;
	color: var(--hre-fg, inherit);
	background: var(--hre-input-bg, #fff);
	box-sizing: border-box;
}
.hre-lead-field-row input.hre-invalid,
.hre-lead-field-row select.hre-invalid,
.hre-lead-field-row textarea.hre-invalid {
	border-color: #d63638;
	box-shadow: 0 0 0 1px #d63638;
}
.hre-lead-field-row input[type="checkbox"] {
	width: 18px;
	height: 18px;
	margin: 0 8px 0 0;
	accent-color: var(--hre-accent, #2271b1);
}
.hre-lead-field-row:has(input[type="checkbox"]) {
	flex-direction: row;
	align-items: flex-start;
}
.hre-lead-form-error {
	margin: 6px 0 0;
	padding: 8px 10px;
	border-radius: 6px;
	background: rgba(214, 54, 56, 0.12);
	color: #b32d2e;
	font-size: 0.9em;
}
@media ( min-width: 782px ) {
	.hre-lead-fields {
		display: grid;
		grid-template-columns: 1fr 1fr;
		column-gap: 16px;
	}
}
