/* ══════════════════════════════════════════════════════════════════
   GELATOMAPS — STREAKS CSS v1.0
   Badge de racha de votación en el header + mini-panel expandible.

   Scope: solo el badge visible en .hdr-user-area (index.html).
   Los estilos de celebración post-voto siguen en votar.css
   (.celeb-streak, .celeb-streak-num, .success-streak-banner).

   Autor: Dpto 06 UX & Diseño — GelatoMaps
   Fecha: 30 Mar 2026
   ══════════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────
   BADGE PRINCIPAL
   ────────────────────────────────────────────────────────────── */

.streak-badge {
  display: none;                    /* JS lo muestra cuando streak >= 2 */
  align-items: center;
  gap: var(--sp-2xs);
  padding: 5px 10px;
  background: linear-gradient(135deg, var(--color-streak-from), var(--color-streak-mid));
  border-radius: var(--radius-pill);
  color: var(--color-white);
  font-family: var(--font-body);
  font-size: var(--font-sm);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  /* Touch target mínimo WCAG 44px */
  min-height: 32px;
  min-width: 44px;
  /* Transiciones */
  transition:
    transform var(--pf-dur-release) var(--pf-spring),
    box-shadow var(--transition);
  /* Posición — a la izquierda del avatar, con separación */
  margin-right: var(--sp-sm);
  position: relative;
}

.streak-badge:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px var(--color-streak-from-a40);
}

.streak-badge:focus-visible {
  outline: 2px solid var(--color-white);
  outline-offset: 2px;
}

.streak-flame {
  font-size: 15px;
  line-height: 1;
}

.streak-count {
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.streak-label {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.90;
  white-space: nowrap;
}

/* ──────────────────────────────────────────────────────────────
   VARIANTE URGENTE (days_until_reset <= 2)
   ────────────────────────────────────────────────────────────── */

.streak-badge.streak-urgent {
  background: linear-gradient(135deg, var(--color-error), var(--color-error-mid));
  animation: streak-urgent-pulse 2s ease-in-out infinite;
}

.streak-badge.streak-urgent:hover {
  box-shadow: 0 4px 12px var(--color-error-a40);
}

@keyframes streak-urgent-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--color-error-a40); }
  50%       { box-shadow: 0 0 0 5px transparent; }
}

/* ──────────────────────────────────────────────────────────────
   ANIMACIÓN AL SUBIR RACHA
   ────────────────────────────────────────────────────────────── */

.streak-badge.streak-pulse {
  animation: streak-pop 300ms var(--pf-spring) forwards;
}

@keyframes streak-pop {
  0%   { transform: scale(1); filter: brightness(1); }
  40%  { transform: scale(1.35); filter: brightness(1.25); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* ──────────────────────────────────────────────────────────────
   FADE-IN al aparecer por primera vez (JS añade la clase)
   ────────────────────────────────────────────────────────────── */

.streak-badge.streak-visible {
  display: flex;
  animation: streak-fade-in var(--pf-dur-enter) var(--pf-out-expo) forwards;
}

@keyframes streak-fade-in {
  from { opacity: 0; transform: scale(0.75) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ──────────────────────────────────────────────────────────────
   TOOLTIP / MINI-PANEL
   ────────────────────────────────────────────────────────────── */

.streak-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-primary);
  border: 1px solid var(--color-border-md);
  border-radius: var(--radius-md);
  padding: var(--sp-md) var(--sp-base);
  min-width: 190px;
  box-shadow: var(--sh-dark-lg);
  color: var(--color-text-on-dark);
  font-family: var(--font-body);
  font-size: var(--font-sm);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s var(--pf-spring);
}

.streak-badge:hover .streak-tooltip,
.streak-badge:focus-within .streak-tooltip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.streak-tooltip-title {
  font-weight: 700;
  color: var(--color-white);
  margin-bottom: var(--sp-xs);
}

.streak-tooltip-row {
  display: flex;
  justify-content: space-between;
  color: var(--color-text-on-dark-mid);
  margin-bottom: 3px;
}

.streak-tooltip-row strong {
  color: var(--color-white);
}

.streak-tooltip-next {
  margin-top: var(--sp-xs);
  padding-top: var(--sp-xs);
  border-top: 1px solid var(--color-border);
  color: var(--color-accent-light);
  font-size: var(--font-xs);
}

.streak-tooltip-urgent {
  color: var(--color-error-light);
  font-size: var(--font-xs);
  margin-top: var(--sp-xs);
}

/* ══════════════════════════════════════════════════════════════════
   STREAK FASE 2 — Mini-panel expandible
   Mejoras al tooltip: barra de progreso, último voto, CTA "Votar hoy"
   Autor: Dpto 06 UX & Diseño — 30 Mar 2026
   ══════════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────
   BARRA DE PROGRESO — al próximo hito
   ────────────────────────────────────────────────────────────── */

.streak-progress-wrap {
  margin: var(--sp-sm) 0 var(--sp-xs);
}

.streak-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--font-xs);
  color: var(--color-text-on-dark-mid);
  margin-bottom: 5px;
}

.streak-progress-label strong {
  color: var(--color-accent-light);
  font-size: var(--font-xs);
  font-weight: 700;
}

.streak-progress-track {
  background: var(--color-border);
  border-radius: var(--radius-pill);
  height: 5px;
  overflow: hidden;
}

.streak-progress-bar {
  height: 100%;
  width: 0%;  /* JS lo setea via style.width */
  background: linear-gradient(90deg, var(--color-streak-from), var(--color-streak-to));
  border-radius: var(--radius-pill);
  transition: width 0.5s var(--pf-out-expo);
  /* Respeta prefers-reduced-motion — ver sección al final */
}

/* ──────────────────────────────────────────────────────────────
   ÚLTIMO VOTO — fila informativa en el panel
   ────────────────────────────────────────────────────────────── */

.streak-last-vote {
  font-size: var(--font-xs);
  color: var(--color-text-on-dark-mid);
  margin-bottom: var(--sp-2xs);
  display: flex;
  align-items: center;
  gap: var(--sp-2xs);
}

/* Último sabor votado — visible solo cuando last_vote_sabor !== null */
.streak-last-sabor {
  font-size: var(--font-xs);
  color: var(--color-text-on-dark-mid);
  margin-bottom: var(--sp-xs);
  display: flex;
  align-items: center;
  gap: var(--sp-2xs);
}

/* ──────────────────────────────────────────────────────────────
   CTA "VOTAR HOY" — botón en el panel cuando no ha votado hoy
   ────────────────────────────────────────────────────────────── */

.streak-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  margin-top: var(--sp-sm);
  padding: 8px var(--sp-md);
  background: var(--color-accent);
  color: var(--color-white);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--font-xs);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  min-height: 36px;   /* touch-friendly dentro del panel */
  transition: background var(--transition-fast), transform var(--pf-dur-press) var(--pf-press-in);
  cursor: pointer;
  border: none;
  width: 100%;
  box-sizing: border-box;
}

.streak-cta-btn:hover {
  background: var(--color-accent-dark);
  transform: translateY(-1px);
}

.streak-cta-btn:active {
  transform: translateY(0);
}

/* Cuando ya votó hoy — estado "check" verde */
.streak-cta-btn.streak-voted-today {
  background: var(--color-success);
  cursor: default;
}

.streak-cta-btn.streak-voted-today:hover {
  background: var(--color-success);
  transform: none;
}

/* ──────────────────────────────────────────────────────────────
   PANEL EXPANDIDO (estado abierto vía JS)
   Clase .streak-panel--open añadida por _toggleStreakTooltip()
   ────────────────────────────────────────────────────────────── */

/* El tooltip ya tiene hover-triggered opacity en reglas anteriores.
   Cuando está abierto via click, se mantiene visible incluso sin hover. */
.streak-badge.streak-panel--open .streak-tooltip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Separador antes del CTA */
.streak-tooltip-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--sp-xs) 0;
}

/* ──────────────────────────────────────────────────────────────
   MOBILE — tablet/mobile: solo flame + número, sin label
   ────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .streak-label {
    display: none;
  }

  .streak-badge {
    padding: 5px 9px;
  }
}

/* Tooltip siempre a la derecha en mobile */
@media (max-width: 480px) {
  .streak-tooltip {
    right: -10px;
    min-width: 170px;
  }
}

/* ──────────────────────────────────────────────────────────────
   MILESTONE — banner dorado en pantalla éxito votar.html (Fase 2B)
   ────────────────────────────────────────────────────────────── */

#success-streak-banner.streak-milestone {
  background: linear-gradient(135deg, var(--color-gold-pure, #FFD700), var(--color-gold-pure-mid, #FFC700)) !important;
  animation: streak-pop 400ms var(--pf-spring, cubic-bezier(0.34,1.56,0.64,1)) forwards;
}

/* ──────────────────────────────────────────────────────────────
   ACCESIBILIDAD — prefers-reduced-motion
   ────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .streak-badge {
    transition: none;
  }
  .streak-badge.streak-pulse {
    animation: none;
  }
  .streak-badge.streak-visible {
    animation: none;
  }
  .streak-badge.streak-urgent {
    animation: none;
  }
  .streak-tooltip {
    transition: none;
  }
  /* Fase 2 — desactivar animaciones del panel */
  .streak-progress-bar {
    transition: none;
  }
  .streak-cta-btn {
    transition: none;
  }
  /* Fase 2B — milestone banner sin animación */
  #success-streak-banner.streak-milestone {
    animation: none;
  }
}
