/* Interface juice: many small answers (2 to 8%, 40 to 300 ms),
   springs, one-shot lights that pass once; nothing blinks, nothing loops but the Play button's breath (.loop: stops
   with less motion). One-shots run in 1 ms with less motion (css/base.css), never "animation: none".
   Every time and size of this layer is in the block below (the JS side: src/ui/feel-ui.js). */
:root {
  --j-lift: 2; /* card with mana for it: sits this many --u higher */
  --j-hop: 260ms; /* card that just became affordable: a hop */
  --j-glint: 420ms; /* the light that passes once (card, mana) */
  --j-tick: 180ms; /* one more point of mana */
  --j-roll: 240ms; /* odometer digit */
  --j-heal: 520ms; /* camp repair */
  --j-star: 520ms; /* camp star going out; stage-grid star glint */
  --j-breathe: 2.8s; /* Play button, 2.5% */
  --j-enter: 200ms; /* a screen comes in (opacity only: the camp scene stays behind, never black) */
  --j-end: 450ms; /* end card: the heroes come in while the stars land */
  --j-hero: 320ms; /* end card: one hero comes in */
  --j-hero-step: 70ms; /* end card: the next hero, this much later */
  --j-arrow: 520ms; /* defeat drawing: the arrow comes in */
  --j-arrow-at: 420ms; /* defeat drawing: after the card rose a little */
  --j-grid-at: 160ms; /* stage grid: the first star glints after the panel pops */
}

/* ---- G1: the hand. A card with mana sits a little higher; the instant it becomes affordable it hops and a light
   passes over it once (clipped to the card's face). Without mana it stays dim but readable. */
.card:not(.off):not(.sel):not(.drag) {
  transform: translateY(calc(var(--u) * var(--j-lift) * -1));
}
.card.ready {
  animation: cardHop var(--j-hop) cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes cardHop {
  40% {
    translate: 0 calc(var(--u) * -5);
  }
}
.card.ready::after {
  content: '';
  position: absolute;
  inset: calc(var(--u) * 4) calc(var(--u) * 5);
  border-radius: calc(var(--u) * 7);
  pointer-events: none;
  background: linear-gradient(105deg, transparent 44%, rgba(255, 255, 255, 0.38) 50%, transparent 56%) no-repeat;
  background-size: 250% 100%;
  background-position: 0 0;
  animation: cardGlint var(--j-glint) ease-out;
}
@keyframes cardGlint {
  from {
    background-position: 100% 0;
  }
}
.card.off .pic {
  filter: grayscale(0.55) brightness(0.82);
}
/* G2: how much mana an unaffordable card still needs, small, on the bottom of its picture */
.card .need {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  bottom: calc(var(--u) * 17);
  padding: calc(var(--u) * 1) calc(var(--u) * 4) 0;
  border-radius: calc(var(--u) * 6);
  background: rgba(8, 18, 24, 0.72);
  color: #bfeaff;
  font-size: calc(var(--u) * 10);
  line-height: 1.25;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}
.card .need:empty {
  display: none;
}
@media (min-aspect-ratio: 4/3) {
  .card .need {
    bottom: calc(var(--u) * 15);
    font-size: calc(var(--u) * 9);
  }
}
@media (min-aspect-ratio: 4/3) and (max-height: 500px) {
  .card .need {
    bottom: 10px;
    font-size: 8px;
    padding: 0 3px;
  }
}

/* ---- G3: every point of mana that comes in: the number gives a small tick (the full meter's glint: css/hud.css) */
#energy > b.tick {
  animation: manaTick var(--j-tick) ease-out;
}
@keyframes manaTick {
  35% {
    scale: 1.12;
    color: #c8f1ff;
  }
}

/* ---- G4: the coin counter rolls like an odometer (only the digits that changed come up) */
#matchCoins i {
  display: inline-block;
  font-style: normal;
}
#matchCoins i.roll {
  animation: coinRoll var(--j-roll) cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes coinRoll {
  from {
    translate: 0 0.4em;
  }
}

/* ---- G5: a repair rises in green (the lost chunk that lingers is .lag in css/hud.css) */
#baseBox .bar.heal > .fill {
  animation: campHeal var(--j-heal) ease-out;
}
@keyframes campHeal {
  30% {
    filter: brightness(1.25) drop-shadow(0 0 calc(var(--u) * 4) rgba(120, 236, 140, 0.9));
  }
}

/* The star count sits beside the health bar. */
#baseBox .cst {
  display: flex;
  align-items: center;
  flex: none;
  gap: 3px;
  padding-inline-start: 4px;
  border-inline-start: 1px solid #56717c;
  color: #ffd978;
  font-size: clamp(10px, calc(var(--u) * 11), 18px);
  white-space: nowrap;
}
#baseBox .cst img {
  width: 1.1em;
  height: 1.1em;
}
#baseBox .cst.lost {
  animation: starOut var(--j-star) ease-out;
}
@keyframes starOut {
  from {
    filter: brightness(1.65);
  }
}
#baseBox.nostars .cst {
  display: none;
}

/* ---- G8: Play breathes very lightly (a loop: still with less motion); the stage grid's earned stars glint one
   after the other when it opens */
/* the face (icon and word) breathes, not the button box: the box stays still for the touch and for test clicks */
#playBtn.loop > span {
  animation: playBreathe var(--j-breathe) ease-in-out infinite;
}
@keyframes playBreathe {
  50% {
    scale: 1.04;
  }
}
.calm #playBtn.loop > span {
  animation-name: none !important;
}
.modal.on .lvgrid .st img.got {
  animation: gridStar var(--j-star) ease-out calc(var(--j-grid-at) + var(--d, 0ms)) backwards;
}
@keyframes gridStar {
  40% {
    scale: 1.3;
    filter: brightness(1.45) drop-shadow(0 0 calc(var(--u) * 3) rgba(255, 214, 107, 0.9));
  }
}

/* ---- G9 + G14: the stage button shows its stars and what comes; the menu shows the stars won beside the coins */
.menu-pills {
  position: absolute;
  top: calc(var(--u) * 10);
  left: calc(var(--u) * 10);
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 8);
  z-index: 3;
}
#menu .menu-pills {
  --chip: max(44px, calc(var(--u) * 42));
}
#menu .menu-pills > .art-pill {
  position: static;
  height: var(--chip);
  min-height: 0;
  border-width: calc(var(--u) * 9);
  font-size: calc(var(--u) * 16);
}
#menu .menu-pills .ic {
  width: calc(var(--u) * 19);
  height: calc(var(--u) * 19);
  object-fit: contain;
}
#menu #achievementsBtn {
  width: var(--chip);
}
#menu #achievementsBtn .ic {
  width: calc(var(--u) * 23);
  height: calc(var(--u) * 23);
}
#menu #achievementsBtn > span {
  padding: 0;
}
#menu #achievementsBtn:focus-visible {
  outline: 2px solid #8ee8bd;
  outline-offset: 2px;
  border-radius: 8px;
}
@media (min-aspect-ratio: 4/3) {
  #menu .menu-pills {
    --u: min(100vw / 390, 100dvh / 480, 2px);
  }
}
.stage-btn .stinfo {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 8);
  flex: none;
}
.stage-btn .stinfo .st {
  display: flex;
  gap: 1px;
}
.stage-btn .stinfo .st img {
  width: calc(var(--u) * 14);
  height: calc(var(--u) * 14);
}

/* ---- G10 / G11: victory. The heroes of the match side by side (their level's body, the level badge, how many they
   defeated); the one with most stands a little bigger on a soft gold glow. Then one short line of numbers. */
.mvp {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: calc(var(--u) * 4);
}
.mvp .hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 1);
  width: calc(var(--u) * 58);
}
.mvp .pic {
  position: relative;
  z-index: 1;
  width: 100%;
  height: calc(var(--u) * 50);
  background: center bottom / contain no-repeat;
}
.mvp .badge {
  position: absolute;
  right: calc(var(--u) * 1);
  bottom: 0;
  width: calc(var(--u) * 19);
  height: calc(var(--u) * 19);
}
.mvp .badge img {
  display: block;
  width: 100%;
  height: 100%;
}
.mvp .badge b {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--u) * 11);
  line-height: 1;
  padding-top: var(--cap);
}
.mvp b {
  display: flex;
  align-items: center;
  gap: 0.2em;
  font-size: calc(var(--u) * 14);
  padding-top: var(--cap);
  white-space: nowrap;
}
.mvp b .ic {
  width: 1em;
  height: 1em;
}
.mvp .hero.top .pic {
  height: calc(var(--u) * 60);
}
.mvp .hero.top b {
  color: var(--gold);
}
.mvp .hero.top::before {
  content: '';
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: calc(var(--u) * 12);
  height: calc(var(--u) * 16);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 211, 106, 0.55), rgba(255, 211, 106, 0));
}
.modal.on .mvp .hero {
  animation: heroIn var(--j-hero) cubic-bezier(0.3, 1.5, 0.5, 1) calc(var(--j-end) + var(--i) * var(--j-hero-step))
    backwards;
}
@keyframes heroIn {
  from {
    translate: 0 calc(var(--u) * 10);
    opacity: 0;
  }
}
.panel p.sum {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: calc(var(--u) * 2) calc(var(--u) * 14);
  font-size: calc(var(--u) * 13);
}
.panel p.sum span {
  white-space: nowrap;
  padding-top: var(--cap);
}
/* landscape: the heroes and their numbers go to a right column, so the card keeps its height and "Next" its size
   (stacked, the 844x390 card shrank to 0.76 and the button under 44 px) */
@media (min-aspect-ratio: 4/3) {
  .panel[data-id='victory']:has(.mvp) {
    width: min(100%, calc(var(--u) * 600));
  }
  .panel[data-id='victory']:has(.mvp) .body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: calc(var(--u) * 16);
    align-content: start;
  }
  .panel[data-id='victory']:has(.mvp) .body > * {
    grid-column: 1;
  }
  .panel[data-id='victory'] .body > .mvp {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: end;
  }
  .panel[data-id='victory'] .body > .sum {
    grid-column: 2;
    grid-row: 4 / span 2;
    align-self: start;
  }
  .panel[data-id='victory']:has(.mvp) .body > .btns {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(100%, calc(var(--u) * 340));
  }
}

/* ---- G12: defeat. The camp in the middle, the hero that was missing on the side the blow came from, the field's
   arrow beyond it pointing at the camp (it comes in once along its own line) */
.lesson {
  display: flex;
  justify-content: center;
}
.lesson .ground {
  position: relative;
  width: calc(var(--u) * 156);
  height: calc(var(--u) * 100);
  border-style: solid;
  border-color: transparent;
  border-image: url(../assets/ui/inner.webp) 36 fill;
  border-width: calc(var(--u) * 7);
}
.lesson .scene {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--u) * 6);
}
.modal.on .lesson .scene {
  animation: lessonIn 260ms ease-out 120ms backwards;
}
@keyframes lessonIn {
  from {
    opacity: 0;
    scale: 0.96;
  }
}
.calm .lesson .scene {
  animation: none;
}

/* the defeat card's layout (drawing beside the text, buttons in rows): css/journey.css */

/* ---- G7: a screen comes in with a short fade, the camp scene always visible behind (no flash, no black) */
.screen.on {
  animation: screenIn var(--j-enter) ease-out;
}
@keyframes screenIn {
  from {
    opacity: 0;
  }
}
/* End of css/juice-ui.css (complete file). */
