/* =============================================================================
   estilos.css — Aspecto visual de hashciv
   -----------------------------------------------------------------------------
   Todos los colores y medidas importantes están como "variables" (--nombre)
   aquí arriba: si quieres retocar la paleta, cámbialos en un solo sitio.
   Los colores del propio mapa (hexágonos) están en js/mapa.js, porque se
   dibujan con JavaScript sobre un <canvas>.
   ============================================================================= */
:root {
  --fondo: #0b1524;          /* azul marino oscuro de fondo */
  --fondo-2: #101d31;        /* paneles */
  --fondo-3: #16263d;        /* cajas dentro de paneles */
  --borde: #24364f;
  --texto: #e7ecf3;
  --texto-tenue: #8d9bb0;
  --naranja: #f7931a;        /* naranja Bitcoin: el color de acento */
  --naranja-oscuro: #c46f0a;
  --verde: #6fcf6a;
  --rojo: #ef5b4c;
  --ancho-panel: 330px;
  --alto-barra: 56px;
  --fuente-titulo: 'Cinzel', Georgia, serif;
  --fuente-texto: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--fuente-texto);
  font-size: 14px;
  /* Evita que el navegador haga sus propios gestos (zoom de página, rebote) */
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--naranja); }

.icono { width: 15px; height: 15px; vertical-align: -2px; margin-right: 5px; }

/* ===================== BARRA SUPERIOR ===================== */
.barra {
  height: var(--alto-barra);
  flex: none;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 16px;
  border-bottom: 1px solid var(--borde);
  background: var(--fondo);
}
.marca { display: flex; align-items: center; gap: 10px; }
.marca__logo {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--naranja); color: #fff;
  font-weight: 700; font-size: 18px;
}
.marca__nombre {
  font-family: var(--fuente-titulo);
  font-weight: 700; font-size: 20px; letter-spacing: .06em;
  text-transform: uppercase;
}
.barra__datos { display: flex; align-items: center; gap: 18px; font-weight: 600; }
.dato--naranja { color: var(--naranja); }
.dato--tenue { color: var(--texto-tenue); font-weight: 500; }
.boton-clasificacion {
  margin-left: auto;
  background: var(--fondo-3); border: 1px solid var(--borde);
  border-radius: 8px; padding: 7px 12px; font-weight: 600;
}
.boton-clasificacion:hover { border-color: var(--naranja); }

/* ===================== DISPOSICIÓN: MAPA + PANEL ===================== */
.escenario {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr var(--ancho-panel);
}

/* ===================== MAPA ===================== */
.mapa {
  position: relative;
  overflow: hidden;
  /* touch-action: none → el navegador nos deja a nosotros los gestos táctiles */
  touch-action: none;
  background: var(--fondo);
}
#lienzo { display: block; width: 100%; height: 100%; cursor: grab; }
#lienzo.sobre-pais { cursor: pointer; }
#lienzo:active { cursor: grabbing; }

/* Leyenda */
.leyenda {
  position: absolute; top: 14px; left: 14px;
  width: 250px; padding: 10px 12px;
  background: rgba(11, 21, 36, .88);
  border: 1px solid var(--borde); border-radius: 8px;
  pointer-events: none;
}
.leyenda__titulo {
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--texto-tenue); margin-bottom: 8px;
}
.leyenda__barra {
  height: 8px; border-radius: 4px;
}
.leyenda__nota { font-size: 11px; color: var(--texto-tenue); margin-bottom: 6px; }
.leyenda__lista {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px;
  font-size: 11.5px;
}
.leyenda__lista i, .mix__leyenda i, .terrenos i {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 6px; vertical-align: -1px;
}
.leyenda__extremos {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--texto-tenue); margin-top: 5px;
}

/* Botones de zoom */
.controles-zoom {
  position: absolute; right: 14px; top: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.controles-zoom button {
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(11, 21, 36, .88); border: 1px solid var(--borde);
  font-size: 18px; line-height: 1;
}
.controles-zoom button:hover { border-color: var(--naranja); color: var(--naranja); }

/* Tooltip que sigue al ratón */
.tooltip {
  position: absolute; z-index: 5;
  padding: 6px 10px; border-radius: 6px;
  background: rgba(11, 21, 36, .95); border: 1px solid var(--borde);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  pointer-events: none;
  transform: translate(14px, 14px);
}
.tooltip small { color: var(--naranja); font-weight: 700; margin-left: 6px; }

/* ===================== ESTANDARTES ===================== */
.capa-estandartes { position: absolute; inset: 0; pointer-events: none; }
.estandarte {
  position: absolute; left: 0; top: 0;
  pointer-events: auto; cursor: pointer;
  background: rgba(11, 21, 36, .93);
  border: 1px solid #33496a; border-radius: 4px;
  padding: 4px 8px 4px 4px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
  /* El punto (left, top) que fijamos desde JS es el centro inferior del estandarte */
  transform: translate(-50%, -100%);
  will-change: left, top;
  transition: border-color .15s;
}
.estandarte:hover, .estandarte.activo { border-color: var(--naranja); }
.estandarte__fila { display: flex; align-items: center; gap: 7px; }
.estandarte__cuota {
  background: var(--naranja); color: #1b1004;
  font-weight: 700; font-size: 12px;
  padding: 1px 5px; border-radius: 3px;
}
.estandarte__nombre {
  font-family: var(--fuente-titulo); font-weight: 700;
  font-size: 13px; letter-spacing: .05em; text-transform: uppercase;
}
.estandarte__tendencia { font-size: 10px; }
.tendencia--sube { color: var(--verde); }
.tendencia--baja { color: var(--rojo); }
.tendencia--estable { color: var(--texto-tenue); }
.estandarte__detalle {
  font-size: 11px; color: var(--texto-tenue);
  margin: 3px 0 0 4px; display: flex; gap: 8px; align-items: center;
}
.estandarte__detalle .icono { width: 11px; height: 11px; margin-right: 3px; }
/* Puntito que marca la ubicación real del país, debajo del estandarte */
.estandarte::after {
  content: ''; position: absolute; left: 50%; bottom: -7px;
  width: 6px; height: 6px; margin-left: -3px; border-radius: 50%;
  background: var(--naranja); box-shadow: 0 0 0 2px var(--fondo);
}
.estandarte.desplazado::after { display: none; }

/* ===================== MARCADORES DE ENERGÍA ===================== */
.marcador {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -50%);
  pointer-events: auto; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 3px; border-radius: 999px;
  background: rgba(11, 21, 36, .9);
  border: 1px solid var(--color-marcador, var(--borde));
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.marcador[hidden] { display: none; }
.marcador:hover { background: var(--fondo-3); }
.marcador__icono {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px;
  background: color-mix(in srgb, var(--color-marcador) 35%, transparent);
}

/* ===================== PIE DEL MAPA: ATRIBUCIÓN + LENTES ===================== */
.pie-mapa {
  position: absolute; left: 14px; right: 14px; bottom: 14px;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; /* deja arrastrar el mapa entre los botones */
}
.pie-mapa > * { pointer-events: auto; }
.lentes { display: flex; gap: 8px; }
.lentes button {
  flex: 1; max-width: 180px;
  padding: 9px 10px; border-radius: 8px;
  background: rgba(11, 21, 36, .92); border: 1px solid var(--borde);
  font-weight: 600;
}
.lentes button:hover { border-color: var(--naranja); }
.lentes button[aria-pressed="true"] { background: var(--naranja); border-color: var(--naranja); color: #1b1004; }

/* ===================== ATRIBUCIÓN (obligatoria) ===================== */
.atribucion { font-size: 12px; line-height: 1.45; color: var(--texto-tenue); }
.atribucion strong { color: var(--texto); font-weight: 600; }
.atribucion__secundaria { font-size: 11px; margin-top: 3px; }
.atribucion--mapa {
  max-width: 780px;
  padding: 8px 12px;
  background: rgba(11, 21, 36, .92);
  border: 1px solid var(--borde); border-left: 3px solid var(--naranja);
  border-radius: 6px;
}
.atribucion--ficha {
  margin-top: 18px; padding: 10px 12px;
  background: var(--fondo-3); border-left: 3px solid var(--naranja); border-radius: 6px;
}
.atribucion--ficha + .atribucion--ficha { margin-top: 8px; }
.atribucion--secundaria { font-size: 11px; border-left-color: var(--texto-tenue); }

/* ===================== FICHA: BLOQUES EDITORIALES ===================== */
.bloques { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--borde); }
.etiqueta {
  display: inline-block; margin-bottom: 12px;
  padding: 3px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
}
.etiqueta--borrador { background: rgba(242, 184, 75, .15); color: #f2b84b; border: 1px dashed #f2b84b; }
.etiqueta--ok { background: rgba(111, 207, 106, .12); color: var(--verde); border: 1px solid var(--verde); }
.bloque { display: grid; grid-template-columns: 34px 1fr; gap: 10px; margin-bottom: 14px; }
.bloque__icono {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center; font-size: 16px;
  background: color-mix(in srgb, var(--color-icono) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-icono) 55%, transparent);
}
.bloque__titulo { margin: 2px 0 4px; font-size: 15px; font-weight: 600; line-height: 1.35; }
.bloque__texto { margin: 0; color: var(--texto-tenue); line-height: 1.55; font-size: 13px; }
.chip {
  display: inline-block; margin-right: 4px; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700; vertical-align: 1px;
  color: var(--color-chip); border: 1px solid var(--color-chip);
}
.fuentes { margin-top: 6px; font-size: 12px; }
.fuentes summary { cursor: pointer; color: var(--naranja); font-weight: 600; }
.fuentes ul { margin: 6px 0 0; padding-left: 16px; line-height: 1.5; }
.fuentes a { color: var(--texto); }

/* ===================== FICHA: MIX ELÉCTRICO Y TERRENO ===================== */
.seccion { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--borde); }
.seccion .antetitulo { margin-bottom: 8px; }
.mix { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--fondo-3); }
.mix span { display: block; height: 100%; }
.mix__leyenda, .terrenos {
  list-style: none; margin: 8px 0 0; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; font-size: 12px;
  color: var(--texto-tenue);
}
.mix__leyenda b, .terrenos b { color: var(--texto); font-weight: 600; }
.nota-pequena { font-size: 11px; color: var(--texto-tenue); margin: 8px 0 0; }

/* ===================== PANEL / FICHA ===================== */
.panel {
  position: relative;
  background: var(--fondo-2);
  border-left: 1px solid var(--borde);
  overflow-y: auto;
}
.panel__contenido { padding: 22px 20px 28px; }
.panel__cerrar {
  display: none; /* solo se ve en móvil */
  position: absolute; top: 8px; right: 10px;
  width: 34px; height: 34px; border: 0; background: none;
  font-size: 26px; color: var(--texto-tenue);
}
.antetitulo {
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--texto-tenue);
}
.titulo-pais {
  font-family: var(--fuente-titulo); font-weight: 700;
  font-size: 27px; line-height: 1.15; margin: 6px 0 16px;
}
.cajas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.caja {
  background: var(--fondo-3); border: 1px solid var(--borde); border-radius: 8px;
  padding: 8px 10px;
}
.caja__etiqueta { font-size: 11px; color: var(--texto-tenue); }
.caja__valor { font-size: 18px; font-weight: 700; margin-top: 2px; white-space: nowrap; }
.caja__valor small { font-size: 11px; font-weight: 600; }
.caja__valor--naranja { color: var(--naranja); }
.texto-ficha { color: var(--texto-tenue); line-height: 1.55; }
.volver {
  margin-top: 16px; background: none; border: 0; padding: 0;
  color: var(--naranja); font-weight: 600;
}

/* Clasificación (vista inicial del panel) */
.ranking { list-style: none; margin: 14px 0 0; padding: 0; }
.ranking li button {
  width: 100%; display: grid; grid-template-columns: 26px 1fr auto;
  align-items: center; gap: 8px;
  padding: 8px 6px; border: 0; border-bottom: 1px solid var(--borde);
  background: none; text-align: left;
}
.ranking li button:hover { background: var(--fondo-3); }
.ranking__puesto { color: var(--texto-tenue); font-size: 12px; }
.ranking__nombre { font-weight: 600; }
.ranking__barra {
  display: block; height: 3px; margin-top: 4px; border-radius: 2px;
  background: var(--naranja);
}
.ranking__cuota { color: var(--naranja); font-weight: 700; }

/* Mensaje de error */
.aviso-error {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 24px; text-align: center; background: var(--fondo);
}
.aviso-error[hidden] { display: none; }
.aviso-error code { background: var(--fondo-3); padding: 2px 6px; border-radius: 4px; }

/* ===================== MÓVIL (pantallas estrechas) ===================== */
@media (max-width: 800px) {
  :root { --alto-barra: 50px; }
  .barra { gap: 12px; padding: 0 12px; }
  .marca__nombre { font-size: 17px; }
  .dato--tenue { display: none; }
  .escenario { grid-template-columns: 1fr; }

  /* El panel se convierte en una "hoja" que sube desde abajo */
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    max-height: 55vh; /* deja a la vista casi la mitad del mapa, con el país encima */
    border-left: 0; border-top: 1px solid var(--borde);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .5);
    transform: translateY(105%);
    transition: transform .25s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.abierto { transform: translateY(0); }
  .panel__cerrar { display: block; }

  .leyenda { width: 200px; top: 10px; left: 10px; padding: 8px 10px; }
  .leyenda__lista { font-size: 10.5px; }
  .leyenda__titulo { font-size: 9.5px; letter-spacing: .1em; }
  .leyenda__extremos { font-size: 10px; }
  .controles-zoom { top: 10px; right: 10px; }
  .pie-mapa { left: 10px; right: 10px; bottom: 10px; gap: 6px; }
  .atribucion--mapa { font-size: 10.5px; padding: 6px 10px; }
  .atribucion__secundaria { font-size: 10px; }
  .lentes button { padding: 8px 6px; font-size: 13px; }
  .estandarte__nombre { font-size: 11px; }
  .estandarte__detalle { font-size: 10px; }
}

/* Avisos de datos (por ejemplo, un código de país mal escrito en hashrate.json) */
.avisos-datos {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  max-width: min(520px, calc(100% - 28px)); z-index: 6;
  padding: 8px 12px; border-radius: 6px;
  background: #3a1612; border: 1px solid var(--rojo); color: #ffd9d4; font-size: 12.5px;
}
.avisos-datos ul { margin: 4px 0 0; padding-left: 18px; }

/* ===================== BARRA SUPERIOR: DATOS EN VIVO Y BUSCADOR ===================== */
.barra__datos {
  min-width: 0;            /* deja que el bloque se encoja… */
  overflow-x: auto;        /* …y, si no cabe, se desplaza en horizontal */
  scrollbar-width: none;
  white-space: nowrap;
}
.barra__datos::-webkit-scrollbar { display: none; }
.dato--violeta { color: #b9a4ff; }
.dato--vivo { color: var(--texto); }
.barra__separador { width: 1px; height: 22px; background: var(--borde); flex: none; }
.dato--era {
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--naranja); color: var(--naranja);
  font-size: 12.5px;
}
.dato--fuente {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 500; color: var(--texto-tenue); text-decoration: none;
}
.dato--fuente:hover { color: var(--texto); }
.punto-vivo {
  width: 7px; height: 7px; border-radius: 50%; background: var(--verde);
  box-shadow: 0 0 0 3px rgba(111, 207, 106, .2);
}
.punto-vivo--error { background: var(--rojo); box-shadow: 0 0 0 3px rgba(239, 91, 76, .2); }

.buscador { position: relative; margin-left: auto; flex: none; }
.buscador input {
  width: 200px; padding: 7px 12px; border-radius: 8px;
  background: var(--fondo-3); border: 1px solid var(--borde); color: var(--texto);
  font: inherit;
}
.buscador input:focus { outline: none; border-color: var(--naranja); }
.buscador__resultados {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 100%; max-width: 280px; margin: 0; padding: 4px; list-style: none;
  background: var(--fondo-2); border: 1px solid var(--borde); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.buscador__resultados li { padding: 7px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.buscador__resultados li[aria-selected="true"], .buscador__resultados li:hover { background: var(--fondo-3); color: var(--naranja); }
.buscador + .boton-clasificacion { margin-left: 0; }

/* Pantallas medianas: quitamos los datos menos importantes de la barra */
@media (max-width: 1700px) { #dato-top3 { display: none; } }
@media (max-width: 1500px) { #dato-subsidio { display: none; } }
@media (max-width: 1260px) { #dato-hashprice { display: none; } }

/* Móvil: la barra pasa a dos filas (marca + buscador arriba, datos abajo) */
@media (max-width: 800px) {
  .barra {
    height: auto; flex-wrap: wrap; row-gap: 6px;
    padding-top: 8px; padding-bottom: 8px;
  }
  .barra__datos { order: 3; flex: 1 0 100%; gap: 14px; font-size: 12.5px; }
  .buscador { order: 1; }
  .buscador input { width: 130px; padding: 6px 10px; }
  .boton-clasificacion { order: 2; padding: 6px 10px; font-size: 13px; }
  /* En móvil el botón muestra solo un icono (el texto sigue ahí para lectores de pantalla) */
  .boton-clasificacion .texto-boton { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .boton-clasificacion::before { content: '🏆'; }
  .marca__nombre { font-size: 16px; }
  #dato-top3, #dato-subsidio, #dato-hashprice { display: inline; }
}
