/* F4MPL Lecteur Morse — prend l'écriture et les couleurs du thème (carnet). */

.f4mpl-morse {
	--morse-mine: var(--carnet-mine, #3E3F44);
	--morse-encre: var(--wp--preset--color--encre-bleue, #24408E);
	--morse-rouge: var(--wp--preset--color--rouge, #B3261E);
	--morse-papier: #FBF7EC;
	margin: 0 0 1.4em;
	font-family: inherit;
	color: var(--morse-mine);
}

.f4mpl-morse button {
	font-family: inherit;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

/* Le bouton d'ouverture, écrit au crayon */
.f4mpl-morse__ouvrir {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 4px 16px 6px;
	border: 2px solid var(--morse-mine);
	border-radius: 14px 10px 13px 9px;
	background: transparent;
	color: var(--morse-mine);
	font-size: 0.9em;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	transform: rotate(-0.6deg);
}

.f4mpl-morse__ouvrir:hover,
.f4mpl-morse__ouvrir:focus-visible,
.f4mpl-morse.est-ouvert .f4mpl-morse__ouvrir {
	color: var(--morse-rouge);
	border-color: var(--morse-rouge);
}

.f4mpl-morse__icone {
	font-family: 'Courier New', monospace;
	font-weight: 700;
	letter-spacing: 1px;
	color: var(--morse-rouge);
}

.f4mpl-morse__panneau {
	margin-top: 14px;
}

.f4mpl-morse__panneau[hidden] {
	display: none;
}

/* La bande télégraphique */
.f4mpl-morse__bande {
	position: relative;
	height: 44px;
	background: var(--morse-papier);
	border-top: 1px solid rgba(90, 70, 40, 0.18);
	border-bottom: 1px solid rgba(90, 70, 40, 0.18);
	box-shadow: 0 2px 4px rgba(60, 40, 15, 0.18), inset 0 0 10px rgba(120, 100, 60, 0.08);
	transform: rotate(-0.4deg);
	overflow: hidden;
}

.f4mpl-morse__bande::before {
	/* Fibres du papier */
	content: "";
	position: absolute;
	inset: 0;
	background: repeating-linear-gradient(90deg, rgba(120, 100, 60, 0.035) 0 1px, transparent 1px 7px);
	pointer-events: none;
}

.f4mpl-morse__bande canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}

.f4mpl-morse__stylet {
	position: absolute;
	left: 82%;
	top: -2px;
	bottom: -2px;
	width: 2px;
	margin-left: -1px;
	background: linear-gradient(180deg, rgba(60, 60, 60, 0.55), rgba(60, 60, 60, 0.1) 30%, rgba(60, 60, 60, 0.1) 70%, rgba(60, 60, 60, 0.55));
}

.f4mpl-morse.est-en-lecture .f4mpl-morse__stylet {
	background: linear-gradient(180deg, var(--morse-rouge), rgba(179, 38, 30, 0.15) 30%, rgba(179, 38, 30, 0.15) 70%, var(--morse-rouge));
}

/* Le texte déchiffré */
.f4mpl-morse__texte {
	min-height: 1.3em;
	margin: 10px 0 6px !important;
	overflow: hidden;
	white-space: pre;
	color: var(--morse-encre);
	letter-spacing: 0.04em;
}

.f4mpl-morse__curseur {
	display: inline-block;
	width: 2px;
	height: 0.9em;
	margin-left: 2px;
	vertical-align: -0.1em;
	background: var(--morse-rouge);
	opacity: 0;
}

.f4mpl-morse.est-en-lecture .f4mpl-morse__curseur {
	animation: f4mpl-morse-curseur 1s steps(2) infinite;
}

@keyframes f4mpl-morse-curseur {
	0% { opacity: 1; }
	100% { opacity: 0; }
}

/* Commandes */
.f4mpl-morse__commandes {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.f4mpl-morse__lire,
.f4mpl-morse__stop {
	width: 46px;
	height: 40px;
	padding: 0;
	border: 2px solid var(--morse-mine);
	border-radius: 12px 9px 11px 8px;
	background: transparent;
	color: var(--morse-mine);
	font-size: 18px;
	line-height: 1;
}

.f4mpl-morse__lire:hover,
.f4mpl-morse__stop:hover {
	color: var(--morse-rouge);
	border-color: var(--morse-rouge);
}

.f4mpl-morse__progression {
	font-size: 0.85em;
	color: #6E6A60;
}

.f4mpl-morse__reglages {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 6px 22px;
	margin-top: 10px;
	font-size: 0.85em;
}

.f4mpl-morse__reglages label {
	display: block;
}

.f4mpl-morse__reglages output {
	font-weight: 700;
	color: var(--morse-encre);
}

.f4mpl-morse__reglages input[type="range"] {
	display: block;
	width: 100%;
	margin: 4px 0 0;
	accent-color: var(--morse-rouge);
}

@media (max-width: 520px) {
	.f4mpl-morse__reglages {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (prefers-reduced-motion: reduce) {
	.f4mpl-morse.est-en-lecture .f4mpl-morse__curseur {
		animation: none;
		opacity: 1;
	}
}
