/* Max's Math Tycoon — avatar (§14): sizing wrapper, costume name tag. Tokens in tokens.css.
   Size comes from --size so a parent rule can shrink it (the mobile rail uses 24 px).
   The wrapper is at least --size wide and grows to hold the tag, so nothing spills onto neighbours. */
.avatar {
  --size: 64px;
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: var(--size); max-width: 100%; vertical-align: middle; line-height: 0;
}
.avatar > svg { display: block; width: var(--size); height: var(--size); overflow: visible; }
.avatar[data-size="24"]  { --size: 24px; }
.avatar[data-size="32"]  { --size: 32px; }
.avatar[data-size="40"]  { --size: 40px; }
.avatar[data-size="48"]  { --size: 48px; }
.avatar[data-size="96"]  { --size: 96px; }
.avatar[data-size="128"] { --size: 128px; }
.avatar[data-size="160"] { --size: 160px; }

/* The equipped complete costume's name appears beneath the figure.
   At most 1.6 × the figure wide and two lines tall: every catalogue costume name fits at 48, 64 and 96 px
   ("The Department Chair" wraps to two lines); anything longer clamps with an ellipsis and keeps its title. */
.avatar-tag {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  box-sizing: border-box; max-width: calc(var(--size) * 1.6); padding: 2px 5px;
  background: var(--ink); color: var(--rail-text);
  font-family: var(--font); font-weight: 600; font-size: max(8px, calc(var(--size) * 0.14)); line-height: 1.25;
  text-align: center; overflow: hidden; overflow-wrap: break-word;
}
/* Too small for type: a 24 / 32 px avatar shows no tag. (A 64 px avatar shrunk by a parent --size rule,
   as in the mobile rail, keeps data-size="64"; hide its tag from that parent rule.) */
.avatar[data-size="24"] .avatar-tag, .avatar[data-size="32"] .avatar-tag { display: none; }

/* Placeholder and portrait SVGs (silhouetteSvg, monogramSvg) size like any inline block. */
.avatar-placeholder, .monogram { display: inline-block; line-height: 0; }
.avatar-placeholder > svg, .monogram > svg { display: block; }

/* Warm illustrated figures: movement belongs to the tiny prop, so the face and
   controls stay steady. The complete character is used in larger previews. */
.avatar > svg { overflow: hidden; border-radius: 14%; }
.avatar-character { filter: none; }
.avatar-tag { border-radius: 8px; background: var(--ink); padding: 3px 7px; }
.costume-part-art { display: block; overflow: visible; max-width: 100%; }
.avatar-propeller { transform-origin: 64px 8px; animation: avatar-propeller 3s ease-in-out infinite; }
.avatar-clock-hand { transform-origin: 65px 28px; animation: avatar-clock 12s linear infinite; }
.avatar-bob { animation: avatar-bob 3s ease-in-out infinite; }
.avatar-float { animation: avatar-float 4s ease-in-out infinite; }
@keyframes avatar-propeller { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes avatar-clock { to { transform: rotate(360deg); } }
@keyframes avatar-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes avatar-float { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-3px) rotate(1deg); } }
@media (prefers-reduced-motion: reduce) {
  .avatar-propeller, .avatar-clock-hand, .avatar-bob, .avatar-float { animation: none !important; }
}
