/* Arquitectura de navegación (REDISENO-MOVIL-MAD.md, Fase 1 §6-§10; maquetas en
   docs/mocks/movil/). Se carga ÚLTIMA: pisa el layout viejo de app.css, componentes.css
   y arreglos.css. Lo que se pinta depende de `body[data-nav]` (js/ui/navegacion.js):
   raiz · seccion (tablero) · empujada (ficha, Git), y de los altos que publica
   js/ui/pieFijo.js (--alto-pestanas, --alto-composer, --pie-alto). */

/* ── Encabezado raíz: título grande + Mac + 2 íconos ─────────────────────── */
.top-fila { min-height: 52px; gap: var(--sp-2); padding: var(--sp-1) var(--borde-x) var(--sp-1); }

.top-titulo {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
}

/* En Inicio el título es la marca, chica y en ámbar (maqueta 1). */
.top-titulo.marca-txt { font: 800 var(--fs-lg) / 1 inherit; letter-spacing: 0.08em; color: var(--accent); }

/* La píldora de la Mac activa con el punto de conexión (selectorAmbito.js). */
.top-fila .ambito { padding: 5px 11px; border: 0; background: var(--fill); color: var(--muted); font-size: var(--fs-sm); max-width: 11rem; }
.top-fila .ambito.sola { cursor: default; }
.top-fila .ambito-punto:not(.off) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }

/* Buscar y Actividad: círculos de 38 px sobre superficie, como en la maqueta. */
.top-fila .lupa {
  position: relative;
  width: 38px;
  height: 38px;
  border: 0;
  background: var(--fill);
  color: var(--ink);
}

/* El contador se monta sobre el ícono de Actividad (js/componentes/actividad.js). */
.campana-n {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 15px;
  padding: 0 3px;
  border-radius: var(--r-pill);
  background: var(--ok);
  color: var(--ground);
  font: 800 var(--fs-xs) / 15px inherit;
  text-align: center;
}

.campana-n[hidden] { display: none; }

.lupa.actividad .campana-n { top: -3px; right: -3px; background: var(--accent-grad); background-color: var(--accent); color: var(--on-accent); }

/* Con contexto (tablero, ficha, Git) el renglón raíz se va: manda «‹ dónde estoy». */
.top.en-ficha .top-fila { display: none; }

.top-ctx,
.top.en-ficha .top-ctx {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 52px;
  padding: var(--sp-1) var(--borde-x);
  border-top: 0;
  background: none;
}

.top-ctx[hidden],
.top.en-ficha .top-ctx[hidden] { display: none; }

.ctx-atras { width: 38px; height: 38px; color: var(--ink); background: var(--fill); }
.ctx-atras svg { margin-left: -2px; }

.ctx-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ctx-chico,
.ctx-grande { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; }
.ctx-chico { color: var(--faint); font-size: 11px; letter-spacing: 0.02em; }
.ctx-chico > * { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ctx-chico > * + *::before { content: '·'; margin-right: 6px; color: var(--faint); }
.ctx-chico .ctx-cod { color: var(--accent); font: 650 11px / 1.3 ui-monospace, SFMono-Regular, Menlo, monospace; flex: none; }
.ctx-chico .ctx-mac::before { content: none; }
.ctx-grande { font-size: 15.5px; font-weight: 650; color: var(--ink); }
.ctx-grande .ctx-tit { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: inherit; font-size: inherit; line-height: 1.25; }
.ctx-grande .ctx-tit::before { content: none; }
.ctx-ident { display: inline-flex; flex: none; }

/* ── Pestañas: cápsula de vidrio flotante ───────────────────────────────── */
.tabs {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(10px + var(--safe-bottom));
  z-index: var(--z-pie);
  height: 64px;
  padding: 0;
  border: 1px solid var(--line-hi);
  border-radius: 26px;
  background-color: var(--vidrio);
  background-image: none;
  backdrop-filter: var(--blur-vidrio);
  -webkit-backdrop-filter: var(--blur-vidrio);
  box-shadow: var(--sh-md);
}

.tab { position: relative; gap: 3px; font-size: 10.5px; cursor: pointer; }
.tab .tab-icono,
.tab.activa .tab-icono {
  display: grid;
  place-items: center;
  width: 52px;
  height: 28px;
  padding: 0;
  border-radius: 14px;
  filter: none;
  text-shadow: none;
}
.tab.activa .tab-icono { background: color-mix(in srgb, var(--accent) 15%, transparent); }

.tab-badge {
  position: absolute;
  top: 5px;
  left: calc(50% + 6px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  border: 2px solid var(--panel);
  background: var(--st-error);
  color: #fff;
  font: 700 10px / 14px inherit;
  text-align: center;
}
.tab-badge[hidden] { display: none; }

/* ── El «+» flotante (FAB), en la zona del pulgar ───────────────────────── */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--techo-pie, 84px) + 14px);
  z-index: var(--z-pie);
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: var(--accent);
  background-image: var(--accent-grad);
  color: var(--on-accent);
  box-shadow: var(--accent-sh), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: transform 160ms ease, bottom 150ms ease;
}
.fab[hidden] { display: none; }
.fab:active { transform: scale(0.94); }
.fab svg { transition: transform 160ms ease; }
/* Con el alta del tablero abierta el «+» gira a ✕: el mismo botón la cierra. */
.alta-abierta .fab svg { transform: rotate(45deg); }

/* ── Contenido y testigo según el pie ───────────────────────────────────── */
/* Raíces y tablero: el contenido corre por DEBAJO de la cápsula (para eso es de vidrio)
   y reserva su alto al final del scroll; el testigo se apoya encima de la cápsula. */
.contenido { padding-bottom: calc(var(--pie-alto, 0px) + 16px); }
.app > .testigo { margin-bottom: calc(var(--alto-pestanas, 0px) + var(--sp-2)); }
.app:has(> .testigo:not([hidden])) > .contenido { padding-bottom: var(--sp-4); }
body[data-nav='raiz'] .app:has(> .fab:not([hidden])) > .contenido,
body[data-nav='seccion'] .app:has(> .fab:not([hidden])) > .contenido { padding-bottom: calc(var(--pie-alto, 0px) + 84px); }
/* En Inicio «Ahora» ya muestra los turnos: el testigo repetiría lo mismo. */
body[data-ruta='/inicio'] .app > .testigo { display: none; }

/* Empujadas (y el alta del tablero): sin pestañas ni FAB; el composer fijo abajo como
   en un chat y la grilla termina ARRIBA de él, así nada del flujo queda tapado. */
body[data-nav='empujada'] .tabs,
body[data-nav='empujada'] .fab,
body.alta-abierta .tabs { display: none; }
body[data-nav='empujada'] .app,
body.alta-abierta .app { padding-bottom: var(--alto-composer, 0px); }
body[data-nav='empujada'] .app > .contenido,
body.alta-abierta .app > .contenido { padding-bottom: var(--sp-4); }
body[data-nav='empujada'] .app > .testigo,
body.alta-abierta .app > .testigo { margin-bottom: var(--sp-2); }

body[data-nav='empujada'] .composer,
body.alta-abierta .composer {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 0;
  z-index: var(--z-pie);
  margin: 0;
  /* Lo justo para no pisar la barra de inicio del iPhone; sin inset (Android) deja 12px
     de aire para que los botones no queden pegados a la barra de gestos. */
  padding-bottom: max(var(--sp-3), calc(env(safe-area-inset-bottom, 0px) - 20px));
  border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background-color: var(--panel-velo);
  box-shadow: var(--sh-alza);
}
body[data-nav='empujada'] .pantalla:has(> .composer) { min-height: 0; }

/* El alta del tablero vive plegada: la despliega el «+». */
body[data-nav='seccion']:not(.alta-abierta) .composer { display: none; }
body.alta-abierta .fab { bottom: calc(var(--alto-composer, 0px) + 12px); width: 44px; height: 44px; }

/* Toasts y «↓ al final» esquivan lo que haya al pie. */
.toasts,
.app:has(> .testigo:not([hidden])) .toasts { bottom: calc(var(--techo-pie, 0px) + var(--sp-3)); }

/* ── Pull-to-refresh (js/ui/tirarRefrescar.js) ─────────────────────────────── */
.ptr {
  position: fixed;
  top: calc(var(--safe-top) + 44px);
  left: 50%;
  z-index: var(--z-aviso);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-pill);
  background: var(--panel-velo);
  color: var(--muted);
  font-size: var(--fs-sm);
  box-shadow: var(--sh-sm);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(var(--ptr-y, 0px) - 30px));
}
.ptr.visible { opacity: 1; }
.ptr.listo { color: var(--accent); }
.ptr-flecha { display: inline-block; transition: transform 150ms ease; }
.ptr.listo .ptr-flecha { transform: rotate(180deg); }

/* ── Carga por ruta (js/core/router.js) ─────────────────────────────────── */
/* Lo que se ve si una pantalla tarda en bajar (o no se pudo): breve y centrado. */
.cargando-ruta { min-height: 40vh; align-items: center; justify-content: center; color: var(--muted); text-align: center; }
.cargando-ruta p { margin: 0; font-size: var(--fs-sm); }
.cargando-ruta .giro {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-hi);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}
