/* ==========================================================================
   17 · La línea de tiempo del proyecto (guía westudio, sección 6.1)

   Encabezado con «Siguiente paso», banda Horizonte (avance, plazo, cobros) y
   el gantt. Marcado: includes/frontend/trait-linea-tiempo.php. Escala y
   plegado: assets/js/raver-linea-tiempo.js.

   Posición en el tiempo: cada elemento trae su día en --d (o --d0 y --d1) y
   #ws-tl trae la ventana visible en --v0 y --v1. Nada de hex sueltos: todo
   sale de --tinta-*.
   ========================================================================== */

/* ---- Utilidades tipográficas y de superficie ---- */
.ws-h1 {
    margin: 0;
    font-family: var(--f-marca);
    font-size: 28px;
    line-height: 32px;
    font-weight: 600;
    letter-spacing: -.02em;
    color: var(--tinta-texto);
}
.ws-t2 { color: var(--tinta-texto-2); }
.ws-t3 { color: var(--tinta-texto-3); }
.ws-acc { color: var(--tinta-acento-tx); }
.ws-cifra-xl { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 28px; line-height: 32px; font-weight: 500; letter-spacing: -.04em; color: var(--tinta-texto); }
.ws-cifra-l  { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 20px; line-height: 24px; font-weight: 500; letter-spacing: -.03em; color: var(--tinta-texto); }
.ws-u { margin-left: .1em; }
.ws-sep-v { display: inline-block; width: 1px; height: 14px; background: var(--tinta-borde-2); align-self: center; }
.ws-panel { background: var(--tinta-sup); border: 1px solid var(--tinta-borde); border-radius: var(--r-2); }
.ws-barra-media { height: 6px; }

/* Los botones del tema se pisan con !important: lo mismo acá para los nuestros */
.ws-tl-titulo, .ws-tl-toggle, .ws-tl-hito, .ws-seg button {
    appearance: none;
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: inherit !important;
    font: inherit !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    text-align: left;
    cursor: pointer;
}

/* ---- Contenedor ---- */
.ws-proy { display: flex; flex-direction: column; gap: 16px; }

/* ---- 1. Encabezado ---- */
.ws-proy-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.ws-proy-cab-info { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ws-proy-cab-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; font-size: 13px; }
.ws-siguiente {
    flex: none;
    width: 400px;
    max-width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--tinta-acento-linea);
    border-radius: var(--r-2);
    background: var(--tinta-sup);
}
.ws-siguiente-fila { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 6px; }
.ws-siguiente-fila strong { font-size: 14px; font-weight: 500; line-height: 1.3; color: var(--tinta-texto); }
.ws-siguiente-meta { font-size: 12px; }

/* ---- 2. Horizonte ---- */
.ws-horizonte { display: grid; grid-template-columns: 1.15fr .85fr 1.5fr; }
.ws-hor-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 20px 24px; }
.ws-hor-col + .ws-hor-col { border-left: 1px solid var(--tinta-borde); }
.ws-hor-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ws-hor-cifra { display: flex; align-items: baseline; gap: 10px; font-size: 13px; }
.ws-hor-sub { font-size: 13px; }
.ws-hor-veredicto { font-size: 12px; }
.ws-hor-tiempo { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.ws-hor-linea { position: relative; display: block; height: 9px; border-bottom: 1px solid var(--tinta-borde-control); }
.ws-hor-linea i { position: absolute; bottom: -1px; width: 1px; height: 9px; background: var(--tinta-texto-2); }
.ws-hor-montos { display: flex; flex-wrap: wrap; gap: 8px 32px; }
.ws-hor-montos > div { display: flex; flex-direction: column; gap: 2px; }
.ws-hor-nota { font-size: 12px; }
.ws-hor-tramos { display: flex; gap: 6px; margin-top: 4px; }
.ws-hor-tramo { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.ws-hor-tramo-txt { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

/* ---- 3. Gantt ---- */
.ws-tl { --c1: 280px; --c3: 108px; position: relative; overflow: hidden; }
.ws-tl-fila {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: var(--c1) minmax(0, 1fr) var(--c3);
    align-items: stretch;
    min-height: 32px;
    border-bottom: 1px solid var(--tinta-borde);
}
.ws-tl-c1 { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 16px; font-size: 13px; color: var(--tinta-texto); }
.ws-tl-c2 { position: relative; min-width: 0; border-left: 1px solid var(--tinta-borde); overflow: hidden; }
.ws-tl-c3 { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 0 16px; font-size: 12px; color: var(--tinta-texto); }
.ws-tl-cab { min-height: 34px; }
.ws-tl-cab .ws-tl-c2 { overflow: visible; }

/* Posición en el tiempo */
.ws-tl-tick,
.ws-tl-punto,
.ws-tl-hito,
.ws-tl-atraso,
.ws-tl-hoy-pill { left: calc((var(--d) - var(--v0)) / (var(--v1) - var(--v0)) * 100%); }
.ws-tl-tick { position: absolute; top: 50%; transform: translateY(-50%); padding-left: 6px; white-space: nowrap; }
.ws-tl-hoy-pill {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translate(-50%, -50%);
    padding: 2px 6px;
    border-radius: 2px;
    background: var(--tinta-acento);
    color: var(--tinta-sobre-acento);
    font-family: var(--f-mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: .08em;
    white-space: nowrap;
}

/* Capa de fondo: la rejilla semanal y la línea de HOY, sobre la columna del medio */
.ws-tl-cuerpo { position: relative; }
.ws-tl-capa { position: absolute; z-index: 3; top: 0; bottom: 0; left: var(--c1); right: var(--c3); overflow: hidden; pointer-events: none; }
.ws-tl-lin { position: absolute; top: 0; bottom: 0; left: calc((var(--d) - var(--v0)) / (var(--v1) - var(--v0)) * 100%); width: 1px; background: var(--tinta-reticula); }
.ws-tl-hoy { position: absolute; top: 0; bottom: 0; left: calc((var(--d) - var(--v0)) / (var(--v1) - var(--v0)) * 100%); width: 2px; margin-left: -1px; background: var(--tinta-acento-tx); }

/* Carriles de cobros y de hitos */
.ws-tl-carril { min-height: 36px; }
.ws-tl-carril .ws-tl-c1 svg { color: var(--tinta-texto-3); }
.ws-tl-carril-cobros { background: var(--tinta-hover); }
.ws-tl-carril-nota { position: absolute; top: 50%; left: 16px; transform: translateY(-50%); font-size: 12px; white-space: nowrap; }
.ws-tl-hilo {
    position: absolute;
    top: 50%;
    left: calc((var(--d0) - var(--v0)) / (var(--v1) - var(--v0)) * 100%);
    width: calc((var(--d1) - var(--d0)) / (var(--v1) - var(--v0)) * 100%);
    height: 1px;
    background: var(--tinta-acento-linea);
}
.ws-tl-hilo-pasado { background: var(--tinta-acento-tx); }
.ws-tl-punto, .ws-tl-hito { position: absolute; top: 50%; display: flex; align-items: center; transform: translate(-50%, -50%); height: 16px; }
.ws-tl-punto i { display: block; width: 10px; height: 10px; border: 1.5px solid var(--tinta-acento-tx); border-radius: 50%; }
.ws-tl-punto.lleno i { background: var(--tinta-acento-tx); }
.ws-tl-punto.vacio i { background: var(--tinta-sup); }
.ws-tl-punto em, .ws-tl-hito em {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-style: normal;
    font-size: 11.5px;
    line-height: 1;
    color: var(--tinta-texto);
    white-space: nowrap;
}
.ws-tl-punto.lleno em, .ws-tl-hito.cerrado em { left: 16px; }
.ws-tl-punto.vacio em, .ws-tl-hito.abierto em { right: 16px; }
.ws-tl-hito i { display: block; width: 9px; height: 9px; border: 1.5px solid var(--tinta-texto-2); transform: rotate(45deg); }
.ws-tl-hito.cerrado i { background: var(--tinta-ok); border-color: var(--tinta-ok); }
.ws-tl-hito.abierto i { background: var(--tinta-sup); }
.ws-tl-hito:hover em { text-decoration: underline; }
.ws-tl-hito:focus-visible { outline: none; box-shadow: var(--foco) !important; }

/* Fases y tareas */
.ws-tl-fase { min-height: 36px; cursor: pointer; }
.ws-tl-fase:hover { background: var(--tinta-hover); }
.ws-tl-fase .ws-tl-c1 b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-tl-toggle { display: inline-flex !important; align-items: center; justify-content: center; width: 16px !important; height: 16px; padding: 0 !important; color: var(--tinta-texto-3) !important; }
.ws-tl-toggle svg { transition: transform var(--m-rapido) var(--c-salida); }
.ws-tl-grupo:not(.abierta) .ws-tl-toggle svg { transform: rotate(-90deg); }
.ws-tl-grupo:not(.abierta) .ws-tl-tareas { display: none; }
.ws-tl-tarea { min-height: 30px; }
.ws-tl-tarea.nivel-2 .ws-tl-c1 { padding-left: 40px; }
.ws-tl-tarea.nivel-1 .ws-tl-c1 { padding-left: 16px; }
.ws-tl-tarea.siguiente { background: var(--tinta-acento-suave); }
.ws-tl-tarea.hecha .ws-tl-titulo { color: var(--tinta-texto-3) !important; }
.ws-tl-titulo { flex: 0 1 auto; min-width: 0 !important; overflow: hidden; padding: 0 !important; font-size: 13px !important; color: var(--tinta-texto-2) !important; text-overflow: ellipsis; white-space: nowrap; }
.ws-tl-titulo:hover { color: var(--tinta-texto) !important; text-decoration: underline; }
.ws-tl-tarea .ws-rotulo { flex: none; font-size: 10px; }

/* Barras: la pista es el plazo; el relleno, lo hecho */
.ws-tl-barra {
    position: absolute;
    top: 50%;
    left: calc((var(--d0) - var(--v0)) / (var(--v1) - var(--v0)) * 100%);
    width: calc((var(--d1) - var(--d0)) / (var(--v1) - var(--v0)) * 100%);
    min-width: 6px;
    height: 10px;
    transform: translateY(-50%);
    overflow: hidden;
    border: 1px solid var(--tinta-borde-2);
    border-radius: 1px;
    background: var(--tinta-pista);
}
.ws-tl-barra > i { position: absolute; top: 0; bottom: 0; left: 0; background: var(--tinta-acento); transition: width var(--m-progreso) var(--c-salida); }
.ws-tl-barra.fina { height: 8px; }
.ws-tl-barra.hecha { border-color: transparent; background: var(--tinta-acento-linea); }
.ws-tl-barra.hecha > i { background: var(--tinta-acento-linea); }
/* Sin fecha límite: la barra corre hasta hoy y se abre a la derecha */
.ws-tl-barra.abierta { -webkit-mask-image: linear-gradient(90deg, #000 55%, transparent); mask-image: linear-gradient(90deg, #000 55%, transparent); }
.ws-tl-atraso { position: absolute; top: 50%; display: flex; align-items: center; gap: 6px; transform: translate(10px, -50%); font-size: 11.5px; white-space: nowrap; }

.ws-tl-vacio { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 44px 24px; text-align: center; font-size: 13px; color: var(--tinta-texto-2); border-bottom: 1px solid var(--tinta-borde); }
.ws-tl-vacio p { max-width: 460px; margin: 0; line-height: 1.5; }
.ws-tl-vacio strong { color: var(--tinta-texto); font-weight: 500; }
.ws-tl-agregar { padding: 6px 12px; }

/* ---- Leyenda y escala ---- */
.ws-tl-pie { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.ws-tl-leyenda { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--tinta-texto-3); }
.ws-tl-leyenda li { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.ley { display: inline-block; flex: none; }
.ley-hecha { width: 20px; height: 6px; background: var(--tinta-acento-linea); }
.ley-curso { width: 20px; height: 6px; background: linear-gradient(90deg, var(--tinta-acento) 50%, var(--tinta-pista) 50%); }
.ley-pista { width: 20px; height: 6px; border: 1px solid var(--tinta-borde-2); background: var(--tinta-pista); }
.ley-hito { width: 8px; height: 8px; border: 1.5px solid var(--tinta-texto-2); transform: rotate(45deg); }
.ley-cobro { width: 9px; height: 9px; border: 1.5px solid var(--tinta-acento-tx); border-radius: 50%; }

.ws-seg { display: inline-flex; padding: 2px; border: 1px solid var(--tinta-borde); border-radius: var(--r-1); background: var(--tinta-hundido); }
.ws-seg button { height: 24px; padding: 0 12px !important; border-radius: 2px !important; font-size: 12px !important; color: var(--tinta-texto-3) !important; }
.ws-seg button.on { background: var(--tinta-sup) !important; box-shadow: 0 0 0 1px var(--tinta-borde-2) !important; color: var(--tinta-texto) !important; }
.ws-seg button:focus-visible { outline: none; box-shadow: var(--foco) !important; }

/* ---- Los cobros de un hito, en su ventana ---- */
.ws-cobros-hito { margin: 4px 0 0; padding: 12px 14px; border: 1px solid var(--tinta-borde); border-radius: var(--r-2); }
.ws-cobros-hito legend { padding: 0 6px; font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--tinta-texto-3); }
.ws-cobros-hito-fila { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; color: var(--tinta-texto); cursor: pointer; }
.ws-cobros-hito-fila input { flex: none; width: 16px !important; height: 16px; margin: 0 !important; }
.ws-cobros-hito-fila span { flex: 1; min-width: 0; }
.ws-cobros-hito-fila small { color: var(--tinta-texto-3); font-size: 11.5px; }
.ws-cobros-hito-fila b { font-weight: 400; color: var(--tinta-texto-2); }
.ws-cobros-hito .raver-cobro-accion { margin-top: 8px; }

/* ---- Pantallas angostas ---- */
@media (max-width: 1240px) {
    .ws-proy-cab { flex-direction: column; }
    .ws-siguiente { width: 100%; }
    .ws-horizonte { grid-template-columns: 1fr 1fr; }
    .ws-hor-cobros { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid var(--tinta-borde); }
}
@media (max-width: 760px) {
    .ws-horizonte { grid-template-columns: 1fr; }
    .ws-hor-col + .ws-hor-col { border-left: 0; border-top: 1px solid var(--tinta-borde); }
    .ws-tl { --c1: 150px; --c3: 74px; }
    .ws-tl-c1 { padding: 0 8px; }
    .ws-tl-c3 { padding: 0 8px; gap: 6px; }
    .ws-tl-tarea.nivel-2 .ws-tl-c1 { padding-left: 24px; }
    .ws-h1 { font-size: 22px; line-height: 26px; }
}

@media (prefers-reduced-motion: reduce) {
    .ws-tl-barra > i, .ws-tl-toggle svg { transition-duration: 1ms !important; }
}

/* ---- Ajustes: encabezado de columnas y rótulos que no se pisan ---- */
.ws-tl-cab .ws-rotulo { font-size: 10.5px; font-weight: 500; color: var(--tinta-texto-3); }
.ws-tl-cab .ws-tl-c1, .ws-tl-cab .ws-tl-c3 { align-items: center; }

/* Los carriles crecen cuando los rótulos se apilan en filas (lo decide el JS) */
.ws-tl-carril { --filas: 1; min-height: calc(36px + (var(--filas) - 1) * 15px); }
.ws-tl-carril .ws-tl-c1, .ws-tl-carril .ws-tl-c3 { align-items: flex-start; height: 36px; padding-top: 0; line-height: 36px; }
.ws-tl-carril .ws-tl-c1 { align-items: center; }
.ws-tl-carril .ws-tl-c3 { align-items: center; }
.ws-tl-punto, .ws-tl-hito { top: 18px; }
.ws-tl-punto em, .ws-tl-hito em { top: 50%; transform: translateY(calc(-50% + var(--fila, 0) * 15px)); }

.ws-tl-punto.sin-rotulo em, .ws-tl-hito.sin-rotulo em { display: none; }
.ws-proy { margin-bottom: 24px; }

/* Rótulo dado vuelta cuando se saldría del borde */
.ws-flip.ws-tl-punto.lleno em, .ws-flip.ws-tl-hito.cerrado em { left: auto; right: 16px; }
.ws-flip.ws-tl-punto.vacio em, .ws-flip.ws-tl-hito.abierto em { right: auto; left: 16px; }

/* Carril apilado: rombos arriba, rótulos debajo alineados a su rombo */
.ws-tl-carril.apilado { min-height: calc(42px + var(--filas) * 15px); }
.ws-tl-carril.apilado .ws-tl-punto, .ws-tl-carril.apilado .ws-tl-hito { top: 15px; }
.ws-tl-carril.apilado .ws-tl-punto em, .ws-tl-carril.apilado .ws-tl-hito em { top: 24px; left: -4px; right: auto; transform: translateY(calc(var(--fila, 0) * 15px)); }
.ws-tl-carril.apilado .ws-flip em { left: auto; right: -4px; }

.ws-tl-tick.ws-oculto { visibility: hidden; }

/* Celular: el gantt no se aplasta, se desplaza de costado */
@media (max-width: 760px) {
    .ws-tl { overflow-x: auto; }
    .ws-tl-cab, .ws-tl-cuerpo { min-width: 640px; }
    .ws-tl { --c1: 170px; --c3: 84px; }
}

/* Los botones del carril no llevan el relleno del tema: su ancho es el del rombo */
.ws-tl-hito { padding: 0 !important; line-height: 0; justify-content: center; }
.ws-tl-carril .ws-tl-c1 span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
