/* Generated character presentation. Loaded after screens.css. */

.char .char-svg {
  z-index: 0;
}

.char .char-img {
  inset: auto auto 0 50%;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: 50% 100%;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  z-index: 1;
  pointer-events: none;
}

.char .char-img--alternate {
  z-index: 2;
}

.char.has-published-art .char-svg {
  opacity: 0 !important;
  visibility: hidden;
}

/* The grey and coloured unicorn paintings are overlaid. Progress reveals the colour
   gradually while the exact sixteen-word count remains visible in the small gem badge. */
.char[data-art-mode="unicorn-progress"] .char-img--alternate.is-shown {
  opacity: 1;
  clip-path: inset(0 calc(100% - var(--char-fill, 0%)) 0 0);
  transition: clip-path 700ms cubic-bezier(.22,.61,.36,1), opacity 120ms linear;
}

/* Butterfly paintings use their authored open and closed frames. The closed frame fully
   replaces the open one at the middle of each flap, so no procedural wing shows through. */
.char[data-art-mode="butterfly-flap"] .char-img--primary.is-shown {
  animation: character-butterfly-open 760ms ease-in-out infinite;
}

.char[data-art-mode="butterfly-flap"] .char-img--alternate.is-shown {
  animation: character-butterfly-closed 760ms ease-in-out infinite;
}

.char.is-flying[data-art-mode="butterfly-flap"] .char-img--primary.is-shown,
.char.is-flying[data-art-mode="butterfly-flap"] .char-img--alternate.is-shown {
  animation-duration: 240ms;
}

@keyframes character-butterfly-open {
  0%, 38%, 62%, 100% { opacity: 1; }
  48%, 52% { opacity: 0; }
}

@keyframes character-butterfly-closed {
  0%, 38%, 62%, 100% { opacity: 0; }
  48%, 52% { opacity: 1; }
}

.char-progress {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.char-progress__badge {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: grid;
  grid-auto-flow: column;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 1.5%, 4px);
  min-height: 12%;
  padding: 3% 5%;
  border: max(1px, calc(var(--char-size, 160px) * .012)) solid rgba(74,59,52,.7);
  border-radius: 999px;
  background: rgba(255,253,248,.92);
  box-shadow: 0 3px 8px rgba(74,59,52,.18);
  transform: translate(-50%, 18%);
}

.char-progress__pip {
  display: block;
  width: clamp(4px, calc(var(--char-size, 160px) * .038), 8px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #e4dfda;
  box-shadow: inset 0 0 0 1px rgba(74,59,52,.2);
}

.char-progress__badge--segments .char-progress__pip.is-earned {
  background: #7fd0ad;
  box-shadow: inset 0 0 0 1px #3d9c77, 0 0 5px #a8e6a1;
}

.char-progress__badge--stripes {
  grid-auto-flow: row;
  grid-template-columns: repeat(8, auto);
  grid-template-rows: repeat(2, auto);
  gap: 2px;
  padding: 3% 5%;
}

.char-progress__badge--stripes .char-progress__pip.is-earned:nth-child(7n+1) { background: #ff9a9e; }
.char-progress__badge--stripes .char-progress__pip.is-earned:nth-child(7n+2) { background: #ffc287; }
.char-progress__badge--stripes .char-progress__pip.is-earned:nth-child(7n+3) { background: #ffe98a; }
.char-progress__badge--stripes .char-progress__pip.is-earned:nth-child(7n+4) { background: #a8e6a1; }
.char-progress__badge--stripes .char-progress__pip.is-earned:nth-child(7n+5) { background: #9fd0ff; }
.char-progress__badge--stripes .char-progress__pip.is-earned:nth-child(7n+6) { background: #b3aef0; }
.char-progress__badge--stripes .char-progress__pip.is-earned:nth-child(7n) { background: #dcaef0; }

.char-progress__leaf {
  position: absolute;
  left: 3%;
  top: 5%;
  display: grid;
  place-items: center;
  width: 26%;
  aspect-ratio: 1.25;
  border: max(1px, calc(var(--char-size, 160px) * .012)) solid #4a3b34;
  border-radius: 70% 24% 70% 24%;
  background: #a8e6a1;
  color: #4a3b34;
  font: 800 clamp(12px, calc(var(--char-size, 160px) * .13), 30px)/1 system-ui, sans-serif;
  transform: rotate(-12deg);
  box-shadow: 0 3px 8px rgba(74,59,52,.18);
}

.char-progress__glow {
  position: absolute;
  inset: 9%;
  border: max(2px, calc(var(--char-size, 160px) * .018)) solid color-mix(in srgb, var(--char-accent, #d9c7ff) 76%, white);
  border-radius: 50%;
  opacity: .58;
  box-shadow: 0 0 clamp(8px, 8%, 18px) var(--char-accent, #d9c7ff);
}

@media (prefers-reduced-motion: reduce) {
  .char[data-art-mode="butterfly-flap"] .char-img--primary.is-shown { animation: none; opacity: 1; }
  .char[data-art-mode="butterfly-flap"] .char-img--alternate.is-shown { animation: none; opacity: 0; }
}

html.reduced-motion .char[data-art-mode="butterfly-flap"] .char-img--primary.is-shown {
  animation: none;
  opacity: 1;
}

html.reduced-motion .char[data-art-mode="butterfly-flap"] .char-img--alternate.is-shown {
  animation: none;
  opacity: 0;
}
