/* Colours in one place, so light and dark differ only here.
   The backend follows Joomla's own signals: data-bs-theme when the administrator
   picked a side, data-color-scheme-os when they left it to the machine. The
   frontend has no such signal, so it follows the machine. */
:root {
	--hk3d-surface: #fff;
	--hk3d-text: #222;
	--hk3d-muted: #555;
	--hk3d-line: rgba(127, 127, 127, 0.4);
	--hk3d-stage: #f5f5f5;
	--hk3d-accent: #2a6fb0;
	--hk3d-accent-text: #fff;
	--hk3d-danger: #b42318;
	--hk3d-shadow: rgba(0, 0, 0, 0.35);
	--hk3d-control: rgba(255, 255, 255, 0.85);
	--hk3d-control-text: #222;
}

html[data-bs-theme="dark"],
html[data-color-scheme="dark"] {
	--hk3d-surface: #23272b;
	--hk3d-text: #e6e6e6;
	--hk3d-muted: #b0b0b0;
	--hk3d-line: rgba(255, 255, 255, 0.25);
	--hk3d-stage: #1b1e21;
	--hk3d-accent: #4a90d9;
	--hk3d-accent-text: #10131a;
	--hk3d-danger: #ff8a80;
	--hk3d-shadow: rgba(0, 0, 0, 0.6);
	--hk3d-control: rgba(20, 20, 20, 0.75);
	--hk3d-control-text: #eee;
}

@media (prefers-color-scheme: dark) {
	/* The administrator left the choice to the machine, or this is the shop front,
	   which carries no such choice to respect. */
	html[data-color-scheme-os]:not([data-bs-theme="light"]),
	html:not([data-bs-theme]):not([data-color-scheme]) {
		--hk3d-surface: #23272b;
		--hk3d-text: #e6e6e6;
		--hk3d-muted: #b0b0b0;
		--hk3d-line: rgba(255, 255, 255, 0.25);
		--hk3d-stage: #1b1e21;
		--hk3d-accent: #4a90d9;
		--hk3d-accent-text: #10131a;
		--hk3d-danger: #ff8a80;
		--hk3d-shadow: rgba(0, 0, 0, 0.6);
		--hk3d-control: rgba(20, 20, 20, 0.75);
		--hk3d-control-text: #eee;
	}
}

/* The viewer, which takes the place of the product image it stands for */
.hikashop_product3d_viewer {
	display: none;
	position: relative;
	width: 100%;
	max-width: 100%;
}

.hikashop_product3d_viewer model-viewer {
	width: 100%;
	height: 100%;
	background-color: transparent;
	--poster-color: transparent;
}

/* Zoom and reset, over the bottom right corner of the model */
.hikashop_product3d_controls {
	position: absolute;
	right: 6px;
	bottom: 6px;
	display: flex;
	gap: 4px;
	z-index: 2;
}

/* model-viewer draws an augmented reality button of its own, in this same
   corner, where it lands on top of these. Ours is in the row with them. */
.hikashop_product3d_viewer model-viewer::part(default-ar-button) {
	display: none;
}

/* Wider than the others: it carries an icon rather than a character, and it is
   the one worth reading as a button rather than a hint. */
.hikashop_product3d_ar {
	width: auto;
	padding: 0 8px;
	opacity: 0.75;
}

.hikashop_product3d_ar svg {
	display: block;
	margin: 0 auto;
}

.hikashop_product3d_control {
	width: 28px;
	height: 28px;
	padding: 0;
	border: 1px solid var(--hk3d-line);
	border-radius: 4px;
	background: var(--hk3d-control);
	color: var(--hk3d-control-text);
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.55;
	transition: opacity 0.15s ease;
}

.hikashop_product3d_viewer:hover .hikashop_product3d_control,
.hikashop_product3d_control:focus {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.hikashop_product3d_control {
		transition: none;
	}
}

/* The badge added to the gallery thumbnails that are models */
.hikashop_thumbnail_3d {
	position: relative;
	display: inline-block;
}

.hikashop_product3d_badge {
	position: absolute;
	right: 3px;
	bottom: 3px;
	padding: 1px 4px;
	border-radius: 3px;
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	font-size: 10px;
	font-weight: bold;
	line-height: 1.4;
	letter-spacing: 0.5px;
	pointer-events: none;
}

/* The dialog where the merchant frames the model before its picture is taken.
   It has to be on screen: model-viewer draws nothing that is out of sight. */
.hikashop_product3d_overlay {
	position: fixed;
	inset: 0;
	z-index: 10000;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.55);
}

.hikashop_product3d_box {
	width: min(90vw, 520px);
	padding: 16px;
	border-radius: 8px;
	background: var(--hk3d-surface);
	color: var(--hk3d-text);
	box-shadow: 0 8px 40px var(--hk3d-shadow);
	text-align: center;
}

.hikashop_product3d_box_title {
	margin: 0 0 10px;
	font-size: 16px;
	font-weight: bold;
	color: var(--hk3d-text);
}

.hikashop_product3d_box_model {
	display: block;
	width: 100%;
	height: min(50vh, 380px);
	background-color: var(--hk3d-stage);
	border-radius: 6px;
}

.hikashop_product3d_box_help {
	margin: 10px 0 0;
	font-size: 13px;
	line-height: 1.45;
	color: var(--hk3d-muted);
}

.hikashop_product3d_box_status {
	margin: 8px 0 0;
	min-height: 1.2em;
	font-size: 13px;
	color: var(--hk3d-danger);
}

.hikashop_product3d_box_actions {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	margin-top: 14px;
}

.hikashop_product3d_box_actions button {
	padding: 8px 16px;
	border-radius: 4px;
	border: 1px solid var(--hk3d-line);
	background: transparent;
	color: var(--hk3d-text);
	font-size: 14px;
	cursor: pointer;
}

.hikashop_product3d_box_use {
	border-color: var(--hk3d-accent);
	background: var(--hk3d-accent);
	color: var(--hk3d-accent-text);
}

.hikashop_product3d_box_actions button[disabled] {
	opacity: 0.5;
	cursor: default;
}

/* The dialog that builds a model from photographs. */

.hikashop_product3d_build {
	max-width: 640px;
	text-align: left;
}

.hikashop_product3d_drop {
	position: relative;
	display: block;
	border: 2px dashed var(--hk3d-line);
	border-radius: 6px;
	padding: 24px 16px;
	text-align: center;
	color: var(--hk3d-muted);
	cursor: pointer;
	margin-bottom: 12px;
}

.hikashop_product3d_drop_over {
	border-color: var(--hk3d-accent);
	color: var(--hk3d-text);
}

.hikashop_product3d_file {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
}

.hikashop_product3d_photos {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 12px;
}

.hikashop_product3d_photo {
	position: relative;
	display: block;
	cursor: pointer;
	border: 2px solid var(--hk3d-line);
	border-radius: 4px;
	padding: 2px;
	line-height: 0;
}

.hikashop_product3d_photo img {
	width: 80px;
	height: 80px;
	object-fit: contain;
}

.hikashop_product3d_photo input {
	position: absolute;
	top: 4px;
	left: 4px;
	margin: 0;
}

.hikashop_product3d_photo:has(input:checked) {
	border-color: var(--hk3d-accent);
}

.hikashop_product3d_photo:focus-within {
	outline: 2px solid var(--hk3d-accent);
	outline-offset: 2px;
}

.hikashop_product3d_added {
	border-color: var(--hk3d-accent);
	cursor: default;
}

.hikashop_product3d_photo_drop {
	position: absolute;
	top: -8px;
	right: -8px;
	width: 22px;
	height: 22px;
	line-height: 1;
	border-radius: 50%;
	border: 1px solid var(--hk3d-line);
	background: var(--hk3d-surface);
	color: var(--hk3d-text);
	cursor: pointer;
	padding: 0;
}

.hikashop_product3d_gen_failed {
	color: var(--hk3d-danger);
}

.hikashop_product3d_working .hikashop_product3d_photos,
.hikashop_product3d_working .hikashop_product3d_drop {
	opacity: 0.5;
	pointer-events: none;
}
