/* Tutorial interactivo (web/tour.js): foco de luz, mano fantasma y la tarjeta de cada paso. Encima de todo (la Vista 3D
   está en 400, la pantalla completa en 200), debajo del login (9999). Sólo la tarjeta recibe clicks: el resto de la app
   se usa normal a través del oscurecido. */
/* modo aislado (web/tour.js): durante el tutorial no se ve nada de la app salvo lo del paso. visibility se hereda y
   un hijo puede volver a mostrarse: body queda oculto y se ven sólo #tour, lo marcado con .tr-show (botón, panel) y,
   con .tr-cv, el gráfico. */
body.tr-solo { visibility: hidden; }
body.tr-solo #tour, body.tr-solo .tr-show, body.tr-solo.tr-cv #cv, body.tr-solo.tr-cv #fx, body.tr-solo #ofLogin { visibility: visible; }
body.tr-solo #htBar:not(.tr-show) { visibility: hidden; }

#tour { position: fixed; inset: 0; z-index: 9600; pointer-events: none; font-family: var(--sans); transition: opacity .45s ease; }
#tour.bye { opacity: 0; }
.tr-spot, .tr-ring { position: fixed; left: 0; top: 0; border-radius: 14px; opacity: 0; will-change: transform, width, height;
  transition: transform .5s cubic-bezier(.2, 1, .3, 1), width .5s cubic-bezier(.2, 1, .3, 1), height .5s cubic-bezier(.2, 1, .3, 1), opacity .35s ease; }
.tr-spot { box-shadow: 0 0 0 200vmax rgba(var(--shadow-rgb), .5); }
body.tr-solo .tr-spot { box-shadow: 0 0 0 200vmax rgba(var(--shadow-rgb), .22); }
.tr-ring { border: 2px solid var(--acc); box-shadow: 0 0 0 4px rgba(var(--acc-rgb), .18), 0 0 30px rgba(var(--acc-rgb), .45); animation: trRing 2s ease-in-out infinite; }
@keyframes trRing { 50% { box-shadow: 0 0 0 8px rgba(var(--acc-rgb), .08), 0 0 44px rgba(var(--acc-rgb), .6); } }
#tour:not(.dim) .tr-spot, #tour:not(.dim) .tr-ring { opacity: 0 !important; }
#tour.end .tr-spot { opacity: 1 !important; width: 0 !important; height: 0 !important; transform: translate(50vw, 50vh) !important; box-shadow: 0 0 0 200vmax rgba(var(--shadow-rgb), .62); }

/* mano fantasma */
.tr-hand { position: fixed; left: 0; top: 0; z-index: 3; opacity: 0; transition: opacity .25s ease; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .5)) drop-shadow(0 0 12px rgba(var(--acc-rgb), .6)); }
.tr-hand.on { opacity: 1; }
.tr-hand svg { display: block; transform-origin: 6px 3px; transition: transform .12s; }
.tr-hand i { position: absolute; left: 6px; top: 3px; width: 44px; height: 44px; margin: -22px; border-radius: 50%; border: 2px solid var(--acc); opacity: 0; pointer-events: none; }
.tr-hand.tap svg { animation: trTap .26s ease; }
.tr-hand.tap i { animation: trRip .55s ease-out; }
@keyframes trTap { 50% { transform: scale(.82); } }
@keyframes trRip { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
.tr-hand.hint i { animation: trRip 1s ease-out infinite; }

/* bienvenida */
.tr-intro { position: fixed; inset: 0; display: grid; place-content: center; gap: 10px; text-align: center; opacity: 0; transform: scale(.96); pointer-events: none;
  transition: opacity .5s ease, transform .7s cubic-bezier(.2, 1, .3, 1); background: radial-gradient(ellipse at center, rgba(var(--bg-rgb), .78), rgba(var(--bg-rgb), .35) 70%); }
#tour.intro .tr-intro { opacity: 1; transform: none; }
.tr-intro b { font: 800 clamp(30px, 5vw, 56px)/1.05 var(--sans); letter-spacing: -.035em; background: linear-gradient(95deg, var(--hi), var(--acc) 55%, var(--sell)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tr-intro span { font-size: clamp(14px, 1.6vw, 18px); color: var(--soft); }

/* la tarjeta */
.tr-card { --c: var(--acc); position: fixed; z-index: 4; width: 380px; max-width: calc(100vw - 24px); padding: 16px 18px 14px; border-radius: 20px; pointer-events: auto; color: var(--text);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 94%, transparent), rgba(var(--float-rgb), .96)); border: 1px solid rgba(var(--hi-rgb), .1);
  box-shadow: 0 30px 80px rgba(var(--shadow-rgb), .6), 0 0 0 1px color-mix(in srgb, var(--c) 18%, transparent), 0 0 50px color-mix(in srgb, var(--c) 14%, transparent);
  backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  transition: left .55s cubic-bezier(.2, 1, .3, 1), top .55s cubic-bezier(.2, 1, .3, 1), right .55s cubic-bezier(.2, 1, .3, 1), bottom .55s cubic-bezier(.2, 1, .3, 1), box-shadow .3s, border-color .3s; }
.tr-card::before { content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, color-mix(in srgb, var(--c) 80%, transparent), transparent 40%, transparent 70%, color-mix(in srgb, var(--sell) 50%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.tr-card:empty { display: none; }
.tr-card[data-pos="bl"] { left: 20px; bottom: 20px; }
.tr-card[data-pos="br"] { right: 20px; bottom: 20px; }
.tr-card[data-pos="tl"] { left: 20px; top: 70px; }
.tr-card[data-pos="tr"] { right: 20px; top: 70px; }
.tr-card[data-pos="m"] { left: 12px; right: 12px; bottom: 12px; width: auto; }
.tr-card[data-pos="c"] { left: 50%; top: 50%; translate: -50% -50%; }
.tr-card.wide { width: 440px; }
.tr-card.in > * { animation: trIn .5s cubic-bezier(.2, 1, .3, 1) both; }
.tr-card.in > :nth-child(2) { animation-delay: .03s; } .tr-card.in > :nth-child(3) { animation-delay: .06s; } .tr-card.in > :nth-child(4) { animation-delay: .1s; }
.tr-card.in > :nth-child(5) { animation-delay: .14s; } .tr-card.in > :nth-child(6) { animation-delay: .18s; } .tr-card.in > :nth-child(7) { animation-delay: .22s; } .tr-card.in > :nth-child(8) { animation-delay: .26s; }
@keyframes trIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tr-top { display: flex; align-items: center; gap: 10px; }
.tr-ic { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 11px; color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 25%, transparent); }
.tr-ic svg { width: 19px; height: 19px; }
.tr-kick { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tr-kick em { font: 700 10.5px var(--sans); font-style: normal; letter-spacing: .08em; text-transform: uppercase; color: var(--c); }
.tr-kick b { font: 600 11.5px var(--sans); color: var(--neutral-2); }
.tr-bar { height: 3px; margin: 12px 0 12px; border-radius: 2px; background: rgba(var(--hi-rgb), .07); overflow: hidden; }
.tr-bar i { display: block; height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--acc), var(--sell)); transition: width .7s cubic-bezier(.2, 1, .3, 1); }
.tr-card h3 { margin: 0 0 6px; font: 700 19px/1.2 var(--sans); letter-spacing: -.02em; color: var(--hi); }
.tr-body { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--neutral); }

.tr-state { display: flex; align-items: center; gap: 8px; margin-top: 12px; font: 600 12px var(--sans); color: var(--soft); }
.tr-sic { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); }
.tr-state[data-st="demo"] .tr-sic { animation: trBeat 1.2s ease-in-out infinite; }
@keyframes trBeat { 50% { transform: scale(1.18); box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 12%, transparent); } }
.tr-state[data-st="ok"] { color: var(--buy); }
.tr-state[data-st="ok"] .tr-sic { color: var(--on-acc); background: var(--buy); }

.tr-task { position: relative; display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; padding: 11px 12px; border-radius: 13px; opacity: .45;
  background: rgba(var(--hi-rgb), .035); border: 1px dashed rgba(var(--hi-rgb), .14); transition: opacity .3s, border-color .3s, background .3s, box-shadow .3s; }
.tr-task b { display: block; font: 700 11px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--c); }
.tr-task div > span { display: block; margin-top: 2px; font-size: 13.5px; line-height: 1.45; color: var(--soft); }
.tr-chk { flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-top: 2px; border-radius: 7px; color: transparent; border: 1.5px solid rgba(var(--hi-rgb), .25); transition: all .3s cubic-bezier(.2, 1.6, .4, 1); }
.tr-card.turn .tr-task { opacity: 1; border-style: solid; border-color: color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 8%, transparent); animation: trWait 2.2s ease-in-out infinite; }
@keyframes trWait { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 10%, transparent), 0 0 24px color-mix(in srgb, var(--c) 18%, transparent); } }
.tr-card.ok .tr-task { opacity: 1; border-style: solid; border-color: color-mix(in srgb, var(--buy) 55%, transparent); background: color-mix(in srgb, var(--buy) 9%, transparent); }
.tr-card.ok .tr-chk { color: var(--on-acc); background: var(--buy); border-color: var(--buy); transform: scale(1.12); box-shadow: 0 0 16px color-mix(in srgb, var(--buy) 60%, transparent); }

.tr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 12px; }
.tr-grid button { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; text-align: left; cursor: pointer; font: 600 12.5px var(--sans); color: var(--soft);
  background: rgba(var(--hi-rgb), .035); border: 1px solid rgba(var(--hi-rgb), .08); transition: border-color .15s, background .15s, transform .15s; }
.tr-grid button i { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.tr-grid button:hover { border-color: color-mix(in srgb, var(--c) 50%, transparent); background: color-mix(in srgb, var(--c) 9%, transparent); transform: translateY(-1px); }
.tr-grid button.on { border-color: color-mix(in srgb, var(--c) 60%, transparent); }

.tr-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.tr-dots { flex: 1; display: flex; gap: 4px; flex-wrap: wrap; }
.tr-dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(var(--hi-rgb), .15); transition: width .3s, background .3s; }
.tr-dots i.done { background: var(--c); opacity: .7; }
.tr-dots i.cur { width: 18px; background: var(--c); }
.tr-redo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; border: 1px solid rgba(var(--hi-rgb), .1); background: transparent; color: var(--neutral); cursor: pointer; }
.tr-redo:hover { color: var(--hi); border-color: rgba(var(--hi-rgb), .25); }
.tr-pass { height: 34px; padding: 0 10px; border-radius: 10px; border: 0; background: none; color: var(--neutral-2); font: 500 12px var(--sans); cursor: pointer; }
.tr-pass:hover { color: var(--soft); }
.tr-next { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 15px; border-radius: 11px; cursor: pointer; isolation: isolate; overflow: hidden;
  font: 800 13.5px var(--sans); letter-spacing: .02em; color: var(--hi); border: 1.5px solid transparent;
  background: linear-gradient(var(--surface-2), var(--surface-2)) padding-box, conic-gradient(from var(--tbm-a, 0deg), #a78bfa, #f0abfc, #67e8f9, #818cf8, #a78bfa) border-box;
  box-shadow: 0 0 14px rgba(167, 139, 250, .25); transition: scale .45s cubic-bezier(.34, 1.9, .5, 1), opacity .2s, filter .2s, box-shadow .3s; }
.tr-next > span { background: linear-gradient(90deg, #c4b5fd, #f0abfc, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tr-next > svg { color: #67e8f9; }
.tr-next:disabled { cursor: not-allowed; opacity: .35; filter: grayscale(.7); }
.tr-next.ready { animation: tbmSpin 4s linear infinite, trReady 1.8s ease-in-out infinite; }
.tr-next.ready:hover { scale: 1.06; }
@keyframes trReady { 0%, 100% { box-shadow: 0 0 14px rgba(167, 139, 250, .3); } 50% { box-shadow: 0 0 26px rgba(167, 139, 250, .6), 0 0 0 3px rgba(240, 171, 252, .08); } }
.tr-next.xl { height: 50px; padding: 0 24px; font-size: 15.5px; border-radius: 14px; }
.tr-ghost { height: 50px; padding: 0 18px; border-radius: 14px; border: 1px solid rgba(var(--hi-rgb), .14); background: transparent; color: var(--soft); font: 600 14px var(--sans); cursor: pointer; }
.tr-ghost:hover { color: var(--hi); border-color: rgba(var(--hi-rgb), .3); }

/* final */
.tr-card.fin { width: 520px; padding: 30px 30px 24px; text-align: center; }
.tr-fin-ic { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; color: var(--on-acc);
  background: linear-gradient(135deg, var(--acc), var(--sell)); box-shadow: 0 0 40px rgba(var(--acc-rgb), .5); animation: trPop .7s cubic-bezier(.2, 1.8, .4, 1) both; }
.tr-fin-ic svg { width: 30px; height: 30px; }
@keyframes trPop { from { transform: scale(0) rotate(-30deg); } }
.tr-card.fin h3 { font-size: 26px; margin-bottom: 8px; }
.tr-card.fin .tr-body { font-size: 14.5px; }
.tr-sum { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 18px 0 20px; padding: 0; list-style: none; }
.tr-sum li { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; border-radius: 999px; font: 600 11.5px var(--sans); color: var(--soft);
  background: color-mix(in srgb, var(--c) 9%, transparent); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); }
.tr-sum li svg { width: 13px; height: 13px; color: var(--c); }
.tr-fin-cta { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.tr-fine { margin: 12px 0 0; font-size: 12px; color: var(--neutral-2); }

.tr-conf { position: fixed; z-index: 6; width: 7px; height: 11px; margin: -5px -3px; border-radius: 2px; pointer-events: none; animation: trConf 1.05s cubic-bezier(.15, .7, .3, 1) forwards; }
@keyframes trConf { 70% { opacity: 1; } to { transform: translate(var(--dx), calc(var(--dy) + 60px)) rotate(var(--r)); opacity: 0; } }

@media (max-width: 700px) {
  .tr-card { padding: 14px 14px 12px; }
  .tr-card h3 { font-size: 17px; }
  .tr-body { font-size: 13px; }
  .tr-card.fin { width: auto; left: 12px; right: 12px; translate: 0 -50%; }
}
@media (prefers-reduced-motion: reduce) { #tour *, #tour *::before { animation: none !important; transition-duration: .01s !important; } }
