/**
 * Cuivro Outils Musicaux - Styles propres à "Cuivro Accordeur".
 *
 * L'habillage général (carte, bandeau, boutons, champs, thèmes, couleurs) est
 * défini dans cuivro-common.css et partagé avec le métronome : ne restent ici
 * que l'afficheur (note, jauge, aiguille) et les pastilles de notes.
 */

/* Afficheur : note, jauge, écart en cents. */
.ca-meter {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 0;
	margin: 0;
	text-align: center;
}

.ca-note-value {
	font-size: 88px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.02em;
	color: var(--cu-text);
	transition: color 0.15s ease, text-shadow 0.15s ease, opacity var(--cu-transition);
}

.ca-note-secondary {
	margin-top: 4px;
	min-height: 1.3em;
	font-size: 13px;
	color: var(--cu-text-muted);
}

.ca-dial {
	position: relative;
	width: 100%;
	height: 64px;
	margin: 10px 0 4px;
}

/* Rail gradué : une graduation tous les 10 cents, de -50 à +50. */
.ca-dial::before {
	content: '';
	position: absolute;
	left: 5%;
	right: 5%;
	top: 50%;
	height: 14px;
	transform: translateY(-50%);
	border-right: 2px solid var(--cu-tick);
	background: repeating-linear-gradient(90deg, var(--cu-tick) 0 2px, transparent 2px 10%);
}

.ca-dial-center {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 3px;
	height: 38px;
	transform: translate(-50%, -50%);
	border-radius: 2px;
	background: var(--cu-accent);
	opacity: 0.55;
	transition: opacity var(--cu-transition), background var(--cu-transition);
}

.ca-dial-label {
	position: absolute;
	top: 0;
	font-size: 1.15rem;
	line-height: 1;
	color: var(--cu-text-muted);
}

.ca-flat {
	left: 1%;
}

.ca-sharp {
	right: 1%;
}

.ca-needle {
	--ca-pos: 0;
	position: absolute;
	top: 50%;
	left: calc(50% + var(--ca-pos) * 0.9%);
	width: 5px;
	height: 52px;
	transform: translate(-50%, -50%);
	border-radius: 3px;
	background: var(--cu-accent);
	box-shadow: 0 0 10px 1px rgba(var(--cu-accent-rgb), 0.55);
	transition: left 0.12s linear, background var(--cu-transition), box-shadow var(--cu-transition), opacity var(--cu-transition);
}

.ca-status {
	min-height: 1.5em;
	font-size: 15px;
	font-weight: 700;
	color: var(--cu-accent-text);
}

.ca-cents {
	margin-top: 2px;
	font-size: 13px;
	color: var(--cu-text-muted);
}

.ca-cents-value {
	font-weight: 700;
	color: var(--cu-text);
}

/* Aucun son détecté. */
.ca-meter.is-idle .ca-note-value {
	opacity: 0.35;
}

.ca-meter.is-idle .ca-needle {
	--ca-pos: 0;
	opacity: 0.3;
	box-shadow: none;
}

/* Note juste (±5 cents). */
.ca-meter.is-in-tune .ca-note-value {
	color: var(--cu-ok);
	text-shadow: 0 0 22px rgba(var(--cu-ok-rgb), 0.55);
}

.ca-meter.is-in-tune .ca-needle {
	background: var(--cu-ok);
	box-shadow: 0 0 14px 3px rgba(var(--cu-ok-rgb), 0.55);
}

.ca-meter.is-in-tune .ca-dial-center {
	background: var(--cu-ok);
	opacity: 1;
}

.ca-meter.is-in-tune .ca-status {
	color: var(--cu-ok);
}

/* Notes de l'instrument (cordes ou gamme chromatique). */
/*
 * Pastilles de notes : au plus six par rangée, réparties sur toute la largeur.
 * Gamme chromatique (voix, instrument à vent) : 12 notes, deux rangées de six ;
 * cordes : une seule rangée (4 ou 6 pastilles). Le JavaScript fixe --ca-cols.
 */
.ca-note-list {
	display: grid;
	flex: 0 0 auto;
	grid-template-columns: repeat(var(--ca-cols, 6), minmax(0, 1fr));
	gap: 6px;
	margin: 0;
}

.ca-note-chip {
	appearance: none;
	min-width: 0;
	height: 40px;
	padding: 0 4px;
	border: 1px solid var(--cu-control-border);
	border-radius: 999px;
	background: var(--cu-control-bg);
	color: var(--cu-text);
	font-family: inherit;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	cursor: default;
	transition: transform 0.15s ease, background var(--cu-transition), border-color var(--cu-transition), color var(--cu-transition), box-shadow var(--cu-transition);
}

.ca-note-chip small {
	font-size: 0.68em;
	font-weight: 600;
	opacity: 0.7;
}

/* En mode manuel, les pastilles deviennent des boutons de sélection. */
.cuivro-accordeur[data-mode='manual'] .ca-note-chip {
	cursor: pointer;
}

.cuivro-accordeur[data-mode='manual'] .ca-note-chip:hover {
	background: var(--cu-accent-soft);
	border-color: var(--cu-accent);
	color: var(--cu-accent-text);
}

.cuivro-accordeur[data-mode='manual'] .ca-note-chip:active {
	transform: scale(0.95);
}

/* Note actuellement entendue (mode automatique). */
.ca-note-chip.is-detected {
	border-color: var(--cu-accent);
	box-shadow: 0 0 0 2px var(--cu-accent-ring);
	color: var(--cu-accent-text);
}

/* Note visée (mode manuel). */
.ca-note-chip.is-selected {
	background: var(--cu-accent);
	border-color: var(--cu-accent-dark);
	color: var(--cu-on-accent);
	box-shadow: 0 4px 10px rgba(var(--cu-accent-rgb), 0.3);
}

.ca-note-chip:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(var(--cu-accent-rgb), 0.4);
}

/* Boutons d'action : toujours sur une seule ligne, y compris sur téléphone. */
.ca-actions {
	display: flex;
	flex: 0 0 auto;
	gap: 10px;
}

.ca-actions .cu-btn {
	flex: 1;
	min-height: 56px;
	padding-block: 0.35rem;
	border-radius: 12px;
}

.ca-actions .ca-microphone-toggle {
	flex: 1.7;
	padding-inline: 0.6rem;
	font-size: 14px;
}

/* Bouton « Réglages » (téléphone) : le seul mot « Réglages », pour occuper le moins de place possible. */
.ca-settings-open {
	flex: 0 0 auto;
	min-height: 44px;
	min-width: 0;
	padding: 0 12px;
	border-radius: 10px;
}

.ca-settings-open .cu-settings-label {
	font-size: 14px;
}

.ca-help {
	margin-top: 0;
}

/* Microphone actif : le bouton devient une action de coupure, en contour. */
.ca-actions .cu-btn-primary[aria-pressed='true'] {
	background: transparent;
	color: var(--cu-accent-text);
	border-color: var(--cu-accent);
	box-shadow: none;
}

.ca-actions .cu-btn-primary[aria-pressed='true']:hover {
	background: var(--cu-accent-soft);
}

/* Téléphone (outil de moins de 640 px) : l'aide se lit dans le panneau « Réglages », pas sous l'outil. */
@container cuivro (max-width: 639.98px) {
	.ca-tab {
		padding: 0.4rem 0.4rem;
	}

	.ca-help {
		text-align: center;
	}

	/* Écran peu haut : chiffres réduits. */
	@media (max-height: 640px) {
		.ca-note-value {
			font-size: clamp(3.5rem, 11svh, 5.5rem);
		}
	}
}

/* Tablette et ordinateur (outil de 640 px ou plus). */
@container cuivro (min-width: 640px) {
	.ca-note-value {
		font-size: 92px;
	}

	.ca-dial {
		height: 72px;
	}

	.ca-settings-open {
		display: none;
	}

	/* Le texte d'aide se colle au bas de la colonne de droite. */
	.cu-settings > .ca-help {
		margin-top: auto;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ca-needle,
	.ca-note-value,
	.ca-note-chip {
		transition: none;
	}
}
