/**
 * STL Viewer — tool-specific styles (Three.js canvas UI).
 * Depends on tools-common.css. Three.js JS loads only with this tool.
 */

.rb3d-stl {
	width: 100%;
	max-width: 100%;
	min-width: 0;
}

.rb3d-stl__layout {
	display: grid;
	gap: 1.25rem;
	width: 100%;
	min-width: 0;
}

@media (min-width: 1024px) {
	.rb3d-stl__layout {
		grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
		align-items: start;
		gap: 1.5rem;
	}
}

.rb3d-stl__layout > * {
	min-width: 0;
	max-width: 100%;
}

.rb3d-stl .rb3d-tool__intro {
	min-width: 0;
}

.rb3d-stl__controls {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin: 1rem 0 0.75rem;
	width: 100%;
}

.rb3d-stl__file {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.rb3d-stl__file-label {
	cursor: pointer;
}

.rb3d-stl .btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.75rem 1.25rem;
	border: 1px solid transparent;
	border-radius: var(--rb3d-radius-md);
	font-family: var(--rb3d-font-sans);
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	box-sizing: border-box;
	max-width: 100%;
}

@media (max-width: 479px) {
	.rb3d-stl__controls {
		flex-direction: column;
		align-items: stretch;
	}

	.rb3d-stl .btn {
		width: 100%;
	}
}

.rb3d-stl .btn--primary {
	background: var(--rb3d-accent);
	color: #5d2f00;
}

.rb3d-stl .btn--secondary {
	background: var(--rb3d-surface-high);
	border-color: var(--rb3d-surface-high);
	color: var(--rb3d-text);
}

.rb3d-stl .btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.rb3d-stl .btn:focus-visible,
.rb3d-stl__file:focus-visible + .rb3d-stl__file-label {
	outline: 2px solid var(--rb3d-accent-dark);
	outline-offset: 2px;
}

.rb3d-stl__status {
	margin: 0;
	font-size: 0.8125rem;
	color: var(--rb3d-muted);
	line-height: 1.45;
	overflow-wrap: anywhere;
	word-break: break-word;
}

.rb3d-stl__stage {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	width: 100%;
	min-width: 0;
	max-width: 100%;
}

.rb3d-stl__viewport {
	position: relative;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	height: min(52vw, 280px);
	min-height: 200px;
	max-height: 420px;
	aspect-ratio: auto;
	background: var(--rb3d-surface-low);
	border: 1px solid var(--rb3d-surface-high);
	border-radius: var(--rb3d-radius-lg);
	overflow: hidden;
	touch-action: none;
	contain: layout paint;
}

@media (min-width: 640px) {
	.rb3d-stl__viewport {
		height: auto;
		min-height: 280px;
		aspect-ratio: 4 / 3;
		max-height: none;
	}
}

@media (min-width: 1024px) {
	.rb3d-stl__viewport {
		min-height: 320px;
	}
}

.rb3d-stl__viewport.is-dragover {
	outline: 2px dashed var(--rb3d-accent-dark);
	outline-offset: -4px;
}

.rb3d-stl__viewport canvas {
	display: block;
	position: absolute;
	inset: 0;
	width: 100% !important;
	height: 100% !important;
	max-width: 100%;
	max-height: 100%;
}

.rb3d-stl__viewport:focus-visible {
	outline: 2px solid var(--rb3d-accent-dark);
	outline-offset: 2px;
}

.rb3d-stl__stats {
	list-style: none;
	margin: 0;
	padding: 0.75rem;
	display: grid;
	gap: 0.75rem;
	grid-template-columns: 1fr;
	background: var(--rb3d-surface);
	border: 1px solid var(--rb3d-surface-high);
	border-radius: var(--rb3d-radius-md);
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	min-width: 0;
}

@media (min-width: 640px) {
	.rb3d-stl__stats {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

.rb3d-stl__stats li {
	min-width: 0;
}

.rb3d-stl__stats strong {
	display: block;
	font-family: var(--rb3d-font-display);
	font-size: 0.9375rem;
	font-weight: 700;
	color: var(--rb3d-text);
	margin-top: 0.15rem;
	overflow-wrap: anywhere;
	word-break: break-word;
}

@media (min-width: 640px) {
	.rb3d-stl__stats strong {
		font-size: 1rem;
	}
}

.rb3d-stl__note {
	margin: 0;
	font-size: 0.75rem;
	color: var(--rb3d-muted);
	line-height: 1.45;
	overflow-wrap: anywhere;
}

/* Move / view rearrange toolbar */
.rb3d-stl__rearrange {
	margin-top: 1rem;
	padding: 0.85rem;
	border: 1px solid var(--rb3d-surface-high);
	border-radius: var(--rb3d-radius-lg);
	background: var(--rb3d-surface-low);
	display: grid;
	gap: 0.75rem;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.rb3d-stl__toolbar-label {
	margin: 0;
	font-family: var(--rb3d-font-mono);
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--rb3d-accent-dark);
}

.rb3d-stl__pad {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.4rem;
	max-width: 16rem;
}

.rb3d-stl__pad-spacer {
	visibility: hidden;
	pointer-events: none;
}

.rb3d-stl__pad-btn,
.rb3d-stl__view-btn {
	appearance: none;
	border: 1px solid var(--rb3d-border);
	border-radius: var(--rb3d-radius);
	background: var(--rb3d-surface);
	color: var(--rb3d-text);
	font-family: var(--rb3d-font-mono);
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	padding: 0.55rem 0.4rem;
	cursor: pointer;
	line-height: 1.2;
}

.rb3d-stl__pad-btn:hover:not(:disabled),
.rb3d-stl__view-btn:hover:not(:disabled) {
	border-color: var(--rb3d-accent-dark);
	color: var(--rb3d-accent-dark);
}

.rb3d-stl__pad-btn:focus-visible,
.rb3d-stl__view-btn:focus-visible {
	outline: 2px solid var(--rb3d-accent-dark);
	outline-offset: 2px;
}

.rb3d-stl__pad-btn:disabled,
.rb3d-stl__view-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.rb3d-stl__step {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
}

.rb3d-stl__step label {
	font-family: var(--rb3d-font-mono);
	font-size: 0.6875rem;
	font-weight: 500;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--rb3d-muted);
}

.rb3d-stl__step input {
	width: 5.5rem;
	max-width: 100%;
	padding: 0.45rem 0.55rem;
	border: 1px solid var(--rb3d-border);
	border-radius: var(--rb3d-radius);
	font-family: var(--rb3d-font-mono);
	font-size: 0.8125rem;
	color: var(--rb3d-text);
	background: var(--rb3d-surface);
}

.rb3d-stl__step input:focus {
	border-color: var(--rb3d-accent-dark);
	outline: none;
	box-shadow: 0 0 0 2px var(--rb3d-accent-soft);
}

.rb3d-stl__toolbar-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.rb3d-stl__toolbar-btn {
	justify-self: start;
}

.rb3d-stl__hint {
	margin: 0;
	font-size: 0.75rem;
	line-height: 1.45;
	color: var(--rb3d-muted);
}

.rb3d-stl__views {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.rb3d-stl__view-btn {
	min-width: 4.25rem;
}

@media (max-width: 479px) {
	.rb3d-stl__pad {
		max-width: none;
	}

	.rb3d-stl__toolbar-btn {
		width: 100%;
		justify-self: stretch;
	}
}
