/* base.css — tokens de diseño y primitivas compartidas (unidad, objeto, rasgo, barra, chips).
   La página (app.css) y el panel de detalle (detail.css) construyen sobre esto. */

:root {
  --bg: #1d1e20;
  --panel: #222326;
  --panel-2: #27282b;
  --panel-3: #313236;
  --border: #3d3e3f;
  --border-soft: #2e2f33;
  --text: #e6e6e6;
  --text-2: #cfcfcf;
  --muted: #a5a5a5;
  --accent: #cbb46c;
  --accent-soft: #c6b78b;
  --link: #8ab4f8;
  --good: #28a745;
  --mid: #e6e6e6;
  --bad: #dc3545;
  --bad-text: #f0717e;   /* mismo rojo aclarado para TEXTO: 5:1 sobre los paneles (#dc3545 se queda en 3.3-3.5:1) */
  --warn: #ffc107;
  --info: #1999bc;
  --reroll: #978956;
  --cost-0: #777;
  --cost-1: #b5b5b5;
  --cost-2: #14cf11;
  --cost-3: #0e2ae3;
  --cost-4: #c211cf;
  --cost-5: #b8a31c;
  --cost-6: #ff5e5e;
  --tier-S: #ff7e83;
  --tier-A: #ffbf7f;
  --tier-B: #ffdf80;
  --tier-C: #feff7f;
  --tier-D: #bffe7f;
  --radius: 6px;
  --radius-sm: 4px;
  --font: Poppins, "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --unit-md: 48px;
  --unit-sm: 36px;
  --unit-lg: 56px;
  --shadow: 0 2px 8px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  min-height: 100vh;
}
img { display: block; max-width: 100%; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- valores coloreados por media de puesto ---------- */
.avg-good { color: var(--good); }
.avg-mid { color: var(--mid); }
.avg-bad { color: var(--bad-text); }
.num-pos { color: var(--bad-text); }   /* +0.39 = peor puesto */
.num-neg { color: var(--good); }  /* -0.13 = mejor puesto */

/* ---------- insignia de tier ---------- */
.tier-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 15px; color: #1d1e20; background: rgba(255, 255, 255, .3);
}
.tier-S { background: var(--tier-S); }
.tier-A { background: var(--tier-A); }
.tier-B { background: var(--tier-B); }
.tier-C { background: var(--tier-C); }
.tier-D { background: var(--tier-D); }
.tier-unknown { background: rgba(255, 255, 255, .3); color: var(--text); }

/* ---------- chips de etiqueta (levelling / dificultad) ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 0 7px; height: 18px; border-radius: 9px; font-size: 11px; font-weight: 500;
  border: 1px solid var(--muted); background: rgba(165, 165, 165, .12); color: var(--text-2); white-space: nowrap;
}
.tag.boost { border-color: var(--info); background: rgba(25, 153, 188, .12); color: #4fc3e4; }
.tag.reroll { border-color: var(--reroll); background: rgba(151, 137, 86, .14); color: #c8b97a; }
.tag.standard { border-color: var(--muted); }
.tag.easy { border-color: #28a745; background: rgba(40, 167, 69, .12); color: #5fd37a; }
.tag.medium { border-color: #b8a31c; background: rgba(184, 163, 28, .12); color: #d9c23a; }
.tag.hard { border-color: #dc3545; background: rgba(220, 53, 69, .12); color: #f0717e; }
.tag .tag-icon { width: 11px; height: 11px; }

/* ---------- unidad ---------- */
.unit { position: relative; display: flex; flex-direction: column; align-items: center; width: var(--unit-md); flex: 0 0 auto; }
.unit-sm { width: var(--unit-sm); }
.unit-lg { width: var(--unit-lg); }
.unit-frame {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden;
  border: 2px solid var(--cost-1); background: #111;
}
.unit-frame.cost-0 { border-color: var(--cost-0); }
.unit-frame.cost-1 { border-color: var(--cost-1); }
.unit-frame.cost-2 { border-color: var(--cost-2); }
.unit-frame.cost-3 { border-color: var(--cost-3); }
.unit-frame.cost-4 { border-color: var(--cost-4); }
.unit-frame.cost-5 { border-color: var(--cost-5); }
.unit-frame.cost-6 { border-color: var(--cost-6); }
.unit-img { width: 100%; height: 100%; object-fit: cover; }
.unit-name {
  margin-top: 2px; width: 100%; font-size: 10px; line-height: 1.1; text-align: center; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.unit-sm .unit-name { font-size: 9px; }
.stars {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: -1px; line-height: 1; z-index: 2; color: #ffd44d;
  text-shadow: 0 0 2px #000, 0 0 3px #000;
}
.stars-4 { color: #7ef0ff; }
.unit-items {
  display: flex; justify-content: center; gap: 1px; margin-top: -8px; position: relative; z-index: 2;
}
.unit-items .item-img { width: 15px; height: 15px; border: 1px solid #000; border-radius: 2px; }
.unit-sm .unit-items .item-img { width: 12px; height: 12px; }
.unit-items + .unit-name { margin-top: 3px; }

/* ---------- objeto ---------- */
.item-img { border-radius: 3px; background: #111; }
.item-xs { width: 16px; height: 16px; }
.item-sm { width: 24px; height: 24px; }
.item-md { width: 32px; height: 32px; border: 1px solid var(--border); }
.item-lg { width: 48px; height: 48px; border: 1px solid var(--border); }

/* ---------- aumento ---------- */
.augment { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 44px; text-align: center; }
.augment-img { width: 36px; height: 36px; border-radius: 50%; background: #111; border: 1px solid var(--border); }
.augment-lg .augment-img { width: 44px; height: 44px; }
.augment-sm { width: 32px; }
.augment-sm .augment-img { width: 28px; height: 28px; }
.augment[data-rarity="Silver"] .augment-img { border-color: #9fb3b8; }
.augment[data-rarity="Gold"] .augment-img { border-color: #dac379; }
.augment[data-rarity="Prismatic"] .augment-img { border-color: #c8a2ff; }
.augment-name { font-size: 9px; line-height: 1.1; color: var(--text-2); }

/* ---------- rasgo compacto ---------- */
.trait-chip {
  display: inline-flex; align-items: center; gap: 3px; height: 16px; padding: 0 5px 0 2px;
  border-radius: 8px; font-size: 10px; font-weight: 600; color: var(--text); background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08); white-space: nowrap;
}
.trait-icon {
  width: 12px; height: 12px; flex: 0 0 12px; display: inline-block;
  -webkit-mask: var(--trait-mask) center / contain no-repeat; mask: var(--trait-mask) center / contain no-repeat;
  background: #444;
}
.trait-chip.trait-bronze .trait-icon { background: linear-gradient(180deg, #b46e45, #6f4b2a); }
.trait-chip.trait-silver .trait-icon { background: linear-gradient(180deg, #96abb2, #596e6f); }
.trait-chip.trait-gold .trait-icon { background: linear-gradient(180deg, #dac379, #a9873b); }
.trait-chip.trait-prismatic .trait-icon { background: linear-gradient(135deg, #ffb3ec, #9fe8ff 50%, #c7ffb3); }
.trait-chip.trait-unique .trait-icon { background: linear-gradient(180deg, #d58df1, #7a4b9c); }
.trait-chip.trait-inactive { opacity: .55; }
.trait-chip.trait-inactive .trait-icon { background: #555; }
.trait-chip.trait-bronze { border-color: rgba(180, 110, 69, .5); }
.trait-chip.trait-silver { border-color: rgba(150, 171, 178, .5); }
.trait-chip.trait-gold { border-color: rgba(218, 195, 121, .55); }
.trait-chip.trait-prismatic { border-color: rgba(200, 162, 255, .6); }
.trait-chip.trait-unique { border-color: rgba(213, 141, 241, .6); }
.trait-chip.trait-lg { height: 22px; font-size: 12px; padding: 0 8px 0 4px; gap: 5px; }
.trait-chip.trait-lg .trait-icon { width: 16px; height: 16px; flex-basis: 16px; }
/* icono de rasgo grande suelto (p. ej. cabecera de la pestaña de rasgos) */
.trait-big {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-3);
}
.trait-big .trait-icon { width: 24px; height: 24px; flex-basis: 24px; background: var(--text); }

/* ---------- barras ---------- */
.bar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; min-height: 22px; }
.bar-label { font-size: 11px; color: var(--text-2); }
.bar-track { height: 18px; background: var(--panel-3); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: #4b4d53; border-radius: 3px; min-width: 2px; transition: width .2s; }
.bar-right { font-size: 11px; text-align: right; line-height: 1.1; white-space: nowrap; }
.bar.bar-good .bar-fill { background: #3d7a4a; }
.bar.bar-bad .bar-fill { background: #8a3a43; }

/* ---------- controles ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); color: var(--text);
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); }
.btn.active, .btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn.btn-sm { height: 24px; padding: 0 8px; font-size: 11px; }
.btn.btn-icon { width: 30px; padding: 0; justify-content: center; }
.input {
  height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel-2); color: var(--text); outline: none; min-width: 0;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }

/* menú desplegable genérico */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; min-width: 180px; max-height: 60vh; overflow: auto;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 0;
}
.dropdown-menu.right { left: auto; right: 0; }
.dropdown-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 6px 12px; background: none; border: 0; text-align: left; color: var(--text);
}
.dropdown-item:hover, .dropdown-item:focus { background: var(--panel-3); outline: none; }
.dropdown-item.active { color: var(--accent); }
.dropdown-item .count { color: var(--muted); font-size: 11px; }
.dropdown-item img { width: 18px; height: 18px; }

/* pestañas */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: 8px 14px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-2); white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* tooltip básico por atributo (también con el foco de teclado) */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  background: #0f1012; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 8px; font-size: 11px; font-weight: 400; line-height: 1.3; width: max-content; max-width: 260px; z-index: 50; pointer-events: none;
  white-space: normal; text-align: left;
}

/* esqueleto / estados */
.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.error { padding: 12px; border: 1px solid var(--bad); border-radius: var(--radius); color: #f0717e; }
