/* fluid css concepts with min, max, clamp */
/* Code Writed by: holasoymalva */
:root {
	--bg-color: #05050a;
	--panel-bg: rgba(20, 20, 30, 0.4);
	--panel-border: rgba(255, 255, 255, 0.08);
	--text-primary: #ffffff;
	--text-secondary: #888899;
	--accent: #00ffcc;
	--accent-glow: rgba(0, 255, 204, 0.5);

	/* Dynamic variables updated by JS */
	--hue: 280;
	--blob-size: 150px;
	--anim-speed: 20s;
}

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

body {
	font-family: "Outfit", sans-serif;
	background-color: var(--bg-color);
	background-image: radial-gradient(
			circle at 10% 20%,
			rgba(20, 10, 50, 0.5) 0%,
			transparent 40%
		),
		radial-gradient(circle at 90% 80%, rgba(10, 40, 40, 0.4) 0%, transparent 40%);
	color: var(--text-primary);
	min-height: 100vh;
	display: flex;
	justify-content: center;
	align-items: center;
	/* CSS clamp() for safe body padding, it never gets too small or too large */
	padding: clamp(1rem, 3vw, 3rem);
	overflow-x: hidden;
}

.app-container {
	/* Using max() and clamp() for responsive width */
	width: 100%;
	width: clamp(320px, 90vw, 1200px);
	display: flex;
	flex-direction: column;
	gap: clamp(1rem, 2vw, 2rem);
}

.header {
	text-align: center;
}

.header h1 {
	/* CSS clamp() for fluid typography */
	font-size: clamp(2.5rem, 5vw, 4rem);
	font-weight: 800;
	letter-spacing: -1px;
	background: linear-gradient(90deg, #fff, var(--text-secondary));
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	margin-bottom: 0.5rem;
}

.header p {
	font-size: clamp(0.9rem, 1.5vw, 1.1rem);
	color: var(--text-secondary);
	font-weight: 300;
}

.header span {
	color: var(--accent);
	font-weight: 500;
}

.main-content {
	display: grid;
	/* Use CSS Grid minmax() to automatically switch from 1 column (mobile) to 2 columns (desktop) */
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
	gap: clamp(1.5rem, 3vw, 2.5rem);
	align-items: stretch;
}

/* --- Artboard (The Visual part) --- */
.artboard-wrapper {
	background: var(--panel-bg);
	border: 1px solid var(--panel-border);
	border-radius: 24px;
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
	position: relative;
	/* max() ensures the box is never too small vertically */
	min-height: max(400px, 50vh);
	display: flex;
	justify-content: center;
	align-items: center;
	overflow: hidden;
	box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4),
		inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.artboard {
	width: 100%;
	height: 100%;
	position: absolute;
	top: 0;
	left: 0;
	filter: url("#gooey");
}

.blob {
	position: absolute;
	/* CSS max() ensures it never gets smaller than 50px */
	width: max(50px, var(--blob-size));
	height: max(50px, var(--blob-size));
	border-radius: 50%;
	background: hsl(var(--hue), 80%, 60%);
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	box-shadow: 0 0 calc(var(--blob-size) * 0.4) hsl(var(--hue), 80%, 50%);
	transition: width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
		height 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.3s;
}

.main-blob {
	animation: organic-movement var(--anim-speed) ease-in-out infinite alternate;
}

.interactive-blob {
	width: max(30px, calc(var(--blob-size) * 0.6));
	height: max(30px, calc(var(--blob-size) * 0.6));
	background: hsl(calc(var(--hue) + 40), 90%, 65%);
	top: 0;
	left: 0;
	transform: translate(-50%, -50%);
	/* Will be controlled by JS */
	pointer-events: none;
	/* So mouse events target the artboard */
	will-change: transform;
}

.orb {
	position: absolute;
	border-radius: 50%;
	background: hsl(calc(var(--hue) - 30), 80%, 60%);
	/* Box shadow to enhance the glow of the gooey effect */
	box-shadow: 0 0 20px hsl(calc(var(--hue) - 30), 80%, 50%);
}

@keyframes organic-movement {
	0% {
		transform: translate(-50%, -50%) scale(1) translate(0, 0) rotate(0deg);
	}

	33% {
		transform: translate(-50%, -50%) scale(1.2) translate(15%, -15%) rotate(15deg);
	}

	66% {
		transform: translate(-50%, -50%) scale(0.8) translate(-15%, 15%)
			rotate(-10deg);
	}

	100% {
		transform: translate(-50%, -50%) scale(1.1) translate(5%, 10%) rotate(5deg);
	}
}

/* --- Control Panel --- */
.control-panel {
	background: var(--panel-bg);
	border: 1px solid var(--panel-border);
	border-radius: 24px;
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
	padding: clamp(1.5rem, 3vw, 2.5rem);
	display: flex;
	flex-direction: column;
	gap: 2rem;
	box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4),
		inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.panel-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-bottom: 1px solid var(--panel-border);
	padding-bottom: 1rem;
}

.panel-header h2 {
	font-size: 1.2rem;
	font-weight: 500;
}

.value-display {
	background: rgba(0, 0, 0, 0.3);
	padding: 0.3rem 0.8rem;
	border-radius: 20px;
	font-size: 0.8rem;
	font-family: monospace;
	color: var(--accent);
	border: 1px solid var(--panel-border);
}

.controls-grid {
	display: grid;
	/* nested minmax for inner controls - guarantees they're responsive */
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 1.5rem;
}

.control-group {
	display: flex;
	flex-direction: column;
	gap: 0.8rem;
}

.span-full {
	grid-column: 1 / -1;
}

.control-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.control-header label {
	font-size: 0.9rem;
	color: var(--text-secondary);
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 1px;
}

.val-out {
	font-variant-numeric: tabular-nums;
	font-family: monospace;
	color: #fff;
	font-size: 0.9rem;
}

/* Range Input Styling */
input[type="range"] {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 6px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 3px;
	outline: none;
	cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
	transition: transform 0.1s;
}

input[type="range"]:active::-webkit-slider-thumb {
	transform: scale(1.3);
}

.range-labels {
	display: flex;
	justify-content: space-between;
	font-size: 0.75rem;
	color: var(--text-secondary);
}

/* Generic inputs & buttons */
.input-with-button {
	display: flex;
	gap: 0.5rem;
}

input[type="number"] {
	background: rgba(0, 0, 0, 0.3);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 8px;
	color: #fff;
	padding: 0.5rem 1rem;
	font-family: "Outfit", sans-serif;
	font-size: 1rem;
	width: 90px;
	outline: none;
}

input[type="number"]:focus {
	border-color: var(--accent);
}

button {
	background: linear-gradient(
		135deg,
		rgba(255, 255, 255, 0.1),
		rgba(255, 255, 255, 0.05)
	);
	border: 1px solid rgba(255, 255, 255, 0.2);
	color: #fff;
	padding: 0.5rem 1rem;
	border-radius: 8px;
	font-family: "Outfit", sans-serif;
	font-size: 0.95rem;
	font-weight: 500;
	cursor: pointer;
	flex-grow: 1;
	transition: all 0.2s ease;
	text-transform: uppercase;
	letter-spacing: 1px;
}

button:hover {
	background: rgba(255, 255, 255, 0.15);
	border-color: rgba(255, 255, 255, 0.4);
	box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
	transform: translateY(-1px);
}

button:active {
	transform: translateY(1px);
}

/* Audio Button specific */
.audio-btn {
	background: rgba(255, 100, 100, 0.1);
	border-color: rgba(255, 100, 100, 0.3);
	color: #ff9999;
	padding: 0.3rem 0.8rem;
	font-size: 0.8rem;
	border-radius: 20px;
	margin: 0;
	flex-grow: 0;
}

.audio-btn.active {
	background: rgba(100, 255, 150, 0.15);
	border-color: rgba(100, 255, 150, 0.4);
	color: #99ffaa;
	box-shadow: 0 0 15px rgba(100, 255, 150, 0.2);
}

/* Focus states with clamp */
*:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: clamp(2px, 0.5vw, 4px);
}

/* --- Fullscreen Jelly Button & Effect --- */
.fullscreen-btn {
	position: absolute;
	top: 1rem;
	right: 1rem;
	z-index: 100;
	width: 44px;
	height: 44px;
	border-radius: 12px;
	background: rgba(0, 0, 0, 0.3);
	border: 1px solid rgba(255, 255, 255, 0.2);
	display: flex;
	justify-content: center;
	align-items: center;
	cursor: pointer;
	color: white;
	backdrop-filter: blur(5px);
	transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
	padding: 0;
	flex-grow: 0;
}

.fullscreen-btn:hover {
	background: rgba(255, 255, 255, 0.15);
	transform: scale(1.15) rotate(5deg);
	border-color: rgba(255, 255, 255, 0.5);
	box-shadow: 0 0 20px rgba(0, 255, 204, 0.3);
}

.fullscreen-btn svg {
	width: 22px;
	height: 22px;
	transition: transform 0.3s ease;
}

/* Fullscreen Active states */
.artboard-wrapper.is-fullscreen {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw !important;
	height: 100vh !important;
	max-width: none;
	max-height: none;
	border-radius: 0;
	border: none;
	z-index: 999;
	/* The Gooey Jelly Bounce using Keyframes */
	animation: jelly-bounce 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.is-fullscreen .fullscreen-btn {
	top: 2rem;
	right: 2rem;
}

@keyframes jelly-bounce {
	0% {
		transform: scale(0.9);
		border-radius: 50%;
		opacity: 0;
	}

	40% {
		transform: scale(1.05);
		border-radius: 10%;
		opacity: 1;
	}

	60% {
		transform: scale(0.98);
		border-radius: 0;
	}

	80% {
		transform: scale(1.01);
	}

	100% {
		transform: scale(1);
		border-radius: 0;
	}
}