/* Per-category levels list — see mockups/claude-mockups/category-levels/index.html
   for the reference design. Rows use flex (not grid): the level number
   participates in setting the row height so vertical centering "just works"
   instead of relying on grid alignment tricks. */

.category-levels {
  position: relative;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
}

/* Dashed divider between the level list and the quest list below.
   --color-border is too faint at ~15% opacity, so muted-fg at 35%
   gives a readable line. */
.category-levels::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px dashed color-mix(in srgb, var(--color-muted-fg) 35%, transparent);
}

/* Focused-level overlay — stacked on top of Totaal-XP inside the
   sticky bar. Both children of .sticky-stats__display; the overlay
   sits absolutely positioned, fading in/out via Stimulus. The min-
   height reserves enough vertical room for the overlay's lvl-row so
   the level number doesn't clip against the bar's top edge. */
.sticky-stats__display {
  position: relative;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.focused-level-slot {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 220ms ease, transform 220ms ease, visibility 0s linear 220ms;
}

/* CSS gate: the overlay only appears when BOTH the bar is stuck AND
   the controller has flagged it as visible. This avoids race conditions
   in JS where the sticky-stats IntersectionObserver can transiently flip
   the class during Turbo Stream reflows — CSS just listens to the
   current state of the class chain. */
.sticky-stats--stuck .focused-level-slot--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 220ms ease, transform 220ms ease, visibility 0s linear 0s;
}

/* Slim horizontal layout: level number · name · thin bar · XP — fits
   inside the sticky bar's existing Totaal-XP height instead of forcing
   the bar to grow. */
.focused-level {
  --pad: var(--color-muted-fg);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  max-width: 22rem;
  /* Solid background so the overlay fully hides the Totaal-XP block
     underneath. Uses --color-bg, which already matches the frosted
     glass behind the bar when stuck. */
  background: var(--color-bg);
  padding: 0.25rem 0.5rem;
  /* Reserve right-side room so the XP value doesn't slide under the
     fixed hamburger button on narrow viewports (matches sticky-stats's
     own padding-right: 3.5rem rule for the same reason). */
  margin-right: 2rem;
  font-variant-numeric: tabular-nums;
}

.focused-level__num {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--pad);
  text-align: center;
  min-width: 1.25rem;
  transform: translateY(-0.16em);
}

.focused-level__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.focused-level__name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9375rem;
  line-height: 1;
  color: var(--color-fg);
}

.focused-level__bar {
  width: 100%;
  height: 3px;
  background: color-mix(in srgb, var(--pad) 16%, transparent);
  border-radius: 2px;
  overflow: hidden;
}

.focused-level__fill {
  height: 100%;
  background: var(--pad);
  border-radius: 2px;
  /* Slower than the canonical .lvl-row__fill — the bar growth is the
     visual moment in this overlay, so let it linger. */
  transition: width 1.2s cubic-bezier(.2,.8,.2,1);
}

.focused-level__xp {
  font-size: 0.75rem;
  line-height: 1;
  color: var(--color-muted-fg);
  white-space: nowrap;
}

.focused-level__xp strong {
  color: var(--pad);
  font-weight: 600;
}

.category-levels__list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.category-levels__empty {
  color: var(--color-muted-fg);
  text-align: center;
  font-size: 0.875rem;
  margin: 0;
}

.lvl-row {
  --pad: var(--color-muted-fg);
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 0.875rem;
  background: var(--color-card, #ffffff);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.lvl-row__num {
  flex: 0 0 3rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--pad);
  text-align: center;
  font-variant-numeric: tabular-nums;
  /* Display-font glyphs sit low in their em-box (extra space above for
     accents + oldstyle figure descenders). Nudge up by 0.16em so the
     numeral lands optically centered against the name + bar. */
  transform: translateY(-0.16em);
}

.lvl-row__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.lvl-row__name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.0625rem;
  line-height: 1;
  color: var(--color-fg);
}

.lvl-row__bar {
  width: 100%;
  height: 4px;
  background: color-mix(in srgb, var(--pad) 16%, transparent);
  border-radius: 2px;
  overflow: hidden;
}

.lvl-row__fill {
  height: 100%;
  background: var(--pad);
  border-radius: 2px;
  transition: width 0.8s cubic-bezier(.2,.8,.2,1);
}

.lvl-row__xp {
  flex: 0 0 5.5rem;
  font-size: 0.8125rem;
  line-height: 1;
  color: var(--color-muted-fg);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.lvl-row__xp strong {
  color: var(--pad);
  font-weight: 600;
}

/* Total-XP header — sits inside the sticky bar above the per-category
   list. Label + value sit inline; text-align: center on the block
   centers them as a pair on the page. No margin-bottom: spacing to
   the level list comes from .sticky-stats's own margin-bottom, and a
   bottom margin here would offset the header within the flex-centered
   sticky bar (asymmetric layout-box shifts the visible text up). */
.category-levels__header {
  text-align: center;
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-muted-fg);
  font-variant-numeric: tabular-nums;
}

.category-levels__header-value {
  color: var(--color-fg);
  font-size: 1.0625rem;
  line-height: 1;
  /* Same optical correction as .lvl-row__num: display-font glyphs sit
     low in their em-box, so nudge up by 0.16em to land visually
     centered against the label baseline. inline-block so the transform
     applies (no-op on plain inline elements). */
  display: inline-block;
  transform: translateY(-0.16em);
}
