/*
 * nodo.css — Nodo, la mascota guía de HappyPath (Pages/Shared/_Nodo.cshtml + js/nodo.js).
 * Animaciones solo con CSS (transform/opacity); con prefers-reduced-motion queda estático.
 */
.nodo {
    --nodo-azul: #009cff;
    --nodo-azul-texto: #0072c6; /* 5:1 sobre blanco; #009cff no llega a 4.5:1 */
    --nodo-azul-claro: #8ad0ff;
    --nodo-verde: #a5c058;
    --nodo-noche: #0b2a45;
    --nodo-tam: 76px;
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1900; /* debajo del banner de cookies (2000) */
    font-family: inherit;
}

/* "Volver arriba" se recorre para no encimarse con Nodo */
#back-top { bottom: 118px; transition: opacity .2s ease; }
body:has(.nodo__burbuja.is-visible) #back-top,
body:has(.nodo__panel:not([hidden])) #back-top { opacity: 0; pointer-events: none; }

/* ---------- Personaje ---------- */
.nodo__bot {
    position: relative;
    display: block;
    width: var(--nodo-tam);
    height: var(--nodo-tam);
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    animation: nodo-flota 4s ease-in-out infinite;
}
.nodo__bot:focus-visible { outline: 3px solid var(--nodo-azul); outline-offset: 4px; border-radius: 50%; }
.nodo__svg { position: relative; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 6px 10px rgba(0, 114, 198, .3)); }
.nodo__sombra {
    position: absolute;
    left: 22%;
    right: 22%;
    bottom: -10px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .18);
    animation: nodo-sombra 4s ease-in-out infinite;
}

.nodo__ojos { transition: transform .12s ease-out; }
.nodo__ojo { transform-box: fill-box; transform-origin: center; animation: nodo-parpadeo 5.5s infinite; }
.nodo__led { transform-box: fill-box; transform-origin: center; animation: nodo-led 2.4s ease-in-out infinite; }
.nodo__anillo { transform-box: fill-box; transform-origin: center; animation: nodo-gira 18s linear infinite; }
.nodo__puerto--der { transform-box: view-box; transform-origin: 96px 64px; }
.nodo__cursor { font: 700 13px/1 Consolas, "Courier New", monospace; opacity: 0; }

/* Saluda moviendo el "puerto" derecho como si fuera un brazo */
.nodo.is-hablando .nodo__puerto--der { animation: nodo-saludo 1.6s ease-in-out; }
/* Escribiendo: la boca se vuelve un cursor de terminal */
.nodo.is-escribiendo .nodo__boca { opacity: 0; }
.nodo.is-escribiendo .nodo__cursor { animation: nodo-cursor .8s steps(1) infinite; }

/* Punto de aviso: hay un comentario que no se mostró */
.nodo__aviso {
    position: absolute;
    top: 8px;
    right: 4px;
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #EE3B24;
    transform: scale(0);
    transition: transform .2s ease;
}
.nodo.has-aviso .nodo__aviso { transform: scale(1); }

/* ---------- Burbuja de sugerencias ---------- */
.nodo__burbuja {
    position: absolute;
    right: 8px;
    bottom: calc(var(--nodo-tam) + 18px);
    width: 280px;
    max-width: calc(100vw - 44px);
    padding: 16px 18px 14px;
    border-radius: 16px 16px 4px 16px;
    background: #fff;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 10px 30px rgba(11, 42, 69, .18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(.96);
    transform-origin: bottom right;
    transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
}
.nodo__burbuja.is-visible { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.nodo__burbuja-texto p { margin: 0 0 8px; }
/* La plantilla pinta todos los <p> de gris (#6a6a6a): dentro de Nodo manda el color del componente */
.nodo__burbuja-texto p, .nodo__msj p, .nodo__msj li { color: inherit; }
.nodo__burbuja-texto { padding-right: 14px; }
.nodo__burbuja-cerrar {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: #5f6b76;
    font-size: 13px;
    line-height: 1;
}
.nodo__burbuja-cerrar:hover { background: #eef4f9; }
.nodo__burbuja-accion {
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid var(--nodo-azul-texto);
    border-radius: 18px;
    background: #fff;
    color: var(--nodo-azul-texto);
    font-size: 13px;
    font-weight: 700;
}
.nodo__burbuja-accion:hover, .nodo__burbuja-accion:focus { background: var(--nodo-azul-texto); color: #fff; }

/* ---------- Panel de conversación ---------- */
.nodo__panel {
    position: absolute;
    right: 0;
    bottom: calc(var(--nodo-tam) + 18px);
    display: flex;
    flex-direction: column;
    width: 360px;
    max-width: calc(100vw - 44px);
    max-height: min(560px, calc(100vh - 140px));
    max-height: min(560px, calc(100dvh - 140px));
    overflow: hidden;
    border-radius: 18px;
    background: #f5f9fc;
    box-shadow: 0 18px 50px rgba(11, 42, 69, .28);
    animation: nodo-entra .25s ease-out;
}
.nodo__panel[hidden] { display: none; }

.nodo__cabecera {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 12px 14px 16px;
    background: linear-gradient(135deg, #0072c6, #005a9e); /* texto blanco ≥ 5:1 en todo el degradado */
    color: #fff;
}
.nodo__avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--nodo-noche);
    color: var(--nodo-verde);
    font: 700 14px/1 Consolas, "Courier New", monospace;
}
.nodo__titulos { flex: 1; min-width: 0; line-height: 1.25; }
.nodo__titulos strong { display: block; font-size: 16px; }
.nodo__titulos span { font-size: 12px; }
.nodo__icono {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    color: #fff;
}
.nodo__icono:hover, .nodo__icono:focus { background: rgba(255, 255, 255, .3); }

.nodo__mensajes {
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    padding: 16px;
    font-size: 14px;
    line-height: 1.5;
}
.nodo__msj {
    max-width: 88%;
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: 14px 14px 14px 4px;
    background: #fff;
    color: #333;
    box-shadow: 0 2px 6px rgba(11, 42, 69, .06);
    animation: nodo-entra .2s ease-out;
}
.nodo__msj p { margin: 0 0 6px; }
.nodo__msj p:last-child, .nodo__msj ul:last-child { margin-bottom: 0; }
.nodo__msj ul { margin: 0 0 6px; padding-left: 18px; }
.nodo__msj a { color: #0072c6; font-weight: 700; }
.nodo__msj--usuario {
    margin-left: auto;
    border-radius: 14px 14px 4px 14px;
    background: var(--nodo-azul-texto);
    color: #fff;
}
.nodo__msj .nodo__accion { margin-top: 8px; }
.nodo__escribiendo { font: 700 14px/1 Consolas, "Courier New", monospace; color: var(--nodo-azul-texto); }
.nodo__escribiendo::after { content: "_"; animation: nodo-cursor .8s steps(1) infinite; }

.nodo__temas {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px;
    border-top: 1px solid #e3edf5;
}
.nodo__tema {
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid #cfe3f3;
    border-radius: 17px;
    background: #fff;
    color: var(--nodo-azul-texto);
    font-size: 13px;
}
.nodo__tema:hover, .nodo__tema:focus { border-color: var(--nodo-azul-texto); background: #e8f5ff; }
/* Ya preguntada: se distingue por fondo y palomita, sin bajar el contraste del texto */
.nodo__tema.is-usado { background: #eef4f9; }
.nodo__tema.is-usado::before { content: "\2713\00a0"; }

/* Foco visible en todos los controles de Nodo */
.nodo button:focus-visible, .nodo a:focus-visible { outline: 3px solid var(--nodo-azul-texto); outline-offset: 2px; }
.nodo__cabecera button:focus-visible { outline-color: #fff; }

.nodo__pie { display: flex; gap: 8px; padding: 10px 16px 14px; }
.nodo__accion {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    padding: 8px 12px;
    border-radius: 20px;
    background: var(--nodo-noche);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}
.nodo__accion:hover, .nodo__accion:focus { color: #fff; text-decoration: none; opacity: .9; }
.nodo__accion--wa { background: #0b7a4b; } /* verde WhatsApp oscurecido: #25D366 con texto blanco da 2:1 */

/* ---------- Ruta lateral ("happy path") — solo en la home y pantallas anchas ---------- */
.nodo-ruta {
    position: fixed;
    left: 22px;
    top: 50%;
    z-index: 900;
    height: 46vh;
    opacity: 0;
    visibility: hidden;
    transform: translate(-12px, -50%);
    transition: opacity .3s ease, transform .3s ease, visibility 0s linear .3s;
}
.nodo-ruta.is-visible { opacity: 1; visibility: visible; transform: translate(0, -50%); transition-delay: 0s; }
.nodo-ruta__linea, .nodo-ruta__avance {
    position: absolute;
    left: 6px;
    top: 0;
    width: 3px;
    border-radius: 2px;
}
.nodo-ruta__linea { bottom: 0; background: repeating-linear-gradient(to bottom, #cfe3f3 0 6px, transparent 6px 12px); }
.nodo-ruta__avance { height: 0; background: linear-gradient(to bottom, var(--nodo-azul, #009cff), #a5c058); }
.nodo-ruta__punto {
    position: absolute;
    left: -2px;
    width: 19px;
    height: 19px;
    margin-top: -9px;
    border-radius: 50%;
    background: #a5c058;
    box-shadow: 0 0 0 4px rgba(165, 192, 88, .25);
}
.nodo-ruta__estacion {
    position: absolute;
    left: -5px;
    display: flex;
    align-items: center;
    margin-top: -12px;
    padding: 5px; /* área de clic de 25px alrededor del punto de 15px */
    text-decoration: none;
}
.nodo-ruta__estacion::before {
    content: "";
    width: 15px;
    height: 15px;
    border: 3px solid #cfe3f3;
    border-radius: 50%;
    background: #fff;
    transition: border-color .3s ease, transform .3s ease;
}
.nodo-ruta__estacion.is-pasada::before { border-color: #009cff; }
.nodo-ruta__estacion.is-actual::before { transform: scale(1.25); }
.nodo-ruta__etiqueta {
    margin-left: 10px;
    padding: 3px 8px;
    border-radius: 10px;
    background: #0b2a45;
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
}
.nodo-ruta__estacion:hover .nodo-ruta__etiqueta,
.nodo-ruta__estacion:focus .nodo-ruta__etiqueta,
.nodo-ruta__estacion.is-actual .nodo-ruta__etiqueta { opacity: 1; transform: none; }
.nodo-ruta__estacion:focus-visible { outline: 2px solid #009cff; outline-offset: 3px; border-radius: 10px; }
@media (max-width: 1299px) { .nodo-ruta { display: none; } }

/* ---------- Celular ---------- */
@media (max-width: 767px) {
    .nodo { --nodo-tam: 60px; right: 14px; bottom: 14px; }
    #back-top { bottom: 92px; right: 20px; }
    .nodo__panel { position: fixed; right: 10px; left: 10px; bottom: 86px; width: auto; max-width: none; max-height: calc(100vh - 110px); max-height: calc(100dvh - 110px); }
    .nodo__burbuja { width: 260px; font-size: 15px; }
    .nodo__mensajes { font-size: 15px; }
    /* Objetivos táctiles de 44px */
    .nodo__tema, .nodo__burbuja-accion { min-height: 44px; font-size: 14px; }
    .nodo__icono { width: 44px; height: 44px; }
    .nodo__accion { min-height: 44px; font-size: 14px; }
}

/* ---------- Animaciones ---------- */
@keyframes nodo-flota { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes nodo-sombra { 0%, 100% { opacity: 1; transform: scaleX(1); } 50% { opacity: .55; transform: scaleX(.78); } }
@keyframes nodo-parpadeo { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes nodo-led { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(.8); } }
@keyframes nodo-gira { to { transform: rotate(360deg); } }
@keyframes nodo-saludo { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-35deg); } 40% { transform: rotate(10deg); } 60% { transform: rotate(-35deg); } 80% { transform: rotate(0); } }
@keyframes nodo-cursor { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes nodo-entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    .nodo *, .nodo *::after, .nodo-ruta * { animation: none !important; transition: none !important; }
    .nodo.is-escribiendo .nodo__cursor { opacity: 1; }
}
