/* Guide walkthrough round 17 (F101, F102; mockups round-17/f101-mockups and f102-mockups, A1): the public level chooser
   and its thin top bar (Views/Shared/Sb/_LevelChooser.cshtml, js/sb/level-chooser.js). Every level is a list in aligned
   columns (read down, then the next column), tinted with the category tree colour of its depth (decisions.md: level 1
   blue, 2 violet, 3 magenta, 4 slate, then again) and a 4px bar on the left. The chosen item is the brand fill with
   --brand-on text (round 29, F170, never the inverted look); --muted keeps 4:1 on every tint. Every colour is a token of
   sb/tokens.css; every gap is compact (decisions.md F42). */

.level-chooser { display: flex; flex-direction: column; padding: var(--sp-1) 0; }
.level-chooser:focus { outline: none; }
.level-chooser:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.level-chooser__level--lv1 { --lv-bg: var(--tree-lv1-bg); --lv-bar: var(--tree-lv1-bar); }
.level-chooser__level--lv2 { --lv-bg: var(--tree-lv2-bg); --lv-bar: var(--tree-lv2-bar); }
.level-chooser__level--lv3 { --lv-bg: var(--tree-lv3-bg); --lv-bar: var(--tree-lv3-bar); }
.level-chooser__level--lv4 { --lv-bg: var(--tree-lv4-bg); --lv-bar: var(--tree-lv4-bar); }

/* One level: the tint and the bar of its depth. */
.level-chooser__level { margin: var(--sp-1) var(--sp-2); padding: 3px var(--sp-1) 3px calc(var(--sp-1) + 4px); border-radius: var(--r-md); background: var(--lv-bg, var(--surface-2)); box-shadow: inset 4px 0 0 var(--lv-bar, var(--line-strong)); }

/* The items of a level in aligned columns, one under another. */
.level-chooser__list { columns: 4 210px; column-gap: var(--sp-1); margin: 0; padding: 0; list-style: none; }
.level-chooser__list > li { break-inside: avoid; padding: 1px 0; }

.level-chooser__item { display: flex; align-items: center; gap: var(--sp-1); width: 100%; min-height: 32px; padding: var(--sp-1) 10px; border: 1px solid transparent; border-radius: var(--r-sm); color: var(--text); font-size: var(--fs-md); font-weight: 600; line-height: var(--lh-tight); text-decoration: none; }
a.level-chooser__item:hover { background: var(--surface); border-color: var(--line-strong); }
.level-chooser__item--all { font-weight: 800; }
.level-chooser__item--empty { color: var(--muted); font-weight: 500; }
.level-chooser__name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.level-chooser__count { flex: none; color: var(--muted); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; }
/* Round 29 (F170): the chosen item is the brand fill with --brand-on text and a border in the fill colour (no frame), in
   both themes; hover keeps the brand fill (--brand-hover). */
.level-chooser__item[aria-current="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-on); }
a.level-chooser__item[aria-current="true"]:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--brand-on); }
.level-chooser__item[aria-current="true"] .level-chooser__count { color: var(--brand-on); }
@media (pointer: coarse) { .level-chooser__item { min-height: var(--tap); } }

/* The thin bar under the site header while the chooser is out of view: the current choice and "Change selection". */
.level-bar { position: fixed; z-index: 30; top: var(--app-header-bottom, var(--header-h)); left: 0; right: 0; pointer-events: none; }
.level-bar__in { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); padding-block: 6px; border: 1px solid var(--line-strong); border-top: 0; border-radius: 0 0 var(--r-md) var(--r-md); background: var(--surface); box-shadow: var(--shadow-2); pointer-events: auto; }
.level-bar__crumb { display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: center; gap: 2px; min-width: 0; font-weight: 700; }
.level-bar__step { padding: 3px 6px; border-radius: var(--r-sm); color: var(--brand-text); text-decoration: underline; overflow-wrap: anywhere; }
.level-bar__current { padding: 3px 6px; overflow-wrap: anywhere; }
.level-bar__sep { color: var(--muted); }
.level-bar__change { flex: none; }
@media (pointer: coarse) { .level-bar__step { display: inline-flex; align-items: center; min-height: var(--tap); } }

/* A phone: two columns per level and the margins of the page. */
@media (max-width: 760px) {
  .level-chooser__list { columns: 2 140px; }
  .level-chooser__level { margin-inline: var(--sp-1); }
}

/* Forced colours: the chosen item keeps a fill of its own in the system colours, so it does not depend on the tint. */
@media (forced-colors: active) {
  .level-chooser__item[aria-current="true"], a.level-chooser__item[aria-current="true"]:hover { forced-color-adjust: none; background: Highlight; border-color: Highlight; color: HighlightText; }
  .level-chooser__item[aria-current="true"] .level-chooser__count { color: HighlightText; }
  .level-chooser__level { border: 1px solid CanvasText; }
}
