/* Editor · corrector ortográfico: subrayado, pastilla y menú.
   Troceado de `compact_workspace.css` (lote C3). Carga en `head_extra` de
   editor/editor.html, ANTES del núcleo: ante una regla del núcleo con la misma
   especificidad, pierde. El orden entre módulos lo fija tests/css_manifest.py. */
/* ---- Corrector ortográfico ----
   Capa de decoraciones ProseMirror (extensión Spellcheck del bundle): NO son
   marcas de regla ni tocan el documento. Se distinguen por diseño de las marcas
   de sugerencia (.text-hit, borde inferior sólido de color + relleno): el error
   ortográfico es un subrayado ONDULADO rojo, sin relleno, de prioridad visual
   baja. En un solapamiento con una marca de regla, la regla (envoltorio) mantiene
   su relleno y su borde legibles y su clic sigue abriendo el popover; el ondulado
   queda como capa inferior en el span interior. */
.spellcheck-error {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: #dc2626;
  text-decoration-skip-ink: none;
  text-underline-offset: 2px;
  /* Sin fondo: no compite con el relleno de las marcas de regla. */
  background: none;
}

/* Pastilla del corrector en la barra de estado: indicador de idioma + estado
   por color (verde activo, ámbar cargando, rojo error, gris apagado) y a la vez
   interruptor. Discreta, en línea con .statusbar-lang. */
.statusbar-spell {
  display:inline-flex; align-items:center; gap:5px; flex:0 0 auto;
  padding:1px 7px 1px 6px; color:var(--insp-muted); background:var(--insp-surface-2);
  border:1px solid transparent; border-radius:6px; font:inherit; cursor:pointer;
  transition:color .15s ease, background .15s ease, border-color .15s ease;
}
.statusbar-spell:hover { color:var(--insp-ink); border-color:var(--insp-line); }
.statusbar-spell svg { width:14px; height:14px; }
.statusbar-spell-lang { font-weight:700; letter-spacing:.03em; }
.statusbar-spell.is-active { color:var(--insp-ink); }
/* Etiqueta corta de estado (Activo/Cargando…/Inactivo/Error): junto al color
   de la pastilla, deja el estado en texto para que no dependa de pasar el
   ratón por encima ni de interpretar un color. */
.statusbar-spell-state { font-size:10.5px; font-weight:650; letter-spacing:.02em; white-space:nowrap; }
.statusbar-spell-state:empty { display:none; }
.statusbar-spell[data-spell-state="on"] { color:#15803d; background:#effaf1; }
.statusbar-spell[data-spell-state="off"] { color:var(--insp-muted); background:var(--insp-surface-2); }
.statusbar-spell[data-spell-state="loading"] { color:#b45309; background:#fff7ed; }
.statusbar-spell[data-spell-state="loading"] svg { animation:spellPulse 1.1s ease-in-out infinite; }
.statusbar-spell[data-spell-state="error"] { color:#b91c1c; background:#fef2f2; }
@keyframes spellPulse { 0%,100%{opacity:.4;} 50%{opacity:1;} }
@media (prefers-reduced-motion: reduce) {
  .statusbar-spell[data-spell-state="loading"] svg { animation:none; }
}

/* Estado del interruptor del corrector en la cinta (pestaña Revisar), con la
   misma etiqueta corta que la pastilla de la barra de estado. */
.ribbon-btn .ribbon-btn-state:empty { display:none; }
.ribbon-btn[data-spell-state="on"] .ribbon-btn-state { color:#15803d; }
.ribbon-btn[data-spell-state="loading"] .ribbon-btn-state { color:#b45309; }
.ribbon-btn[data-spell-state="error"] .ribbon-btn-state { color:#b91c1c; }

/* Menú de corrección: flota fijo junto a la palabra, independiente del popover
   de reglas. */
.spellcheck-menu {
  position:fixed; z-index:80; min-width:200px; max-width:280px;
  display:flex; flex-direction:column; gap:6px; padding:8px;
  background:var(--bg-card); border:1px solid var(--insp-line); border-radius:12px;
  box-shadow:0 18px 44px rgba(15,23,42,.18);
  font:500 12.5px var(--font-heading, inherit);
}
.spellcheck-menu[hidden] { display:none; }
.spellcheck-menu-word {
  margin:0; padding:2px 8px 6px; color:var(--insp-muted); font-size:11px; font-weight:650;
  letter-spacing:.02em; border-bottom:1px solid var(--insp-line-2);
}
.spellcheck-menu-word::before { content:"“"; }
.spellcheck-menu-word::after { content:"”"; }
.spellcheck-menu-suggestions { display:flex; flex-direction:column; gap:1px; }
.spellcheck-menu-suggestion {
  display:block; width:100%; padding:7px 9px; color:var(--insp-ink); text-align:left;
  background:transparent; border:0; border-radius:7px; font:600 13px var(--font-heading, inherit);
  cursor:pointer;
}
.spellcheck-menu-suggestion:hover, .spellcheck-menu-suggestion:focus-visible {
  background:#f5f5ff; color:var(--insp-primary); outline:none;
}
.spellcheck-menu-empty { margin:0; padding:6px 9px; color:var(--insp-muted); font-size:12px; font-style:italic; }
.spellcheck-menu-actions { display:flex; gap:4px; padding-top:6px; border-top:1px solid var(--insp-line-2); }
.spellcheck-menu-action {
  flex:1; display:inline-flex; align-items:center; justify-content:center; gap:5px;
  padding:6px 8px; color:var(--insp-muted); background:transparent; border:0; border-radius:7px;
  font:600 11.5px var(--font-heading, inherit); cursor:pointer;
}
.spellcheck-menu-action:hover { background:var(--insp-surface-2); color:var(--insp-ink); }
.spellcheck-menu-action svg { width:14px; height:14px; }

/* En impresión, la ayuda de edición no debe verse. */
@media print {
  .spellcheck-error { text-decoration:none !important; }
  .spellcheck-menu, .statusbar-spell { display:none !important; }
}
