:root {
	/* Color Palette */
	--bg-color: #F5F2EB;
	--text-color: #222222;
	--accent-sage: #8ba892;
	--accent-rust: #c07663;
	--accent-slate: #3B4B5B;
	--accent-william: #336666;
	--white: #FFFFFF;

	/* Typography */
	--font-header: 'Poppins', sans-serif;
	--font-body: 'Inter', sans-serif;
}

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

/*
body {
	font-family: var(--font-body);
	background-color: var(--bg-color);
	background-image: url('/images/background-pattern.jpg'); 
	background-size: cover;
	background-position: center;
	background-attachment: fixed;
	color: var(--text-color);
	line-height: 1.6;
}
*/

body {
	display: flex;
	flex-direction: column;
	font-family: var(--font-body);
	color: var(--text-color);
	line-height: 1.6;

	/* Simulate a soft, warm studio wall with lighting from the top left */
	background: radial-gradient(
		circle at 15% 15%, 
		#FFFFFF 0%, 
		#F5F2EB 40%, 
		#EAE6DF 100%
	);
	background-attachment: fixed;
	min-height: 100vh;
}

main {
	flex: 1;
}

/* Header */
.header-container {
	background-color: var(--white);
	border-bottom: 1px solid #E0DCD3;
	position: sticky;
	top: 0;
	z-index: 100;
}

.header-banner {
	display: flex;
	justify-content: space-between;
	align-items: center;
	max-width: 1100px;
	margin: auto;
	padding: 0.5rem 1rem;
}

.header-left {
	display: flex;
	align-items: center;
	gap: 10px;
}

.logo {
	max-height: 60px;
	width: auto;
	object-fit: contain;
}

.site-title {
	font-family: var(--font-header);
	font-size: 1.5rem;
	font-weight: 700;
}

.header-nav {
	display: flex;
	gap: 30px;
}

.header-nav a {
	text-decoration: none;
	color: var(--text-color);
	font-weight: 700;
}

.header-nav a.active {
	color: var(--accent-william);
	border-bottom: 3px solid var(--accent-william);
}

.header-right {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.social-icons {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.social-icons a {
	color: var(--text-color);
	display: flex;
	align-items: center;
	transition: color 0.2s ease, transform 0.2s ease;
}

.social-icons a:hover {
	color: var(--accent-william);
	transform: translateY(-2px);
}

.header-right .btn {
	background-color: var(--accent-rust);
	color: var(--white);
	border: none;
	border-radius: 0.5rem;
	padding: 0.75rem 3rem;
	font-weight: 700;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.header-right .btn:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(200, 106, 83, 0.3);
}

/* Typography */
h1, h2, h3 {
	font-family: var(--font-header);
}

.visualizer-container {
	max-width: 1100px;
	margin: 0 auto;
}

.visualizer-headline {
	text-align: center;
	font-size: 2.5rem;
	margin: 3rem auto;
	color: var(--accent-slate);
	text-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 30px rgba(255, 255, 255, 1);
}

.visualizer-description {
	margin: 0 auto;
	color: var(--text-color);
	font-size: 1.1rem;
	padding: 0rem 2rem 2rem 2rem;
}

/* Layout Grid */
.visualizer-grid {
	display: grid;
	grid-template-columns: 2.5fr 1fr;
	max-width: 1100px;
	margin: 0 auto;
	gap: 1rem;

	/* Floating Card Styling */
	background-color: rgba(255, 255, 255, 0.95);
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
	padding: 1rem;
	margin-bottom: 4rem;
}

.canvas-column {
	align-self: center;
}

/* Left Column: Canvas */
.canvas-container {
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 4;
	position: relative;
	overflow: hidden;
	background-color: #EAE6DF; /* Fallback empty state */
	background-image: url('/img/canvas-bg.jpg');
	background-size: contain;
	border-radius: 8px;
	box-shadow: 0 4px 12px rgba(0,0,0,0.05);
	margin: 0 auto;
	border: 2px solid var(--accent-william);
}

/* --- Empty State CTA --- */
.empty-state-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	background-color: rgba(255, 255, 255, 0.75);
	backdrop-filter: blur(3px);
	z-index: 25; /* Above guide, below controls */
	text-align: center;
	pointer-events: none; /* Prevents the overlay from blocking drag events on the canvas */
	transition: opacity 0.3s ease, background-color 0.2s ease;
}

.empty-state-overlay .upload-icon {
	color: var(--accent-slate);
	margin-bottom: 0.5rem;
	transition: transform 0.2s ease, color 0.2s ease;
}

.empty-state-overlay h3 { 
	color: var(--accent-slate); 
	margin-bottom: 0.2rem; 
}

.empty-state-overlay p { 
	color: var(--text-color);
	font-size: 0.9rem; 
}

/* --- Active Drag State --- */
.canvas-container.drag-active {
	border-color: var(--accent-rust);
}

.canvas-container.drag-active .empty-state-overlay {
	background-color: rgba(255, 255, 255, 0.9);
}

.canvas-container.drag-active .upload-icon {
	transform: translateY(-5px);
	color: var(--accent-rust);
}

#fabricLayer {
	position: absolute;
	top: 50%;
	left: 50%;
	max-width: 100%;
	height: auto;
	cursor: grab;
	display: none;
	z-index: 5;
}

.hoop-assembly {
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 10;
}

.hoop-texture {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	background-size: contain;
	background-position: center;
	background-repeat: no-repeat;
	z-index: 1;
	pointer-events: none;
}

/* This is the color layer */
.hoop-mask {
	position: absolute;
	inset: 0;
	z-index: 2;
	background-color: var(--accent-william); /* Default fallback */

	-webkit-mask-size: contain;
	-webkit-mask-position: center;
	-webkit-mask-repeat: no-repeat;
	mask-size: contain;
	mask-position: center;
	mask-repeat: no-repeat;
	mix-blend-mode: multiply;

	pointer-events: none;
}

#trueScaleGuide {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	border: 2px dashed var(--accent-rust);
	background-color: rgba(200, 106, 83, 0.1);
	display: none; 
	z-index: 20;
	pointer-events: none;
	transition: width 0.2s ease, height 0.2s ease;
}

.zoom-controls {
	position: absolute;
	bottom: 1rem;
	left: 50%;
	transform: translateX(-50%);
	background-color: var(--white);
	backdrop-filter: blur(4px);
	border: 1px solid #E0DCD3;
	padding: 0.5rem 1rem;
	border-radius: 2rem;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
	display: flex;
	align-items: center;
	gap: 1rem;
	z-index: 30;
	width: 60%;
}

.zoom-icon {
	font-size: 1.2rem;
	font-weight: bold;
	color: var(--accent-slate);
	cursor: pointer;
	user-select: none;
	transition: color 0.2s;
	width: 20px;
	text-align: center;
}

.zoom-icon:hover {
	color: var(--accent-william);
}

.custom-slider {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 4px;
	background: #E0DCD3;
}

.custom-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--accent-slate);
	cursor: pointer;
	transition: background 0.2s, transform 0.1s;
}

.custom-slider::-webkit-slider-thumb:hover {
	background: var(--accent-william);
	transform: scale(1.1);
}

.custom-slider::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--accent-slate);
	cursor: pointer;
	border: none;
}

.custom-slider::-moz-range-thumb:hover {
	background: var(--accent-william);
	transform: scale(1.1);
}

/* Right Column: Controls */
.controls-column {
	display: flex;
	justify-content: space-around;
	flex-direction: column;
	gap: 0.5rem;
}

.control-group h3 {
	font-size: 1rem;
	margin-bottom: 0.5rem;
	text-transform: uppercase;
	letter-spacing: 1px;
	color: var(--accent-slate);
}

/* Buttons & Inputs */
.btn {
	padding: 10px 20px;
	border: none;
	border-radius: 4px;
	font-family: var(--font-header);
	font-size: 0.9rem;
	cursor: pointer;
	text-align: center;
	text-decoration: none;
	transition: background-color 0.2s;
}

.btn-primary { background-color: var(--accent-slate); color: var(--white); }
.btn-secondary { background-color: transparent; border: 2px solid var(--accent-slate); color: var(--accent-slate); }
.btn-outline { background-color: transparent; border: 2px solid var(--text-color); color: var(--text-color); }
.btn-accent { background-color: var(--accent-rust); color: var(--white); }

.btn-large {
	display: block;
	width: 100%;
	padding: 15px;
	font-size: 1.1rem;
}

.upload-btn {
	display: inline-block;
}

.full-width {
	width: 100%;
	display: block; /* Forces elements like labels/links to take full width */
	box-sizing: border-box;
}

.btn-sage {
	background-color: var(--accent-william);
	color: var(--white);
}

.btn-sage:hover {
	background-color: #2E5356; /* A slightly darker sage for hover states */
}

/* Ensure inputs are explicitly white and styled cleanly */
.input-white {
	background-color: #FFFFFF;
	border: 1px solid #CCC;
	border-radius: 4px;
	padding: 10px;
	font-family: var(--font-body);
	color: var(--text-color);
	box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); /* Very soft inner shadow */
}

/* --- Pattern Dimensions Layout --- */
.dimension-inputs {
	display: flex;
	gap: 1rem;
	margin-bottom: 0.5rem;
}

.dim-group {
	display: flex;
	flex-direction: column;
	flex: 1; /* Forces both inputs to take up exactly 50% of the space */
	gap: 0.2rem;
}

.dim-group input {
	width: 100%;
}

.dim-label {
	font-size: 0.75rem;
	color: var(--accent-slate);
	letter-spacing: 0.5px;
	margin: auto;
}

.aida-group {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}

.scale-btn {
	margin-top: 5px;
}

/* --- PNG Shape Selectors Grid --- */
.shape-selectors {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
	gap: 1rem;
	max-height: 220px; 
	overflow-y: auto; 
	padding-right: 0.5rem;
}

.shape-selectors::-webkit-scrollbar { width: 6px; }
.shape-selectors::-webkit-scrollbar-track { background: var(--white); border-radius: 4px; }
.shape-selectors::-webkit-scrollbar-thumb { background: var(--white); border-radius: 4px; }
.shape-selectors::-webkit-scrollbar-thumb:hover { background: var(--accent-slate); }

.btn-shape {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 0.5rem;
	background-color: var(--white);
	border: 2px solid #E0DCD3;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s ease;
	color: var(--accent-slate);
}

.shape-icon {
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: contain; 
	margin-bottom: 0.25rem;
	transition: transform 0.2s ease, filter 0.2s ease;
	pointer-events: none; 
}

.shape-label {
	font-size: 0.65rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	pointer-events: none; 
}

.btn-shape:hover {
	border-color: var(--accent-william);
	background-color: rgba(51, 102, 102, 0.05); 
}

.btn-shape:hover .shape-icon {
	transform: scale(1.15); 
}

.btn-shape.active {
	background-color: var(--accent-william);
	color: var(--white);
	border-color: var(--accent-william);
}

.btn-shape.active .shape-icon {
	filter: brightness(0) invert(1); 
}

/* --- Color Swatches --- */
.color-swatches {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(25px, 1fr));
	gap: 1rem;
	max-height: 220px; 
	overflow-y: auto; 
	padding-right: 0.5rem;
}

.swatch {
	width: 35px;
	height: 35px;
	border-radius: 50%;
	border: 2px solid transparent;
	cursor: pointer;
	box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.swatch:hover, .swatch.active {
	border-color: var(--text-color);
}

.divider {
	border: 0;
	height: 2px;
	background-color: #E0DCD3;
}

/* --- Gallery Header --- */
.gallery-container {
	max-width: 1100px;
	margin: 0 auto;
}

.gallery-headline {
	text-align: center;
	font-size: 2.5rem;
	margin: 3rem auto;
	color: var(--accent-slate);
	text-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 30px rgba(255, 255, 255, 1);
}

.gallery-description {
	margin: 0 auto;
	color: var(--text-color);
	font-size: 1.1rem;
	padding: 0rem 2rem 2rem 2rem;
}

/* --- Masonry Grid --- */
.masonry-grid {
	column-count: 3;
	column-gap: 1.5rem;
}

.gallery-item {
	position: relative;
	margin: 0 0 1.5rem; /* Replaces margin-bottom to work cleanly with columns */
	break-inside: avoid; /* Crucial: stops images from being split in half across columns */
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 8px 25px rgba(0,0,0,0.08);
	background-color: var(--white);
}

.gallery-item img {
	width: 100%;
	height: auto;
	display: block;
	transition: transform 0.5s ease;
}

/* --- The Hover Overlay --- */
.gallery-overlay {
	position: absolute;
	inset: 0;
	/* Creates a dark gradient from the bottom up so the white text is always readable */
	background: linear-gradient(to top, rgba(59, 75, 91, 0.95) 0%, rgba(59, 75, 91, 0.4) 60%, transparent 100%);
	opacity: 0;
	transition: opacity 0.3s ease;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	padding: 1.5rem;
}

/* When the user hovers over the figure, fade in the overlay and slightly zoom the image */
.gallery-item:hover .gallery-overlay {
	opacity: 1;
}

.gallery-item:hover img {
	transform: scale(1.05);
}

.overlay-content {
	transform: translateY(20px);
	transition: transform 0.3s ease;
}

.gallery-item:hover .overlay-content {
	transform: translateY(0);
}

.overlay-title {
	color: var(--white);
	font-size: 1.25rem;
	margin-bottom: 0.25rem;
	font-family: var(--font-header);
}

.overlay-caption {
	color: #EAE6DF;
	font-size: 0.9rem;
	margin-bottom: 1rem;
	line-height: 1.4;
}

.btn-small {
	padding: 8px 16px;
	font-size: 0.85rem;
	display: inline-block;
	width: auto;
}

/* --- Footer --- */
.footer-container {
	background-color: var(--white);
	border-top: 1px solid #E0DCD3;
	padding: 0.5rem 1rem;
	margin: 0;
}

.footer-content {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	max-width: 1100px;
	margin: auto;
	padding-bottom: 0.5rem;
}

.footer-left {
	justify-self: start;
	margin: 0;
}

.footer-left h3 {
	color: var(--text-color);
	margin: 0;
}

.footer-center {
	justify-self: center;
}

.footer-center p {
	color: var(--accent-william);
	margin: 0;
}

.footer-links {
	justify-self: end;
	display: flex;
	gap: 30px;
}

.footer-links a {
	color: var(--text-color);
	text-decoration: none;
	font-weight: 500;
	transition: color 0.2s ease;
}

.footer-links a:hover {
	color: var(--accent-william);
}

.footer-bottom {
	text-align: center;
	color: #999999;
	font-size: 0.9rem;
	padding: 0.5rem;
	border-top: 1px solid #EEEEEE;
	max-width: 1100px;
	margin: auto;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
	.header-banner {
		flex-direction: row; 
		flex-wrap: wrap; 
		justify-content: space-between;
		padding: 0.5rem 1rem;
		gap: 0.5rem;
	}

	.logo { max-height: 40px; }
	.site-title { font-size: 1.2rem; }

	.header-nav {
		order: 3; 
		width: 100%;
		justify-content: space-around;
		font-size: 0.9rem;
		gap: 10px;
		padding-top: 0.5rem;
		border-top: 1px solid #E0DCD3;
	}

	.header-right {
		width: auto; 
		flex-direction: row;
	}

	.header-right .btn {
		display: none;
	}

	.visualizer-headline {
		font-size: 1.8rem;
		margin: 2rem 1rem;
	}

	.visualizer-grid {
		display: block;
		margin: 0 1rem 2rem;
	}

	.canvas-column {
		position: sticky;
		top: 100px; /* This safely clears your new compact sticky header */
		z-index: 50; /* Stays below the header (100), but above the controls (30) */
		
		/* The card background is needed here to hide the controls as they scroll up underneath it */
		background-color: rgba(255, 255, 255, 0.98); 
		padding-bottom: 1rem;
		margin-bottom: 1rem;
		border-bottom: 1px solid #E0DCD3; /* Gives a clean dividing line */
		
		/* Pull it up slightly to sit flush with the padding of the visualizer-grid */
		margin-top: -0.5rem;
		padding-top: 0.5rem;
	}

	.canvas-container {
		/* Slightly shrink the canvas on mobile so it doesn't take up the ENTIRE vertical screen, ensuring users have room to see and scroll the controls */
		max-width: 320px; 
		margin: 0 auto;
	}

	.gallery-headline {
		font-size: 1.8rem;
		margin: 2rem 1rem;
	}

	.zoom-controls {
		width: 90%;
		bottom: 0.5rem;
	}

	/* --- STICKY BOTTOM CTA --- */
	.cta-container {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		background-color: var(--bg-color);
		padding: 1rem;
		box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.15);
		z-index: 1000;
		border-top: 1px solid #E0DCD3;
	}

	/* Ensure the button inside the sticky container spans cleanly */
	.cta-container .btn {
		margin: 0;
		box-shadow: none;
	}

	/* Footer overrides */
	.footer-content {
		display: flex;
		flex-direction: column;
		gap: 1rem;
		text-align: center;
		padding-bottom: 80px;
	}

	.footer-links {
		justify-content: center;
		width: 100%;
		flex-wrap: wrap;
	}
}

@media (max-width: 900px) {
	.masonry-grid {
		column-count: 2;
	}
}

@media (max-width: 600px) {
	.masonry-grid {
		column-count: 1;
	}

	.gallery-overlay {
		opacity: 0; 
		background: linear-gradient(to top, rgba(59, 75, 91, 0.95) 0%, rgba(59, 75, 91, 0.4) 60%, transparent 100%);
	}

	.overlay-content {
		transform: translateY(20px);
	}

	.gallery-item.is-active .gallery-overlay {
		opacity: 1;
	}

	.gallery-item.is-active .overlay-content {
		transform: translateY(0);
	}

	.gallery-item::after {
		content: "•••";
		position: absolute;
		bottom: 10px;
		right: 15px;
		color: rgba(255, 255, 255, 0.7);
		font-size: 1rem;
		letter-spacing: 2px;
		text-shadow: 0 2px 4px rgba(0,0,0,0.5);
		opacity: 1;
		transition: opacity 0.3s ease;
		pointer-events: none;
	}

	.gallery-item.is-active::after {
		opacity: 0;
	}
}