/* Spaces Cube Visualization — stage wrapper, canvas, tooltip, marker panel.
   Scoped via .iso-stage-wrap to avoid collisions with theme styles. */

.iso-stage-wrap {
	background: #f5f5f3;
	position: relative;
	width: 100%;
	overflow: hidden;
}

.iso-stage-wrap .iso-ui {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	padding: 16px;
	pointer-events: none;
	z-index: 8;
	gap: 12px;
}

.iso-stage-wrap .iso-explainer {
	position: relative;
	margin-top: auto;
	max-width: min(420px, calc(100% - 88px));
	padding: 12px 14px;
	/* background: rgba(255, 255, 255, 0.74); */
	/* border: 1px solid rgba(32, 32, 32, 0.08); */
	/* backdrop-filter: blur(10px); */
	box-shadow: 0 16px 38px rgba(17, 17, 17, 0.08);
	border-radius: 10px;
	font-family: Arial, sans-serif;
	pointer-events: auto;
}

.iso-stage-wrap .iso-explainer[hidden] {
	display: none;
}

.iso-stage-wrap .iso-explainer-close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 20px;
	height: 20px;
	border: 0;
	background: transparent;
	color: #6c675f;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.6;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 120ms ease;
}

.iso-stage-wrap .iso-explainer-close:hover {
	opacity: 1;
}

.iso-stage-wrap .iso-explainer-title {
	margin: 0 24px 6px 0;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: #6c675f;
}

.iso-stage-wrap .iso-explainer-body {
	margin: 0;
	font-size: 13px;
	line-height: 1.45;
}

.iso-stage-wrap .iso-explainer-timeframe {
	margin: 10px 0 0;
	display: flex;
	gap: 10px;
	align-items: baseline;
	flex-wrap: wrap;
	font-size: 12px;
	color: #5b564f;
}

.iso-stage-wrap .iso-explainer-timeframe strong {
	font-weight: 700;
}

.iso-stage-wrap .iso-ui-right {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 8px;
}

.iso-stage-wrap .iso-ui-tag {
	margin: 0;
	padding: 6px 13px;
	background: #1f1d19;
	border-radius: 999px;
	font-family: Arial, sans-serif;
	font-size: 11px;
	font-weight: 600;
	color: #fffdf9;
	white-space: nowrap;
	pointer-events: none;
}

.iso-stage-wrap .iso-fps {
	display: block;
	font-family: ui-monospace, monospace;
	font-size: 10px;
	color: rgba(0, 0, 0, 0.28);
	pointer-events: none;
	text-align: right;
}

.iso-stage-wrap .iso-view-toggle {
	display: inline-flex;
	gap: 6px;
	padding: 6px;
	border-radius: 999px;
	border: 1px solid rgba(32, 32, 32, 0.08);
	box-shadow: 0 14px 30px rgba(17, 17, 17, 0.08);
	backdrop-filter: blur(10px);
	pointer-events: auto;
}

.iso-stage-wrap .iso-view-button {
	border: 0;
	border-radius: 999px;
	padding: 8px 12px;
	background: transparent;
	color: #524d46;
	font-family: Arial, sans-serif;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.04em;
	cursor: pointer;
	transition:
		background 120ms ease,
		color 120ms ease,
		transform 120ms ease;
}

.iso-stage-wrap .iso-view-button:hover {
	background: rgba(0, 0, 0, 0.06);
	color: #1c1a17;
}

.iso-stage-wrap .iso-view-button.is-active {
	background: #1f1d19;
	color: #fffdf9;
}

.iso-stage-wrap .iso-fullscreen-button {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 8px;
	text-decoration: none;
}

.iso-stage-wrap .iso-icon-fullscreen {
	display: block;
	width: 14px;
	height: 14px;
	position: relative;
	box-sizing: border-box;
	border: 1.5px solid currentColor;
	border-radius: 1px;
}

/* Add gaps to create the classic 'corner' look */
.iso-stage-wrap .iso-icon-fullscreen::before,
.iso-stage-wrap .iso-icon-fullscreen::after {
	content: "";
	position: absolute;
	background: #f5f5f3; /* Default background of wrap */
}

/* When the parent button is active, the icon background should match the black button */
.iso-stage-wrap .is-active .iso-icon-fullscreen::before,
.iso-stage-wrap .is-active .iso-icon-fullscreen::after {
	background: #1f1d19;
}

.iso-stage-wrap .iso-icon-fullscreen::before {
	top: 15%;
	bottom: 15%;
	left: -2px;
	right: -2px;
}

.iso-stage-wrap .iso-icon-fullscreen::after {
	left: 15%;
	right: 15%;
	top: -2px;
	bottom: -2px;
}

/* Film grain: SVG fractalNoise tile, multiplied at low opacity over the whole
   wrap. Sits above the canvas (z=4) but below tooltip/panel (z=5–10).
   No impact on three.js render — purely a CSS layer. */
.iso-stage-wrap::before {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 4;
	opacity: 0.25;
	mix-blend-mode: soft-light;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch' seed='4'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.iso-stage-wrap .iso-stage {
	width: 100%;
	height: 100%;
	display: block;
	touch-action: none;
	cursor: grab;
}

.iso-stage-wrap .iso-tooltip {
	position: absolute;
	pointer-events: none;
	padding: 4px 10px;
	background: #cc4444;
	color: #fff;
	font-family: Arial, sans-serif;
	font-size: 11px;
	font-weight: 500;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	border-radius: 2px;
	opacity: 0;
	transition: opacity 120ms ease;
	white-space: nowrap;
	z-index: 10;
}

/* Marker panel: shown when a cube is clicked. Background is set inline by JS to
   the cube's palette colour so the panel reads as belonging to that cube. */
.iso-stage-wrap .iso-mark-panel {
	position: absolute;
	top: 16px;
	left: 16px;
	max-width: 320px;
	padding: 14px 16px 16px;
	background: #cc4444;
	color: #fff !important;
	font-family: Arial, sans-serif;
	border-radius: 4px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
	z-index: 11;
}

.iso-stage-wrap .iso-mark-panel[hidden] {
	display: none;
}

.iso-stage-wrap .iso-mark-close {
	position: absolute;
	top: 6px;
	right: 8px;
	width: 24px;
	height: 24px;
	border: 0;
	background: transparent;
	color: #fff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.75;
}

.iso-stage-wrap .iso-mark-close:hover {
	opacity: 1;
}

.iso-stage-wrap .iso-mark-title {
	margin: 0 24px 6px 0;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.4px;
	text-transform: uppercase;
}

.iso-stage-wrap .iso-mark-desc {
	margin: 0 0 12px;
	font-size: 13px;
	line-height: 1.4;
	opacity: 0.95;
	--max-h: 30vh;
	max-height: var(--max-h);
	overflow-y: auto;
	color: #fff;

	/* Hide scrollbar */
	scrollbar-width: none;
	-ms-overflow-style: none;

	/* Fallback: gradient fixed to max-height so short content remains opaque */
	-webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
	mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
	-webkit-mask-size: 100% var(--max-h);
	mask-size: 100% var(--max-h);
	mask-repeat: no-repeat;

	/* Modern CSS: Only apply fade if actually overflowing + fade out at bottom */
	@supports (animation-timeline: scroll()) {
		-webkit-mask-image: none;
		mask-image: none;
		mask-size: 100% 100%;
		animation: mask-reveal linear both;
		animation-timeline: scroll(self);
	}
}

.iso-stage-wrap .iso-mark-note {
	margin: 0 0 16px;
	font-size: 11px;
	line-height: 1.4;
	opacity: 0.8;
	font-style: italic;
	border-top: 1px solid rgba(255, 255, 255, 0.2);
	padding-top: 10px;
}

@keyframes mask-reveal {
	0%,
	90% {
		-webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
		mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
	}
	100% {
		-webkit-mask-image: none;
		mask-image: none;
	}
}

.iso-stage-wrap .iso-mark-desc::-webkit-scrollbar {
	display: none;
}

.iso-stage-wrap .iso-mark-visit {
	display: inline-block;
	padding: 6px 12px;
	background: rgba(255, 255, 255, 0.18);
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	text-decoration: none;
	border-radius: 3px;
	letter-spacing: 0.3px;
}

.iso-stage-wrap .iso-mark-visit:hover {
	background: rgba(255, 255, 255, 0.28);
}

@media (max-width: 600px) {
	.iso-stage-wrap .iso-mark-panel {
		left: 8px;
		right: 8px;
		max-width: none;
	}

	.iso-stage-wrap .iso-ui {
		padding: 8px;
		align-items: stretch;
		flex-direction: column;
	}

	.iso-stage-wrap .iso-explainer {
		max-width: none;
		margin-top: 0;
		margin-bottom: 20px;
		order: 2;
	}

	.iso-stage-wrap .iso-ui-right {
		align-self: flex-end;
		order: 1;
	}

	.iso-stage-wrap .iso-ui-tag {
		display: none;
	}
}
