<script lang="ts">
	type Emoji = '💚' | '🟡' | '🔴';

	let {
		value,
		emoji,
		isDemo = false,
		onClick
	}: {
		value: number;
		emoji: Emoji;
		isDemo?: boolean;
		onClick?: () => void;
	} = $props();

	let isHovered = $state(false);
</script>

<button
	type="button"
	class="serenity-card"
	class:hovered={isHovered}
	onclick={onClick}
	onmouseenter={() => (isHovered = true)}
	onmouseleave={() => (isHovered = false)}
	aria-label="Score Sérénité - Cliquez pour plus de détails"
>
	<div class="card-header">
		<h3 class="title">Score Sérénité</h3>
		{#if isDemo}
			<span class="demo-badge">Données de démonstration</span>
		{/if}
	</div>

	<div class="score-display">
		<span class="emoji" class:animated={isHovered}>{emoji}</span>
		<span class="value">{value}</span>
		<span class="max">/100</span>
	</div>

	<p class="hint">Cliquez pour en savoir plus</p>
</button>

<style>
	.serenity-card {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 1rem;
		padding: 1.5rem;
		background: var(--surface-elevated, #ffffff);
		border: 1px solid var(--border-subtle, #e5e7eb);
		border-radius: 1rem;
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
		cursor: pointer;
		transition: transform 0.2s ease, box-shadow 0.2s ease;
		width: 100%;
		text-align: center;
	}

	.serenity-card:hover,
	.serenity-card.hovered {
		transform: translateY(-2px);
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	}

	.serenity-card:focus-visible {
		outline: 2px solid var(--accent-primary, #0ea5e9);
		outline-offset: 2px;
	}

	.card-header {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 0.5rem;
		width: 100%;
	}

	.title {
		margin: 0;
		font-size: 1rem;
		font-weight: 600;
		color: var(--text-primary, #1f2937);
	}

	.demo-badge {
		font-size: 0.75rem;
		padding: 0.25rem 0.5rem;
		background: var(--color-attention, #f59e0b);
		color: white;
		border-radius: 0.25rem;
		font-weight: 500;
	}

	.score-display {
		display: flex;
		align-items: baseline;
		gap: 0.5rem;
	}

	.emoji {
		font-size: 3rem;
		transition: transform 0.3s ease;
	}

	.emoji.animated {
		animation: bounce 0.5s ease;
	}

	.value {
		font-size: 3rem;
		font-weight: 700;
		color: var(--text-primary, #1f2937);
	}

	.max {
		font-size: 1.25rem;
		color: var(--text-secondary, #6b7280);
	}

	.hint {
		margin: 0;
		font-size: 0.875rem;
		color: var(--text-secondary, #6b7280);
	}

	@keyframes bounce {
		0%,
		100% {
			transform: translateY(0);
		}
		50% {
			transform: translateY(-8px);
		}
	}
</style>
