/* Smocza Matematyka — module 'karty' (Magiczne karty). Every selector starts with .mod-karty. */

/* ---------- task band ---------- */

.mod-karty .kt-band {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}
.mod-karty .kt-band-text {
  font-family: var(--font);
  font-size: calc(var(--fs-md) + 4px);
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.mod-karty .kt-qcard {
  width: 150px;
  height: 84px;
  flex: none;
  border-radius: 14px;
  border: 3px solid #d9ccae;
  background: linear-gradient(180deg, #fffefb, #fbf6ea);
  box-shadow: 0 3px 0 rgba(42, 34, 56, 0.1), 0 5px 12px rgba(42, 34, 56, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--accent);
  padding: 0;
}
.mod-karty .kt-qcard:active {
  transform: scale(0.96);
}
.mod-karty .kt-q {
  font-family: var(--font-num);
  font-size: 58px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-soft);
}

/* ---------- the bead tray (App.mata, read-only) ---------- */

.mod-karty .kt-tray .mata-board {
  background: linear-gradient(180deg, #fbf2dc 0%, #f4e5c2 100%);
  box-shadow:
    inset 0 0 0 4px #d6b47a,
    inset 0 0 0 9px #f0ddb3,
    0 4px 0 rgba(120, 84, 30, 0.12),
    0 10px 20px rgba(42, 34, 56, 0.08);
}

/* ---------- card stacks ---------- */

.mod-karty .kt-stacks {
  position: absolute;
  z-index: 6;
}
.mod-karty .kt-stack {
  position: absolute;
  top: 0;
  padding: 0;
  border-radius: 20px;
  border: 3px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.mod-karty .kt-stack::after {
  /* colour code of the category under the pile */
  content: '';
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 7px;
  height: 6px;
  border-radius: 3px;
  background: var(--cat);
  opacity: 0.6;
}
.mod-karty .kt-stack:active {
  transform: scale(0.97);
}
.mod-karty .kt-stack.is-open {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: 0 0 0 5px rgba(242, 183, 5, 0.3), var(--shadow);
}
.mod-karty .kt-stack.is-locked {
  opacity: 0.42;
  filter: grayscale(0.85);
  box-shadow: none;
}
.mod-karty .kt-stack .kt-lock {
  position: absolute;
  right: 6px;
  top: 4px;
}
.mod-karty .kt-pile {
  position: relative;
  display: inline-block;
  margin: -6px 0 0 8px;
}
.mod-karty .kt-pile > .mat-card {
  position: relative;
  z-index: 2;
}
.mod-karty .kt-pile-back {
  position: absolute;
  inset: 0;
  border-radius: 7px;
  background: #f6eedb;
  box-shadow: inset 0 0 0 2px #d9ccae;
}
.mod-karty .kt-pile-back.b1 {
  transform: translate(-4px, -4px);
  z-index: 1;
}
.mod-karty .kt-pile-back.b2 {
  transform: translate(-8px, -8px);
  z-index: 0;
  background: #efe4cb;
}

/* ---------- the card frame ---------- */

.mod-karty .kt-frame {
  position: absolute;
  z-index: 3;
}
.mod-karty .kt-strip {
  position: absolute;
  border-radius: 18px;
  background: linear-gradient(180deg, #e9d6ae, #dcc292);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -3px 0 rgba(120, 84, 30, 0.18),
    0 4px 0 rgba(120, 84, 30, 0.14),
    0 10px 18px rgba(42, 34, 56, 0.1);
  transition: opacity 0.35s ease, box-shadow 0.3s ease;
}
.mod-karty .kt-slot {
  position: absolute;
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.92);
  box-shadow: inset 0 0 0 2px rgba(201, 176, 128, 0.7);
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
}
.mod-karty .kt-slot.is-fam1 {
  /* the thousands family lives on the grey floor (Montessori family colours) */
  background: #e6e2db;
}
.mod-karty .kt-slot.is-glow {
  background: #fff1d6;
  box-shadow: inset 0 0 0 5px var(--err), 0 0 0 4px rgba(240, 140, 46, 0.25);
  animation: kt-soft-pulse 1.6s ease-in-out infinite;
}
/* WRONG_FAMILY: "Mieszkają na szarym piętrze" — the thousands place stays visibly grey while it glows */
.mod-karty .kt-slot.is-fam1.is-glow {
  background: #d8d3ca;
}
.mod-karty .kt-letters {
  position: absolute;
  display: flex;
  height: 30px;
  transition: opacity 0.35s ease;
}
.mod-karty .kt-letter {
  display: inline-block;
  text-align: center;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 26px;
  line-height: 30px;
}
.mod-karty .kt-frame.is-fan .kt-strip,
.mod-karty .kt-frame.is-fan .kt-letters {
  opacity: 0.18;
}
.mod-karty .kt-cards,
.mod-karty .kt-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.mod-karty .kt-marks {
  z-index: 30;
}
.mod-karty .kt-card {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.5s cubic-bezier(0.34, 1.2, 0.5, 1), box-shadow 0.3s ease;
}
.mod-karty .kt-frame.is-static .kt-card {
  cursor: default;
}
/* transparent hit area: a fanned (scaled-down) card still answers a tap in ≥ 88 × 88 px (sizes set in JS) */
.mod-karty .kt-card::after {
  content: '';
  position: absolute;
  left: calc(-1 * var(--hx, 0px));
  right: calc(-1 * var(--hx, 0px));
  top: calc(-1 * var(--hy, 0px));
  bottom: calc(-1 * var(--hy, 0px));
}
.mod-karty .kt-frame:not(.is-fan) .kt-card {
  box-shadow:
    inset 0 0 0 2px #d9ccae,
    -3px 0 0 rgba(42, 34, 56, 0.07),
    0 3px 0 rgba(42, 34, 56, 0.1);
}
.mod-karty .kt-frame.no-anim .kt-card,
.mod-karty .kt-frame.no-anim .kt-ghost {
  transition: none;
}
.mod-karty .kt-frame.is-fan .kt-card.is-extra {
  box-shadow: inset 0 0 0 2px #d9ccae, 0 0 0 5px rgba(240, 140, 46, 0.6);
  animation: kt-extra 1.2s ease-in-out infinite;
}
/* layered: only the visible slot of the card (its first digit) pulses — never the parts hidden under other cards */
.mod-karty .kt-frame:not(.is-fan) .kt-card.is-extra > .mat-card-digit:first-child {
  border-radius: 6px;
  background-color: rgba(240, 140, 46, 0.15);
  box-shadow: inset 0 0 0 4px rgba(240, 140, 46, 0.7);
  animation: kt-extra-digit 1.2s ease-in-out infinite;
}
.mod-karty .kt-card.is-glow {
  box-shadow:
    inset 0 0 0 2px #d9ccae,
    0 0 0 6px var(--gold),
    0 0 24px 6px rgba(242, 183, 5, 0.55) !important;
}
.mod-karty .kt-card.is-pulse {
  animation: kt-pulse 0.85s ease-out;
}
.mod-karty .kt-plus {
  position: absolute;
  width: 40px;
  height: 60px;
  text-align: center;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 54px;
  line-height: 60px;
  color: var(--ink-soft);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.3s ease, transform 0.3s ease, left 0.5s ease;
}
.mod-karty .kt-plus.is-on {
  opacity: 1;
  transform: none;
}
.mod-karty .kt-mark {
  position: absolute;
  border: 5px solid var(--err);
  border-radius: 14px;
  background: rgba(255, 233, 212, 0.18);
  box-shadow: 0 0 0 4px rgba(240, 140, 46, 0.2);
  animation: kt-soft-pulse 1.6s ease-in-out infinite;
  transition: left 0.5s ease, top 0.5s ease, width 0.5s ease, height 0.5s ease;
}
.mod-karty .kt-mark.is-zero::after {
  /* ZERO_PLACEHOLDER: the "0" that guards this place in the stack */
  content: '0';
  position: absolute;
  right: -22px;
  top: -26px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--panel);
  border: 4px solid var(--err);
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 28px;
  line-height: 36px;
  text-align: center;
  color: var(--ink);
}
.mod-karty .kt-mark.is-soft {
  border-color: var(--gold);
  border-style: dashed;
  background: transparent;
  box-shadow: none;
  animation: none;
}
.mod-karty .kt-ghost {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  border: 4px dashed var(--err);
  border-radius: 8px;
  background: rgba(255, 233, 212, 0.75);
  transition: transform 0.5s cubic-bezier(0.34, 1.2, 0.5, 1);
  animation: kt-soft-pulse 1.6s ease-in-out infinite;
}
.mod-karty .kt-frame.is-ok .kt-strip {
  box-shadow:
    inset 0 0 0 4px var(--gold),
    0 0 0 6px rgba(242, 183, 5, 0.35),
    0 0 30px 8px rgba(242, 183, 5, 0.45);
}
.mod-karty .kt-frame.is-ok::after {
  content: '';
  position: absolute;
  inset: -16px;
  pointer-events: none;
  z-index: 40;
  background:
    radial-gradient(circle at 12% 22%, #fff7c8 0 5px, transparent 6px),
    radial-gradient(circle at 86% 18%, #ffe27a 0 6px, transparent 7px),
    radial-gradient(circle at 22% 84%, #ffe27a 0 4px, transparent 5px),
    radial-gradient(circle at 74% 80%, #fff7c8 0 5px, transparent 6px),
    radial-gradient(circle at 50% 8%, #f2b705 0 4px, transparent 5px),
    radial-gradient(circle at 95% 55%, #f2b705 0 3px, transparent 4px),
    radial-gradient(circle at 4% 55%, #ffe27a 0 4px, transparent 5px);
  animation: kt-sparkle 1.4s ease-out forwards;
}

/* the asked digit on L5 pulses (attention: accent, never the error colour) */
.mod-karty .kt-ask {
  border-radius: 10px;
  /* static cue first (reduced motion keeps it), the pulse on top */
  background-color: rgba(123, 92, 214, 0.14);
  box-shadow: 0 0 0 4px rgba(123, 92, 214, 0.35);
  animation: kt-ask 1.5s ease-in-out infinite;
}

/* ---------- Stos ⇄ Wachlarz ---------- */

.mod-karty .kt-toggle {
  position: absolute;
  z-index: 4;
  width: 210px;
  height: 96px;
  padding: 0 14px;
  border-radius: 22px;
  border: 3px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 27px;
  font-weight: 700;
  color: var(--accent);
}
.mod-karty .kt-toggle .btn-label {
  color: var(--ink);
}
.mod-karty .kt-toggle.is-fan {
  background: var(--accent-soft);
  border-color: #cfc2f2;
}
.mod-karty .kt-toggle:active {
  transform: scale(0.97);
}

/* ---------- card picker (3 × 3) ---------- */

.mod-karty .kt-picker {
  position: absolute;
  z-index: 40;
  border-radius: 24px;
  background: var(--panel);
  border: 3px solid var(--line);
  border-top: 6px solid var(--cat);
  box-shadow: var(--shadow);
  animation: kt-pop 0.18s ease-out;
}
.mod-karty .kt-picker::before {
  content: '';
  position: absolute;
  left: calc(var(--arrow-x) - 14px);
  top: -20px;
  border: 14px solid transparent;
  border-bottom-color: var(--cat);
  border-top: 0;
}
.mod-karty .kt-tile {
  position: absolute;
  padding: 0;
  border-radius: 16px;
  border: 3px solid #eadfc6;
  background: linear-gradient(180deg, #fffdf8, #f6eedc);
  box-shadow: 0 3px 0 rgba(42, 34, 56, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mod-karty .kt-tile:active {
  transform: scale(0.96);
}
.mod-karty .kt-tile.is-current {
  background: #f3ead2;
  box-shadow: inset 0 0 0 3px rgba(201, 176, 128, 0.55);
}
.mod-karty .kt-tile.is-current::after {
  /* the card that already lies in the frame: a small dot, quieter than a hint */
  content: '';
  position: absolute;
  right: 10px;
  top: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink-soft);
  opacity: 0.45;
}
.mod-karty .kt-tile.kt-hint,
.mod-karty .kt-choice.kt-hint {
  border-color: var(--gold);
  border-width: 5px;
  animation: glow 1.2s ease-in-out infinite;
}

/* ---------- L5 choices ---------- */

.mod-karty .kt-choices {
  position: absolute;
  left: 0;
  top: 410px;
  width: 1040px;
  display: flex;
  justify-content: center;
  gap: 56px;
  z-index: 5;
}
.mod-karty .kt-choice {
  min-width: 200px;
  height: 120px;
  padding: 0 24px;
  border-radius: 22px;
  border: 3px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.mod-karty .kt-choice:active {
  transform: scale(0.97);
}
.mod-karty .kt-choice.is-tried {
  border-color: var(--err);
  box-shadow: 0 0 0 5px var(--err-soft);
}
.mod-karty .kt-choice.is-ok {
  border-color: var(--gold);
  background: var(--gold-soft);
  box-shadow: 0 0 0 6px rgba(242, 183, 5, 0.3), 0 0 24px rgba(242, 183, 5, 0.55);
}

/* ---------- first-visit presentation ---------- */

.mod-karty .kt-board {
  position: absolute;
  left: 16px;
  top: 116px;
  width: 500px;
  height: 470px;
  border-radius: 24px;
  background: linear-gradient(180deg, #f7ecd4, #efdfbd);
  box-shadow: inset 0 0 0 4px #e0c995, 0 6px 16px rgba(42, 34, 56, 0.08);
}
.mod-karty .kt-board-col {
  position: absolute;
  border-radius: 12px;
}
.mod-karty .kt-board-card {
  position: absolute;
  opacity: 0;
  transform: translateY(-12px) scale(0.92);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.mod-karty .kt-board-card.is-in {
  opacity: 1;
  transform: none;
}
.mod-karty .kt-board-card.is-taken {
  opacity: 0.25;
}
.mod-karty .kt-show {
  position: absolute;
  left: 536px;
  top: 116px;
  width: 488px;
  height: 470px;
  border-radius: 24px;
}
.mod-karty .kt-big {
  position: absolute;
  z-index: 2;
  transition: left 0.75s cubic-bezier(0.34, 1.2, 0.5, 1);
  box-shadow:
    inset 0 0 0 2px #d9ccae,
    -3px 0 0 rgba(42, 34, 56, 0.08),
    0 4px 10px rgba(42, 34, 56, 0.14);
}
.mod-karty .kt-big.is-onto {
  z-index: 3;
}

/* the core's demo glow (App.ui.highlight) is animation-only; keep a static ring so it survives reduced motion */
.mod-karty .fx-highlight {
  box-shadow: 0 0 0 5px rgba(242, 183, 5, 0.55);
}

/* ---------- animations ---------- */

@keyframes kt-soft-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@keyframes kt-extra {
  0%, 100% { box-shadow: inset 0 0 0 2px #d9ccae, 0 0 0 3px rgba(240, 140, 46, 0.35); }
  50% { box-shadow: inset 0 0 0 2px #d9ccae, 0 0 0 8px rgba(240, 140, 46, 0.75); }
}
@keyframes kt-extra-digit {
  0%, 100% { background-color: rgba(240, 140, 46, 0.08); box-shadow: inset 0 0 0 3px rgba(240, 140, 46, 0.45); }
  50% { background-color: rgba(240, 140, 46, 0.22); box-shadow: inset 0 0 0 5px rgba(240, 140, 46, 0.9); }
}
@keyframes kt-pulse {
  0% { box-shadow: inset 0 0 0 2px #d9ccae, 0 0 0 0 rgba(242, 183, 5, 0.9); }
  60% { box-shadow: inset 0 0 0 2px #d9ccae, 0 0 0 10px rgba(242, 183, 5, 0.35); }
  100% { box-shadow: inset 0 0 0 2px #d9ccae, 0 0 0 14px rgba(242, 183, 5, 0); }
}
@keyframes kt-ask {
  0%, 100% { background-color: rgba(123, 92, 214, 0.06); box-shadow: 0 0 0 2px rgba(123, 92, 214, 0.35); }
  50% { background-color: rgba(123, 92, 214, 0.2); box-shadow: 0 0 0 7px rgba(123, 92, 214, 0.28); }
}
@keyframes kt-sparkle {
  0% { opacity: 0; transform: scale(0.85); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.12); }
}
@keyframes kt-pop {
  0% { opacity: 0; transform: translateY(-8px) scale(0.97); }
  100% { opacity: 1; transform: none; }
}
