/* ==========================================================================
   1. VARIABLES DE DISEÑO & CONFIGURACIÓN GLOBAL
   ========================================================================== */
:root {
  --font:          system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bg:            #f4f7fb;
  --bg-alt:        #eaf0f8;
  --card-bg:       #ffffff;
  --blue:          #004a99;
  --blue-2:        #1a6dcc;
  --blue-pale:     #e8f0fe;
  --orange:        #FC5200;
  --orange-pale:   #fff2ec;
  --green:         #16a34a;
  --text:          #1e293b;
  --muted:         #475569;
  --muted-2:       #94a3b8;
  --border:        #e2e8f0;
  --radius:        18px;
  --radius-sm:     10px;
  --shadow:        0 6px 20px rgba(0, 0, 0, 0.07);
  --shadow-md:     0 10px 30px rgba(0, 0, 0, 0.12);
  --dim:           #64748b;
}

/* --- Reset Universal & Base --- */
*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

html { 
  background: var(--bg); 
  height: 100%; 
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100%;
  overflow-x: hidden;
}

a { 
  color: var(--blue); 
  text-decoration: none !important; 
}

a:hover { 
  text-decoration: none !important; 
}

strong { 
  font-weight: 700; 
}

/* --- Contenedores y Wrappers --- */
.rh-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 35px 20px;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 28px;
}

.rh-divider { 
  height: 1px; 
  background: var(--border); 
  margin: 16px 0; 
}


/* ==========================================================================
   2. NAVEGACIÓN Y CINTA SUPERIOR (MÓVIL / DESKTOP MULTI-TENANT)
   ========================================================================== */

/* --- Cinta Negra Fija Superior (Móvil / Tablet < 769px) --- */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background: #0f1420; /* var(--blue); */
  z-index: 1005; /* Por encima del contenido de la página */
  display: flex;
  align-items: center;
  padding: 0 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.hamburger {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: #ffffff !important;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
  z-index: 1006;
}

.hamburger:active {
  opacity: 0.7;
}

.top-bar-title {
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  margin-left: 10px;
  letter-spacing: 0.05em;
  /*text-transform: uppercase;*/
}

/* --- Menú Lateral Desplegable (Drawer Móvil) --- */
.drawer {
  position: fixed;
  top: 0;
  left: -280px;
  width: 250px;
  height: 100%;
  background: #ffffff;
  z-index: 1020; /* Por encima de la cinta negra */
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 15px 12px;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.25);
  overflow-y: auto;
}

.drawer.open {
  left: 0;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  padding: 0;
  margin-bottom: 10px;
  cursor: pointer;
  color: var(--text);
  display: block;
  line-height: 1;
}

#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  z-index: 1010;
  backdrop-filter: blur(2px);
}

#overlay.active {
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  text-decoration: none !important;
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  color: var(--blue);
  background-color: rgba(0, 74, 153, 0.05);
}

.nav-item .icon {
  margin-right: 8px;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
}

/* Menú móvil: las opciones del reto ('sub' en navItems) van sangradas bajo "Reto" ('section'),
   separadas de las del club (Inicio, Calendario). En escritorio no cambia nada. */
.drawer .nav-section {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  border-radius: 0;
}

.drawer .nav-sub {
  margin-left: 18px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
  border-radius: 0 6px 6px 0;
  font-weight: 600;
}

.drawer .nav-sub:hover {
  border-left-color: var(--blue);
}

/* Página actual (aria-current, rh-app.js) */
.drawer .nav-item.is-active {
  color: var(--blue);
  background-color: var(--blue-pale);
}

.drawer .nav-sub.is-active {
  border-left-color: var(--blue);
}

/* --- Menú Superior (Escritorio > 768px) --- */
.rh-navbar {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 100;
  padding: 12px 20px;
  background: transparent;
}

.rh-desktop-menu {
  display: flex;
  gap: 18px;
}

.rh-desktop-menu .nav-item {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 700;
  font-size: 0.8rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.rh-desktop-menu .nav-item:hover {
  color: #ffffff;
  background-color: transparent;
}

/* Desplegable del reto (solo escritorio): Inicio / Calendario / Reto ▾ */
.nav-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-caret {
  background: none;
  border: none;
  padding: 8px 6px 8px 2px;
  margin-left: -4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.nav-caret::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid rgba(255, 255, 255, 0.9);
  border-bottom: 2px solid rgba(255, 255, 255, 0.9);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s ease;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.nav-dropdown:hover .nav-caret::before,
.nav-dropdown.open .nav-caret::before {
  transform: translateY(2px) rotate(-135deg);
}

.nav-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  padding: 6px;
  margin-top: 6px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 200;
}

/* Puente invisible para que el ratón no "caiga" al bajar al desplegable */
.nav-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 10px;
}

.nav-dropdown:hover .nav-menu,
.nav-dropdown.open .nav-menu {
  display: block;
}

/* Página actual en la barra: subrayada (si es una opción del reto, se subraya «Reto») */
.rh-desktop-menu > .nav-item.is-active,
.rh-desktop-menu .nav-dropdown > .nav-item.is-active {
  color: #ffffff;
  box-shadow: inset 0 -2px 0 #ffffff;
  border-radius: 0;
}

.rh-desktop-menu .nav-menu .nav-item {
  color: var(--text);
  text-shadow: none;
  padding: 9px 12px;
  border-radius: 8px;
}

.rh-desktop-menu .nav-menu .nav-item.is-active,
.rh-desktop-menu .nav-menu .nav-item:hover {
  color: var(--blue);
  background-color: var(--blue-pale);
}

/* Control de Visibilidad Responsive */
@media (min-width: 769px) {
  .top-bar, .drawer, #overlay { 
    display: none !important; 
  }
}

@media (max-width: 768px) {
  .rh-navbar { 
    display: none !important; 
  }
}


/* ==========================================================================
   3. CABECERA Y HERO DE PÁGINA
   ========================================================================== */
.rh-hero {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-2) 100%); /* Imagen de fondo: la pone cada club en css/rh-club.css */
  min-height: 210px; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  padding: 65px 18px 24px !important; /* Espacio reservado para compensar la cinta fija */
  text-align: center;
}

.rh-hero h1 { 
  color: #ffffff; 
  font-size: clamp(22px, 4.5vw, 38px); 
  font-weight: 800; 
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); 
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.rh-hero h2 { 
  color: #ffffff; 
  font-size: clamp(16px, 3vw, 24px); 
  font-weight: 800; 
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); 
  margin: 0 0 4px 0;
  line-height: 1.2;
}

.rh-hero p { 
  color: rgba(255, 255, 255, 0.82); 
  margin-top: 6px; 
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

/* Versión Compacta (sin fondo de imagen de montaña) */
.rh-hero.compact {
  min-height: 0;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-2) 100%);
  padding: 65px 18px 22px !important;
}


/* ==========================================================================
   4. SISTEMA DE SECCIONES, SUBTÍTULOS Y REGLAMENTO
   ========================================================================== */
.rh-section {
  padding: 28px 0;
}

.rh-section + .rh-section {
  border-top: 1px solid var(--border);
}

.rh-section-title {
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.rh-section-title .emoji { 
  font-size: 22px; 
}

.rh-subsection-title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--blue);
  margin: 20px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Lista estilo reglamento */
.rh-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
}

.rh-list li {
  padding-left: 18px;
  position: relative;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.rh-list li::before {
  content: "▪";
  position: absolute;
  left: 0;
  color: var(--blue);
  font-size: 11px;
  top: 3px;
}

.rh-hashtag {
  display: inline;
  font-weight: 700;
  color: var(--orange);
}

/* Fórmula / Bloques de código o reglas */
.rh-formula {
  background: var(--bg-alt);
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  margin: 10px 0;
  font-family: 'Courier New', monospace;
}


/* ==========================================================================
   5. SISTEMA DE PESTAÑAS (CATEGORÍAS Y TEMPORADAS)
   ========================================================================== */
.rh-cat-tabs { 
  display: flex; 
  gap: 12px; 
  margin: -25px 0 25px 0; 
  position: relative;
  z-index: 10;
  flex-wrap: wrap; 
  justify-content: center; 
}

.rh-tab {
  padding: 8px 20px; 
  border-radius: 30px; 
  font-size: 12px; 
  font-weight: 600; 
  cursor: pointer;
  border: 1.5px solid var(--border); 
  background: var(--card-bg); 
  color: var(--muted);
  text-transform: uppercase; 
  letter-spacing: 0.05em; 
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 6px;
}

.rh-tab.active { 
  background: var(--blue); 
  border-color: var(--blue); 
  color: #ffffff; 
}

.rh-tab:hover:not(.active) { 
  border-color: var(--blue); 
  color: var(--blue); 
}

.cat-block { 
  display: none; 
}

.cat-block.active { 
  display: block; 
}


/* ==========================================================================
   6. PODIO OLÍMPICO HOMOGÉNEO (REORDENADO POR CSS: 2º - 1º - 3º)
   ========================================================================== */
.rh-podium { 
  display: grid; 
  grid-template-columns: 1fr 1fr 1fr; 
  gap: 12px; 
  margin-bottom: 25px; 
  align-items: start; 
}

.rh-podium-card {
  background: var(--card-bg); 
  border-radius: 24px; 
  padding: 20px 10px;
  text-align: center; 
  box-shadow: var(--shadow); 
  border: 1px solid var(--border);
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 8px;
  transition: transform 0.2s ease;
  min-height: 190px; 
}

/* Reordenación visual del podio olímpico */
.rh-podium-card.p1 { border-top: 4px solid #f59e0b; order: 2; } 
.rh-podium-card.p2 { border-top: 4px solid #94a3b8; order: 1; } 
.rh-podium-card.p3 { border-top: 4px solid #b45309; order: 3; } 

.pod-medal { 
  font-size: 28px; 
  margin-bottom: 2px; 
}

.pod-alias { 
  font-size: 13px; 
  font-weight: 600; 
  color: var(--text); 
  line-height: 1.2;
  height: 32px; 
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.pod-pts-container {
  font-size: 15px; 
  font-weight: 500; 
  color: var(--blue); 
  line-height: 1.2;
}

.pod-pts-val { 
  display: block; 
  font-size: 16px; 
  font-weight: 700; 
}

.pod-pts-lbl { 
  display: block; 
  font-size: 12px; 
  color: var(--muted); 
  letter-spacing: 0.05em; 
}

/* ==========================================================================
   7. CONTENEDORES DE GRÁFICAS, TARJETAS Y RETÍCULAS
   ========================================================================== */

/* --- 7.1. Tarjetas de Retos / Tracks (Restauración de Diseño y Márgenes) --- */
.rh-track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px; /* Margen de separación holgado entre tarjetas */
  margin-top: 20px;
}

.rh-track-card {
  background: var(--card-bg, #ffffff);
  border-radius: 20px; /* Curvatura suave original */
  padding: 24px 22px; /* Relleno amplio para recuperar el aire visual */
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01); /* Sombra flotante sutil */
  border: 1px solid var(--border, #e2e8f0);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px; /* Separación vertical entre bloques internos */
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.rh-track-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px -4px rgba(0, 0, 0, 0.08);
}

/* Fila Superior de Etiquetas (#Reto + Dificultad) */
.rh-card-header-tags {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Título Principal del Reto */
.rh-track-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text, #1e293b);
  line-height: 1.25;
  margin: 2px 0;
}

/* Fila de Datos Técnicos (Km, Desnivel, Tiempo Ref) */
.rh-track-meta {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  font-size: 13.5px;
  color: var(--muted, #475569);
  font-weight: 600;
}

.rh-track-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* --- 7.2. Contenedor de Mapas / Iframe (Si aplica visualización gráfica) --- */
.rh-track-map {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-alt, #eaf0f8);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  border-radius: 12px;
  margin-bottom: 8px;
}

.rh-track-map img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rh-track-map iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* --- 7.3. Tarjetas de Ranking y Gráficas de Chart.js --- */
.ranking-card { 
  background: var(--card-bg, #ffffff); 
  padding: 20px; 
  border-radius: var(--radius, 18px); 
  box-shadow: var(--shadow, 0 6px 20px rgba(0, 0, 0, 0.07)); 
  border: 1px solid var(--border, #e2e8f0); 
  margin-bottom: 30px; 
  position: relative;
}

.rh-loader { 
  text-align: center; 
  padding: 50px; 
  color: var(--muted, #475569); 
  font-weight: bold; 
}

/* --- 7.4. Tarjetas Genéricas y Grid Multiuso --- */
.rh-card {
  background: var(--card-bg, #ffffff);
  border-radius: var(--radius, 18px);
  padding: 22px 18px;
  box-shadow: var(--shadow, 0 6px 20px rgba(0, 0, 0, 0.07));
  border: 1px solid var(--border, #e2e8f0);
}

.rh-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

/* --- 7.5. Navegación por Tarjetas (Home Distributiva) --- */
.rh-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.rh-nav-card {
  background: var(--card-bg, #ffffff);
  border-radius: var(--radius, 18px);
  padding: 20px 14px;
  box-shadow: var(--shadow, 0 6px 20px rgba(0, 0, 0, 0.07));
  border: 1px solid var(--border, #e2e8f0);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-decoration: none !important;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.rh-nav-card:hover { 
  transform: translateY(-3px); 
  box-shadow: var(--shadow-md, 0 10px 30px rgba(0, 0, 0, 0.12)); 
}

.rh-nav-card .icon { font-size: 32px; }
.rh-nav-card .label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text, #1e293b); }
.rh-nav-card .desc  { font-size: 11.5px; color: var(--muted, #475569); line-height: 1.4; }
.rh-nav-card.blue   { border-top: 3px solid var(--blue, #004a99); }
.rh-nav-card.orange { border-top: 3px solid var(--orange, #FC5200); }

/* --- 7.6. Guías de Etiquetado y Pasos (Step Cards) --- */
.rh-step {
  background: var(--card-bg, #ffffff);
  border-radius: var(--radius, 18px);
  padding: 18px 20px;
  box-shadow: var(--shadow, 0 6px 20px rgba(0, 0, 0, 0.07));
  border: 1px solid var(--border, #e2e8f0);
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.rh-step-num {
  background: var(--blue, #004a99);
  color: #ffffff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

.rh-step-body h4 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.rh-step-body p  { font-size: 13px; color: var(--muted, #475569); line-height: 1.5; }

/* --- 7.7. Accesos Rápidos (Quick Cards) --- */
.rh-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.rh-quick-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 14px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.rh-quick-card:hover {
  transform: translateY(-3px);
  border-color: var(--blue);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.rh-quick-card .q-ico { font-size: 28px; margin-bottom: 8px; line-height: 1; }
.rh-quick-card .q-tit { font-weight: 800; font-size: 14.5px; color: var(--blue); }

/* Portada: dos accesos (rh-app.js, [data-rh-quick]) en una sola fila, también en el móvil */
.rh-quick-grid.rh-quick-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
@media (max-width: 560px) {
  .rh-quick-2 .rh-quick-card { padding: 12px 8px; }
  .rh-quick-2 .rh-quick-card .q-ico { font-size: 24px; margin-bottom: 6px; }
}

/* --- Ficha de recorrido (tracks.html, common/js/rh-tracks.js): punto de encuentro, compartir, mapa y perfil --- */
.rh-track-start { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 7px 8px; line-height: 1.4; }
.rh-track-start > svg { flex-shrink: 0; }
/* Siempre en una línea (el nombre tiene hasta 30 caracteres en /admin; si aun así no cabe, puntos suspensivos) */
.rh-track-start > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rh-track-start b { color: var(--text); font-weight: 700; }
.rh-track-start a { color: var(--blue); font-weight: 700; }
/* Mapa y perfil (el resto de la fila) · GPX; solo en los recorridos con traza GPS */
.rh-track-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.rh-track-actions > * { min-width: 0; }
.rh-track-card .rh-track-body { container-type: inline-size; }
/* Fichas estrechas (escritorio, 3 o 4 por fila): «Mapa y perfil» sin el emoji para que quepa */
@container (max-width: 250px) { .rh-track-btn-map .rh-track-btn-ico { display: none; } }
.rh-track-btn-gpx { padding-inline: 10px; }
.rh-track-actions .rh-track-btn-map { padding-inline: 6px; }
.rh-track-btn-gpx { color: #1e293b; border-color: #1e293b; text-decoration: none; }   /* gris pizarra: el Compartir de WhatsApp ya es verde */
.rh-track-btn-gpx:hover { background: #f1f5f9; text-decoration: none; }
.rh-track-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 700 12px/1.1 var(--font); white-space: nowrap;
  padding: 9px 8px; border-radius: var(--radius-sm); border: 1.5px solid; background: var(--card-bg); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.rh-track-btn-map { color: var(--blue); border-color: var(--blue); }
.rh-track-btn-map[aria-expanded="true"], .rh-track-btn-map:hover { background: var(--blue); color: #fff; }
.rh-track-foot {
  /* Compartir a la derecha (el hueco preferente desde que no está Wikiloc), centrado en el hueco entre los botones y el
     borde de la ficha: 10px de gap + 6px arriba; abajo, 6px del cuerpo + 24px de la ficha − 14px = 16px */
  display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin: 6px 0 -14px;
}
.rh-track-share {
  display: inline-flex; align-items: center; gap: 6px;
  font: 700 12.5px/1.1 var(--font); color: #128c7e; background: none;   /* el verde del Compartir de la agenda */ border: 0; padding: 2px 0; cursor: pointer;
}
.rh-track-share:hover { opacity: 0.8; }   /* sin subrayado */
.rh-track-share:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.rh-track-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.rh-track-card.is-open { grid-column: 1 / -1; }
.rh-track-card.is-target { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 74, 153, 0.15), var(--shadow); }
.rh-track-geo { display: flex; flex-direction: column; gap: 8px; }
.rh-track-geo[hidden] { display: none; }
.rh-track-map { position: relative; z-index: 0; width: 100%; aspect-ratio: 16 / 8; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: #e9efe4; }
.rh-track-map-hint { position: absolute; z-index: 1000; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(15, 20, 32, 0.75); color: #fff; font-size: 11.5px; padding: 4px 10px; border-radius: 999px; white-space: nowrap; pointer-events: none; }
.rh-track-profile { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 8px 4px; background: var(--card-bg); }
.rh-track-profile-head { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); font-weight: 600; min-height: 17px; }
.rh-track-profile-head b, .rh-track-profile-foot b { color: var(--text); font-variant-numeric: tabular-nums; }
.rh-track-profile canvas { display: block; width: 100%; height: 130px; cursor: crosshair; touch-action: pan-y; }
.rh-track-profile-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--muted); }
/* Alt. máx. y mín. | distancia y desnivel: si no caben los cuatro en una línea, la segunda pareja baja entera (2 + 2).
   Cada pareja ocupa lo que le toca de la línea y reparte sus dos datos a mitades: en dos líneas quedan en columna */
.rh-track-profile-pair { flex: 1 1 auto; display: grid; grid-template-columns: repeat(2, minmax(max-content, 1fr)); column-gap: 14px; }
.rh-track-profile-pair > span { white-space: nowrap; }
.rh-track-profile-none { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 8px 10px; }
/* Botón de pantalla completa (arriba a la derecha; el zoom de Leaflet va a la izquierda) y la vista a pantalla completa:
   el mapa ocupa lo que deja libre el perfil */
.rh-track-map-full { position: absolute; z-index: 1000; top: 10px; right: 10px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; padding: 0; border: 2px solid rgba(0, 0, 0, 0.2); border-radius: 4px; background: #fff; color: #1e293b; cursor: pointer; background-clip: padding-box; }
.rh-track-map-full:hover { background-color: #f4f4f4; }
.rh-track-map-full:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.rh-track-geo.is-full { position: fixed; inset: 0; z-index: 3000; margin: 0; background: var(--card-bg, #fff); padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); gap: 6px; }
.rh-track-geo.is-full .rh-track-map { flex: 1 1 auto; min-height: 0; aspect-ratio: auto; }
.rh-track-geo.is-full .rh-track-profile, .rh-track-geo.is-full .rh-track-profile-foot, .rh-track-geo.is-full .rh-track-profile-none { flex: none; }
html.rh-noscroll, html.rh-noscroll body { overflow: hidden; }
@media (max-width: 600px) {
  .rh-track-map { aspect-ratio: 4 / 3; }
  .rh-track-profile canvas { height: 110px; }
}

/* --- 7.8. Página 404 --- */
.rh-404 { text-align: center; padding: 8px 0 64px; }
.rh-404 .ico { font-size: 28px; margin-bottom: 8px; }
.rh-404 p { color: var(--muted); font-size: 16px; line-height: 1.55; }


/* ==========================================================================
   8. MENÚ HUB Y NAVEGACIÓN HISTÓRICA (DISTRIBUTIVO LIMPIO SIN SUBRAYADOS)
   ========================================================================== */
.rh-history-menu {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.rh-history-link {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none !important;
  color: var(--text);
  transition: all 0.2s ease;
}

.rh-history-link:hover,
.rh-history-link:focus,
.rh-history-link:active {
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none !important;
}

.rh-link-title {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 18px;
  font-weight: 700;
}

.rh-link-icon { 
  font-size: 24px; 
}

.rh-link-arrow {
  font-size: 20px;
  color: var(--blue);
  font-weight: 700;
}


/* ==========================================================================
   9. TABLAS, BADGES, BOTONES Y BARRAS DE PROGRESO
   ========================================================================== */

/* --- Botones Genéricos con Brillo --- */
.rh-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #ffffff;
  padding: 12px 18px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none !important;
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: transform 0.2s, background 0.2s;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  width: 100%;
  border: none;
  cursor: pointer;
}

.rh-btn::after {
  content: "";
  position: absolute;
  top: -50%; 
  left: -100%;
  width: 30%; 
  height: 200%;
  background: rgba(255, 255, 255, 0.25);
  transform: rotate(30deg);
}

.rh-btn:hover { 
  transform: translateY(-2px); 
}

.rh-btn:hover::after { 
  left: 150%; 
  transition: left 0.5s ease; 
}

.rh-btn-blue   { background: var(--blue); box-shadow: 0 4px 12px rgba(0, 74, 153, 0.2); }
.rh-btn-blue:hover { background: var(--blue-2); }
.rh-btn-orange { background: var(--orange); box-shadow: 0 4px 12px rgba(252, 82, 0, 0.2); }
.rh-btn-orange:hover { background: #e64a00; }
.rh-btn-ghost  { background: transparent; color: var(--blue); border: 1.5px solid var(--blue); box-shadow: none; }
.rh-btn-ghost:hover { background: var(--blue-pale); color: var(--blue); }

/* --- Badges / Etiquetas --- */
.rh-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.rh-badge-blue   { background: var(--blue-pale); color: var(--blue); }
.rh-badge-orange { background: var(--orange-pale); color: var(--orange); }
.rh-badge-green  { background: #dcfce7; color: var(--green); }

/* --- Barra de Progreso CSS --- */
.rh-bar-wrap { 
  background: var(--bg-alt); 
  border-radius: 99px; 
  height: 10px; 
  overflow: hidden; 
}

.rh-bar { 
  height: 100%; 
  background: linear-gradient(90deg, var(--blue), var(--blue-2)); 
  border-radius: 99px; 
}

/* --- Tabla de Ranking --- */
.rh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.rh-table th {
  background: var(--bg-alt);
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border);
}

.rh-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.rh-table tr:last-child td { border-bottom: none; }
.rh-table tr:hover td { background: var(--bg); }

.rh-rank { font-weight: 800; color: var(--muted-2); width: 32px; }
.rh-rank.gold   { color: #f59e0b; }
.rh-rank.silver { color: #94a3b8; }
.rh-rank.bronze { color: #b45309; }
.rh-pts { font-weight: 700; color: var(--blue); font-family: 'Courier New', monospace; }
.rh-alias { font-weight: 600; }

/* --- Footers --- */
footer {
  padding: 34px 0;
  border-top: 1px solid rgba(245,247,251,0.08);
}

footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

footer p {
  font-size: 12.5px;
  color: var(--dim);
}

/* Pie (todas las webs: clubes con rh-app.js y la portada de rankhub.es, que repite la regla en css/landing.css): logo
   y copyright siempre en una línea. El logo ocupa lo que quepa en una caja máxima (sin deformarse): los alargados (MO,
   Trail42) llegan al ancho y los más cuadrados (DendroCT) al alto. Si el texto aún no cabe, se corta con «…» */
footer .wrap { flex-wrap: nowrap; }
footer .wrap > img {
  width: auto;
  height: auto;
  max-width: 200px;
  max-height: 64px;
  min-width: 0;
  flex: 0 1 auto;
  object-fit: contain;
  object-position: left center;
}
footer .wrap > p { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 600px) {
  footer .wrap { padding: 0 4px; }
  footer .wrap > img { max-width: 50%; max-height: 52px; }
}

#rh-footer { 
  text-align: center; 
  padding: 20px; 
  background: var(--card-bg); 
  border-top: 1px solid var(--border); 
  margin-top: 10px; 
}


/* ==========================================================================
   10. ADAPTACIONES RESPONSIVAS Y MEDIA QUERIES
   ========================================================================== */
@media (max-width: 992px) { 
  .rh-track-grid { 
    grid-template-columns: repeat(2, 1fr); 
  } 
}

@media (max-width: 600px) { 
  .rh-track-grid { 
    grid-template-columns: 1fr; 
  } 
}

@media (max-width: 560px) {
  .rh-hero h1 { font-size: 20px; }
  .rh-track-grid, .rh-card-grid { grid-template-columns: 1fr; }
  .rh-nav-grid { grid-template-columns: repeat(2, 1fr); }
  .rh-section { padding: 20px 0; }
  .rh-table { font-size: 12px; }
  .rh-table th, .rh-table td { padding: 8px; }
  .rh-podium { gap: 8px; }
  .rh-podium-card { padding: 14px 6px; min-height: 170px; }
  .pod-medal { font-size: 22px; }
  .pod-alias { font-size: 11.5px; height: 28px; }
  .pod-pts-val { font-size: 14px; }
  .ranking-card { padding: 12px; }
}

/* Enlace a RankHub en el pie (en el HTML de cada página: visible también sin JavaScript) */
footer .wrap > p.rh-strava { flex: 0 0 100%; margin: 10px 0 0; line-height: 0; text-align: center; overflow: visible; }
#rh-footer .wrap { flex-wrap: wrap; }
.rh-strava img { height: 12px; width: auto; }
.rh-powered { font-size: 11.5px; color: var(--muted-2); margin-top: 6px; }
.rh-powered a { color: var(--muted); font-weight: 700; text-decoration: none; }
.rh-powered a:hover { color: var(--blue); }
