/* Éditeur visuel pour SPIP : interface et éléments propres à l'édition (classes tts-*). */

.tts-editor {
	border: 1px solid #ccc;
	border-radius: 4px;
	background: #fff;
}

/* .cadre-formulaire-editer .formulaire_spip est en overflow: hidden dans l'espace privé : le formulaire
   devient le conteneur de défilement de la barre collante, qui part avec la page. clip masque toujours ce
   qui dépasse sans créer de conteneur de défilement : la barre colle à la fenêtre */
.cadre-formulaire-editer .formulaire_spip:has(.tts-toolbar) {
	overflow: clip;
}

.tts-toolbar {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px;
	padding: 4px;
	border-bottom: 1px solid #ccc;
	background: #f7f7f7;
}

/* Barre d'outils (lot L5.1) : boutons à icône, menus, séparateurs. */
.tts-outil {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2em;
	height: 2em;
	padding: 0 0.3em;
	border: 1px solid transparent;
	border-radius: 3px;
	background: transparent;
	color: #333;
	font: inherit;
	cursor: pointer;
}

.tts-outil svg,
.tts-menu__element svg {
	width: 1.2em;
	height: 1.2em;
}

.tts-outil:hover:not(:disabled),
.tts-outil:focus-visible {
	border-color: #aaa;
	background: #fff;
	color: #333;
}

.tts-outil[aria-pressed="true"],
.tts-outil--actif,
.tts-outil[aria-expanded="true"] {
	border-color: #999;
	background: #e2e8f0;
}

.tts-outil:disabled {
	opacity: 0.4;
	cursor: default;
}

.tts-separateur {
	width: 1px;
	height: 1.5em;
	margin: 0 4px;
	background: #ccc;
}

/* Bouton multi sur un site monolingue, séparateur sans groupe visible. */
.tts-outil[hidden],
.tts-separateur[hidden] {
	display: none;
}

.tts-menu {
	position: relative;
}

.tts-menu__liste {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 20;
	/* hauteur limitée par placerMenu() : bordure et marges comprises */
	box-sizing: border-box;
	min-width: 14em;
	padding: 4px 0;
	background: #fff;
	border: 1px solid #aaa;
	border-radius: 4px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tts-menu__liste:popover-open {
	position: fixed;
	inset: auto;
	margin: 0;
	min-width: min(14em, calc(100vw - 16px));
	max-width: calc(100vw - 16px);
}

.tts-menu__liste[hidden] {
	display: none;
}

.tts-menu__liste [role="separator"] {
	margin: 4px 0;
	border-top: 1px solid #ddd;
}

.tts-menu__element {
	display: flex;
	align-items: center;
	gap: 0.5em;
	width: 100%;
	padding: 0.3em 0.8em 0.3em 1.8em;
	border: 0;
	background: transparent;
	color: #333;
	font: inherit;
	text-align: left;
	cursor: pointer;
	position: relative;
}

.tts-menu__element:hover:not(:disabled),
.tts-menu__element:focus {
	background: #e2e8f0;
	outline: none;
}

.tts-menu__element:disabled {
	opacity: 0.4;
	cursor: default;
}

.tts-menu__element[aria-checked="true"]::before {
	content: "✓";
	position: absolute;
	left: 0.5em;
}

/* Plein écran (spec 06 §3) : par CSS, sous la modalbox des modèles (z-index de mediabox plus grand). */
html.tts-plein-ecran {
	overflow: hidden;
}

/* un ancêtre positionné avec un z-index (.formulaire_spip : 2) enfermerait l'éditeur plein écran sous
   le bandeau : il passe au même niveau */
html.tts-plein-ecran :has(.tts-editor--plein-ecran) {
	z-index: 9000;
}

/* au-dessus du bandeau de l'espace privé (.bando-haut : 1001), sous la modalbox de mediabox (lity :
   9990), qui doit couvrir l'éditeur plein écran (catalogue des modèles) */
.tts-editor.tts-editor--plein-ecran {
	position: fixed;
	inset: 0;
	z-index: 9000;
	display: flex;
	flex-direction: column;
	border-radius: 0;
}

.tts-editor--plein-ecran > .tts-content,
.tts-editor--plein-ecran > textarea {
	flex: 1;
	overflow: auto;
}

/* Texte aligné selon le sens de la langue, même dans une page centrée (formulaire des crayons). */
.tts-content {
	text-align: start;
}

.tts-content .tts-prosemirror {
	padding: 0.5em 1em;
	outline: none;
}

/* Englober les documents flottants, même lorsqu'ils sont seuls dans le contenu. */
.tts-content .tts-prosemirror::after {
	content: "";
	display: block;
	clear: both;
}

/* Avec _AUTOBR vide, le retour source vaut une espace, sauf entre deux vers. */
.tts-retour-source {
	white-space: normal;
}

.ProseMirror .spip_poesie .tts-retour-source {
	white-space: pre;
}

.tts-editor > textarea {
	display: block;
	width: 100%;
	box-sizing: border-box;
	border: 0;
}

.tts-editor > textarea[hidden],
.tts-content[hidden] {
	display: none;
}

/* Porte-plume posé en mode source : barre de l'éditeur masquée (sauf composants tiers actifs en
   source), enveloppe de markItUp masquée en visuel */
.tts-toolbar[hidden],
.tts-masque-pp,
.tts-porte-plume[hidden] {
	display: none !important;
}

/* Bloc de code : repère de l'étiquette de langage de code.css (div.precode chez SPIP). */
.tts-editor pre.spip_code_block {
	position: relative;
}

/* Bloc coloré avec le thème de Coloration Code (fond et couleur posés par l'éditeur). */
.tts-editor pre.spip_code_block.hljs {
	text-shadow: none;
}

/* Le <code class="hljs"> écarte le script de Coloration Code ; le thème s'applique au <pre>. */
.tts-editor pre.spip_code_block > code.hljs {
	display: inline;
	overflow: visible;
	padding: 0;
	background: none;
	color: inherit;
}

/* Constructions conservées telles quelles : affichées comme du code. */
.tts-raw,
.tts-raw-inline {
	font-family: monospace;
	background: #f4f4f4;
	color: #555;
	white-space: pre-wrap;
}

.tts-raw {
	padding: 0.25em 0.5em;
	border-left: 3px solid #bbb;
}

.tts-verbatim {
	white-space: pre-wrap;
	background: #f8f8f8;
	padding: 0.25em 0.5em;
}

/* Bloc <md> du plugin Markdown : texte brut, signalé comme tel. */
.tts-markdown {
	border-left: 3px solid #ccc;
}

.tts-markdown::before {
	content: "Markdown";
	display: block;
	font: 0.75em sans-serif;
	color: #666;
	user-select: none;
}

/* Liens, ancres et modèles (affichage compact ; prévisualisation des modèles : lot L2c). */
.tts-link {
	color: #1a5fb4;
	text-decoration: underline;
	cursor: text;
}

.tts-link-auto,
.tts-anchor,
.tts-model {
	font-family: monospace;
	font-size: 0.9em;
	padding: 0 0.25em;
	border-radius: 3px;
	background: #eef3fb;
	white-space: pre-wrap;
}

.tts-anchor {
	background: #f3eefb;
}

/* appel de note : numéro calculé (décoration data-tts-label), puce pour une note sans appel */
.tts-note {
	cursor: pointer;
	color: #2d5aa0;
}

.tts-note::before {
	content: "[" attr(data-tts-label) "]";
}

/* note d'une partie de multi non affichée : pas numérotée par SPIP dans cette langue */
.tts-note:not([data-tts-label])::before {
	content: "[–]";
}

.tts-note[data-tts-note-name=""]::before {
	content: "•";
}

.tts-note.ProseMirror-selectednode {
	outline: 2px solid #2d5aa0;
}

.tts-glossary,
.tts-abbr {
	text-decoration: underline dotted;
}

.tts-glossary::after {
	content: "?";
	font-size: 0.7em;
	vertical-align: super;
	color: #888;
}

.tts-model-block {
	display: block;
	margin: 0.5em 0;
	padding: 0.5em;
	border: 1px dashed #9ab;
}

/* Modèles prévisualisés (lot L2.3) : rendu calculé par SPIP, inerte. */
.tts-editor {
	position: relative;
}

.tts-model {
	position: relative;
	display: inline-block;
	max-width: 100%;
	vertical-align: middle;
	font-family: inherit;
	font-size: inherit;
	padding: 0;
	background: none;
}

.tts-model-block {
	display: block;
}

/* Un modèle inline flottant doit flotter dans le paragraphe, comme dans le rendu SPIP. */
.tts-model--flottant {
	display: inline;
}

.tts-model.ProseMirror-selectednode {
	outline: 2px solid #1a5fb4;
}

/* La boîte inline est vide : le contrôle et le contour suivent l'aperçu flottant. */
.tts-model__flottant {
	position: relative;
}

.tts-model--flottant.ProseMirror-selectednode {
	outline: none;
}

.tts-model--flottant.ProseMirror-selectednode .tts-model__flottant {
	outline: 2px solid #1a5fb4;
}

.tts-model__preview img {
	max-width: 100%;
	height: auto;
}

.tts-model .tts-chip {
	font-family: monospace;
	font-size: 0.9em;
	padding: 0 0.25em;
	border-radius: 3px;
	background: #eef3fb;
}

.tts-model--chargement .tts-chip {
	opacity: 0.6;
}

.tts-model--erreur .tts-chip {
	background: #fbeeee;
}

.tts-model__modifier {
	position: absolute;
	top: 0;
	right: 0;
	display: none;
	font-size: 0.8em;
}

.tts-model:hover .tts-model__modifier,
.tts-model.ProseMirror-selectednode .tts-model__modifier {
	display: block;
}

/* Popovers (lien, modèle, note, glossaire, abréviation). */
.tts-popover-dialogue:popover-open {
	position: fixed;
	inset: auto;
	margin: 0;
	padding: 0;
	border: 0;
	width: max-content;
	max-width: calc(100vw - 16px);
}

.tts-popover {
	position: absolute;
	z-index: 10;
	min-width: 18em;
	max-width: 28em;
	padding: 0.5em;
	background: #fff;
	border: 1px solid #aaa;
	border-radius: 4px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tts-popover-dialogue:popover-open > .tts-popover {
	position: static;
}

.tts-popover__champ {
	display: block;
	margin-bottom: 0.4em;
}

.tts-popover__champ > span {
	display: block;
	font-size: 0.85em;
}

.tts-popover__champ input:not([type="checkbox"]),
.tts-popover__champ textarea {
	width: 100%;
	box-sizing: border-box;
}

.tts-popover__champ textarea {
	min-width: 100%;
	max-width: calc(100vw - 3em);
	resize: both;
	font-family: monospace;
}

/* le popover de modèle s'élargit avec sa zone de saisie (ticket #15) */
.tts-popover.tts-popover--modele {
	max-width: none;
}

.tts-popover--modele textarea {
	width: 40em;
}

.tts-popover__suggestions {
	margin: 0;
	padding: 0;
	list-style: none;
	max-height: 12em;
	overflow-y: auto;
}

.tts-popover__suggestions li {
	padding: 0.15em 0.3em;
	cursor: pointer;
}

.tts-popover__suggestions li:hover {
	background: #eef3fb;
}

.tts-popover__erreur {
	margin: 0 0 0.4em;
	color: #a00;
}

.tts-popover__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

/* Popover de note : un peu plus large, sous-éditeur sans barre d'outils. */
.tts-popover--note {
	min-width: 24em;
	max-width: 36em;
}

.tts-note__texte .tts-prosemirror {
	min-height: 4em;
	max-height: 16em;
	overflow-y: auto;
	padding: 0.25em 0.4em;
	border: 1px solid #aaa;
	border-radius: 3px;
	background: #fff;
}

/* Popover ouvert depuis un autre (lien du sous-éditeur d'une note) : au-dessus de son parent. */
.tts-popover-dialogue + .tts-popover-dialogue > .tts-popover {
	z-index: 11;
}

/* Panneau des notes, sous l'éditeur : zone grise claire séparée du texte par un filet, comme la
   barre d'outils et la barre d'état. Couleurs et police posées sur le bouton de chaque note : celles
   des boutons de l'espace privé (texte blanc) ne doivent pas s'appliquer. */
.tts-notes {
	margin: 0;
	border-top: 1px solid #ccc;
	background: #fafafa;
	color: #555;
	font-size: 0.9em;
}

/* sans note : masqué, même si le reset de l'espace privé affiche details en block */
.tts-notes[hidden] {
	display: none;
}

.tts-notes > summary {
	padding: 4px 8px;
	color: #555;
	font-weight: 600;
	cursor: pointer;
	user-select: none;
	transition: color 0.15s, background-color 0.15s;
}

.tts-notes > summary:hover {
	background: #f2f2f2;
	color: #333;
}

.tts-notes > summary:focus-visible,
.tts-notes .tts-notes__note:focus-visible {
	outline: 2px solid #7a9cc6;
	outline-offset: -2px;
}

.tts-notes__liste {
	margin: 0;
	padding: 2px 4px 6px;
	border-top: 1px solid #e6e6e6;
	list-style: none;
}

.tts-notes .tts-notes__note {
	display: block;
	width: 100%;
	margin: 0;
	padding: 0.3em 0.5em;
	border: 0;
	border-radius: 3px;
	background: none;
	box-shadow: none;
	color: #555;
	font: inherit;
	line-height: 1.4;
	text-align: left;
	text-transform: none;
	cursor: pointer;
	transition: color 0.15s, background-color 0.15s;
}

.tts-notes .tts-notes__note:hover,
.tts-notes .tts-notes__note:focus-visible {
	background: #efefef;
	color: #333;
}

.tts-notes__appel {
	margin-inline-end: 0.25em;
	font-weight: bold;
	color: #333;
}

@media (prefers-reduced-motion: reduce) {
	.tts-notes > summary,
	.tts-notes .tts-notes__note {
		transition: none;
	}
}

/* Multilinguisme : langue en badge ; partie sans langue marquée d'un astérisque. */
.tts-multi {
	border-bottom: 1px dashed #7a9cc6;
}

.tts-multi::after,
.tts-lang::before {
	content: attr(data-tts-lang);
	margin-left: 2px;
	padding: 0 3px;
	font-size: 0.7em;
	vertical-align: super;
	color: #fff;
	background: #7a9cc6;
	border-radius: 2px;
}

.tts-multi[data-tts-lang=""]::after,
.tts-lang:not([data-tts-lang])::before {
	content: "*";
}

.tts-multi-block {
	margin: 0.5em 0;
	padding: 0.25em 0.5em;
	border-left: 3px solid #7a9cc6;
}

.tts-lang::before {
	display: inline-block;
	margin: 0 0 0.25em;
	vertical-align: baseline;
}

.tts-lang + .tts-lang {
	margin-top: 0.5em;
	padding-top: 0.25em;
	border-top: 1px dashed #c8d6e8;
}

.tts-idiome {
	padding: 0 0.25em;
	font-size: 0.9em;
	background: #f3eefb;
	border-radius: 3px;
}

/* Partie d'un multi bloc dans une autre langue que celle affichée : estompée. */
.tts-lang--autre {
	opacity: 0.55;
}

.tts-idiome--traduit {
	font-family: inherit;
}

/* Popover de multi : une ligne par langue (code, texte, retirer). */
.tts-popover--multi {
	min-width: 24em;
	max-width: 36em;
}

.tts-multi__partie {
	display: flex;
	gap: 4px;
	align-items: flex-start;
	margin-bottom: 0.4em;
}

/* sélecteur de langue à sa largeur naturelle (l'espace privé étire les select) */
.tts-multi__partie select {
	flex: 0 0 auto;
	width: auto;
	max-width: 12em;
}

.tts-multi__texte {
	flex: 1;
	min-width: 10em;
}

.tts-multi__texte .tts-prosemirror {
	min-height: 1.6em;
	padding: 0.15em 0.4em;
	border: 1px solid #aaa;
	border-radius: 3px;
	background: #fff;
}

/* Langue affichée par les multis : bouton « [fr] ⌄ » et menu des langues du texte. */
.tts-menu--langues[hidden] {
	display: none;
}

.tts-outil--texte {
	gap: 0.1em;
	padding: 0 0.15em 0 0.4em;
	font-family: monospace;
}

.tts-outil--texte svg {
	width: 1em;
	height: 1em;
}

.tts-menu--langues .tts-menu__liste {
	min-width: 6em;
}

/* Anomalies de syntaxe (lot L5.2) : raccourci cassé souligné, explication en bulle. */
.tts-anomalie {
	text-decoration: underline wavy #c01c28;
	text-decoration-skip-ink: none;
	background: #fdecea;
	cursor: pointer;
}

/* Barre d'état : message, mots, anomalies. */
.tts-etat {
	display: flex;
	gap: 1em;
	justify-content: flex-end;
	padding: 2px 8px;
	border-top: 1px solid #ccc;
	background: #f7f7f7;
	color: #555;
	font-size: 0.9em;
}

.tts-etat[hidden],
.tts-etat__anomalies[hidden],
.tts-etat [hidden] {
	display: none;
}

/* message ponctuel (images collées, spec 10), à gauche des compteurs */
.tts-etat__message {
	margin-inline-end: auto;
	color: #333;
}

.tts-etat__message button {
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

.tts-etat__anomalies {
	padding: 0;
	border: 0;
	background: none;
	color: #a51d2d;
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

.tts-etat__anomalies::before {
	content: "⚠ ";
}

/* Popover d'un nœud brut : source éditable. */
.tts-popover__explication {
	margin: 0 0 0.5em;
	padding: 0.3em 0.5em;
	border-left: 3px solid #c01c28;
	background: #fdecea;
}

.tts-popover--brut {
	max-width: 40em;
}

.tts-popover--brut textarea {
	display: block;
	width: 100%;
	box-sizing: border-box;
	font-family: monospace;
}

/* Marqueur d'envoi d'une image collée (spec 10 §3) */
.tts-envoi {
	display: inline-flex;
	align-items: center;
	gap: 0.3em;
	padding: 0 0.3em;
	border: 1px dashed currentColor;
	border-radius: 3px;
	font-size: 0.85em;
	opacity: 0.75;
}

.tts-envoi progress {
	width: 4em;
}

/* Survol de la zone d'édition avec des fichiers (spec 10 §8) */
.tts-editor--depot {
	position: relative;
	outline: 2px dashed #3584e4;
	outline-offset: -2px;
}

.tts-editor--depot::after {
	content: attr(data-tts-depot);
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgb(53 132 228 / 12%);
	color: #1c71d8;
	font-weight: bold;
	pointer-events: none;
}

/* Enveloppe de sélecteur : couche supérieure indépendante du dialogue et de son formulaire. */
.tts-suggestions-panneau,
.tts-suggestions {
	position: fixed;
	inset: auto;
	margin: 0;
	box-sizing: border-box;
	max-width: calc(100vw - 16px);
	padding: 0;
	border: 1px solid #888;
	border-radius: 4px;
	background: #fff;
	color: #222;
	box-shadow: 0 3px 12px rgb(0 0 0 / 20%);
}

.tts-suggestions-panneau__corps {
	padding: 0.75em;
}

.tts-suggestions-panneau__corps:focus-visible {
	outline: 2px solid #3584e4;
	outline-offset: 2px;
}

.tts-suggestions-sentinelle {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
}

.tts-suggestions {
	max-width: min(28em, calc(100vw - 16px));
	padding: 0.25em;
	font-size: 0.9em;
}

.tts-suggestions__option {
	padding: 0.3em 0.5em;
	cursor: pointer;
	overflow-wrap: anywhere;
}

.tts-suggestions__option[aria-selected="true"] {
	background: #dcecff;
	color: #111;
}

.tts-suggestions__option small {
	display: block;
}

.tts-suggestions__annonce {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
}

/* Dimensions publiques du web component ; ses contrôles internes gardent leur clavier natif. */
.tts-emoji emoji-picker {
	width: min(350px, calc(100vw - 3em));
	height: min(400px, calc(100vh - 4em));
}

.tts-suggestions__action {
	display: block;
	width: 100%;
	border: 0;
	padding: 0.3em 0.5em;
	background: transparent;
	color: inherit;
	text-align: start;
	cursor: pointer;
}
.tts-suggestions__action[hidden] { display: none; }
.tts-suggestions__action[data-active="true"] { background: #dcecff; color: #111; }

.tts-emoji-acces { margin: 0.15em 0; }
.tts-emoji-acces svg { width: 1.2em; height: 1.2em; }
.tts-emoji emoji-picker {
	--background: #fff;
	--border-color: transparent;
	--outline-color: #3584e4;
	color: #222;
}

/* Citation courte (plugin citations_bb) : guillemets français, comme css/citations_bb.css du plugin */
.tts-content q.spip:lang(fr) {
	quotes: "\00AB\00A0" "\00A0\00BB" "\201C" "\201D";
}
