/* Smocza Matematyka — module 'sakiewka' (Sakiewka), js/modules/sakiewka.js.
 * Module area 1040 x 712: task band 0–110 (question + answer fields + ear) | table 16–688 x 122–580 with the
 * poured-out purse | keypad column 712–1028 | action bar 592–712 (Cofnij, Posortuj … Dalej).
 * Every selector starts with .mod-sakiewka. Error = amber (--err), success = gold (--gold).
 * Text with 'zł' uses --font (Arial Rounded has no 'ł'); digits-only boxes use --font-num.
 */

.mod-sakiewka {
  background: radial-gradient(ellipse at 40% 45%, #fcf7ea 0%, #f5ead2 62%, #eedfc0 100%);
}

/* ---------- task band: question, answer fields ---------- */

.mod-sakiewka .sk-band .task-content {
  font-family: var(--font);
}
.mod-sakiewka .sk-bandrow {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.mod-sakiewka .sk-bicon {
  display: flex;
  flex: none;
  filter: drop-shadow(0 3px 2px rgba(60, 35, 15, 0.2));
}
.mod-sakiewka .sk-ask {
  font-family: var(--font);
  font-size: 34px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.mod-sakiewka .sk-gap {
  flex: 1;
}
.mod-sakiewka .sk-ans {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: none;
}
.mod-sakiewka .sk-fgroup {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mod-sakiewka .sk-field {
  width: 100px;
  height: 88px;
  padding: 0;
  border-radius: 18px;
  border: 4px solid #b9ab8f;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-size: 54px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  box-shadow: inset 0 3px 0 rgba(42, 34, 56, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.mod-sakiewka .sk-field.is-wide {
  width: 150px;
}
.mod-sakiewka .sk-field.is-empty .sk-fval {
  color: #cbbfa8;
}
.mod-sakiewka .sk-field.is-active {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 6px var(--gold-soft), inset 0 3px 0 rgba(42, 34, 56, 0.06);
}
.mod-sakiewka .sk-ans:not(.is-two) .sk-field.is-active {
  box-shadow: inset 0 3px 0 rgba(42, 34, 56, 0.06);
}
.mod-sakiewka .sk-field.is-err {
  border-color: var(--err);
  background: var(--err-soft);
  box-shadow: 0 0 0 6px rgba(240, 140, 46, 0.25);
}
.mod-sakiewka .sk-field.is-stale .sk-fval {
  opacity: 0.45;
}
.mod-sakiewka .sk-field.is-ok {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.mod-sakiewka .sk-unit {
  font-family: var(--font);
  font-size: 34px;
  font-weight: 700;
  color: var(--ink-soft);
}
.mod-sakiewka .sk-unit.is-coin {
  display: flex;
  filter: drop-shadow(0 3px 3px rgba(40, 25, 10, 0.25));
}

/* the answer after success: '3 zł = 300 gr', 'Razem: 7 zł 80 gr = 7,80 zł' */
.mod-sakiewka .sk-done {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 6px 26px;
  border-radius: 22px;
  background: var(--gold-soft);
  box-shadow: 0 0 0 4px var(--gold), 0 6px 14px rgba(201, 143, 0, 0.25);
  font-family: var(--font);
  font-size: 38px;
  font-weight: 700;
  color: #5a3d00;
  white-space: nowrap;
  animation: sk-done-in 0.45s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
@keyframes sk-done-in {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
}
.mod-sakiewka .sk-spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}
.mod-sakiewka .sk-spark i {
  position: absolute;
  left: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
  background: var(--gold);
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
  transform: rotate(calc(var(--i) * 51deg)) translateX(40px);
  animation: sk-spark 0.9s ease-out 0.1s forwards;
  opacity: 0.95;
}
@keyframes sk-spark {
  to {
    transform: rotate(calc(var(--i) * 51deg)) translateX(190px) scale(0.3);
    opacity: 0;
  }
}

/* ---------- the table with the poured-out purse ---------- */

.mod-sakiewka .sk-table {
  position: absolute;
  left: 16px;
  top: 122px;
  width: 672px;
  height: 458px;
  border-radius: 30px;
  background:
    radial-gradient(ellipse 75% 55% at 42% 38%, rgba(255, 238, 205, 0.38), rgba(255, 238, 205, 0) 72%),
    repeating-linear-gradient(177deg, rgba(110, 66, 28, 0.07) 0 2px, rgba(110, 66, 28, 0) 2px 21px),
    repeating-linear-gradient(183deg, rgba(255, 240, 210, 0.09) 0 1px, rgba(255, 240, 210, 0) 1px 13px),
    linear-gradient(180deg, #cf9d68 0%, #bf8955 100%);
  box-shadow:
    inset 0 0 0 5px rgba(120, 72, 32, 0.32),
    inset 0 10px 18px rgba(255, 230, 190, 0.18),
    inset 0 -14px 24px rgba(90, 50, 20, 0.2),
    0 7px 0 #8a5a2c,
    0 15px 26px rgba(42, 34, 56, 0.2);
  transition: box-shadow 0.25s ease;
}
.mod-sakiewka .sk-table.is-err {
  box-shadow:
    inset 0 0 0 6px var(--err),
    0 0 0 7px rgba(240, 140, 46, 0.3),
    inset 0 -14px 24px rgba(90, 50, 20, 0.2),
    0 7px 0 #8a5a2c,
    0 15px 26px rgba(42, 34, 56, 0.2);
}
.mod-sakiewka .sk-pouch {
  position: absolute;
  left: 8px;
  top: -8px;
  z-index: 0;
  pointer-events: none;
  filter: drop-shadow(0 6px 4px rgba(60, 35, 15, 0.3));
  transform-origin: 50% 80%;
}
.mod-sakiewka .sk-pouch.is-shake {
  animation: sk-pouch 0.7s ease;
}
@keyframes sk-pouch {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-14deg) translateY(-6px); }
  45% { transform: rotate(10deg); }
  70% { transform: rotate(-5deg); }
}
.mod-sakiewka .sk-table.is-conv .sk-pouch {
  opacity: 0;
}
.mod-sakiewka .sk-count {
  position: absolute;
  right: 16px;
  top: 10px;
  height: 46px;
  padding: 0 18px;
  display: none;
  align-items: center;
  gap: 10px;
  border-radius: 14px;
  background: #fffaf0;
  border: 3px solid #e2c78f;
  box-shadow: 0 3px 0 rgba(90, 50, 20, 0.25);
  font-family: var(--font);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink-soft);
  z-index: 4;
}
.mod-sakiewka .sk-count.is-on {
  display: flex;
}
.mod-sakiewka .sk-count-val {
  min-width: 82px;
  color: var(--ink);
  font-size: 30px;
}
.mod-sakiewka .sk-area {
  position: absolute;
  left: 0;
  top: 64px;
  width: 672px;
  height: 386px;
  z-index: 1;
}

/* App.money.purse used as the table top: no leather here */
.mod-sakiewka .sk-purse.money-purse {
  background: none;
  box-shadow: none;
}
.mod-sakiewka .sk-purse.money-purse::before {
  display: none;
}
.mod-sakiewka .sk-purse.is-waiting {
  visibility: hidden;
}
.mod-sakiewka .sk-purse .money-face {
  filter: drop-shadow(0 4px 3px rgba(55, 30, 10, 0.35));
}
.mod-sakiewka .sk-purse .money-item.is-counted .money-face {
  filter: saturate(0.4) drop-shadow(0 2px 2px rgba(55, 30, 10, 0.2));
}
.mod-sakiewka .sk-pour .money-item {
  animation: sk-pour 0.62s cubic-bezier(0.25, 0.8, 0.35, 1) var(--fd, 0ms) backwards;
}
@keyframes sk-pour {
  0% {
    translate: var(--fx, 0px) var(--fy, 0px);
    scale: 0.35;
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    translate: 0 0;
    scale: 1;
    opacity: 1;
  }
}
/* rung-2 model: 1 zł = a square of 100 grosze; her grosze fill squares.
   The purse moves up into rows first (.is-compact, 64–300), so the model (310–450) never covers a piece
   or its value label (the core purse labels: App.money.purse labels / setLabels). */
.mod-sakiewka .sk-model {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 8px;
  height: 140px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 26px;
  border-radius: 22px;
  background: rgba(255, 251, 240, 0.95);
  border: 3px solid #e2c78f;
  box-shadow: 0 4px 0 rgba(90, 50, 20, 0.2);
  z-index: 5;
  animation: sk-model-in 0.35s ease both;
}
.mod-sakiewka .sk-model.is-on {
  display: flex;
}
@keyframes sk-model-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}
.mod-sakiewka .sk-mref,
.mod-sakiewka .sk-mfill,
.mod-sakiewka .sk-mone {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mod-sakiewka .sk-mfill {
  gap: 12px;
  min-width: 96px;
}
.mod-sakiewka .sk-mdiv {
  width: 0;
  height: 104px;
  border-left: 3px dashed #e2c78f;
}
.mod-sakiewka .sk-meq,
.mod-sakiewka .sk-mone {
  font-family: var(--font);
  font-size: 40px;
  font-weight: 700;
  color: var(--ink-soft);
}
.mod-sakiewka .sk-model .money-gsq-label {
  font-size: 22px;
}
.mod-sakiewka .sk-model .money-gsq.is-full .money-gsq-frame {
  stroke: var(--gold-deep);
  stroke-width: 5;
}
.mod-sakiewka .sk-mone {
  animation: sk-mone-in 0.35s ease both;
}
@keyframes sk-mone-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- L4 conversions: 1 zł <-> a square of 100 grosze ---------- */

.mod-sakiewka .sk-conv.is-grid {
  position: absolute;
  inset: 0 0 6px 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), 108px);
  grid-auto-rows: 168px;
  gap: 24px; /* §1.4: tap cells 24 px apart (5 x 108 + 4 x 24 = 636 <= 672; 2 rows = 360 <= 380) */
  justify-content: center;
  align-content: center;
}
/* up to 5 units: one row of taller cells (5 x 112 + 4 x 24 = 656 <= 672) */
.mod-sakiewka .sk-conv.is-grid.is-big {
  grid-template-columns: repeat(var(--cols, 5), 112px);
  grid-auto-rows: 186px;
}
.mod-sakiewka .sk-conv.is-big .sk-cu {
  width: 112px;
  height: 186px;
}
.mod-sakiewka .sk-conv.is-big .sk-cu-sq,
.mod-sakiewka .sk-conv.is-big .sk-cu-coin {
  left: 4px;
  width: 104px;
  height: 104px;
}
.mod-sakiewka .sk-conv.is-big .sk-cu-lab {
  bottom: 16px;
  font-size: 25px;
}
.mod-sakiewka .sk-cu {
  position: relative;
  width: 108px;
  height: 168px;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: rgba(255, 246, 225, 0.22);
  -webkit-tap-highlight-color: transparent;
}
.mod-sakiewka .sk-cu-sq,
.mod-sakiewka .sk-cu-coin {
  position: absolute;
  left: 4px;
  top: 10px;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.4s cubic-bezier(0.3, 1.3, 0.5, 1), opacity 0.35s ease;
}
.mod-sakiewka .sk-cu-coin {
  filter: drop-shadow(0 4px 3px rgba(55, 30, 10, 0.35));
}
.mod-sakiewka .sk-cu-lab {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  text-align: center;
  font-family: var(--font);
  font-size: 23px;
  font-weight: 700;
  color: #4a2f12;
  white-space: nowrap;
}
.mod-sakiewka .sk-cu.is-coin .sk-cu-sq {
  opacity: 0;
  transform: scale(0.6);
}
.mod-sakiewka .sk-cu.is-coin.is-open .sk-cu-sq,
.mod-sakiewka .sk-cu.is-square .sk-cu-sq {
  opacity: 1;
  transform: none;
}
.mod-sakiewka .sk-cu.is-coin.is-open .sk-cu-coin {
  transform: scale(0.6);
}
.mod-sakiewka .sk-cu.is-square .sk-cu-coin {
  opacity: 0;
  transform: scale(0.2);
}
.mod-sakiewka .sk-cu.is-square.is-open .sk-cu-coin {
  opacity: 1;
  transform: scale(0.6);
}
.mod-sakiewka .sk-cu.is-counted .sk-cu-sq,
.mod-sakiewka .sk-cu.is-counted .sk-cu-coin {
  opacity: 0.45;
  filter: saturate(0.4);
}
.mod-sakiewka .sk-cu.is-coin.is-counted:not(.is-open) .sk-cu-sq {
  opacity: 0;
}
.mod-sakiewka .sk-cu.is-counted::after {
  content: '';
  position: absolute;
  right: 6px;
  top: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gold)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='%232a2238' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 22px no-repeat;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* "Ile monet po 10 gr to 1 zł?": 1 zł = a tray of grosze coins */
.mod-sakiewka .sk-conv.is-count {
  position: absolute;
  inset: 0 0 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.mod-sakiewka .sk-cnt-left {
  display: flex;
  flex-direction: column;
  gap: 14px;
  filter: drop-shadow(0 4px 3px rgba(55, 30, 10, 0.35));
}
.mod-sakiewka .sk-eq {
  font-family: var(--font);
  font-size: 64px;
  font-weight: 700;
  color: #4a2f12;
}
.mod-sakiewka .sk-tray {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 80px);
  grid-template-rows: repeat(2, 80px);
  gap: 10px 8px;
  padding: 16px;
  border-radius: 24px;
  border: 4px dashed rgba(255, 244, 220, 0.85);
  background: rgba(255, 246, 225, 0.25);
}
.mod-sakiewka .sk-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mod-sakiewka .sk-slot > .mat {
  opacity: 0;
  filter: drop-shadow(0 4px 3px rgba(55, 30, 10, 0.35));
}
.mod-sakiewka .sk-slot.is-real > .mat {
  opacity: 1;
}
.mod-sakiewka .sk-slot.is-drop > .mat {
  animation: sk-drop 0.4s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}
@keyframes sk-drop {
  from {
    transform: translateY(-50px) scale(0.6);
    opacity: 0;
  }
}
/* rung 2: ghost outlines where the coins go */
.mod-sakiewka .sk-tray.is-ghosts .sk-slot:not(.is-real)::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 4px dashed var(--err);
  background: rgba(255, 233, 212, 0.55);
}
.mod-sakiewka .sk-tray-q {
  position: absolute;
  right: -18px;
  top: -26px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fffaf0;
  border: 3px solid #e2c78f;
  font-family: var(--font);
  font-size: 44px;
  font-weight: 700;
  color: var(--accent);
  box-shadow: 0 3px 0 rgba(90, 50, 20, 0.25);
}
.mod-sakiewka .sk-tray.is-ghosts .sk-tray-q {
  display: none;
}
/* rung 2 "Policzmy razem": the ghost outlines light up one by one */
.mod-sakiewka .sk-tray.is-ghosts .sk-slot.is-pulse::before {
  background: rgba(240, 140, 46, 0.4);
  animation: sk-slot-pulse 0.55s ease;
}
.mod-sakiewka .sk-slot.is-pulse > .mat {
  animation: sk-slot-pulse 0.55s ease;
}
@keyframes sk-slot-pulse {
  50% {
    transform: scale(1.12);
  }
}

/* ---------- keypad column ---------- */

.mod-sakiewka .sk-pad {
  position: absolute;
  left: 712px;
  top: 128px;
  width: 316px;
}
.mod-sakiewka .sk-pad .numin.locked .key {
  opacity: 0.4;
}

/* ---------- action bar: Cofnij + Posortuj on the left, Dalej on the right ---------- */

.mod-sakiewka .sk-left {
  display: flex;
  align-items: center;
  gap: 24px;
}
.mod-sakiewka .sk-sort {
  min-height: 96px;
  height: 96px;
  min-width: 220px;
  font-size: 30px;
  padding: 0 26px;
}
.mod-sakiewka .sk-sort .sk-sort-ico {
  width: 46px;
  height: 46px;
}
.mod-sakiewka .sk-sort.is-disabled {
  opacity: 0.45;
  filter: grayscale(0.6);
}
