/* ==========================================================================
   Breath Flow - Calm Breathing Game
   Stylesheet: calming dark UI, glassy buttons, responsive layout.
   ========================================================================== */

.breath-flow-container {
	--bf-bg-1: #0b1120;
	--bf-bg-2: #131c31;
	--bf-inhale: #38bdf8;
	--bf-hold: #a78bfa;
	--bf-exhale: #f5b350;
	--bf-text: #e7edf7;
	--bf-text-muted: #9fb0c9;

	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: 720px;
	margin: 2rem auto;
	padding: clamp(1.25rem, 4vw, 2.5rem);
	border-radius: 24px;
	overflow: hidden;
	background: radial-gradient(circle at 50% 20%, var(--bf-bg-2), var(--bf-bg-1) 70%);
	color: var(--bf-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	text-align: center;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
	isolation: isolate;
}

.breath-flow-container *,
.breath-flow-container *::before,
.breath-flow-container *::after {
	box-sizing: border-box;
}

/* Ambient background particle field (soft "stars" for depth) */
.bf-bg-particles {
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	overflow: hidden;
}

.bf-bg-particles span {
	position: absolute;
	display: block;
	width: 2px;
	height: 2px;
	border-radius: 50%;
	background: rgba(200, 220, 255, 0.6);
	animation: bf-twinkle 5s ease-in-out infinite;
}

@keyframes bf-twinkle {
	0%, 100% { opacity: 0.15; transform: scale(1); }
	50% { opacity: 0.7; transform: scale(1.6); }
}

/* Screens */
.bf-screen {
	position: relative;
	z-index: 1;
	display: none;
	flex-direction: column;
	align-items: center;
	gap: 1.25rem;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.5s ease, transform 0.5s ease;
}

.bf-screen.bf-active {
	display: flex;
	opacity: 1;
	transform: translateY(0);
}

.bf-title {
	margin: 0;
	font-size: clamp(1.4rem, 4vw, 2rem);
	font-weight: 600;
	letter-spacing: 0.02em;
}

.bf-subtitle {
	margin: -0.5rem 0 0;
	color: var(--bf-text-muted);
	font-size: clamp(0.85rem, 2.5vw, 1rem);
	max-width: 480px;
}

/* Buttons */
.bf-options {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.75rem;
}

.bf-btn {
	appearance: none;
	border: 1px solid rgba(255, 255, 255, 0.18);
	background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
	color: var(--bf-text);
	padding: 0.85rem 1.6rem;
	border-radius: 999px;
	font-size: 1rem;
	font-weight: 500;
	cursor: pointer;
	backdrop-filter: blur(6px);
	transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.bf-btn:hover,
.bf-btn:focus-visible {
	transform: translateY(-2px);
	box-shadow: 0 8px 24px rgba(56, 189, 248, 0.25);
	background: linear-gradient(160deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
}

.bf-btn:active {
	transform: translateY(0);
}

.bf-try-again-btn {
	margin-top: 0.5rem;
}

/* Mood scale */
.bf-mood-scale {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	justify-content: center;
}

.bf-mood-btn {
	appearance: none;
	border: 1px solid rgba(255, 255, 255, 0.15);
	background: rgba(255, 255, 255, 0.05);
	font-size: clamp(1.6rem, 6vw, 2.1rem);
	line-height: 1;
	padding: 0.6rem;
	border-radius: 16px;
	cursor: pointer;
	transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.bf-mood-btn:hover,
.bf-mood-btn:focus-visible {
	transform: translateY(-3px) scale(1.05);
	background: rgba(255, 255, 255, 0.12);
	box-shadow: 0 10px 24px rgba(167, 139, 250, 0.25);
}

.bf-mood-btn.bf-selected {
	background: rgba(56, 189, 248, 0.22);
	box-shadow: 0 0 0 2px var(--bf-inhale);
}

/* Session header */
.bf-session-header {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
}

.bf-timer {
	font-variant-numeric: tabular-nums;
	font-size: 1.1rem;
	color: var(--bf-text-muted);
	letter-spacing: 0.05em;
}

.bf-mute-btn {
	appearance: none;
	border: 1px solid rgba(255, 255, 255, 0.15);
	background: rgba(255, 255, 255, 0.06);
	color: var(--bf-text);
	width: 2.4rem;
	height: 2.4rem;
	border-radius: 50%;
	font-size: 1.1rem;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease, transform 0.2s ease;
}

.bf-mute-btn:hover {
	background: rgba(255, 255, 255, 0.14);
	transform: scale(1.05);
}

/* Orb area */
.bf-orb-wrap {
	position: relative;
	width: min(100%, 320px);
	aspect-ratio: 1 / 1;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0.25rem 0;
}

.bf-canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	border-radius: 50%;
}

/* CSS fallback orb, used only if WebGL / Three.js is unavailable */
.bf-css-orb {
	position: absolute;
	width: 55%;
	height: 55%;
	border-radius: 50%;
	background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.85), var(--bf-inhale) 45%, rgba(56, 189, 248, 0.05) 75%);
	box-shadow: 0 0 60px 10px rgba(56, 189, 248, 0.45), 0 0 120px 40px rgba(56, 189, 248, 0.2);
	transform: scale(1) translateZ(0);
	transition: background 1.2s ease;
	animation: bf-css-wobble 6s ease-in-out infinite;
}

@keyframes bf-css-wobble {
	0%, 100% { border-radius: 50% 50% 48% 52% / 52% 48% 52% 48%; }
	50% { border-radius: 48% 52% 50% 50% / 48% 52% 48% 52%; }
}

.bf-phase-text {
	position: relative;
	z-index: 2;
	font-size: clamp(1.1rem, 4vw, 1.5rem);
	font-weight: 600;
	text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
	opacity: 1;
	transition: opacity 0.4s ease;
	pointer-events: none;
}

.bf-phase-text.bf-fade {
	opacity: 0;
}

.bf-cycle-count {
	color: var(--bf-text-muted);
	font-size: 0.9rem;
}

/* Results screen */
.bf-score-circle {
	position: relative;
	width: 150px;
	height: 150px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: conic-gradient(var(--bf-inhale) calc(var(--bf-score, 0) * 1%), rgba(255, 255, 255, 0.08) 0);
	transition: background 1s ease;
}

.bf-score-circle::before {
	content: "";
	position: absolute;
	inset: 8px;
	border-radius: 50%;
	background: var(--bf-bg-1);
}

.bf-score-num {
	position: relative;
	z-index: 1;
	font-size: 2.4rem;
	font-weight: 700;
}

.bf-score-message {
	max-width: 480px;
	color: var(--bf-text-muted);
	font-size: 1rem;
}

/* Responsive tweaks */
@media (max-width: 480px) {
	.breath-flow-container {
		margin: 1rem auto;
		border-radius: 18px;
	}

	.bf-options {
		flex-direction: column;
		width: 100%;
	}

	.bf-options .bf-btn {
		width: 100%;
	}
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
	.bf-css-orb,
	.bf-bg-particles span {
		animation: none !important;
	}

	.bf-screen {
		transition: none !important;
	}
}
