/* ========================================
   Tournament section nav — tabs sticky bajo el título del torneo.
   Única navegación de las sub-secciones (Resumen · Pronosticar · Mis pálpitos ·
   Fixture · Tabla · Premio · Salas). Markup en
   app/views/tournaments/_section_nav.html.erb.

   MOBILE: segmento tipo grilla — ícono arriba + ETIQUETA abajo, SIEMPRE
   visibles (antes solo la activa mostraba texto y la gente no encontraba la
   Tabla). Entran ~5 por fila y las demás bajan a una segunda fila (sin scroll).
   DESKTOP: fila horizontal con ícono + texto al lado, sticky bajo el ribbon.
   ======================================== */
/* Frame de contenido del torneo: al cambiar de tab solo se recarga ESTE frame.
   Mientras Turbo trae el contenido ([busy]), mostramos un scrim + spinner sobre
   el contenido anterior, así la espera no se ve "colgada". */
#tournament_tab { position: relative; display: block; }
#tournament_tab[busy] { pointer-events: none; }
#tournament_tab[busy]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 50%, transparent);
  backdrop-filter: blur(1px);
}
#tournament_tab[busy]::after {
  content: "";
  /* Fijo y centrado en el viewport (antes quedaba absolute cerca del tope del
     frame → tapado por el menú sticky). z-index alto para verse por encima. */
  position: fixed;
  top: 50%;
  left: 50%;
  /* Centrado con margin (no translate): el translate chocaba con la animación
     rotate y el spinner se movía en diagonal. Con margin, transform solo rota. */
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  z-index: 60;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: tt-spin 0.7s linear infinite;
}
@keyframes tt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  #tournament_tab[busy]::after { animation: none; }
}

/* Salas dentro del torneo (tab Salas, vista enfocada — mantiene hero + tabs). */
.tournament-salas__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 16px;
  flex-wrap: wrap;
}
.tournament-salas__lead { color: var(--muted); font-size: 13px; margin: 0; }
.tournament-salas__all { margin: 18px 0 0; text-align: center; }
.tournament-salas__all a { color: var(--accent); font-size: 13px; }

.tnav {
  display: flex;
  gap: 4px;
  /* Mobile: barra full-bleed (rompe el padding de .content con margin negativo)
     — al quedar sticky se lee como un toolbar limpio de borde a borde en vez de
     una pill flotante recortada. Padding lateral = --content-pad para alinear
     los tabs con el contenido. Desktop la vuelve a pill (ver media query). */
  margin: 0 calc(-1 * var(--content-pad)) 18px;
  padding: 6px var(--content-pad);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  /* Casi opaco: al quedar sticky el contenido pasa por debajo sin verse a
     través (antes 82% dejaba "colarse" el contenido detrás). */
  background: color-mix(in srgb, var(--bg) 97%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  /* Sticky también en mobile: queda fija JUSTO debajo del header (topbar +
     banda "en línea"). --header-h lo publica topbar_controller midiendo el alto
     real; el fallback cubre el primer paint antes de que corra el JS. */
  position: sticky;
  top: var(--header-h, calc(var(--topbar-height) + var(--active-band-height) + env(safe-area-inset-top)));
  z-index: 20;
}

.tnav__tab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Ícono arriba (flex-start): así TODAS las tabs alinean el ícono a la misma
     altura aunque una etiqueta envuelva a 2 líneas (antes "centradas" la subían). */
  justify-content: flex-start;
  gap: 6px;
  padding: 9px 3px;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 600;
  font-size: 10.5px;
  text-align: center;
  text-decoration: none;
  line-height: 1.1;
  transition: color 150ms, background 150ms;
}
.tnav__tab svg { width: 18px; height: 18px; opacity: 0.85; flex: none; }
/* Etiqueta: todas en una línea ahora ("Pálpitos"), altura consistente. */
.tnav__tab > span:not(.tnav__badge) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.3em;
  white-space: nowrap;
}
.tnav__tab:hover { color: var(--ink); background: var(--card); }
.tnav__tab.-active {
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.tnav__tab.-active svg { opacity: 1; }

/* Contador de pendientes en "Mis pálpitos" — burbuja en la esquina del tab. */
.tnav__badge {
  position: absolute;
  top: 3px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--coral);
  color: #2a0d09;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}
.tnav__tab.-active .tnav__badge { background: rgba(42, 13, 9, 0.2); color: var(--accent-ink); }

/* Desktop: fila horizontal (ícono + texto al lado), pill, sticky bajo el ribbon. */
@media (min-width: 720px) {
  .tnav {
    display: flex;
    flex-wrap: wrap;
    /* Reset del full-bleed mobile: vuelve a pill con márgenes/borde normales. */
    margin: 0 0 20px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--bg-2);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  .tnav__tab {
    flex: 0 1 auto;
    flex-direction: row;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius-pill);
    font-size: 13.5px;
    line-height: 1;
  }
  .tnav__tab svg { width: 16px; height: 16px; }
  /* En desktop la etiqueta es inline (fila), sin reserva de 2 líneas. */
  .tnav__tab > span:not(.tnav__badge) { min-height: 0; display: inline; }
  /* En desktop el badge vuelve a ser inline, al lado del texto. */
  .tnav__badge {
    position: static;
    margin-left: 2px;
  }
}
