/* ============================================================================
   SALVIATI — el tutor de la hoja (public/app/js/salviati.js)
   ----------------------------------------------------------------------------
   .sv-art ...... el dibujo: papel y tinta (--sv-paper, --sv-ink)
   .sv-dock ..... el avatar flotante (en #trabajo): abajo a la derecha de la
                  zona libre, sin encimarse con el panel Resultados (--ws-r y
                  --ws-b del shell); en el teléfono, a la izquierda de la fila
                  de las unidades, sobre la barra «Paso n de m». Su insignia:
                  cuántas preguntas tiene el paso actual
   .sv-ghost .... el avatar levantado: cuelga del puntero (ratón) o flota
                  sobre el dedo, unido por su cordel
   .sv-tag ...... qué paso explicará al soltarlo
   .sv-spot ..... un paso de la hoja donde se puede soltar (contorno y halo)
   .sv-bub ...... la burbuja (diálogo): «Explícame este paso» (.sv-bub-a) y
                  «Pregúntale» (.sv-bub-l); la respuesta breve, .sv-ans
   .sv-say ...... una frase de Salviati (doble clic)
   Solo tokens de tokens.css. Sin animaciones con prefers-reduced-motion;
   nada de esto se imprime.
   ========================================================================== */

/* ---------------------------------------------------------------- EL ARTE
   En los dos temas es tinta oscura sobre papel claro (positivo): en oscuro
   el papel toma --ink (claro) y la tinta --paper (oscura), así el achurado
   sigue siendo sombra y el medallón se ve como una moneda de plata.      */
.sv-art { display: block; --sv-paper: var(--paper); --sv-ink: var(--ink); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sv-art { --sv-paper: var(--ink); --sv-ink: var(--paper); }
}
:root[data-theme="dark"] .sv-art { --sv-paper: var(--ink); --sv-ink: var(--paper); }

.sv-vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---------------------------------------------------------------- EL DOCK */
.sv-dock {
  position: absolute; z-index: 19; display: none;
  right: calc(var(--ws-r, 0px) + 16px); bottom: calc(var(--ws-b, 0px) + 16px);
  transition: right .22s ease;
}
#app[data-mode="solucion"] .sv-dock { display: block; }
.sv-av {
  position: relative; display: block; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink); cursor: grab;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  box-shadow: var(--float); transition: transform .16s ease, box-shadow .16s ease;
}
.sv-av:hover { transform: translateY(-2px); }
.sv-av:active { cursor: grabbing; }
.sv-av:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sv-av-art { display: block; width: 100%; height: 100%; border-radius: 50%; transition: opacity .15s ease; }
.sv-av-art > svg { display: block; width: 100%; height: 100%; }
/* insignia: explicaciones del paso que siguen plegadas */
.sv-badge {
  position: absolute; top: -3px; right: -5px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--salviati); color: var(--paper); font: 600 12px/20px var(--ui); text-align: center;
  box-shadow: 0 0 0 2px var(--desk); pointer-events: none;
}
.sv-dock.is-open .sv-av { box-shadow: 0 0 0 2px var(--salviati), var(--float); }
/* levantado: en el dock queda su hueco, para saber adónde regresa */
.sv-dock.is-lifted .sv-av { box-shadow: none; transform: none; }
.sv-dock.is-lifted .sv-av-art { opacity: 0; }
.sv-dock.is-lifted .sv-av::after { content: ""; position: absolute; inset: 4px; border: 1.5px dashed var(--salviati); border-radius: 50%; }
.sv-dock.is-lifted .sv-badge { opacity: .45; }

#app[data-form="phone"] .sv-dock { right: auto; left: calc(16px + var(--m-sl, 0px)); bottom: calc(var(--m-sb, 34px) + 76px); }
#app[data-form="phone"] .sv-av { width: 48px; height: 48px; }
#app[data-form="phone"] .sv-av:hover { transform: none; }
#app[data-form="phone"] .sv-badge { min-width: 22px; height: 22px; border-radius: 11px; line-height: 22px; }

/* ----------------------------------------------------------- EL ARRASTRE */
html.sv-dragging, html.sv-dragging * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }
.sv-ghost { position: fixed; left: 0; top: 0; z-index: 60; width: 0; height: 0; transform-origin: 0 0; pointer-events: none; will-change: transform; --sv-w: 56px; }
#app[data-form="phone"] .sv-ghost { --sv-w: 48px; }
.sv-ghost-av { position: absolute; left: calc(var(--sv-w) / -2); width: var(--sv-w); height: var(--sv-w); border-radius: 50%; box-shadow: var(--float); }
.sv-ghost-av > svg { display: block; width: 100%; height: 100%; }
.sv-cord { position: absolute; left: -.75px; width: 1.5px; border-radius: 1px; background: var(--ink2); }
/* con el ratón cuelga del puntero, como una plomada */
.sv-ghost.is-hang::before { content: ""; position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink2); }
.sv-ghost.is-hang .sv-cord { top: 0; height: 14px; }
.sv-ghost.is-hang .sv-ghost-av { top: 14px; }
/* con el dedo flota encima (el dedo taparía lo de abajo); el aro marca dónde cae */
.sv-ghost.is-float::before { content: ""; position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--salviati); background: var(--salviati-soft); }
.sv-ghost.is-float .sv-cord { top: -64px; height: 55px; background: none; border-left: 1.5px dashed var(--ink2); }
.sv-ghost.is-float .sv-ghost-av { top: calc(-64px - var(--sv-w)); }

.sv-tag {
  position: fixed; left: 0; top: 0; z-index: 61; max-width: min(340px, calc(100vw - 16px)); padding: 6px 12px; border-radius: 12px;
  background: var(--glass2); -webkit-backdrop-filter: var(--glass-fx); backdrop-filter: var(--glass-fx);
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 .5px var(--glass-line), var(--float);
  color: var(--ink2); font: 500 13px/18px var(--ui); pointer-events: none;
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.sv-tag.is-on { background: var(--salviati); color: var(--paper); box-shadow: var(--float); }

/* Los pasos donde se puede soltar: el equivalente a las líneas azules de Street View */
.hj-sheet .sv-spot { outline: 2px solid var(--salviati); outline-offset: 3px; box-shadow: 0 0 0 7px var(--salviati-soft); animation: sv-spot .24s ease-out both; }
.hj-sheet .sv-spot.is-hot { outline-width: 3px; box-shadow: 0 0 0 11px var(--salviati-soft); }
@keyframes sv-spot { from { outline-color: transparent; box-shadow: 0 0 0 0 transparent; } }
.sv-tag i, .sv-it-t i, .sv-next-t i, .sv-bub-s i, .sv-ans-b i { font-family: var(--math); font-size: 1.08em; }
.sv-tag sub, .sv-it-t sub, .sv-next-t sub, .sv-bub-s sub, .sv-ans-b sub { font-size: .72em; line-height: 0; }

/* ------------------------------------------------------------ LA BURBUJA */
.sv-bub {
  position: absolute; z-index: 40; display: flex; flex-direction: column;
  right: calc(var(--ws-r, 0px) + 16px); bottom: calc(var(--ws-b, 0px) + 86px);
  width: min(372px, calc(100vw - var(--ws-r, 0px) - var(--ws-l, 0px) - 32px));
  max-height: calc(100vh - var(--ws-t, 0px) - var(--ws-b, 0px) - 110px);
  border-radius: 18px; color: var(--ink); font-family: var(--ui);
}
#app:not([data-mode="solucion"]) .sv-bub { display: none !important; }
/* la punta, sobre el avatar */
.sv-bub::after { content: ""; position: absolute; right: 22px; bottom: -6px; width: 12px; height: 12px; background: var(--glass2); transform: rotate(45deg); box-shadow: .5px .5px 0 var(--glass-line); }
/* solo la lista se encoge (y se desplaza) cuando no cabe todo */
.sv-bub > * { flex: none; }
.sv-bub > .sv-bub-l { flex: 1 1 auto; }
.sv-bub-h { display: flex; align-items: center; gap: 10px; padding: 12px 8px 2px 14px; }
.sv-bub-av { flex: none; width: 40px; height: 40px; border-radius: 50%; }
.sv-bub-av > svg { display: block; width: 100%; height: 100%; }
.sv-bub-ht { flex: 1 1 auto; min-width: 0; }
.sv-bub-t { margin: 0; font: 600 15px/20px var(--ui); color: var(--salviati); }
.sv-bub-s { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 13px/18px var(--ui); color: var(--ink2); }
.sv-x { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 16px; background: transparent; color: var(--ink2); }
.sv-x:hover { background: var(--fill); }
/* «Explícame este paso»: lo primero; debajo, dónde lo explica */
.sv-bub-a { display: grid; gap: 4px; padding: 10px 14px 10px; }
.sv-next { height: 36px; padding: 0 16px; border: 0; border-radius: 18px; background: var(--salviati); color: var(--paper); font: 600 14px/1 var(--ui); cursor: pointer; }
.sv-next:hover { filter: brightness(1.08); }
.sv-next:focus-visible, .sv-it:focus-visible, .sv-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sv-next-t { margin: 0; font: 12.5px/17px var(--ui); color: var(--ink2); text-align: center; }
/* «Pregúntale»: las preguntas del paso */
.sv-bub-l { min-height: 0; overflow-y: auto; padding: 0 6px 2px; box-shadow: inset 0 .5px 0 var(--sep); }
.sv-list-h { margin: 10px 8px 2px; font: 600 11.5px/16px var(--ui); letter-spacing: .02em; text-transform: uppercase; color: var(--ink2); }
.sv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sv-it {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 8px; align-items: start; width: 100%; padding: 7px 8px;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink); text-align: left; font: 13.5px/18px var(--ui); cursor: pointer;
}
.sv-it:hover { background: var(--fill); }
.sv-it-k { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-top: 0; border-radius: 9px; border: 1.2px solid var(--salviati); color: var(--salviati); font: 600 11px/1 var(--ui); }
/* los signos son decorativos: «/ ""» los calla para los lectores de pantalla (el primer content es el respaldo) */
.sv-it-k::before { content: "?"; content: "?" / ""; }
.sv-qi.is-open .sv-it-k::before { content: "–"; content: "–" / ""; }
/* la que abre el pizarrón lleva su flecha */
.sv-it.is-piz::after { content: "›"; content: "›" / ""; align-self: center; font: 400 18px/1 var(--ui); color: var(--ink2); }
.sv-it-b { display: grid; gap: 1px; min-width: 0; }
.sv-it-t { overflow-wrap: anywhere; }
.sv-it-s { font-size: 12px; line-height: 16px; color: var(--ink2); }
/* la respuesta breve, en la voz de Salviati: su cara y lo que dice */
.sv-ans { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; align-items: start; margin: 2px 4px 8px 32px; padding: 8px 10px; border-radius: 12px; background: var(--salviati-soft); color: var(--ink); }
.sv-ans[hidden] { display: none; }
.sv-ans-av { display: block; width: 24px; height: 24px; color: var(--ink); }
.sv-ans-av > svg { display: block; width: 100%; height: 100%; }
.sv-ans-b { min-width: 0; overflow-x: auto; font: 13.5px/1.5 var(--ui); }
.sv-ans-b p { margin: 0; }
.sv-ans-b p + p, .sv-ans-b .st-list, .sv-ans-b p + div { margin-top: 6px; }
.sv-ans-b .st-list { padding-left: 18px; }
.sv-ans.is-in { animation: sv-in .26s ease-out; }
.sv-bub-hint { margin: 6px 14px 12px; font: 12px/16px var(--ui); color: var(--ink2); text-align: center; }

#app[data-form="phone"] .sv-bub {
  left: calc(16px + var(--m-sl, 0px)); right: calc(16px + var(--m-sr, 0px)); width: auto;
  bottom: calc(var(--m-sb, 34px) + 136px); max-height: calc(100dvh - var(--m-top-h, 150px) - var(--m-sb, 34px) - 148px); border-radius: 22px;
}
#app[data-form="phone"] .sv-bub::after { right: auto; left: 18px; }
#app[data-form="phone"] .sv-x { width: 44px; height: 44px; border-radius: 22px; }
#app[data-form="phone"] .sv-it { min-height: 44px; align-items: center; font-size: 15px; line-height: 20px; }
#app[data-form="phone"] .sv-it-s { font-size: 13px; line-height: 17px; }
#app[data-form="phone"] .sv-next { height: 44px; border-radius: 22px; font-size: 15px; }
#app[data-form="phone"] .sv-ans-b { font-size: 15px; }
#app[data-form="phone"] .sv-bub-hint { margin-bottom: 10px; font-size: 13px; line-height: 17px; }

/* ----------------------------------------------------- UNA FRASE DE SALVIATI */
.sv-say { position: absolute; right: 0; bottom: calc(100% + 12px); width: max-content; max-width: 288px; padding: 10px 14px 11px; border-radius: 16px; color: var(--ink); }
.sv-say-t { margin: 0; font: 400 15px/21px var(--math); color: var(--ink); }
.sv-say-a { margin: 5px 0 0; font: 12px/16px var(--ui); color: var(--ink2); }
.sv-say.is-in { animation: sv-in .26s ease-out; }
#app[data-form="phone"] .sv-say { right: auto; left: 0; max-width: calc(100vw - 32px); }
@keyframes sv-in { from { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------ MOVIMIENTO Y PAPEL */
@media (prefers-reduced-motion: reduce) {
  .sv-dock, .sv-av, .sv-av-art, .sv-say, .sv-ans, .hj-sheet .sv-spot { transition: none !important; animation: none !important; }
  .sv-av:hover { transform: none; }
}
@media print {
  .sv-dock, .sv-bub, .sv-ghost, .sv-tag, .sv-say { display: none !important; }
  .hj-sheet .sv-spot { outline: none !important; box-shadow: none !important; }
}
