/* ════════════════════════════════════════════════════════════════
   NEWS TICKER · estilo "bolsa" — banda full-width bajo el hero
   Reemplaza la antigua .trust-band. Marquee continuo hacia la izquierda,
   pausa en hover, accesible y respeta prefers-reduced-motion.
   ════════════════════════════════════════════════════════════════ */

.ticker {
  position: relative;
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  /* Fondo casi sólido (sin backdrop-filter): el blur sobre contenido en
     movimiento fuerza repaints por frame y genera el "salto" no fluido. */
  background:
    linear-gradient(180deg, rgba(255,255,255,0.025) 0%, rgba(255,255,255,0.01) 100%),
    rgba(11, 15, 26, 0.65);
  margin-top: clamp(40px, 6vh, 72px);
  overflow: hidden;
  --ticker-duration: 110s;         /* fallback; JS lo recalcula por velocidad constante (px/s) */
}

/* Fades laterales · el contenido "aparece/desaparece" en los bordes */
.ticker::before,
.ticker::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(40px, 8vw, 120px);
  z-index: 3;
  pointer-events: none;
}
.ticker::before {
  left: 0;
  background: linear-gradient(90deg, var(--bg) 0%, transparent 100%);
}
.ticker::after {
  right: 0;
  background: linear-gradient(270deg, var(--bg) 0%, transparent 100%);
}

.ticker__inner {
  display: flex;
  align-items: stretch;
}

/* ── Etiqueta fija a la izquierda · "MERCADOS · EN VIVO" ── */
.ticker__label {
  position: relative;
  z-index: 4;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px 0 var(--pad-x);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text);
  background: linear-gradient(90deg, var(--bg) 70%, transparent);
  white-space: nowrap;
}
.ticker__label-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FF6B6B;
  box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.5);
  animation: tickerLiveDot 1.6s ease-out infinite;
  flex-shrink: 0;
}
@keyframes tickerLiveDot {
  0%   { box-shadow: 0 0 0 0 rgba(255,107,107,0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(255,107,107,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,107,107,0); }
}

/* ── Viewport del marquee ── */
.ticker__viewport {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* Pista que se desplaza · contiene 2 sets idénticos para loop sin costuras */
.ticker__track {
  display: flex;
  width: max-content;
  align-items: center;
  animation: tickerScroll var(--ticker-duration) linear infinite;
  /* Compositing en GPU · evita repaints y subpixel jitter del marquee */
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}
.ticker:hover .ticker__track,
.ticker:focus-within .ticker__track {
  animation-play-state: paused;
}
@keyframes tickerScroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }   /* recorre exactamente 1 de los 2 sets */
}

/* ── Item individual · titular · medio · fecha ── */
.ticker__item {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 26px;
  text-decoration: none;
  color: var(--text-secondary);
  white-space: nowrap;
  border-right: 1px solid var(--glass-border);
  transition: color 0.3s ease, background 0.3s ease;
}
.ticker__item:hover {
  color: var(--text);
  background: var(--glass-hover);
}
.ticker__item:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: -2px;
}

/* Flecha tendencia · estilo bolsa */
.ticker__trend {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  flex-shrink: 0;
}
.ticker__trend--up   { color: #6CE26C; background: rgba(82,174,50,0.14); }
.ticker__trend--down { color: #FF8585; background: rgba(255,107,107,0.12); }
.ticker__trend svg { width: 11px; height: 11px; }

/* Medio · monograma + nombre */
.ticker__source {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.ticker__source-mono {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-green), var(--brand-blue));
}
.ticker__source-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ticker__title {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.ticker__time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ── CTA al final · enlace a la página de noticias ── */
.ticker__more {
  position: relative;
  z-index: 4;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 var(--pad-x) 0 18px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--brand-green);
  text-decoration: none;
  background: linear-gradient(270deg, var(--bg) 70%, transparent);
  white-space: nowrap;
  transition: color 0.3s ease;
}
.ticker__more:hover { color: var(--text); }
.ticker__more svg {
  width: 13px; height: 13px;
  transition: transform 0.3s var(--ease);
}
.ticker__more:hover svg { transform: translateX(3px); }

/* Skeleton mientras carga */
.ticker__track--loading .ticker__item {
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .ticker__label { font-size: 10px; padding-right: 14px; }
  .ticker__label-text { display: none; }   /* deja solo el dot en pantallas chicas */
  .ticker__more-text { display: none; }
  .ticker__item { padding: 14px 20px; gap: 10px; }
  .ticker__title { font-size: 12.5px; }
}

/* ── Accesibilidad: sin animación → fila estática desplazable ── */
@media (prefers-reduced-motion: reduce) {
  .ticker__track { animation: none; }
  .ticker__viewport {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .ticker__viewport::-webkit-scrollbar { display: none; }
  /* Con scroll manual no necesitamos el set duplicado visible */
  .ticker__track[data-duplicated] .ticker__set--dupe { display: none; }
}
