/* ============================================================
   WolfnAnalytics V5 — tokens.css
   Design tokens y chrome compartido (SOP-622 carril C).
   SSOT de la barra superior unificada (topbar.js).
   Se linkea DESPUÉS de vendor/fonts.css en cada página.
   ============================================================ */

/* ── Tokens de diseño (variables globales) ─────────────────── */
:root {
  --bg-1: #090a0f; --bg-2: #0d1017; --bg-3: #12151e;
  --border: rgba(255,255,255,0.08); --border-hover: rgba(255,255,255,0.15); --border-active: rgba(255,255,255,0.25);
  --text-1: #ffffff; --text-2: #aab2c0; --text-3: #949db1; --text-muted: #7d8598;
  --accent: #0066ff; --accent-hover: #3388ff; --accent-text: #3388ff;
  --bull: #22c55e; --bear: #ef4444; --caution: #f59e0b; --info: #3b82f6;
  --r-riskon: #22c55e; --r-riskoff: #f43f5e; --r-neutral: #94a3b8; --r-dcain: #38bdf8; --r-dcaout: #fbbf24; --r-mixed: #a78bfa;
  --font-display: "Plus Jakarta Sans", "Inter", sans-serif;
  --font-body: "Inter", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", monospace;
}

/* La escala tipográfica (--fs-*) y la raíz del rem viven en type-scale.css.
   Se separaron porque 7 páginas necesitan la escala pero NO este chrome.
   type-scale.css debe linkearse ANTES que tokens.css en todas las páginas. */

/* ── Base ──────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg-1); color: var(--text-2);
  font-family: var(--font-body); font-size: var(--fs-md);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: #1c2230; border-radius: 6px; border: 2px solid var(--bg-1); }
#root { min-height: 100vh; }

/* ── Topbar unificada (topbar.js) ──────────────────────────── */
.wolfn-topbar { position: sticky; top: 0; z-index: 100; height: 56px; display: flex; align-items: center; gap: 22px; padding: 0 24px; background: rgba(9,10,15,0.9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.tb-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; text-decoration: none; }
.tb-mark { width: 28px; height: 28px; border-radius: 7px; overflow: hidden; position: relative; background: #050505; box-shadow: 0 0 14px rgba(0,102,255,0.3); }
.tb-mark img { position: absolute; width: 168%; height: 168%; top: -34%; left: -34%; mix-blend-mode: screen; }
/* SOP-683 Bloque B: única definición de la marca. La landing necesita un
   tamaño mayor (era .nav-mark, 32px) — modificador, no una segunda clase. */
.tb-mark--lg { width: 32px; height: 32px; border-radius: 8px; }
.tb-title { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); color: var(--text-1); letter-spacing: -0.01em; }
.navpills { display: flex; gap: 2px; flex: 1; justify-content: center; }
.pill { position: relative; font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 600; letter-spacing: 0.045em; color: var(--text-3); background: transparent; border: none; cursor: pointer; padding: 7px 13px; border-radius: 9999px; transition: all 0.15s ease; text-decoration: none; white-space: nowrap; }
.pill:hover { color: var(--text-1); background: rgba(255,255,255,0.04); }
.pill.active { color: var(--text-1); background: rgba(255,255,255,0.09); }
.pill.disabled { opacity: 0.35; cursor: default; }
.pill.active-tab { cursor: default; }
.tb-right { display: flex; align-items: center; gap: 18px; flex-shrink: 0; }
.tb-prices { display: flex; gap: 16px; align-items: center; }
.tb-price { display: flex; align-items: baseline; gap: 6px; font-size: var(--fs-sm); }
.tb-price .sym { color: var(--text-3); font-weight: 600; font-family: var(--font-display); letter-spacing: 0.03em; }
.tb-price .val { font-family: var(--font-mono); font-weight: 500; color: var(--text-1); }
.tb-price .delta { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; margin-left: 1px; }
.tb-sep { width: 1px; height: 22px; background: var(--border); }
.regime-pill { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.04em; color: #7dd3fc; background: rgba(56,189,248,0.1); border: 1px solid rgba(56,189,248,0.32); padding: 5px 11px; border-radius: 9999px; }
.regime-pill .rp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--r-dcain); box-shadow: 0 0 8px var(--r-dcain); }
.tb-mobile-section, .tb-menu-button, .tb-menu-scrim, .tb-mobile-panel { display: none; }
.tb-mobile-btc { display: none; font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600; margin-left: 8px; }

/* ── Zona de sesión (topbar.js) ────────────────────────────── */
/* Mismo lenguaje visual que el resto del chrome: pill con border
   subtle, font-display 12px, radio 9999px. La sesión es acción del
   usuario, no ruta de producto — por eso vive acá y no en nav-items. */
.tb-session { display: flex; align-items: center; }
/* SOP-683 Bloque E (D7): tres niveles de énfasis, no dos estilos sueltos.
   .tb-login es la acción primaria (deslogueado) — acento relleno.
   .tb-user-btn es un estado, no una acción — se mantiene ghost (abajo). */
.tb-login {
  display: inline-flex; align-items: center; white-space: nowrap;
  font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: 0.04em; color: #fff; text-decoration: none;
  padding: 6px 13px; border: none; border-radius: 9999px;
  background: var(--accent); transition: background 0.15s ease;
}
.tb-login:hover { background: var(--accent-hover); }
.tb-user { position: relative; }
.tb-user-btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--border-hover); border-radius: 9999px;
  background: rgba(255,255,255,0.04); padding: 3px 10px 3px 3px;
  transition: all 0.15s ease;
}
.tb-user-btn:hover { background: rgba(255,255,255,0.07); border-color: var(--border-active); }
.tb-user-btn[aria-expanded="true"] { border-color: var(--border-active); background: rgba(255,255,255,0.07); }
.tb-avatar {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 24px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #38bdf8, #0066ff);
}
.tb-user-name {
  font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-1); max-width: 128px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-caret { color: var(--text-3); font-size: var(--fs-label); line-height: 1; margin-right: 2px; }
.tb-user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 120;
  min-width: 184px; padding: 6px; border: 1px solid var(--border-hover); border-radius: 8px;
  background: rgba(13,16,23,0.98); box-shadow: 0 24px 70px rgba(0,0,0,0.55);
  display: none;
}
.tb-user.open .tb-user-menu { display: block; }
.tb-user-menu-item {
  display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 6px;
  color: var(--text-2); font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: 0.03em; text-decoration: none; background: none; border: 0; cursor: pointer;
}
.tb-user-menu-item:hover { color: var(--text-1); background: rgba(255,255,255,0.05); }
.tb-user-menu-item.danger { color: #f87171; }
.tb-user-menu-item.danger:hover { background: rgba(239,68,68,0.12); color: #fca5a5; }
.tb-user-menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }

.tb-menu-button {
  width: 38px; height: 38px; flex: 0 0 38px; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 7px; color: var(--text-1);
  background: rgba(255,255,255,0.035); cursor: pointer;
}
.tb-menu-button:hover, .tb-menu-button:focus-visible { border-color: var(--border-active); background: rgba(255,255,255,0.07); outline: none; }
.tb-menu-icon { width: 17px; display: grid; gap: 4px; }
.tb-menu-icon span { display: block; height: 1px; background: currentColor; transition: transform 0.16s ease, opacity 0.16s ease; }
.menu-open .tb-menu-icon span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.menu-open .tb-menu-icon span:nth-child(2) { opacity: 0; }
.menu-open .tb-menu-icon span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }
.tb-mobile-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

@media (min-width: 1100px) and (max-width: 1320px) {
  .wolfn-topbar { gap: 12px; padding-inline: 16px; }
  .pill { padding-inline: 9px; font-size: var(--fs-xs); }
  .tb-right { gap: 12px; }
  .tb-prices .tb-price:not(:first-child) { display: none; }
}

@media (max-width: 1099px) {
  .wolfn-topbar { height: 56px; gap: 12px; padding: 0 16px; }
  .wolfn-topbar > .navpills, .wolfn-topbar > .tb-right { display: none; }
  .tb-mobile-section {
    display: inline-flex; align-items: center; min-width: 0; margin-left: auto; overflow: hidden;
    color: var(--text-2); font-family: var(--font-display); font-size: var(--fs-xs);
    font-weight: 700; letter-spacing: 0.06em; text-overflow: ellipsis; white-space: nowrap;
  }
  .tb-mobile-btc { display: inline-flex; align-items: baseline; gap: 4px; }
  .tb-menu-button { display: inline-flex; }
.tb-menu-scrim {
    position: fixed; inset: 56px 0 0; z-index: 98; width: 100%; height: calc(100dvh - 56px);
    border: 0; background: rgba(0,0,0,0.62); cursor: default;
  }
  .tb-mobile-panel {
    position: fixed; z-index: 99; top: 64px; right: 12px; width: min(320px, calc(100vw - 24px));
    padding: 8px; border: 1px solid var(--border-hover); border-radius: 8px;
    background: rgba(13,16,23,0.98); box-shadow: 0 24px 70px rgba(0,0,0,0.55);
  }
  .menu-open .tb-menu-scrim, .menu-open .tb-mobile-panel { display: block; }
  .tb-mobile-link {
    display: block; padding: 13px 14px; border-radius: 6px; color: var(--text-2);
    font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 700;
    letter-spacing: 0.05em; text-decoration: none;
  }
  .tb-mobile-link:hover { color: var(--text-1); background: rgba(255,255,255,0.05); }
  .tb-mobile-link.active { color: var(--text-1); background: rgba(255,255,255,0.09); }
  .tb-mobile-session { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
  .tb-mobile-action {
    display: block; width: 100%; text-align: left; padding: 13px 14px; border-radius: 6px;
    color: var(--text-2); background: none; border: 0; cursor: pointer;
    font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.05em;
  }
  .tb-mobile-action:hover { color: var(--text-1); background: rgba(255,255,255,0.05); }
  .tb-mobile-action.danger { color: #f87171; }
}

.tb-noscript-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.tb-noscript-nav a {
  color: var(--text-2);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 480px) {
  .wolfn-topbar { padding-inline: 12px; gap: 10px; }
  .tb-brand { gap: 8px; min-width: 0; }
  .tb-title { font-size: var(--fs-md); }
  .tb-mobile-section { font-size: var(--fs-label); }
}

/* ── SOP-666 §6.2: azul de texto para links (no toca --accent) ─── */
a { color: var(--accent-text); }

/* ── SOP-905 §6.7: regreso contextual a My Positions (lo pinta topbar.js) ── */
.tb-return-chip {
  position: fixed; left: 16px; bottom: 16px; z-index: 120;
  font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.02em;
  color: var(--text-1); text-decoration: none; padding: 9px 14px; border-radius: 9999px;
  background: rgba(13,16,23,0.94); border: 1px solid var(--border-hover);
  box-shadow: 0 6px 22px rgba(0,0,0,0.45);
}
.tb-return-chip:hover { border-color: var(--border-active); }

/* El foco de teclado (:focus-visible) y el bloque prefers-reduced-motion se
   mudaron a base.css. Vivían acá y por eso NO llegaban a las 7 páginas que no
   linkean tokens.css — entre ellas login.html, donde 5 de sus 8 controles
   seguían sin indicador de foco pese a estar SOP-666 implementado. */

/* ── Badges de veredicto (SOP-695 bloque A) ──────────────────────
   SSOT única: antes cada página decidía el color por su cuenta con un `if`
   binario (COPIAR=verde, todo lo demás=ámbar) — DESCARTAR se pintaba igual
   que ADAPTAR RANGO, dos decisiones opuestas con el mismo peso visual.
   Los 6 códigos que el motor puede producir (verdict_engine.py + STALE
   inyectado por curated_report_generator.py) tienen acá su propia clase.
   Consumir vía window.VerdictDisplay.present() (verdict-display.js), nunca
   decidir el color con un `if` de nuevo en una página. */
.badge { display: inline-block; padding: 3px 8px; border-radius: 5px; font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-family: var(--font-body); }
.badge-copiar    { background: rgba(34,197,94,0.14);   color: var(--bull);    border: 1px solid rgba(34,197,94,0.4); }
.badge-adaptar   { background: rgba(245,158,11,0.14);  color: var(--caution); border: 1px solid rgba(245,158,11,0.4); }
.badge-observar  { background: rgba(59,130,246,0.14);  color: var(--info);    border: 1px solid rgba(59,130,246,0.4); }
.badge-descartar { background: rgba(239,68,68,0.14);   color: var(--bear);    border: 1px solid rgba(239,68,68,0.4); }
.badge-idea      { background: rgba(148,163,184,0.14); color: var(--text-2);  border: 1px solid rgba(148,163,184,0.4); }
.badge-stale     { background: rgba(113,121,141,0.16); color: var(--text-2);  border: 1px solid rgba(113,121,141,0.4); }

/* ── SOP-762 §5: HOME Hierarchy Composition Helpers ───────────── */
.home-section-block { display: flex; flex-direction: column; gap: 12px; }
.home-context-group { display: flex; flex-direction: column; gap: 20px; }

