/* Birdy Branch: panels (how to play, pause, victory, no moves, sound, settings, language). Panel always centered on both
   axes; if it does not fit, it shrinks evenly (src/ui/modal.js, fitPanel). Straight banner mounted on the top edge, one size
   only; X centered on the top right corner. Spring entrance by a class removed at the end (changing a setting does not replay it). */
:root {
  --pb: calc(var(--u) * 6);
  --rh: calc(var(--u) * 10.5);
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 60, 18, 0.42);
}
.panel {
  position: relative;
  width: calc(var(--u) * 60);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 3);
  padding: calc(var(--rh) / 2 + var(--u) * 1.6) calc(var(--u) * 1.5) calc(var(--u) * 1.5);
  border: var(--pb) solid transparent;
  border-image: url(../assets/ui/panel.webp) 64 fill / var(--pb);
}
.panel > .ribbon {
  position: absolute;
  z-index: 2;
  top: calc(var(--pb) * -1 - var(--rh) / 2);
  left: 50%;
  translate: -50% 0;
  --h: var(--rh);
}
.panel > .x {
  position: absolute;
  z-index: 3;
  right: calc(var(--pb) * -1);
  top: calc(var(--pb) * -1);
  translate: 50% -50%;
  width: max(44px, calc(var(--u) * 10));
  height: max(44px, calc(var(--u) * 10));
  background: url(../assets/ui/close.webp) center / 100% 100% no-repeat;
}
.panel > .x[data-p='dn'] {
  filter: brightness(0.88);
}
.modal.in .panel {
  animation: pop-in 0.34s var(--pop) both;
}
@keyframes pop-in {
  from {
    transform: scale(0.84);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
.modal.in {
  animation: dim-in 0.2s both;
}
@keyframes dim-in {
  from {
    background: rgba(22, 60, 18, 0);
  }
}
body.reduced .modal.in .panel {
  animation: fade-in 0.16s both;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* ---- pause: cat sleeping on top of the banner ---- */
#m-pause .panel {
  width: calc(var(--u) * 60);
  gap: calc(var(--u) * 3.2);
  padding-bottom: calc(var(--u) * 2.4);
}
#m-pause .pb,
#m-stuck .pb {
  --h: calc(var(--u) * 12.5);
  --w: calc(var(--u) * 44);
  --wmax: calc(var(--u) * 52);
}
#m-pause .pb {
  --wmax: calc(var(--u) * 46);
} /* 52u leaked 3 px out of the pause frame with "Продолжить"; "No moves left" does not leak */
.peek {
  position: absolute;
  z-index: 3;
  width: calc(var(--u) * 26);
  left: 50%;
  translate: -50% 0;
  top: calc(var(--pb) * -1 - var(--rh) / 2 - var(--u) * 26 * 0.977 + var(--u) * 1.6);
  pointer-events: none;
}

/* ---- victory: balloon with the cats in the basket, 3 stars, moves, replay + next. No X. ---- */
#m-win .panel {
  width: calc(var(--u) * 82);
  --rh: calc(var(--u) * 10.5);
  gap: calc(var(--u) * 3.4);
  padding-top: calc(var(--rh) / 2 + var(--u) * 3);
  padding-bottom: calc(var(--u) * 3);
}
/* one art only (balloon, basket and cats inside): the bottom of the basket touches the title banner */
.win-art {
  position: absolute;
  z-index: 1;
  left: 50%;
  translate: -50% 0;
  bottom: calc(100% + var(--pb) + var(--rh) / 2 - var(--u) * 1.6);
  height: calc(var(--u) * 72 * var(--wk, 1));
  width: auto;
  aspect-ratio: 700 / 1000;
  pointer-events: none;
}
/* Birdy Branch: whole win-balloon art (700x1000: nest with 4 birds and a heart on the disc) */
.win-art img {
  position: absolute;
}
.win-art .wg {
  inset: 0;
  width: 100%;
  height: 100%;
}
body.land .win-art {
  --wk: 0.68;
}
.stars {
  display: flex;
  align-items: flex-end;
  gap: calc(var(--u) * 2);
}
.stars img {
  width: calc(var(--u) * 17.5);
}
.stars img:nth-child(2) {
  width: calc(var(--u) * 19);
  translate: 0 calc(var(--u) * -2);
}
.stars img.pop {
  animation: star-pop 0.42s var(--pop) both;
}
@keyframes star-pop {
  from {
    scale: 0.2;
    opacity: 0;
  }
}
body.reduced .stars img.pop {
  animation-duration: 1ms;
}
#win-moves {
  --h: calc(var(--u) * 9);
  min-width: calc(var(--u) * 41);
}
#win-moves .face {
  font-size: calc(var(--h) * 0.58);
}
.win-btns {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 3);
}
#b-again {
  --s: calc(var(--u) * 17.5);
}
#b-again .ic {
  left: 25%;
  top: 22%;
  width: 50%;
  height: 50%;
}
#b-next {
  --h: calc(var(--u) * 16.5);
  --w: calc(var(--u) * 41);
  --wmax: calc(var(--u) * 54);
}

#win-moves {
  position: relative;
}
.seal {
  position: absolute;
  --h: calc(var(--u) * 6.4);
  right: calc(var(--u) * -15);
  top: calc(var(--u) * -1.8);
  rotate: 8deg;
  min-width: calc(var(--u) * 18);
  border-image-source: url(../assets/ui/pill-pink.webp);
  border-image-slice: 0 76 fill;
}
.seal .face {
  font-size: calc(var(--h) * 0.5);
}
.seal.pop {
  animation: seal-in 0.45s var(--pop);
}
@keyframes seal-in {
  from {
    scale: 2;
    opacity: 0;
  }
}
.stars img.wait {
  opacity: 0;
}
#b-next.live {
  animation: next-live 1.8s ease-in-out infinite;
}
@keyframes next-live {
  50% {
    scale: 1.04;
    filter: brightness(1.08);
  }
}

/* ---- no moves (soft): sad cat on a little cloud ---- */
#m-stuck .panel {
  width: calc(var(--u) * 59);
  gap: calc(var(--u) * 2.6);
  padding-bottom: calc(var(--u) * 2.4);
}
.sad {
  position: relative;
  width: calc(var(--u) * 36);
  height: calc(var(--u) * 27);
  flex: none;
}
.sad .sc {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
}
.sad .sk {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  width: calc(var(--u) * 24);
  bottom: calc(var(--u) * 7.4);
}
.stuck-helps {
  display: flex;
  gap: calc(var(--u) * 5);
  margin-top: calc(var(--u) * 1);
}
.hb.small {
  --s: max(48px, calc(var(--u) * 12.5));
}
/* no moves arrives slowly, no spring; undo breathes (soft invitation) */
#m-stuck.in .panel {
  animation: soft-in 0.5s ease-out both;
}
@keyframes soft-in {
  from {
    opacity: 0;
    translate: 0 calc(var(--u) * 3);
  }
}
#s-undo:not(.off) {
  animation: breathe-btn 1.8s ease-in-out infinite;
}
@keyframes breathe-btn {
  50% {
    scale: 1.06;
  }
}
body.reduced #s-undo {
  animation: none;
}

/* ---- sound: Music first, Effects after; icon on a pink button, label, bar (track + fill + knob) ---- */
#m-sound .panel {
  width: calc(var(--u) * 87);
  gap: calc(var(--u) * 3.6);
  padding: calc(var(--rh) / 2 + var(--u) * 4) calc(var(--u) * 2) calc(var(--u) * 5);
}
#m-sound .slider {
  width: calc(var(--u) * 33);
}
.row-set {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 2.6);
}
.row-set > .lbl {
  flex: 1 1 auto;
  min-width: 0;
  font-size: calc(var(--u) * 5.2);
  text-align: left;
  translate: 0 var(--cap);
}
.ri {
  width: calc(var(--u) * 12.8);
  height: calc(var(--u) * 12.8);
  flex: none;
  position: relative;
  background: url(../assets/ui/btn-round-pink.webp) center / 100% 100% no-repeat;
}
.ri img {
  position: absolute;
  left: 25%;
  top: 22%;
  width: 50%;
  height: 50%;
  object-fit: contain;
}
.slider {
  --k: calc(var(--u) * 6.8);
  --v: 0.5;
  position: relative;
  flex: none;
  width: calc(var(--u) * 37);
  height: var(--k);
  touch-action: none;
  cursor: pointer;
}
.slider .trk,
.slider .fill {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  translate: 0 -50%;
  height: calc(var(--u) * 5.2);
  border: 0 solid transparent;
  border-width: 0 calc(var(--u) * 2.6);
}
.slider .trk {
  border-image: url(../assets/ui/slider-bg.webp) 0 40 fill / 0 calc(var(--u) * 2.6);
}
.slider .fill {
  border-image: url(../assets/ui/slider-fill.webp) 0 40 fill / 0 calc(var(--u) * 2.6);
  clip-path: inset(
    0 calc((1 - var(--v)) * (100% - var(--k)) + var(--k) / 2 - var(--u) * 0.1) 0 0 round calc(var(--u) * 2.6)
  );
}
.slider .knob {
  position: absolute;
  top: 0;
  width: var(--k);
  height: var(--k);
  left: calc(var(--v) * (100% - var(--k)));
  filter: drop-shadow(0 calc(var(--u) * 0.3) calc(var(--u) * 0.3) rgba(24, 70, 18, 0.3));
}

/* ---- settings: rows with a background (row art), label on the left, switch or language pill on the right ---- */
#m-settings .row-set {
  cursor: pointer;
}
#m-settings .row-set::before {
  content: '';
  position: absolute;
  left: calc(var(--h) * -0.45);
  right: calc(var(--h) * -0.45);
  top: 50%;
  translate: 0 -50%;
  height: calc(100% + var(--u) * 2.6);
} /* the whole row turns on the switch (settings.js) */
#m-settings .panel {
  width: calc(var(--u) * 80);
  gap: calc(var(--u) * 2.6);
  padding: calc(var(--rh) / 2 + var(--u) * 3) calc(var(--u) * 2) calc(var(--u) * 3.4);
}
.row-set.boxed {
  --h: calc(var(--u) * 10);
  height: var(--h);
  padding: 0 calc(var(--u) * 1.6) 0 calc(var(--u) * 1);
  border: 0 solid transparent;
  border-width: 0 calc(var(--h) * 0.45);
  border-image: url(../assets/ui/row.webp) 0 58 fill / 0 calc(var(--h) * 0.45);
}
.row-set.boxed > .lbl {
  font-size: calc(var(--u) * 4.6);
  translate: 0 calc(var(--cap) + var(--h) * 0.01);
}
.sw {
  width: calc(var(--u) * 12.6);
  height: calc(var(--u) * 6.8);
  flex: none;
}
.sw img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.sw[data-p='dn'] {
  filter: brightness(0.92);
}
#b-lang {
  --h: calc(var(--u) * 7.8);
  --w: calc(var(--u) * 26);
  --wmax: calc(var(--u) * 34);
  flex: none;
  margin-right: calc(var(--u) * -1.4);
}

/* ---- language: grid with all 14 in view (2 columns portrait, 3 landscape), tapping switches at once ---- */
#m-lang .panel {
  width: calc(var(--u) * 87);
  padding: calc(var(--rh) / 2 + var(--u) * 3.4) calc(var(--u) * 3) calc(var(--u) * 3.4);
}
#lang-list {
  --lg: calc(var(--u) * 1.9);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--lg) calc(var(--u) * 3.4);
  width: 100%;
  flex: 0 1 auto;
  min-height: 0;
}
.lrow {
  --h: calc(var(--u) * 10.4);
  --cw: calc(var(--h) * 0.44);
  height: var(--h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 1.6);
  min-width: 0;
  border: 0 solid transparent;
  border-width: 0 var(--cw);
  border-image: url(../assets/ui/pill-violet.webp) 0 76 fill / 0 var(--cw);
}
/* invisible touch area: also covers the gap to the row below/above (44 px step) */
.lrow {
  position: relative;
}
.lrow::after {
  content: '';
  position: absolute;
  left: calc(var(--cw) * -1);
  right: calc(var(--cw) * -1);
  top: 50%;
  translate: 0 -50%;
  height: calc(100% + var(--lg));
}
.lrow.on {
  border-image-source: url(../assets/ui/pill-pink.webp);
}
.lrow .rowtxt {
  min-width: 0;
  max-width: 100%;
  font-size: calc(var(--h) * 0.46);
  translate: 0 calc(var(--cap) + var(--h) * -0.018 + var(--pd, 0px));
}
.lrow .chk {
  height: calc(var(--h) * 0.42);
  width: auto;
  flex: none;
  display: none;
  translate: 0 calc(var(--h) * -0.018 + var(--pd, 0px));
}
.lrow.on .chk {
  display: block;
}
.lrow[data-p='dn'] {
  filter: brightness(0.9);
}
body.land #m-lang .panel {
  width: calc(var(--u) * 118);
}
body.land #lang-list {
  grid-template-columns: repeat(3, 1fr);
  --lg: calc(var(--u) * 2.2);
  gap: var(--lg) calc(var(--u) * 3);
}
body.land .lrow {
  --h: calc(var(--u) * 9.2);
}

/* ---- how to play: 3 illustrated steps with the game art (portrait one below the other; landscape side by side) ---- */
#m-how .panel {
  width: calc(var(--u) * 88);
  gap: calc(var(--u) * 2.6);
  padding: calc(var(--rh) / 2 + var(--u) * 3) calc(var(--u) * 3) calc(var(--u) * 3.4);
}
.how-steps {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 2.6);
  width: 100%;
}
.how-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 1.2);
  width: 100%;
}
.how-step .lbl {
  font-size: calc(var(--u) * 5.2);
  max-width: 100%;
  text-align: center;
}
.how-art {
  position: relative;
  width: var(--aw);
  aspect-ratio: var(--ar);
  flex: none;
}
.how-art > * {
  position: absolute;
  display: block;
  pointer-events: none;
}
#how-1 .how-art {
  --aw: calc(var(--u) * 64);
  --ar: 2.5;
}
#how-2 .how-art {
  --aw: calc(var(--u) * 82);
  --ar: 3.1;
}
#how-3 .how-art {
  --aw: calc(var(--u) * 74);
  --ar: 2.4;
}
.how-art .hand {
  animation: hand-tap 1.6s ease-in-out infinite;
}
@keyframes hand-tap {
  0%,
  100% {
    translate: 0 0;
  }
  45% {
    translate: 0 -8%;
  }
  60% {
    translate: 0 4%;
    scale: 0.94;
  }
}
.how-art .fly {
  animation: hop 1.8s ease-in-out infinite;
}
@keyframes hop {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -6%;
  }
}
body.reduced .how-art .hand,
body.reduced .how-art .fly {
  animation: none;
}
#how-ok {
  --h: calc(var(--u) * 11.6);
  --w: calc(var(--u) * 40);
  --wmax: calc(var(--u) * 56);
}
body.land #m-how .panel {
  width: calc(var(--u) * 150);
}
body.land .how-steps {
  flex-direction: row;
  align-items: flex-end;
  gap: calc(var(--u) * 3);
}
body.land .how-step {
  width: calc(var(--u) * 46);
}
body.land #how-1 .how-art,
body.land #how-2 .how-art,
body.land #how-3 .how-art {
  --aw: calc(var(--u) * 44);
}
body.land .how-step .lbl {
  font-size: calc(var(--u) * 4.2);
}

/* reduce motion: no interface animation (panel, stars, shake, breathing) goes past this rule */
body.reduced,
body.reduced * {
  animation-duration: 1ms !important;
  animation-delay: 0s !important;
  animation-iteration-count: 1 !important;
}
/* (1ms and not none: with none, turning off "reduce motion" makes every entrance play again from zero = the screen blinks) */
/* exceptions: with 1ms they would end on the last frame = invisible. Floating praise and world banner: only appear and disappear
   (opacity, no movement, in the time juice.js already gives under "reduce motion"); How to play loops: still. */
body.reduced #s-game > .float.lbl {
  animation: banner-fade 0.9s both !important;
}
body.reduced #world-banner.fade {
  animation: banner-fade 1.6s both !important;
}
body.reduced .how-art :is(.hand, .lift, .float, .pop, .go, .b5, .zz, .up, .fly) {
  animation-iteration-count: infinite !important;
  animation-play-state: paused !important;
  animation-duration: 1s !important;
  animation-delay: 0s !important;
}
body.reduced .how-art :is(.pop, .b5) {
  animation-delay: -0.5s !important;
} /* still on the frame where they appear (their 1st frame is invisible) */
/* End of css/panels.css (complete file). */
