/**
 * SC-ICG Pet Avatar Builder — Frontend Styles
 *
 * @package SC_ICG_Pet_Builder
 */

/* ─── Font ─── */
@font-face {
	font-family: 'Courgette';
	src: url('../fonts/Courgette-Regular.ttf') format('truetype');
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: 'jf-openhuninn';
	src: url('../fonts/jf-openhuninn-2.1.ttf') format('truetype');
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

/* ─── Reset ─── */
.sc-pet-builder {
	max-width: 1000px;
	margin: 0 auto;
	padding: 24px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans TC', sans-serif;
	color: #1a1a2e;
	line-height: 1.5;
}

.sc-pet-builder * {
	box-sizing: border-box;
}

/* ─── Loading ─── */
.sc-pet-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 400px;
	gap: 16px;
	color: #6b7280;
}

.sc-pet-loading-spinner {
	width: 40px;
	height: 40px;
	border: 3px solid #e5e7eb;
	border-top-color: #6366f1;
	border-radius: 50%;
	animation: sc-pet-spin 0.8s linear infinite;
}

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

/* ─── Progress ─── */
.sc-pet-progress {
	margin-bottom: 20px;
	display: flex;
	align-items: center;
	gap: 12px;
}

.sc-pet-progress-bar {
	flex: 1;
	height: 6px;
	background: #e5e7eb;
	border-radius: 3px;
	overflow: hidden;
}

.sc-pet-progress-fill {
	height: 100%;
	background: linear-gradient(90deg, #6366f1, #8b5cf6);
	border-radius: 3px;
	transition: width 0.4s ease;
}

.sc-pet-progress-text {
	font-size: 13px;
	color: #6b7280;
	white-space: nowrap;
}

/* ─── Layout ─── */
.sc-pet-layout {
	display: flex;
	gap: 32px;
	align-items: flex-start;
}

@media (max-width: 768px) {
	.sc-pet-layout {
		flex-direction: column;
		align-items: center;
	}
}

/* ─── Preview Stage (DOM-based image stacking) ─── */
.sc-pet-canvas-wrap {
	flex-shrink: 0;
	position: relative;
}

.sc-pet-preview-stage {
	position: relative;
	width: 400px;
	height: 400px;
	max-width: 100%;
	border: 2px solid #e5e7eb;
	border-radius: 20px;
	background: #ffffff;
	background-image:
		linear-gradient(45deg, #f3f4f6 25%, transparent 25%),
		linear-gradient(-45deg, #f3f4f6 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #f3f4f6 75%),
		linear-gradient(-45deg, transparent 75%, #f3f4f6 75%);
	background-size: 20px 20px;
	background-position: 0 0, 0 10px, 10px -10px, -10px 0;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
	transition: box-shadow 0.3s;
	overflow: hidden;
}

.sc-pet-preview-stage:hover {
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.sc-pet-layer {
	position: absolute;
	top: -40px;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	pointer-events: none;
}

.sc-pet-preview-hint {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	text-align: center;
	color: #9ca3af;
	font-size: 15px;
	pointer-events: none;
	z-index: 0;
}

.sc-pet-live-name {
	position: absolute;
	bottom: 36px;
	left: 0;
	right: 0;
	text-align: center;
	font-size: 44px;
	font-weight: 700;
	color: #333;
	text-shadow: 0 1px 4px rgba(255, 255, 255, 0.9);
	pointer-events: none;
	font-family: 'Courgette', cursive, sans-serif;
	padding: 0 10px;
	line-height: 1.2;
}

.sc-pet-live-name.sc-pet-font-zh {
	font-family: 'jf-openhuninn', 'Noto Sans TC', sans-serif;
}

.sc-pet-preview-hint p {
	margin: 0;
	line-height: 1.8;
}

/* ─── Controls ─── */
.sc-pet-controls {
	flex: 1;
	min-width: 0;
}

/* ─── Type Selector ─── */
.sc-pet-type-selector {
	display: flex;
	gap: 10px;
	margin-bottom: 20px;
}

.sc-pet-type-btn {
	flex: 1;
	padding: 12px 16px;
	border: 2px solid #e5e7eb;
	border-radius: 14px;
	background: #fff;
	font-size: 16px;
	cursor: pointer;
	transition: all 0.2s;
}

.sc-pet-type-btn:hover {
	border-color: #a5b4fc;
	background: #f5f3ff;
}

.sc-pet-type-btn.active {
	border-color: #6366f1;
	background: #eef2ff;
	font-weight: 600;
	box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ─── Category Tabs ─── */
.sc-pet-category-tabs {
	display: flex;
	gap: 6px;
	margin-bottom: 16px;
	flex-wrap: wrap;
}

.sc-pet-cat-btn {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 8px 14px;
	border: 2px solid #e5e7eb;
	border-radius: 24px;
	background: #fff;
	font-size: 14px;
	cursor: pointer;
	transition: all 0.2s;
	position: relative;
}

.sc-pet-cat-btn:hover {
	background: #f5f3ff;
	border-color: #c7d2fe;
}

.sc-pet-cat-btn.active {
	background: #6366f1;
	color: #fff;
	border-color: #6366f1;
	box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.sc-pet-cat-btn.has-selection:not(.active) {
	border-color: #a5b4fc;
	background: #f5f3ff;
}

.sc-pet-cat-icon {
	font-size: 15px;
}

.sc-pet-cat-label {
	font-weight: 500;
}

.sc-pet-cat-check {
	font-size: 11px;
	width: 16px;
	height: 16px;
	line-height: 16px;
	text-align: center;
	background: #22c55e;
	color: #fff;
	border-radius: 50%;
	margin-left: 2px;
}

.sc-pet-cat-btn.active .sc-pet-cat-check {
	background: rgba(255, 255, 255, 0.3);
}

/* ─── Parts Grid ─── */
.sc-pet-parts-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
	gap: 10px;
	margin-bottom: 20px;
	max-height: 340px;
	overflow-y: auto;
	padding: 4px;
	scrollbar-width: thin;
	scrollbar-color: #d1d5db transparent;
}

.sc-pet-parts-grid::-webkit-scrollbar {
	width: 6px;
}

.sc-pet-parts-grid::-webkit-scrollbar-track {
	background: transparent;
}

.sc-pet-parts-grid::-webkit-scrollbar-thumb {
	background: #d1d5db;
	border-radius: 3px;
}

.sc-pet-part-btn {
	width: 100%;
	aspect-ratio: 1;
	padding: 6px;
	border: 2px solid #e5e7eb;
	border-radius: 14px;
	background: #fafafa;
	cursor: pointer;
	transition: all 0.2s;
	overflow: hidden;
	position: relative;
}

.sc-pet-part-btn img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.sc-pet-part-btn:hover {
	border-color: #a5b4fc;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.sc-pet-part-btn.selected {
	border-color: #6366f1;
	box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2), 0 4px 12px rgba(99, 102, 241, 0.15);
	background: #f5f3ff;
}

.sc-pet-part-check {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 20px;
	height: 20px;
	line-height: 20px;
	text-align: center;
	background: #6366f1;
	color: #fff;
	border-radius: 50%;
	font-size: 11px;
	font-weight: 700;
}

.sc-pet-no-parts {
	grid-column: 1 / -1;
	text-align: center;
	color: #9ca3af;
	padding: 30px 20px;
	font-size: 14px;
}

/* ─── Buttons ─── */
.sc-pet-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 12px 24px;
	border: none;
	border-radius: 12px;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
	text-decoration: none;
}

.sc-pet-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	transform: none !important;
}

.sc-pet-btn-full {
	width: 100%;
}

.sc-pet-btn-primary {
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	color: #fff;
	box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.sc-pet-btn-primary:hover:not(:disabled) {
	transform: translateY(-1px);
	box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.sc-pet-btn-primary:active:not(:disabled) {
	transform: translateY(0);
}

.sc-pet-btn-secondary {
	background: #f3f4f6;
	color: #374151;
	border: 1px solid #e5e7eb;
}

.sc-pet-btn-secondary:hover:not(:disabled) {
	background: #e5e7eb;
}

.sc-pet-btn-link {
	background: none;
	color: #6366f1;
	padding: 8px;
	font-size: 14px;
	font-weight: 500;
}

.sc-pet-btn-link:hover {
	text-decoration: underline;
}

.sc-pet-btn-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: sc-pet-spin 0.6s linear infinite;
}

/* ─── Name Input ─── */
.sc-pet-name-section {
	margin-bottom: 24px;
}

.sc-pet-name-section h3 {
	margin: 0 0 4px;
	font-size: 22px;
	color: #1a1a2e;
}

.sc-pet-name-hint {
	color: #6b7280;
	font-size: 14px;
	margin: 0 0 16px;
}

.sc-pet-name-input {
	width: 100%;
	padding: 14px 18px;
	border: 2px solid #e5e7eb;
	border-radius: 14px;
	font-size: 18px;
	outline: none;
	transition: all 0.2s;
	font-family: inherit;
}

.sc-pet-name-input:focus {
	border-color: #6366f1;
	box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.sc-pet-name-input::placeholder {
	color: #c4c7cc;
}

.sc-pet-name-counter {
	display: block;
	text-align: right;
	font-size: 12px;
	color: #9ca3af;
	margin-top: 6px;
}

.sc-pet-name-warn {
	display: block;
	font-size: 13px;
	color: #dc2626;
	margin-top: 4px;
	min-height: 20px;
}

/* ─── Turnstile ─── */
.sc-pet-turnstile-wrap {
	margin-bottom: 16px;
}

.sc-pet-name-actions {
	display: flex;
	gap: 10px;
}

.sc-pet-name-actions .sc-pet-btn {
	flex: 1;
}

/* ─── Preview ─── */
.sc-pet-step-preview {
	text-align: center;
	max-width: 500px;
	margin: 0 auto;
}

.sc-pet-preview-header h3 {
	font-size: 24px;
	margin: 0 0 4px;
}

.sc-pet-preview-subtitle {
	color: #6b7280;
	font-size: 15px;
	margin: 0 0 24px;
}

.sc-pet-preview-image {
	margin-bottom: 28px;
}

.sc-pet-preview-image img {
	max-width: 400px;
	width: 100%;
	border-radius: 20px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.sc-pet-preview-name {
	font-size: 28px;
	font-weight: 700;
	margin: 16px 0;
	background: linear-gradient(135deg, #6366f1, #ec4899);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.sc-pet-preview-actions {
	display: flex;
	gap: 12px;
	justify-content: center;
	margin-bottom: 16px;
}

/* ─── Mockups ─── */
.sc-pet-step-mockups {
	text-align: center;
}

.sc-pet-step-mockups h3 {
	font-size: 22px;
	margin: 0 0 20px;
}

.sc-pet-mockup-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 20px;
	margin: 20px 0;
}

.sc-pet-mockup-card {
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 20px;
	padding: 16px;
	text-align: center;
	transition: all 0.3s;
}

.sc-pet-mockup-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
}

.sc-pet-mockup-card img {
	width: 100%;
	border-radius: 12px;
	margin-bottom: 12px;
}

.sc-pet-mockup-card h4 {
	margin: 0 0 8px;
	font-size: 16px;
}

.sc-pet-price {
	font-size: 20px;
	font-weight: 700;
	color: #ef4444;
	margin: 0 0 12px;
}

/* ─── Error ─── */
.sc-pet-error {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	margin-bottom: 16px;
	background: #fef2f2;
	border: 1px solid #fecaca;
	border-radius: 12px;
	color: #dc2626;
	animation: sc-pet-slide-in 0.3s ease;
}

@keyframes sc-pet-slide-in {
	from {
		opacity: 0;
		transform: translateY(-8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.sc-pet-error p {
	margin: 0;
	font-size: 14px;
}

.sc-pet-error button {
	background: none;
	border: none;
	font-size: 18px;
	cursor: pointer;
	color: #dc2626;
	padding: 0 4px;
	line-height: 1;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
	.sc-pet-builder {
		padding: 16px;
	}

	.sc-pet-canvas {
		width: 320px;
		height: 320px;
	}

	.sc-pet-category-tabs {
		gap: 4px;
	}

	.sc-pet-cat-btn {
		padding: 6px 10px;
		font-size: 13px;
	}

	.sc-pet-cat-icon {
		display: none;
	}

	.sc-pet-parts-grid {
		grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
		max-height: 260px;
	}

	.sc-pet-preview-actions {
		flex-direction: column;
	}

	.sc-pet-name-actions {
		flex-direction: column;
	}
}
