/* Paper doll (centre) and inspect column (right): comp A. Composes base.css primitives; tokens only. */

/* ================= paper doll ================= */
#doll { position: relative; display: flex; flex-direction: column; padding: var(--s5) var(--s5) var(--s4); }
/* header slot, top right in the panel's padding: the warnings badge (its list opens right-aligned below) */
.doll-head { position: absolute; top: var(--s1); right: var(--s3); z-index: 3; }
.doll-head-slot:empty { display: none; }
.doll-body { flex: 1; display: flex; flex-direction: column; }
.doll {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1fr);
  grid-template-rows: auto auto; /* both slot columns share the taller one's height; the left spreads its 6 slots */
  align-content: start;
  grid-template-areas: "left sum right" "weap weap weap";
  column-gap: var(--s4);
}
.doll-left { grid-area: left; }
.doll-right { grid-area: right; }
.doll-col { display: flex; flex-direction: column; justify-content: space-between; gap: clamp(var(--s2), 1.8vh, var(--s4)); padding-bottom: var(--s5); }

/* the slim summary column between the slot columns */
.doll-sum {
  grid-area: sum;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s4);
  margin-bottom: var(--s5);
  border-left: var(--hair); border-right: var(--hair);
}
.sum-block { display: grid; justify-items: center; gap: 2px; }
.sum-need { white-space: nowrap; padding: 0 var(--s2); }
.sum-label { font-family: var(--font-display); font-size: var(--fs-base); color: var(--muted); }
.sum-num { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: var(--fw-medium); line-height: 1.1; color: var(--text); }
.sum-rule { width: 64px; border-top: var(--hair); }
/* hit vs the cap: "4.2 / 5%", the cap part quieter; gold at the cap, warn well over it */
.sum-hit .sum-num { font-size: var(--fs-xl); white-space: nowrap; }
.sum-of { font-size: var(--fs-base); color: var(--muted); }
.sum-hit.is-at .sum-num { color: var(--gold); }
.sum-hit.is-over .sum-num { color: var(--warn); }
.sum-changed { min-height: 1.5em; font-size: var(--fs-xs); color: var(--muted); text-align: center; }

/* weapons row along the bottom, hairline above and between */
.doll-weapons {
  grid-area: weap;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4);
  padding-top: var(--s4); border-top: var(--hair);
}
.doll-weapons > .slot:not(:first-child)::before {
  content: ""; position: absolute; top: var(--s2); bottom: var(--s2); left: calc(var(--s4) / -2 - 1px);
  border-left: var(--hair);
}

/* one slot: icon in its quality frame, muted label, name in quality colour, score */
.slot {
  position: relative;
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; padding: var(--s2);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  color: inherit; font: inherit; text-align: left; cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.slot:hover { border-color: var(--line-strong); }
.slot.is-selected { border-color: var(--gold); }
.slot.is-loading { cursor: default; }
.slot.is-loading:hover { border-color: transparent; }
.slot-text { display: grid; gap: 1px; min-width: 0; }
.slot-label { font-family: var(--font-display); font-size: var(--fs-md); color: var(--muted); line-height: 1.3; }
/* long names (suffix items) wrap to a second line instead of losing "of Strength" to an ellipsis */
.slot-name { font-size: var(--fs-base); line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.slot-score { font-family: var(--font-display); font-size: var(--fs-md); color: var(--text-2); line-height: 1.3; }
.slot.is-zero .slot-name { opacity: 0.55; }
.slot .sk-line { height: 8px; margin: 3px 0; width: 120px; }
.slot .sk-line.sk-short { width: 48px; }
.slot .sk-line.sk-tiny { width: 24px; }
.sfx { opacity: 0.8; }

/* the memorable moment: a changed pick glints once (gold hairline fading out) */
@keyframes slot-glint {
  from { border-color: var(--gold); background-color: var(--gold-soft); }
  to { border-color: transparent; background-color: transparent; }
}
@keyframes slot-glint-selected {
  from { background-color: var(--gold-soft); }
  to { background-color: transparent; }
}
.slot.glint { animation: slot-glint 600ms var(--ease); }
.slot.is-selected.glint { animation-name: slot-glint-selected; }
@media (prefers-reduced-motion: reduce) {
  .slot.glint { animation: none; }
}

/* state marks on an icon corner: lock (top right), owned (bottom right), set pick (bottom left, grid) */
.icon .mark {
  display: grid; place-items: center;
  background: var(--bg); border: var(--hair-strong); border-radius: 1px;
  color: var(--gold);
}
.icon .mark svg { width: 9px; height: 9px; stroke-width: 2; }
.icon .mark-owned { top: auto; bottom: -4px; color: var(--text); }
.icon .mark-pick { top: auto; right: auto; bottom: -4px; left: -4px; color: var(--gold); border-color: var(--gold-line); }
.icon.sm .mark { width: 11px; height: 11px; right: -3px; top: -3px; }
.icon.sm .mark-owned { top: auto; bottom: -3px; }

/* doll states: error / fatal in place of the doll */
.doll-msg {
  margin: auto; max-width: 52ch;
  display: flex; gap: var(--s2); align-items: flex-start;
  padding: var(--s3) var(--s4); border: var(--hair-strong); border-radius: var(--radius);
  color: var(--text-2); font-size: var(--fs-md);
}
.doll-msg svg { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--warn); }
.doll-msg.is-fatal svg { color: var(--bad); }
.doll-msg code { font-size: var(--fs-sm); color: var(--text); background: var(--panel-3); padding: 1px 4px; border-radius: var(--radius); }

/* ================= inspect column ================= */
.inspect { display: flex; flex-direction: column; }
.inspect.is-stale .insp-alts, .inspect.is-stale .insp-tip { opacity: 0.5; }
.insp-head { align-items: center; border-bottom: 0; padding: var(--s4) var(--s4) var(--s2); }
/* three columns: the inspect panel scrolls inside the viewport (layout.css); its header stays put */
@media (min-width: 1280px) {
  .insp-head { position: sticky; top: 0; z-index: 2; background: var(--panel); }
}
.insp-title { display: flex; align-items: baseline; gap: var(--s2); font-size: var(--fs-xl); min-width: 0; }
.insp-title > span:first-child { white-space: nowrap; }
.insp-dot { font-weight: var(--fw-regular); }
.insp-view > button { display: inline-grid; place-items: center; height: 24px; padding: 0 8px; }
.insp-view svg { width: 14px; height: 14px; }

/* ranked rows (comp A scale, image-led): rank, 44 px icon, name over a score-length bar, score over Δ */
.alts { list-style: none; margin: 0; padding: 0 var(--s3); display: grid; }
.alt { position: relative; }
.alt + .alt { border-top: var(--hair); }
.alt-gap { height: var(--s2); border-top: 1px dashed var(--line); margin-top: var(--s1); }
.alt-main {
  width: 100%;
  display: grid;
  grid-template-columns: 24px 44px minmax(0, 1fr) 52px;
  grid-template-areas: "rank icon name score" "rank icon bar delta";
  column-gap: var(--s3); row-gap: var(--s2); align-items: center; align-content: center;
  padding: var(--s3) var(--s2);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  color: inherit; font: inherit; text-align: left; cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.alt-main:hover { background: var(--panel-2); }
.alt.is-focus .alt-main { border-color: var(--gold); }
.alt-rank { grid-area: rank; font-family: var(--font-display); font-size: var(--fs-xl); color: var(--muted); text-align: center; }
.alt-main > .icon { grid-area: icon; }
.alt-main > .icon.sm { width: 44px; height: 44px; }
.alt-name { grid-area: name; align-self: end; font-size: var(--fs-base); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alt-bar { grid-area: bar; align-self: start; height: 6px; }
.alt-score { grid-area: score; align-self: end; justify-self: end; font-family: var(--font-display); font-size: var(--fs-base); color: var(--text-2); line-height: 1.3; }
.alt-delta { grid-area: delta; align-self: start; justify-self: end; font-size: var(--fs-xs); color: var(--muted); line-height: 1; }
.alt-pick { grid-area: delta; align-self: start; justify-self: end; display: inline-flex; color: var(--gold); line-height: 1; }
.alt-pick svg { width: 12px; height: 12px; }
.alts.is-empty .alt-main, .alts.is-loading .alt-main { cursor: default; }
.alts.is-empty .alt-main:hover, .alts.is-loading .alt-main:hover { background: transparent; }
.alts.is-loading .sk-line { height: 8px; width: 70%; grid-area: name; align-self: end; }
.alts.is-loading .sk-bar { grid-area: bar; align-self: start; height: 6px; }
.alts-none { padding: var(--s3) var(--s4); font-size: var(--fs-md); }

/* quick marks: appear on row hover / focus; an active mark stays */
.marks { display: inline-flex; gap: 3px; }
.mk {
  width: 24px; height: 24px; padding: 0;
  display: grid; place-items: center;
  background: var(--panel-2); border: var(--hair-strong); border-radius: var(--radius);
  color: var(--muted); cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.mk svg { width: 13px; height: 13px; }
.mk:hover { color: var(--text); border-color: var(--muted); }
.mk[aria-pressed="true"] { color: var(--gold); border-color: var(--gold-line); background: var(--gold-soft); }
.marks.compact { position: absolute; top: calc(var(--s3) + 1px); right: calc(var(--s2) + 52px + var(--s3)); }
.marks.compact .mk { width: 20px; height: 20px; background: var(--panel); }
.marks.compact .mk svg { width: 11px; height: 11px; }
.alt .marks.compact .mk { opacity: 0; }
.alt .marks.compact .mk[aria-pressed="true"],
.alt:hover .marks.compact .mk,
.alt:focus-within .marks.compact .mk { opacity: 1; }
.alt:hover .alt-name, .alt:focus-within .alt-name, .alt.has-marks .alt-name { padding-right: 70px; }

/* packed icon grid (direction raise): stamp-size icons, marks persist */
.alt-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: var(--s1);
  padding: var(--s1) var(--s3);
}
.cell {
  display: grid; justify-items: center; gap: 3px;
  padding: 6px 0 4px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  color: inherit; font: inherit; cursor: pointer;
}
.cell:hover { background: var(--panel-2); }
.cell.is-focus { border-color: var(--gold); }
.cell-score { font-size: var(--fs-xs); color: var(--muted); line-height: 1; }
.cell-rank { position: absolute; inset: 0; display: grid; place-items: center; font-size: var(--fs-xs); color: var(--muted); }

.alts-foot { display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s3); }
.alts-foot .grow { flex: 1; }
.alts-foot .btn { height: 26px; font-size: var(--fs-sm); gap: 6px; }
.alts-foot .btn svg { width: 14px; height: 14px; }
.alts-more .num { font-size: var(--fs-xs); color: var(--muted); }

/* hidden items: grouped reasons */
.hidden-list { margin: 0 var(--s4) var(--s3); border: var(--hair); border-radius: var(--radius); max-height: 340px; overflow: auto; }
.hid-group + .hid-group { border-top: var(--hair); }
.hid-group summary {
  display: flex; justify-content: space-between; gap: var(--s2);
  padding: 6px var(--s3); cursor: pointer; font-size: var(--fs-sm); color: var(--text-2);
  list-style: none;
}
.hid-group summary::-webkit-details-marker { display: none; }
.hid-group summary:hover { color: var(--text); background: var(--panel-2); }
.hid-group[open] summary { border-bottom: var(--hair); }
.hid-group ul { list-style: none; margin: 0; padding: var(--s1) 0; }
.hid-row { display: flex; align-items: center; gap: var(--s1); padding-right: var(--s2); }
.hid-row.is-focus { background: var(--gold-soft); }
.hid-main {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: var(--s2);
  padding: 4px var(--s3); background: transparent; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.hid-main:hover { background: var(--panel-2); }
.hid-text { display: grid; min-width: 0; font-size: var(--fs-sm); line-height: 1.3; }
.hid-text > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hid-why { font-size: var(--fs-xs); color: var(--muted); }
.hid-include { height: 24px; font-size: var(--fs-xs); }
.hid-cap { padding: var(--s2) var(--s3); font-size: var(--fs-xs); }

/* ================= tooltip panel ================= */
.insp-tip { padding: var(--s3) var(--s4) var(--s4); }
.insp-tip:empty { display: none; }
.tt { display: grid; gap: var(--s3); }
.tt.is-loading { gap: var(--s2); }
.tt-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s3); align-items: start; }
.tooltip .tt-name { font-family: var(--font-display); font-size: var(--fs-lg); line-height: 1.25; }
.tt-title { display: grid; gap: 2px; min-width: 0; }
.tt-sub { font-size: var(--fs-sm); color: var(--q, var(--muted)); }
.tt-body { display: grid; }
.tt-row { display: flex; justify-content: space-between; gap: var(--s3); }
.tooltip .tt-right { color: var(--text); white-space: nowrap; }
.tooltip .tt-unmet { color: var(--bad); }
.tooltip .tt-set { color: var(--text-2); }

.tt-sec { display: grid; gap: var(--s2); padding-top: var(--s3); border-top: var(--hair); }
.tt-h { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); font-size: var(--fs-base); color: var(--text); }
.tt-h-val { display: inline-flex; align-items: baseline; gap: 4px; font-family: var(--font); font-weight: var(--fw-regular); font-size: var(--fs-sm); color: var(--text-2); }
.tt-h-val .badge { align-self: center; }

.sc-lines, .sc-list, .sc-issues, .src-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.sc-line, .sc-list li { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.sc-line.zero { color: var(--muted); }
.sc-lbl { display: inline-flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-val { flex: none; color: var(--text-2); white-space: nowrap; }
.sc-line.zero .sc-val { color: var(--muted); }
.sc-est { height: 16px; font-size: 10px; }
.sc-tag { height: 16px; margin-left: 6px; font-size: 10px; }
.sc-issue { color: var(--bad); }
.sc-toggles { display: flex; gap: var(--s1); margin-left: calc(-1 * var(--s2)); }
.sc-toggle { height: 24px; padding: 0 var(--s2); font-size: var(--fs-xs); gap: 4px; }
.sc-toggle svg { width: 12px; height: 12px; }
.sc-list { font-size: var(--fs-xs); color: var(--muted); padding-left: var(--s1); }

.src { display: flex; align-items: baseline; gap: var(--s2); font-size: var(--fs-sm); }
.src.low { opacity: 0.7; }
.src-mark { flex: none; min-width: 56px; justify-content: center; color: var(--text-2); }
.src-text { display: flex; flex-wrap: wrap; column-gap: 6px; min-width: 0; }
.src-text > * + *::before { content: "\00b7"; margin-right: 6px; color: var(--dim); }
.src-ent { color: var(--text); }
.src-place, .src-det { color: var(--muted); }
.src-status { margin-left: auto; flex: none; }
.src-more { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.src-more-bar { display: inline-block; width: 40px; height: 4px; }

.tt-foot { padding-top: var(--s2); border-top: var(--hair); }
.tt-link { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-sm); }
.tt-link svg { width: 12px; height: 12px; }

/* ================= responsive ================= */
@media (max-width: 1279px) {
  /* right column sits under the doll: alternatives and tooltip side by side */
  .inspect {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "head tip" "alts tip";
  }
  .insp-head { grid-area: head; }
  .insp-alts { grid-area: alts; padding-bottom: var(--s3); }
  .insp-tip { grid-area: tip; padding-top: var(--s4); }
}
@media (max-width: 899px) {
  .inspect { display: flex; }
}
@media (max-width: 640px) {
  #doll { padding: var(--s3); }
  .doll {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "sum" "left" "right" "weap";
  }
  .doll-sum { flex-direction: row; justify-content: space-around; border: 0; border-bottom: var(--hair); margin: 0 0 var(--s3); padding-bottom: var(--s3); }
  .sum-rule { width: 0; height: 40px; border-top: 0; border-left: var(--hair); }
  .doll-col { padding-bottom: var(--s2); }
  .doll-weapons { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .doll-weapons > .slot:not(:first-child)::before { display: none; }
}
.hidden-list.is-loading { display: grid; gap: var(--s2); padding: var(--s3); }
