/* Crypto Atalaya · PWA de noticias
   Tema unico oscuro: la paleta sale del logo (noche azul-negra + haz dorado).
   Todo pensado primero para el iPhone en pantalla completa. */

:root {
  --fondo: #070b14;
  --fondo-2: #0b1120;
  --superficie: #111a2b;
  --superficie-2: #16213a;
  --borde: rgba(255, 255, 255, .07);
  --borde-vivo: rgba(245, 182, 10, .35);
  --texto: #eef2f8;
  --texto-2: #97a3b8;
  --texto-3: #64748b;
  --oro: #f5b60a;
  --oro-claro: #ffd45e;

  /* Un color por categoria: el mismo criterio que los emojis del bot. */
  --c-mercado: #34d399;
  --c-regulacion: #fb923c;
  --c-institucional: #f5b60a;
  --c-seguridad: #f87171;
  --c-lanzamiento: #c084fc;
  --c-general: #60a5fa;

  --seguro-arriba: env(safe-area-inset-top, 0px);
  --seguro-abajo: env(safe-area-inset-bottom, 0px);
  --alto-cabecera: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--fondo); }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--texto);
  background: var(--fondo);
  /* El haz del faro: un resplandor dorado muy tenue arriba del todo. */
  background-image:
    radial-gradient(120% 60% at 50% -10%, rgba(245, 182, 10, .13), transparent 60%),
    radial-gradient(80% 40% at 80% 5%, rgba(96, 165, 250, .08), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body.bloqueado { overflow: hidden; }

/* ---------- Cabecera ---------- */
.cabecera {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(var(--seguro-arriba) + 8px) 16px 8px;
  background: rgba(7, 11, 20, .72);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--borde);
}

.marca { display: flex; align-items: center; gap: 10px; min-width: 0; }
.marca-icono { border-radius: 8px; flex: none; }
.marca-texto { display: flex; flex-direction: column; min-width: 0; }
.marca-texto strong {
  font-size: 14px; letter-spacing: .14em; font-weight: 700;
  background: linear-gradient(92deg, var(--oro-claro), var(--oro) 60%, #b98707);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.estado {
  font-size: 11px; color: var(--texto-3);
  display: flex; align-items: center; gap: 5px; margin-top: 1px;
}
.punto {
  width: 6px; height: 6px; border-radius: 50%; background: var(--c-mercado);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .6);
  animation: latido 2.6s infinite;
}
@keyframes latido {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, .5); }
  70%  { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.boton-recargar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--borde); background: var(--superficie);
  color: var(--texto-2); display: grid; place-items: center;
  transition: transform .5s, color .2s;
}
.boton-recargar:active { transform: scale(.92); color: var(--oro); }
.boton-recargar.girando svg { animation: giro .9s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }

/* Aviso flotante de noticias nuevas */
.aviso-nuevas {
  position: fixed; z-index: 45;
  top: calc(var(--seguro-arriba) + var(--alto-cabecera) + 10px);
  left: 50%; transform: translateX(-50%);
  border: 1px solid var(--borde-vivo); border-radius: 999px;
  background: rgba(245, 182, 10, .16);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--oro-claro); font-size: 13px; font-weight: 600;
  padding: 8px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  animation: baja .35s ease;
}
@keyframes baja { from { opacity: 0; transform: translate(-50%, -14px); } }

/* ---------- Carrusel ---------- */
.destacadas { padding-top: 14px; }

.carrusel {
  display: flex; gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 0 16px 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.carrusel::-webkit-scrollbar { display: none; }

.tarjeta-grande {
  position: relative; flex: 0 0 86%; scroll-snap-align: center;
  min-height: 208px; border-radius: 20px; overflow: hidden;
  border: 1px solid var(--borde);
  background: linear-gradient(160deg, var(--superficie-2), var(--superficie) 55%, var(--fondo-2));
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 16px; text-align: left; color: inherit;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  transition: transform .18s ease;
}
.tarjeta-grande:active { transform: scale(.985); }

/* Barra de color de la categoria */
.tarjeta-grande::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--color-cat);
  box-shadow: 0 0 18px var(--color-cat);
}
/* Resplandor de categoria en la esquina */
.tarjeta-grande::after {
  content: ""; position: absolute; inset: -40% 40% 55% -30%;
  background: radial-gradient(circle, var(--color-cat), transparent 70%);
  opacity: .16; pointer-events: none;
}

.tarjeta-grande .foto {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: .5;
}
.tarjeta-grande .velo-foto {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(7, 11, 20, .96) 22%, rgba(7, 11, 20, .55) 60%, rgba(7, 11, 20, .3));
}

/* Sin foto: el logo de la cripto hace de sello, grande y tenue detras del
   titular. Da cuerpo a la tarjeta sin competir con el texto. */
.tarjeta-grande .sello {
  position: absolute; top: -14px; right: -18px;
  width: 148px; height: 148px; object-fit: contain;
  opacity: .17; filter: saturate(120%);
  pointer-events: none;
}

.tarjeta-grande h2 {
  position: relative; margin: 10px 0 0;
  font-size: 19px; line-height: 1.28; font-weight: 700; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.tarjeta-grande .pie {
  position: relative; margin-top: 10px;
  font-size: 11.5px; color: var(--texto-3);
  display: flex; align-items: center; gap: 8px;
}

.etiqueta {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px;
  color: var(--color-cat);
  background: color-mix(in srgb, var(--color-cat) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-cat) 30%, transparent);
}

.puntos { display: flex; justify-content: center; gap: 6px; padding: 12px 0 4px; }
.puntos i {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255, 255, 255, .18); transition: all .25s;
}
.puntos i.activo { width: 18px; border-radius: 3px; background: var(--oro); }

/* ---------- Filtros ---------- */
.filtros {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 6px 16px 14px; scrollbar-width: none;
}
.filtros::-webkit-scrollbar { display: none; }
.filtro {
  flex: none; border: 1px solid var(--borde); border-radius: 999px;
  background: var(--superficie); color: var(--texto-2);
  font-size: 13px; font-weight: 600; padding: 8px 14px;
  transition: all .18s;
}
.filtro.activo {
  color: var(--fondo); background: linear-gradient(180deg, var(--oro-claro), var(--oro));
  border-color: transparent; font-weight: 700;
}

/* ---------- Historico ---------- */
.historico { padding: 0 16px calc(30px + var(--seguro-abajo)); }

.dia {
  position: sticky; top: calc(var(--seguro-arriba) + var(--alto-cabecera));
  z-index: 20;
  margin: 18px 0 10px; padding: 6px 0;
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--texto-3);
  background: linear-gradient(to bottom, var(--fondo) 65%, transparent);
  display: flex; align-items: baseline; gap: 8px;
}
.dia span { color: var(--texto-3); opacity: .6; font-weight: 500; letter-spacing: .04em; }

.tarjeta {
  display: flex; gap: 12px; width: 100%; text-align: left;
  padding: 12px; margin-bottom: 10px;
  border: 1px solid var(--borde); border-radius: 16px;
  background: var(--superficie); color: inherit;
  transition: transform .16s ease, border-color .2s;
}
.tarjeta:active { transform: scale(.985); border-color: var(--borde-vivo); }

.tarjeta .miniatura {
  flex: none; width: 76px; height: 76px; border-radius: 12px; object-fit: cover;
  background: var(--superficie-2);
}
/* Sin foto: cuadro con el emoji de la categoria, mismo hueco visual */
.tarjeta .emblema {
  flex: none; width: 76px; height: 76px; border-radius: 12px;
  display: grid; place-items: center; font-size: 26px;
  background:
    radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--color-cat) 22%, transparent), transparent 70%),
    var(--superficie-2);
  border: 1px solid color-mix(in srgb, var(--color-cat) 22%, transparent);
}
.tarjeta .emblema img { width: 42px; height: 42px; object-fit: contain; }
.tarjeta .texto { min-width: 0; flex: 1; }
.tarjeta h3 {
  margin: 4px 0 0; font-size: 15px; line-height: 1.32; font-weight: 650;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tarjeta .cabeza { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tarjeta .hora { font-size: 11px; color: var(--texto-3); flex: none; font-variant-numeric: tabular-nums; }
.tarjeta .mini-etiqueta {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--color-cat);
  display: inline-flex; align-items: center; gap: 5px;
}
.tarjeta .mini-etiqueta::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-cat); box-shadow: 0 0 8px var(--color-cat);
}

/* ---------- Ficha de la noticia ---------- */
.velo {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3, 6, 12, .72);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: aparece .2s ease;
}
@keyframes aparece { from { opacity: 0; } }

.ficha {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0;
  max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--borde);
  background: linear-gradient(180deg, var(--superficie) 0%, var(--fondo-2) 40%);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .6);
  animation: sube .28s cubic-bezier(.22, 1, .36, 1);
  padding-bottom: calc(20px + var(--seguro-abajo));
}
@keyframes sube { from { transform: translateY(100%); } }

.ficha-asa {
  position: sticky; top: 0; z-index: 2;
  padding: 10px 0 6px; display: flex; justify-content: center;
  background: linear-gradient(to bottom, var(--superficie), transparent);
}
.ficha-asa::after {
  content: ""; width: 38px; height: 4px; border-radius: 2px;
  background: rgba(255, 255, 255, .22);
}
.ficha-cuerpo { padding: 4px 20px 0; }
.ficha-foto {
  width: calc(100% + 40px); margin: 0 -20px 16px; display: block;
  max-height: 46vh; object-fit: cover;
}
/* Cabecera de la ficha cuando no hay foto: el logo de la cripto sobre el
   color de su categoria, ocupando el mismo sitio que ocuparia la imagen. */
.ficha-sello {
  width: calc(100% + 40px); margin: 0 -20px 4px;
  padding: 30px 20px 26px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background:
    radial-gradient(70% 100% at 50% 0%, color-mix(in srgb, var(--color-cat) 24%, transparent), transparent 70%),
    linear-gradient(180deg, var(--superficie-2), transparent);
  border-bottom: 1px solid var(--borde);
}
.ficha-sello img { width: 76px; height: 76px; object-fit: contain; }
.ficha-sello span {
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--texto-2);
}

.ficha h2 {
  margin: 12px 0 0; font-size: 23px; line-height: 1.24; letter-spacing: -.015em;
}
.ficha .fecha { margin-top: 10px; font-size: 12px; color: var(--texto-3); }
.ficha p.cuerpo {
  margin: 16px 0 0; font-size: 16px; line-height: 1.62; color: #d6dced;
  white-space: pre-wrap;
}
.analisis {
  margin-top: 18px; padding: 14px 16px;
  border-radius: 14px; border: 1px solid var(--borde);
  border-left: 3px solid var(--oro);
  background: linear-gradient(100deg, rgba(245, 182, 10, .09), rgba(245, 182, 10, .02));
  font-size: 15px; line-height: 1.58; color: #e7ddc4;
  white-space: pre-wrap;
}
.analisis strong {
  display: block; margin-bottom: 6px; color: var(--oro);
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
}
.acciones { display: flex; gap: 10px; margin-top: 22px; }
.accion {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px; border-radius: 14px; font-size: 14px; font-weight: 650;
  border: 1px solid var(--borde); background: var(--superficie-2);
  color: var(--texto); text-decoration: none;
}
.accion.primaria {
  background: linear-gradient(180deg, var(--oro-claro), var(--oro));
  color: #1a1204; border-color: transparent;
}
.accion:active { transform: scale(.97); }

/* ---------- Estados ---------- */
.cargando { display: flex; justify-content: center; gap: 6px; padding: 22px 0 34px; }
.cargando i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--texto-3);
  animation: rebote 1.1s infinite ease-in-out;
}
.cargando i:nth-child(2) { animation-delay: .15s; }
.cargando i:nth-child(3) { animation-delay: .3s; }
@keyframes rebote { 0%, 80%, 100% { opacity: .25; transform: translateY(0); }
                    40% { opacity: 1; transform: translateY(-5px); } }

.fin { text-align: center; color: var(--texto-3); font-size: 12.5px;
       padding: 8px 0 34px; }

.vacio { text-align: center; padding: 56px 24px; color: var(--texto-2); }
.vacio .faro { font-size: 44px; display: block; margin-bottom: 14px; opacity: .8; }
.vacio h2 { font-size: 17px; margin: 0 0 8px; color: var(--texto); }
.vacio p { font-size: 14px; line-height: 1.55; margin: 0; color: var(--texto-3); }

/* Esqueleto mientras carga la primera vez */
.hueso {
  border-radius: 20px; flex: 0 0 86%; min-height: 208px;
  background: linear-gradient(100deg, var(--superficie) 30%, var(--superficie-2) 50%, var(--superficie) 70%);
  background-size: 220% 100%; animation: brillo 1.4s infinite;
}
@keyframes brillo { to { background-position: -120% 0; } }

button { font: inherit; cursor: pointer; }
a { color: var(--oro); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Pantallas grandes: la app se queda centrada, como en el movil */
@media (min-width: 620px) {
  body { max-width: 600px; margin: 0 auto;
         border-inline: 1px solid var(--borde); min-height: 100vh; }
  .cabecera { max-width: 600px; margin: 0 auto; }
  .tarjeta-grande { flex-basis: 76%; }
}
