/* detail.css — panel de detalle de una composición (5 pestañas).
   Todos los selectores llevan el prefijo .cd- y construyen sobre los tokens y primitivas de base.css.
   El contenedor recibe la clase .comp-detail desde detail.js. */

.comp-detail { background: var(--panel); color: var(--text); font-size: 12px; overflow: hidden; }
.cd-tabs { padding: 0 6px; background: var(--panel-2); }
.cd-tab { font-size: 13px; font-weight: 500; padding: 9px 14px; }
.cd-body { padding: 12px; min-width: 0; }

/* ---------- piezas comunes ---------- */
.cd-section { margin-bottom: 16px; min-width: 0; }
.cd-section:last-child { margin-bottom: 0; }
.cd-h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; text-align: center; color: var(--text); }
.cd-h4 { font-size: 12px; font-weight: 600; margin: 12px 0 6px; text-align: center; color: var(--text-2); }
.cd-empty { color: var(--muted); text-align: center; padding: 14px 8px; font-size: 12px; }
.cd-empty-inline { color: var(--muted); }
.cd-link { background: none; border: 0; color: var(--link); padding: 4px; font-size: 11px; text-decoration: underline; cursor: pointer; }
.cd-link:hover { color: var(--text); }
.cd-stat { text-align: center; min-width: 62px; }
.cd-stat-v { font-size: 16px; font-weight: 600; line-height: 1.15; }
.cd-stat-l { font-size: 10px; color: var(--muted); white-space: nowrap; }
.cd-avg { font-weight: 600; }
.cd-units { display: flex; flex-wrap: wrap; gap: 6px 4px; padding-top: 8px; min-width: 0; } /* hueco para las estrellas */
.cd-units-mini { gap: 4px 3px; padding-top: 6px; }
.cd-img-missing {
  display: inline-grid; place-items: center; width: 100%; height: 100%; min-width: 16px; min-height: 16px;
  color: var(--muted); background: var(--panel-3); font-size: 11px; font-weight: 600; border-radius: 3px;
}
.augment .cd-img-missing { width: 36px; height: 36px; border-radius: 50%; }
.cd-search { width: 100%; height: 28px; font-size: 12px; margin-bottom: 6px; }
.cd-search::-webkit-search-cancel-button { filter: invert(.7); }

/* sub-pestañas (Early / Lvl N, Items / Full Builds, variaciones de pro comps) */
.cd-subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; margin-bottom: 8px; scrollbar-width: thin; }
.cd-subtab {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 5px 10px; color: var(--text-2);
  display: flex; flex-direction: column; align-items: center; line-height: 1.15; white-space: nowrap; cursor: pointer;
}
.cd-subtab b { font-weight: 600; font-size: 12px; }
.cd-subtab small { font-size: 10px; color: var(--muted); }
.cd-subtab:hover { color: var(--text); }
.cd-subtab.active { color: var(--accent); border-bottom-color: var(--accent); }
.cd-subtab.active small { color: var(--accent-soft); }

/* filas de barra (unidades, objetos, rasgos) */
.cd-rows { display: flex; flex-direction: column; gap: 3px; max-height: 480px; overflow-y: auto; padding-right: 2px; scrollbar-width: thin; }
.cd-brow {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 50px; gap: 6px; align-items: center;
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 2px; text-align: left; color: inherit; cursor: pointer;
}
.cd-brow:hover { background: var(--panel-2); }
.cd-brow.active { border-color: var(--accent); background: var(--panel-2); }
.cd-brow-icon { display: flex; justify-content: center; }
.cd-brow .unit { width: 32px; }
.cd-brow-track { height: 26px; background: var(--panel-3); border-radius: 3px; overflow: hidden; }
.cd-brow-fill { height: 100%; background: #4b4d53; min-width: 2px; border-radius: 0 3px 3px 0; }
.cd-brow.active .cd-brow-fill { background: #5a5d66; }
.cd-brow-val { display: flex; flex-direction: column; line-height: 1.15; font-size: 11px; }
.cd-brow-val .cd-avg { font-size: 12px; }
.cd-brow-pct { color: var(--text-2); font-size: 10px; }
.cd-mrow { display: grid; grid-template-columns: 56px minmax(0, 1fr) 50px; gap: 6px; align-items: center; margin-bottom: 3px; }
.cd-mrow .cd-brow-track { height: 22px; }
.cd-mrow-label { font-size: 11px; text-align: right; color: var(--text-2); white-space: nowrap; }
.cd-starlbl { color: #ffd44d; letter-spacing: -1px; font-size: 12px; }
.cd-starlbl.t1 { color: #b5b5b5; }
.cd-starlbl.t2 { color: #d8d8d8; }
.cd-starlbl.t4 { color: #7ef0ff; }

/* cabecera de detalle (unidad / objeto / rasgo elegido) */
.cd-dname { font-size: 14px; text-align: center; margin: 2px 0 8px; }
.cd-dhead { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 4px; }
.cd-dhead-stats { display: flex; gap: 14px; }
.cd-dhead .item-lg { width: 52px; height: 52px; }

/* tablas */
.cd-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cd-table th { font-weight: 600; color: var(--text-2); font-size: 11px; padding: 4px 6px; text-align: center; border-bottom: 1px solid var(--border); white-space: nowrap; }
.cd-table td { padding: 4px 6px; text-align: center; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.cd-table td:first-child { text-align: left; }
.cd-table .unit, .cd-table .trait-chip { margin: 0; }
.cd-pchange { font-size: 11px; }

/* ---------- tablero hexagonal (4 × 7) ---------- */
.cd-board { position: relative; width: 100%; max-width: 420px; aspect-ratio: 7.5 / 3.7528; margin: 0 auto; }
.cd-hex { position: absolute; width: 13.3333%; height: 30.769%; }
.cd-hex-shape {
  position: absolute; inset: 1px; background: var(--panel-3);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.cd-hex-unit .cd-hex-shape { background: var(--cost-1); }
.cd-hex-unit.cost-0 .cd-hex-shape { background: var(--cost-0); }
.cd-hex-unit.cost-2 .cd-hex-shape { background: var(--cost-2); }
.cd-hex-unit.cost-3 .cd-hex-shape { background: var(--cost-3); }
.cd-hex-unit.cost-4 .cd-hex-shape { background: var(--cost-4); }
.cd-hex-unit.cost-5 .cd-hex-shape { background: var(--cost-5); }
.cd-hex-unit.cost-6 .cd-hex-shape { background: var(--cost-6); }
.cd-hex-img {
  position: absolute; inset: 2.5px; overflow: hidden; background: #111;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.cd-hex-img img { width: 100%; height: 100%; object-fit: cover; }
.cd-hex-name {
  position: absolute; left: 0; right: 0; bottom: 18%; padding: 0 4px; text-align: center;
  font-size: 9px; line-height: 1.1; color: #fff; text-shadow: 0 0 2px #000, 0 0 3px #000, 0 1px 2px #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cd-hex-items { position: absolute; left: 50%; bottom: 2%; transform: translateX(-50%); display: flex; gap: 1px; z-index: 2; }
.cd-hex-items .item-img { width: 13px; height: 13px; border: 1px solid #000; border-radius: 2px; }
@media (max-width: 420px) {
  .cd-hex-name { font-size: 7.5px; bottom: 16%; }
  .cd-hex-items .item-img { width: 10px; height: 10px; }
}

/* ---------- 1. Options & Quick Start ---------- */
.cd-options { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; }
.cd-opt-left, .cd-opt-right { min-width: 0; }
.cd-opt-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border-soft); }
.cd-lvl-row { grid-template-columns: minmax(0, 1fr) auto; }
.cd-lvl-label { font-weight: 600; font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px 0; text-align: center; background: var(--panel-2); }
.cd-lvl-label-empty { visibility: hidden; }
.cd-opt-main { min-width: 0; }
.cd-opt-main .cd-units { padding-top: 10px; }
.cd-opt-traits { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.cd-opt-stats { display: flex; gap: 10px; justify-content: flex-end; }
.cd-early-block, .cd-lvl-options { display: flex; flex-direction: column; }
.cd-early-block > .cd-link, .cd-lvl-options > .cd-link { align-self: flex-end; }

.cd-lvl-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; }
.cd-lvl-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; }
.cd-lvl-chip b { font-weight: 600; }
.cd-ico { width: 12px; height: 12px; display: inline-block; vertical-align: middle; }
.cd-lvl-chip .cd-ico { color: var(--info); }
.cd-rerolls { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; }
.cd-reroll { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; }
.cd-reroll .cd-ico { color: var(--accent); }
.cd-reroll small { color: var(--muted); font-weight: 400; font-size: 10px; }

.cd-carousel { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; }
.cd-carousel-item { display: inline-flex; align-items: center; gap: 2px; }
.cd-carousel-n { font-size: 10px; color: var(--text-2); }
.cd-carousel-sep { color: var(--muted); }

.cd-aug-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 8px; }
.cd-aug { position: relative; }
.cd-aug-tier-mini { position: absolute; top: -4px; left: -2px; width: 15px; height: 15px; font-size: 9px; border-radius: 3px; z-index: 2; }
.cd-aug-tier { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; align-items: start; margin-bottom: 8px; }
.cd-aug-tier .cd-aug-grid { justify-content: flex-start; }
.cd-aug-box > .cd-link { display: block; margin: 6px auto 0; }

/* ---------- 2. Units & Items ---------- */
.cd-units-tab { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; }
.cd-col { min-width: 0; }
.cd-unit-detail, .cd-item-detail, .cd-trait-detail { padding: 0 4px; }
.cd-item-list .cd-subtabs { justify-content: center; }
.cd-builds { display: flex; flex-direction: column; max-height: 480px; overflow-y: auto; scrollbar-width: thin; }
.cd-build-group { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.cd-build-unit { padding-top: 8px; }
.cd-build-row { display: grid; grid-template-columns: minmax(0, 1fr) 54px 46px; gap: 6px; align-items: center; margin-bottom: 4px; }
.cd-build-items { display: flex; gap: 3px; }
.cd-build-stat { display: flex; flex-direction: column; align-items: center; line-height: 1.15; font-size: 12px; font-weight: 600; }
.cd-build-rows > .cd-link { float: right; }

/* ---------- 3. Traits & Stats ---------- */
.cd-traits-tab { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 18px; }
.cd-traits-left { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; min-width: 0; }
.cd-traits-right { min-width: 0; }
.cd-ticon { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-3); display: inline-grid; place-items: center; }
.cd-ticon .trait-icon { width: 18px; height: 18px; flex-basis: 18px; background: var(--text-2); }
.cd-trow.active .cd-ticon { background: #3a3b40; }
.cd-stack { display: flex; height: 26px; background: var(--panel-3); border-radius: 3px; overflow: hidden; gap: 1px; }
.cd-seg { display: grid; place-items: center; font-size: 10px; font-weight: 600; color: #fff; text-shadow: 0 0 2px #000; min-width: 0; overflow: hidden; flex: 0 0 auto; }
.cd-seg-bronze { background: linear-gradient(180deg, #8f5a39, #6f4b2a); }
.cd-seg-silver { background: linear-gradient(180deg, #7f9096, #596e6f); }
.cd-seg-gold { background: linear-gradient(180deg, #c4ad63, #a9873b); }
.cd-seg-prismatic { background: linear-gradient(135deg, #d99cc8, #8fc8dc 50%, #a8d99a); }
.cd-seg-unique { background: linear-gradient(180deg, #a86fc0, #7a4b9c); }
.cd-seg-inactive { background: #555; }

.cd-charts-top { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 12px; margin-bottom: 10px; }
.cd-chart { min-width: 0; }
.cd-chart-wrap { position: relative; }
.cd-svg { width: 100%; height: auto; display: block; max-height: 260px; }
.cd-svg-bar { fill: #4b4d53; }
.cd-svg-bar.first { fill: #5c5e68; }
.cd-svg-val { font-size: 9px; fill: var(--text-2); font-family: var(--font); }
.cd-svg-x { font-size: 10px; fill: var(--text-2); font-family: var(--font); }
.cd-svg-x.first { fill: var(--accent); font-weight: 700; }
.cd-svg-axis { font-size: 9px; fill: var(--muted); font-family: var(--font); }
.cd-svg-axis-l { fill: var(--accent); }
.cd-svg-tick { font-size: 9px; fill: var(--muted); font-family: var(--font); }
.cd-svg-tick-l { fill: var(--accent-soft); }
.cd-svg-grid { stroke: var(--border-soft); stroke-width: 1; }
.cd-svg-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.cd-svg-line-avg { stroke: var(--accent); }
.cd-svg-line-pick { stroke: #dedede; }
.cd-svg-dot-avg { fill: var(--accent); stroke: var(--panel); stroke-width: 1.5; }
.cd-svg-dot-pick { fill: #dedede; stroke: var(--panel); stroke-width: 1.5; }
.cd-svg-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.cd-legend { display: flex; justify-content: center; gap: 16px; font-size: 11px; color: var(--text-2); margin-bottom: 2px; }
.cd-legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 5px; border-radius: 1px; }
.cd-legend-avg { background: var(--accent); }
.cd-legend-pick { background: #dedede; }
.cd-radio { display: inline-flex; gap: 10px; font-size: 12px; font-weight: 400; vertical-align: middle; }
.cd-radio label { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; }
.cd-radio input { accent-color: var(--accent); margin: 0; }
.cd-tip {
  position: absolute; pointer-events: none; background: #0f1012; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 8px; font-size: 11px; white-space: nowrap; z-index: 5; transform: translate(-50%, 0); line-height: 1.35;
}
.cd-tip-title { font-weight: 600; margin-bottom: 2px; }

/* ---------- 4. Pro Augments and Tips ---------- */
.cd-pro-head { display: flex; justify-content: flex-start; margin-bottom: 8px; }
.cd-pro-select { max-width: 100%; min-width: 220px; }
.cd-pro-meta { margin-bottom: 6px; }
.cd-pro-title { font-size: 14px; }
.cd-pro-by { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--text-2); margin-top: 2px; }
.cd-pro-region { border: 1px solid var(--border); border-radius: 3px; padding: 0 5px; font-size: 10px; }
.cd-pro-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.cd-pro-left, .cd-pro-right { min-width: 0; }
.cd-notes { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: 12.5px; color: var(--text); padding: 4px 6px; }
.cd-tiers { display: flex; flex-direction: column; gap: 6px; }
.cd-tier-row { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; align-items: stretch; }
.cd-tier-label { display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #1d1e20; border-radius: var(--radius-sm); min-height: 36px; }
.cd-tier-content { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--panel-2); border-radius: var(--radius-sm); padding: 4px 6px; min-height: 36px; }

/* ---------- 5. Counters ---------- */
.cd-counters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.cd-counter-col { min-width: 0; }
.cd-counter-title { display: inline-block; border: 1px solid var(--border); border-radius: 16px; padding: 4px 14px; margin-bottom: 10px; }
.cd-good .cd-counter-title { border-color: var(--good); color: #6fd38a; }
.cd-weak .cd-counter-title { border-color: var(--accent); color: var(--accent); }
.cd-counter { padding: 6px 0 8px; border-bottom: 1px solid var(--border-soft); }
.cd-counter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cd-counter-name { background: none; border: 0; padding: 0; color: var(--text); font-weight: 600; font-size: 12.5px; text-align: left; cursor: pointer; }
.cd-counter-name:hover { color: var(--accent); text-decoration: underline; }
.cd-counter-avg { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cd-counter-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.cd-counter-stats { display: flex; gap: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .cd-units-tab { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .cd-options, .cd-traits-tab, .cd-pro-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .cd-counters { grid-template-columns: 1fr; }
  .cd-tab { padding: 8px 10px; font-size: 12px; }
}
/* en pantallas estrechas las pestañas se parten en dos filas en vez de cortarse con scroll invisible */
@media (max-width: 800px) {
  .cd-tabs { flex-wrap: wrap; overflow-x: visible; }
}
@media (max-width: 640px) {
  .cd-units-tab, .cd-traits-left, .cd-charts-top { grid-template-columns: 1fr; }
  .cd-rows, .cd-builds { max-height: 360px; }
  .cd-body { padding: 10px 8px; }
}
@media (max-width: 480px) {
  .cd-opt-row { grid-template-columns: 40px minmax(0, 1fr); }
  .cd-lvl-row { grid-template-columns: minmax(0, 1fr); }
  .cd-opt-stats { grid-column: 1 / -1; justify-content: flex-start; }
  .cd-lvl-row .cd-opt-stats { justify-content: flex-end; }
  .cd-counter-body { grid-template-columns: 1fr; }
  .cd-counter-stats { justify-content: flex-start; }
  .cd-stat { min-width: 56px; }
  .cd-stat-v { font-size: 14px; }
  .cd-dhead { gap: 10px; }
  .cd-pro-select { min-width: 0; width: 100%; }
}

/* histogramas: centrados y sin escalar de más (max-width inline desde detail.js) */
.cd-svg-hist { margin: 0 auto; }
.cd-chart-host { min-width: 0; }
