/* DM UI kit — shared component primitives (pairs with app/static/views/ui.js).
   New controls live here; tokens + older primitives (.btn/.seg/.field/.toast/.modal) live in theme.css.
   Everything derives from the theme tokens so the whole app shares one ember identity. */

/* ── Switch — a boolean on/off toggle (NOT a selection-from-a-set; that's .seg or Select) ── */
.ui-switch { display: inline-flex; align-items: center; gap: var(--sp-5); cursor: pointer; user-select: none; font-size: var(--fs-smplus); color: var(--text); }
.ui-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ui-switch-track { position: relative; flex: none; width: 2.125rem; height: 1.1875rem; border-radius: var(--r-pill);
  background: var(--panel-2); border: 0.0625rem solid var(--border); transition: background .15s, border-color .15s; }
.ui-switch-thumb { position: absolute; top: 0.0625rem; left: 0.0625rem; width: 0.9375rem; height: 0.9375rem; border-radius: var(--r-round);
  background: var(--muted); transition: transform .15s, background .15s; }
.ui-switch input:checked + .ui-switch-track { background: var(--accent); border-color: var(--accent); }
.ui-switch input:checked + .ui-switch-track .ui-switch-thumb { transform: translateX(0.9375rem); background: var(--on-accent); }
.ui-switch input:focus-visible + .ui-switch-track { outline: 0.125rem solid var(--accent); outline-offset: 0.125rem; }
.ui-switch.disabled { opacity: .5; cursor: default; }

/* ── Checkbox / Radio — native controls tinted to the ember accent, in a labelled row ── */
.ui-check { display: inline-flex; align-items: center; gap: 0.4375rem; cursor: pointer; user-select: none; font-size: var(--fs-smplus); color: var(--text); }
.ui-check input { flex: none; width: 0.9375rem; height: 0.9375rem; accent-color: var(--accent); cursor: pointer; }
.ui-check.disabled { opacity: .5; cursor: default; }

/* ── Chip — a compact label/tag; optional × is a remove ACTION, not a selection toggle ── */
.ui-chip { display: inline-flex; align-items: center; gap: 0.3125rem; background: var(--panel-2); border: 0.0625rem solid var(--border);
  color: var(--text); border-radius: var(--r-pill); padding: var(--sp-1) var(--sp-6); font-size: var(--fs-xs); line-height: 1.6; }
.ui-chip.accent { background: rgba(var(--accent-rgb), .12); border-color: rgba(var(--accent-rgb), .5); color: var(--accent); }
.ui-chip.gold   { background: rgba(var(--gold-rgb), .12);   border-color: rgba(var(--gold-rgb), .5);   color: var(--gold); }
.ui-chip.good   { border-color: rgba(63,185,80,.5);  color: var(--good); }
.ui-chip.bad    { border-color: rgba(248,81,73,.5);  color: var(--bad); }
.ui-chip.has-x { padding-right: var(--sp-3); }
.ui-chip-x { width: 0.875rem; height: 0.875rem; border-radius: var(--r-round); font-size: var(--fs-micro); }  /* icon-btn (2.2) */

/* ── Number field — the rule-compliant numeric input (replaces +/− button steppers) ── */
.ui-num { width: 4.5rem; background: var(--bg); border: 0.0625rem solid var(--border); color: var(--text); border-radius: var(--r-sm);
  padding: 0.3125rem var(--sp-5); font-size: var(--fs-base); font-family: var(--font-sans); font-variant-numeric: tabular-nums;
  transition: border-color .16s var(--ease-soft); }
.ui-num:focus { border-color: var(--accent); }
.ui-num:disabled { opacity: .55; }
/* NumberField label + unit affix (0.2) */
.ui-numfield { display: inline-flex; flex-direction: column; gap: var(--sp-3); }
.ui-numfield-lbl { --mlbl-fs: 0.625rem; color: var(--muted); }
.ui-numwrap { display: inline-flex; align-items: baseline; gap: var(--sp-4); }
.ui-numunit { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Tooltip / info dot — help text on hover/focus, never an on-page info dump ── */
.ui-info { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 0.9375rem; height: 0.9375rem;
  border-radius: var(--r-round); border: 0.0625rem solid var(--border); background: var(--panel-2); color: var(--muted);
  font-size: var(--fs-2xs); cursor: help; vertical-align: middle; }
.ui-info:hover, .ui-info:focus-visible { border-color: var(--accent); color: var(--accent); }
/* position:fixed + coords set inline (from the dot's rect) so the bubble is never clipped by an
   overflow:auto column and always wins the stacking order. transform centers it on the computed left. */
.ui-info-bubble { position: fixed; transform: translateX(-50%);
  width: max-content; max-width: 15rem; background: var(--panel); border: 0.0625rem solid rgba(var(--accent-rgb), .35);
  border-radius: var(--r-lg); padding: 0.4375rem var(--sp-6); font-size: var(--fs-xs); line-height: 1.4; color: var(--text); text-align: left;
  box-shadow: var(--shadow-drop-md); z-index: 1000; pointer-events: none; animation: ui-info-in .12s ease; }
@keyframes ui-info-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .ui-switch-track, .ui-switch-thumb, .ui-num { transition: none; }
  .ui-info-bubble { animation: none; }
}

/* Shared empty/loading state for ALL rosters (characters · campaigns · worlds): a centred panel with
   a brass ✦ medallion, a display-font line, and the primary CTA. */
.roster-empty {
  padding: 3.375rem 2.5rem; text-align: center; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-8);
}
.roster-empty-ico {
  width: 3.375rem; height: 3.375rem; border-radius: var(--r-round); display: inline-flex;
  align-items: center; justify-content: center; font-size: var(--fs-modal); color: var(--gold);
  background: radial-gradient(circle at 50% 34%, rgba(var(--gold-rgb), .2), rgba(var(--gold-rgb), .03));
  border: 0.0625rem solid rgba(var(--gold-rgb), .45);
  box-shadow: inset 0 0 0.75rem -0.25rem rgba(var(--gold-rgb), .5);
}
.roster-empty-msg { font-family: var(--font-display); font-size: var(--fs-modal); color: var(--text); margin: 0; }
.roster-empty .btn { margin-top: var(--sp-1); }
.roster-empty-hint { font-size: var(--fs-base); color: var(--muted); margin: -0.375rem 0 0; }

/* Campaign-tab roster headers: ONE scale + layout for Adventures/Maps/Encounters/Characters.
   Scoped under .cshell-body so legacy screens keep their own headers. */
.cshell-body .roster-head { display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-7); margin: var(--sp-3) 0 var(--sp-9); }
.cshell-body .roster-head h1 { font-family: var(--font-display); font-size: var(--fs-page);
  font-weight: 600; margin: 0; }

/* ── IconBtn — ONE square icon button (2.2). Neutral hover→ember, destructive→red (via .icon-btn-bad),
   selected→gold-fill (via .is-on) — consistent with the ember=action / gold=selected / red=danger canon.
   Two sizes: base (1.875rem) + .icon-btn-sm (1.25rem). Component: IconBtn in /static/views/ui.js. */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 1.875rem; height: 1.875rem; padding: 0;
  background: var(--panel-2); border: 0.0625rem solid var(--border); color: var(--muted);
  border-radius: var(--r-md); cursor: pointer; font-size: var(--fs-md); line-height: 1; text-decoration: none;
  transition: border-color 140ms var(--ease-soft), color 140ms var(--ease-soft), background 140ms var(--ease-soft);
}
.icon-btn:hover:not(:disabled):not(.is-on) { border-color: var(--accent); color: var(--accent); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn.icon-btn-bad:hover:not(:disabled) { border-color: var(--bad); color: var(--bad-hover); }
.icon-btn.icon-btn-sm { width: 1.25rem; height: 1.25rem; border-radius: var(--r-sm); font-size: var(--fs-sm); }
.icon-btn.is-on { background: var(--gold); border-color: var(--gold); color: var(--bg); }

/* ── Slider — one range control (2.5). `.ui-zoomslider` stays its own zoom idiom (panels.css). */
.ui-slider { display: inline-flex; align-items: center; gap: var(--sp-5); min-width: 0; flex: 1 1 auto; }
.ui-slider-track { flex: 1 1 auto; min-width: 0; accent-color: var(--accent); cursor: pointer; }
.ui-slider-track:disabled { opacity: 0.5; cursor: not-allowed; }
.ui-slider-out { flex: none; min-width: 2.5rem; text-align: right; font: 600 var(--fs-xs)/1 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Icon — the ONE inline-SVG chrome glyph (Phase 4; registry in _icons.js). currentColor + two sizes. */
.ui-icon { width: 0.875rem; height: 0.875rem; flex: none; display: inline-block; vertical-align: -0.125em; color: currentColor; }
.ui-icon-lg { width: 1.125rem; height: 1.125rem; }

/* ── ContextMenu — THE right-click action menu (_menu.js). Summoned by another element's gesture,
   floats at viewport coords. Rows are ACTIONS or MODE-TOGGLES (.on = currently-active mode).
   z-index must beat every raised panel (panel zSeq grows unbounded). */
.ui-menu { position: fixed; z-index: 10000; display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-4); background: var(--panel); border: 0.0625rem solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--glow-gold); }
.ui-menu-it { display: flex; align-items: center; gap: 0.5625rem; white-space: nowrap; text-align: left;
  border: 0.0625rem solid transparent; background: transparent; color: var(--text); border-radius: var(--r-md);
  padding: var(--sp-4) 0.5625rem; font: 500 var(--fs-sm) var(--font-sans); cursor: pointer; }
.ui-menu-it:hover:not(:disabled) { background: var(--panel-2); border-color: var(--border); }
.ui-menu-it.on { background: rgba(var(--accent-rgb), .16); border-color: var(--accent); }
.ui-menu-it:disabled { opacity: .4; cursor: default; }
.ui-menu-it.bad { color: var(--bad); }                      /* destructive row (danger canon) */
.ui-menu-it.bad:hover:not(:disabled) { background: rgba(var(--bad-rgb), .12); border-color: var(--bad); }
.ui-menu-ic { width: 1.125rem; text-align: center; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; }
.ui-menu-lbl { flex: 1 1 auto; }
.ui-menu-chk { width: 0.75rem; text-align: center; color: var(--accent); font-weight: 700; flex: 0 0 auto; }


/* ── Pop — the click-toggled popover primitive (views/_pop.js) ────────────────
   Opens on CLICK, closes on outside-click/Escape; never hover (operator law). Kit, not play
   chrome: the Library grid's settings uses the same component. Play keeps its own width/layout
   variants (.tf-viewpop, .tf-rulespop, …) in play.css. Class names kept as-is so no play surface
   has to change. */
.tf-pop { position: relative; }
.tf-popbtn { min-width: 2rem; padding: var(--sp-3) var(--sp-4); }
.tf-popmenu { position: absolute; top: calc(100% + 0.375rem); right: 0; z-index: 40; width: 20rem;
  max-height: 60vh; overflow-y: auto; padding: var(--sp-6);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 0.0625rem solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-drop-md); }
.tf-popmenu-up { top: auto; bottom: calc(100% + 0.375rem); }
.tf-popmenu-left { left: 0; right: auto; }     /* a button on the LEFT — hang the menu the other way */
