/* ==========================================================
   Ceylon AI Aquascape Visualizer — frontend styles
   Plain CSS, no preprocessor, no framework dependency.
   ========================================================== */

.ceylon-aquascape-tool {
	--ceylon-water: #1f8fce;
	--ceylon-water-deep: #0c5a8c;
	--ceylon-ink: #16221c;
	--ceylon-border: #d8ddd6;
	--ceylon-bg: #f7f8f5;
	max-width: 640px;
	margin: 0 auto;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color: var(--ceylon-ink);
	box-sizing: border-box;
}
.ceylon-aquascape-tool * {
	box-sizing: border-box;
}

/* ---------------- Form ---------------- */
.ceylon-aquascape-form {
	display: flex;
	flex-direction: column;
	gap: 20px;
	background: var(--ceylon-bg);
	border: 1px solid var(--ceylon-border);
	border-radius: 8px;
	padding: 28px;
}

.ceylon-aquascape-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.ceylon-aquascape-field label {
	font-weight: 600;
	font-size: 14px;
}
.ceylon-aquascape-hint {
	margin: 0;
	font-size: 12px;
	color: #6b7a6e;
}

.ceylon-aquascape-field input[type="file"] {
	border: 1px dashed var(--ceylon-border);
	border-radius: 6px;
	padding: 14px;
	background: #fff;
	font-size: 14px;
	cursor: pointer;
}
.ceylon-aquascape-field input[type="file"]:focus-visible {
	outline: 2px solid var(--ceylon-water);
	outline-offset: 2px;
}

.ceylon-aquascape-field select {
	border: 1px solid var(--ceylon-border);
	border-radius: 6px;
	padding: 12px 14px;
	font-size: 15px;
	background: #fff;
	color: var(--ceylon-ink);
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2316221c' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	padding-right: 36px;
}
.ceylon-aquascape-field select:focus-visible {
	outline: 2px solid var(--ceylon-water);
	outline-offset: 2px;
}

.ceylon-aquascape-preview {
	margin-top: 8px;
	border-radius: 6px;
	overflow: hidden;
	border: 1px solid var(--ceylon-border);
	max-height: 240px;
}
.ceylon-aquascape-preview img {
	display: block;
	width: 100%;
	height: 100%;
	max-height: 240px;
	object-fit: contain;
	background: #000;
}

.ceylon-aquascape-error {
	background: #fdeeee;
	border: 1px solid #e8a3a3;
	color: #8a1f1f;
	padding: 10px 14px;
	border-radius: 6px;
	font-size: 13px;
}

.ceylon-aquascape-submit {
	background: var(--ceylon-water-deep);
	color: #fff;
	border: none;
	border-radius: 6px;
	padding: 14px 20px;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease;
}
.ceylon-aquascape-submit:hover:not(:disabled) {
	background: var(--ceylon-water);
}
.ceylon-aquascape-submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* ==========================================================
   Custom loading state — "tank filling with water"
   A glass-like rectangle with a blue gradient body that rises from the
   bottom to the top on a loop, plus a few bubbles drifting upward, used
   in place of a generic spinner while the Replicate prediction runs.
   ========================================================== */
.ceylon-aquascape-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 18px;
	padding: 48px 20px;
}

.ceylon-tank-loader {
	position: relative;
	width: 160px;
	height: 200px;
	border: 4px solid #2c3a33;
	border-top: none;
	border-radius: 0 0 6px 6px;
	background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.06));
	overflow: hidden;
}
/* The glass "rim" — a lighter top border standing in for the open top of the tank */
.ceylon-tank-loader::before {
	content: "";
	position: absolute;
	top: -4px;
	left: -4px;
	right: -4px;
	height: 4px;
	background: #4a5c52;
}

.ceylon-tank-loader-water {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 0%;
	background: linear-gradient(180deg, #5fc2ec 0%, var(--ceylon-water) 45%, var(--ceylon-water-deep) 100%);
	animation: ceylonTankFill 3.6s ease-in-out infinite;
}
/* A subtle moving highlight band suggests water surface shimmer rather than a flat fill */
.ceylon-tank-loader-water::after {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 10px;
	background: rgba(255,255,255,0.35);
	filter: blur(2px);
}

@keyframes ceylonTankFill {
	0%   { height: 6%; }
	50%  { height: 92%; }
	85%  { height: 92%; }
	100% { height: 6%; }
}

.ceylon-tank-loader-bubbles {
	position: absolute;
	inset: 0;
	pointer-events: none;
}
.ceylon-tank-loader-bubbles span {
	position: absolute;
	bottom: -10px;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: rgba(255,255,255,0.55);
	animation: ceylonBubbleRise 3.2s linear infinite;
}
.ceylon-tank-loader-bubbles span:nth-child(1) { left: 20%; width: 5px; height: 5px; animation-delay: 0s; }
.ceylon-tank-loader-bubbles span:nth-child(2) { left: 38%; width: 7px; height: 7px; animation-delay: 0.6s; }
.ceylon-tank-loader-bubbles span:nth-child(3) { left: 55%; width: 4px; height: 4px; animation-delay: 1.2s; }
.ceylon-tank-loader-bubbles span:nth-child(4) { left: 70%; width: 6px; height: 6px; animation-delay: 1.8s; }
.ceylon-tank-loader-bubbles span:nth-child(5) { left: 85%; width: 5px; height: 5px; animation-delay: 2.4s; }

@keyframes ceylonBubbleRise {
	0%   { bottom: -10px; opacity: 0; transform: translateX(0); }
	10%  { opacity: 0.8; }
	50%  { transform: translateX(4px); }
	90%  { opacity: 0.5; }
	100% { bottom: 100%; opacity: 0; transform: translateX(-4px); }
}

.ceylon-aquascape-loading-text {
	font-size: 14px;
	color: #4a5c52;
	margin: 0;
	min-height: 20px; /* avoid layout shift as the message text cycles */
}

/* Respect users who've asked for less motion */
@media (prefers-reduced-motion: reduce) {
	.ceylon-tank-loader-water,
	.ceylon-tank-loader-bubbles span {
		animation: none;
	}
	.ceylon-tank-loader-water {
		height: 60%;
	}
}

/* ==========================================================
   Before / After comparison slider
   Two stacked, identically-sized image layers: the original "before"
   image as the base layer, and the AI-generated "after" image as a top
   layer whose visible width is clipped via clip-path to follow a
   draggable handle.
   ========================================================== */
.ceylon-aquascape-result h3 {
	margin: 0 0 12px;
	font-size: 15px;
	font-weight: 600;
	text-align: center;
	color: #4a5c52;
}

.ceylon-slider {
	position: relative;
	width: 100%;
	aspect-ratio: 4 / 3;
	border-radius: 8px;
	overflow: hidden;
	border: 1px solid var(--ceylon-border);
	background: #000;
	cursor: ew-resize;
	user-select: none;
	touch-action: none; /* prevents page scroll from hijacking a touch-drag on the handle */
}

.ceylon-slider-image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}
.ceylon-slider-image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	pointer-events: none; /* dragging starts from the handle, not the images themselves */
}

/* The AFTER layer sits on top and gets clipped to hide everything LEFT
   of the handle position, so only its right-hand portion is visible —
   meeting the BEFORE (bottom) layer exactly at the handle with no gap or
   overlap. JS updates this inline as the handle moves; this initial value
   just matches the handle's default 50% starting position on first paint. */
.ceylon-slider-after {
	clip-path: inset(0 0 0 50%);
}

.ceylon-slider-handle {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 50%;
	width: 0;
	transform: translateX(-50%);
	cursor: ew-resize;
}
.ceylon-slider-handle-line {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 50%;
	width: 3px;
	transform: translateX(-50%);
	background: #fff;
	box-shadow: 0 0 6px rgba(0,0,0,0.4);
}
.ceylon-slider-handle-grip {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 40px;
	height: 40px;
	transform: translate(-50%, -50%);
	background: #fff;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--ceylon-ink);
	box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.ceylon-slider-handle:focus-visible .ceylon-slider-handle-grip {
	outline: 2px solid var(--ceylon-water);
	outline-offset: 2px;
}

/* Small "BEFORE"/"AFTER" labels for clarity, purely decorative so they're
   hidden from assistive tech (the meaningful label lives on the handle's
   aria attributes instead). */
.ceylon-slider::before,
.ceylon-slider::after {
	position: absolute;
	top: 12px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.05em;
	color: #fff;
	background: rgba(0,0,0,0.55);
	padding: 4px 10px;
	border-radius: 20px;
	z-index: 2;
	pointer-events: none;
}
.ceylon-slider::before {
	content: "BEFORE";
	left: 12px;
}
.ceylon-slider::after {
	content: "AFTER";
	right: 12px;
}

.ceylon-aquascape-result-actions {
	display: flex;
	gap: 12px;
	margin-top: 16px;
	flex-wrap: wrap;
}
.ceylon-aquascape-secondary-btn {
	flex: 1;
	text-align: center;
	background: #fff;
	border: 1px solid var(--ceylon-border);
	border-radius: 6px;
	padding: 12px 16px;
	font-size: 14px;
	font-weight: 600;
	color: var(--ceylon-ink);
	text-decoration: none;
	cursor: pointer;
	min-width: 140px;
}
.ceylon-aquascape-secondary-btn:hover {
	border-color: var(--ceylon-water);
	color: var(--ceylon-water-deep);
}

@media (max-width: 480px) {
	.ceylon-aquascape-form {
		padding: 20px;
	}
	.ceylon-slider-handle-grip {
		width: 36px;
		height: 36px;
	}
}
