/* "Your items by level" (levels-panel.mjs) — in the Library and in the teacher's
   view of a student. Chess Bender's level tiles (repertoire.css `.ovlevel`):
   the count is the tile, big and in its level's colour, the name small under
   it; a level with nothing on it stays on the ladder, faded. Set from JS:
   style="--lvl: var(--lvl-3)", and --ui-accent for New. One rule, six
   colours. No colour of its own: theme.css has them all. */

.lvbox { container: levels / inline-size; }
/* In the Library it folds away (levels-view.js remembers), titled like a panel. */
details.lvbox { margin-bottom: 1rem; }
details.lvbox > summary { font: 800 1.25rem/1.25 var(--ui-display, var(--ui-font)); color: var(--ui-text); }
details.lvbox[open] > summary { margin-bottom: 0.75rem; }
.lvhint { margin: 0 0 0.75rem; }

/* Three to a row on a phone (two rows), all six in one when there is room. */
.lvtiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}
@container levels (min-width: 36rem) {
  .lvtiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.lvtile {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
  padding: 0.75rem 0.25rem 0.625rem;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: var(--ui-panel);
  color: var(--ui-text);
  font: inherit;
  cursor: pointer;
}
@media (hover: hover) { .lvtile:hover:not(:disabled) { border-color: var(--lvl); } }
.lvtile.empty { opacity: 0.45; cursor: default; }
.lvtile[aria-pressed="true"] { border-color: var(--lvl); box-shadow: inset 0 0 0 1px var(--lvl); }
.lvnum {
  font: 800 1.625rem/1 var(--ui-font);
  font-variant-numeric: tabular-nums;
  color: var(--lvl);
}
.lvname {
  font-size: max(0.75rem, var(--text-min));
  font-weight: 600;
  color: var(--ui-dim);
  overflow-wrap: anywhere;
}

.lvsub {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ui-text);
  margin: 1.125rem 0 0.5rem;
}

/* A kind or a deck: its name and total, then its levels as one bar. */
.lvrows { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.375rem; }
.lvrow {
  display: grid;
  grid-template-columns: minmax(7rem, 12rem) minmax(0, 1fr);
  gap: 0.625rem;
  align-items: center;
  padding-inline-start: calc(var(--depth, 0) * 0.875rem);
}
.lvrow.empty { opacity: 0.45; }
.lvrowname {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.25rem 0.5rem;
  border: 1px solid transparent;
  border-radius: var(--ui-radius);
  background: none;
  color: var(--ui-text);
  font: inherit;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
}
.lvrowname:disabled { cursor: default; }
@media (hover: hover) { .lvrowname:hover:not(:disabled) { background: var(--ui-btn); } }
.lvrowname[aria-pressed="true"] { border-color: var(--ui-accent); }
.lvrowlabel { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvrowtotal { color: var(--ui-dim); font-variant-numeric: tabular-nums; }

.lvbar { display: flex; gap: 2px; min-width: 0; }
.lvseg {
  flex: 1 1 0;
  min-width: 2rem;
  padding: 0.3125rem 0.25rem;
  border: 0;
  border-bottom: 3px solid var(--lvl);
  border-radius: 0.375rem;
  background: color-mix(in srgb, var(--lvl) 18%, transparent);
  color: var(--lvl);
  font: 800 max(0.8125rem, var(--text-min))/1.1 var(--ui-font);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
@media (hover: hover) { .lvseg:hover { background: color-mix(in srgb, var(--lvl) 30%, transparent); } }
.lvseg[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--lvl); }
@media (pointer: coarse) { .lvseg, .lvrowname { min-height: var(--touch-target); } }

/* On a phone the name goes above its bar. */
@container levels (max-width: 30rem) {
  .lvrow { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
}

.lvpick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.875rem 0 0;
  font-weight: 700;
}
