/* Toaster del portafolio.
 *
 * Componente reutilizable: avisos apilados abajo a la derecha, con una
 * variante especial "envío" que dibuja el recorrido del mensaje de un punto
 * a otro mientras se resuelve la promesa.
 *
 * Misma línea que el resto del sitio: escala de grises con los tokens
 * --pf-*, cuerpo monoespaciado, bordes de 1px. El único color es el
 * semántico del estado (éxito / error), y va atenuado.
 */

.toaster {
    --ts-ok: #2f7d54;
    --ts-error: #b3261e;
    --ts-espera: #8a8a8a;

    /* Abajo y centrado: es donde el ojo vuelve después de pulsar el botón
       de enviar, que está en esa misma columna. */
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 11000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

body.active_dark .toaster {
    --ts-ok: #6bbd92;
    --ts-error: #f2867d;
    --ts-espera: #9a9a9a;
}

@media (max-width: 520px) {
    .toaster {
        bottom: 12px;
        width: calc(100vw - 24px);
    }
}


/* ---------------------------------------------------------------- */
/*  Tarjeta                                                          */
/* ---------------------------------------------------------------- */

.toast {
    pointer-events: auto;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    padding: 13px 14px;
    background: var(--pf-surface);
    color: var(--pf-text);
    border: 1px solid var(--pf-border);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transition: opacity 0.26s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

body.active_dark .toast {
    background: #171717;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.toast.is-visible {
    opacity: 1;
    transform: none;
}

.toast.is-saliendo {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    transition-duration: 0.2s;
}


/* --- Cabecera ---------------------------------------------------- */

.toast__cabecera {
    display: flex;
    align-items: flex-start;
    gap: 9px;
}

.toast__marca {
    flex-shrink: 0;
    margin-top: 1px;
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1.5px solid var(--ts-espera);
    color: var(--ts-espera);
}

.toast__marca svg {
    width: 11px;
    height: 11px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.toast--ok .toast__marca {
    border-color: var(--ts-ok);
    color: var(--ts-ok);
}

.toast--error .toast__marca {
    border-color: var(--ts-error);
    color: var(--ts-error);
}

/* Anillo girando mientras se espera */
.toast--espera .toast__marca {
    border-color: var(--pf-border);
    border-top-color: var(--ts-espera);
    animation: ts-girar 0.9s linear infinite;
}

@keyframes ts-girar {
    to { transform: rotate(360deg); }
}

.toast__textos {
    flex: 1 1 auto;
    min-width: 0;
}

.toast__titulo {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.86rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--pf-text);
}

.toast--ok .toast__titulo { color: var(--ts-ok); }
.toast--error .toast__titulo { color: var(--ts-error); }

.toast__texto {
    margin: 2px 0 0;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--pf-text-muted);
    overflow-wrap: anywhere;
}

.toast__texto:empty { display: none; }

.toast__cerrar {
    flex-shrink: 0;
    align-self: flex-start;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--pf-text-faint);
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.toast__cerrar:hover {
    background: var(--pf-surface-2);
    border-color: var(--pf-border);
    color: var(--pf-text);
}

.toast__cerrar svg {
    width: 11px;
    height: 11px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
}


/* --- Acciones ---------------------------------------------------- */

.toast__acciones {
    display: flex;
    gap: 7px;
    margin-top: 11px;
}

.toast__accion {
    flex: 1 1 auto;
    padding: 7px 12px;
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--pf-text);
    background: var(--pf-surface-2);
    border: 1px solid var(--pf-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
}

body.active_dark .toast__accion {
    background: rgba(255, 255, 255, 0.05);
}

.toast__accion:hover {
    border-color: var(--pf-text-faint);
}


/* --- Barra de tiempo restante ------------------------------------ */

.toast__tiempo {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    transform-origin: left;
    background: var(--pf-text-faint);
    opacity: 0.35;
    animation: ts-agotar linear forwards;
}

.toast--ok .toast__tiempo { background: var(--ts-ok); }
.toast--error .toast__tiempo { background: var(--ts-error); }

@keyframes ts-agotar {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}


/* ---------------------------------------------------------------- */
/*  Variante "envío": el recorrido del mensaje                       */
/* ---------------------------------------------------------------- */

.toast__ruta {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 12px;
    overflow: visible;
}

/* Arco de fondo, siempre punteado y tenue */
.toast__ruta-base {
    fill: none;
    stroke: var(--pf-border);
    stroke-width: 1.4;
    stroke-dasharray: 4 4;
    stroke-linecap: round;
}

/* Arco que se va dibujando encima */
.toast__ruta-avance {
    fill: none;
    stroke: var(--ts-espera);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-dasharray: 220;
    stroke-dashoffset: 220;
    transition: stroke-dashoffset 0.55s ease, stroke 0.3s ease;
}

.toast--ok .toast__ruta-avance {
    stroke: var(--ts-ok);
    stroke-dashoffset: 0;
}

.toast--error .toast__ruta-avance {
    stroke: var(--ts-error);
    stroke-dasharray: 6 5;
    stroke-dashoffset: 0;
    opacity: 0.75;
}

/* El paquete que viaja por el arco */
.toast__paquete {
    fill: var(--ts-espera);
}

.toast--ok .toast__paquete,
.toast--error .toast__paquete {
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Extremos */
.toast__nodo {
    fill: var(--pf-surface);
    stroke: var(--pf-border);
    stroke-width: 1.4;
}

body.active_dark .toast__nodo {
    fill: #171717;
}

.toast__nodo-icono {
    fill: none;
    stroke: var(--pf-text-muted);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.toast--ok .toast__nodo--destino {
    stroke: var(--ts-ok);
}

.toast--ok .toast__nodo-icono--destino {
    stroke: var(--ts-ok);
}

.toast--error .toast__nodo--destino {
    stroke: var(--ts-error);
}

.toast--error .toast__nodo-icono--destino {
    stroke: var(--ts-error);
}

.toast__extremos {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
}

.toast__extremo {
    min-width: 0;
    font-size: 0.66rem;
    line-height: 1.35;
    color: var(--pf-text-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast__extremo:last-child {
    text-align: right;
}

.toast__extremo b {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pf-text-muted);
}


/* ---------------------------------------------------------------- */
/*  Movimiento reducido                                              */
/* ---------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .toast,
    .toast__ruta-avance {
        transition: none;
    }
    .toast--espera .toast__marca,
    .toast__tiempo {
        animation: none;
    }
    .toast__paquete {
        display: none;
    }
}
