/* Smocza Matematyka — module 'zegar' (Smoczy zegar). All selectors start with .mod-zegar.
 * Module area 1040 x 712: task band 0–110, material 110–592 (clock on the left, answer tools on the right),
 * action bar 592–712. Red = the short hand (hours), blue = the long hand (minutes) — on the face, the buttons
 * and the digital watch alike.
 */

/* ---------- the clock ---------- */

.mod-zegar .zg-clock {
  position: absolute;
  left: 24px;
  top: 112px;
  width: 580px;
  height: 480px;
  transform-origin: 0 0;
  transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.25, 1), left 0.45s cubic-bezier(0.3, 0.7, 0.25, 1);
  z-index: 2;
}
.mod-zegar .zg-svg {
  display: block;
  width: 580px;
  height: 480px;
  overflow: visible;
}
.mod-zegar .zg-num {
  font-family: var(--font-num);
  font-size: 44px;
  font-weight: 700;
  fill: var(--ink);
  /* a thin halo in the face colour: the long hand passes under the number, the number stays readable */
  stroke: #faf3e3;
  stroke-width: 6px;
  stroke-linejoin: round;
  paint-order: stroke;
  transform-box: fill-box;
  transform-origin: center;
  transition: fill 0.25s ease;
}
.mod-zegar .zg-num.zg-glow {
  fill: var(--gold-deep);
  stroke: #fff3c4;
  stroke-width: 10px;
  paint-order: stroke;
}
.mod-zegar .zg-pulse {
  animation: zg-pulse 0.7s ease-out;
}
@keyframes zg-pulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.4); fill: var(--gold-deep); }
  100% { transform: scale(1); }
}
.mod-zegar .zg-tick {
  stroke: #cbbd9f;
  stroke-width: 2;
  stroke-linecap: round;
}
.mod-zegar .zg-tick-major {
  stroke: #6b6080;
  stroke-width: 4.5;
  stroke-linecap: round;
}

/* minute ring 5…60 (L4) */
.mod-zegar .zg-ring {
  opacity: 0;
  transition: opacity 0.4s ease;
}
.mod-zegar .zg-ring.on {
  opacity: 1;
}
.mod-zegar .zg-rnum {
  font-family: var(--font-num);
  font-size: 20px;
  font-weight: 700;
  fill: var(--m-tens);
  transform-box: fill-box;
  transform-origin: center;
}

/* 24-hour ring 13–24 (L5 Księga) */
.mod-zegar .zg-ring24 {
  opacity: 0;
  transition: opacity 0.35s ease;
}
.mod-zegar .zg-ring24.on {
  opacity: 1;
}
.mod-zegar .zg-n24 {
  font-family: var(--font-num);
  font-size: 22px;
  font-weight: 700;
  fill: #5b3fc4;
  /* above the short hand, with a halo in the ring colour: the hand passes under the number */
  stroke: #ece6ff;
  stroke-width: 6px;
  stroke-linejoin: round;
  paint-order: stroke;
  transform-box: fill-box;
  transform-origin: center;
}
.mod-zegar .zg-rnum.zg-glow {
  fill: var(--gold-deep);
  stroke: #fff3c4;
  stroke-width: 7px;
  paint-order: stroke;
}
.mod-zegar .zg-n24.zg-glow {
  fill: var(--gold-deep);
  stroke: #fff3c4;
  stroke-width: 7px;
  paint-order: stroke;
}

/* swept part of the face: half / quarter / elapsed minutes */
.mod-zegar .zg-sector {
  fill: rgba(35, 103, 201, 0.15);
  stroke: rgba(35, 103, 201, 0.55);
  stroke-width: 2.5;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.mod-zegar .zg-sector.on {
  opacity: 1;
}
.mod-zegar .zg-sector.ghost {
  fill: rgba(35, 103, 201, 0.07);
  stroke-dasharray: 9 7;
}

/* counting labels (5, 10, 15 …) */
.mod-zegar .zg-label circle {
  fill: var(--m-tens);
  stroke: #fff;
  stroke-width: 3;
}
.mod-zegar .zg-label text {
  font-family: var(--font-num);
  font-size: 19px;
  font-weight: 700;
  fill: #fff;
}
.mod-zegar .zg-label {
  animation: zg-label-in 0.3s ease-out;
  transform-box: fill-box;
  transform-origin: center;
}
.mod-zegar .zg-label.ghost circle {
  fill: #fff;
  stroke: var(--m-tens);
  stroke-dasharray: 5 4;
}
.mod-zegar .zg-label.ghost text {
  fill: var(--m-tens);
}
.mod-zegar .zg-label.ask circle {
  fill: var(--gold-soft);
  stroke: var(--gold-deep);
  stroke-dasharray: none;
}
.mod-zegar .zg-label.ask text {
  fill: var(--gold-deep);
}
@keyframes zg-label-in {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* the end mark of L6 (story picture on the rim) */
.mod-zegar .zg-flag-bg {
  fill: #fff;
  stroke: var(--m-tens);
  stroke-width: 3;
}

/* ghost hands (rung 2): where the hands should stand */
.mod-zegar .zg-ghost {
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.mod-zegar .zg-ghost.on {
  opacity: 0.9;
}
.mod-zegar .zg-ghost path {
  stroke-width: 4;
  stroke-dasharray: 9 6;
  stroke-linejoin: round;
}
.mod-zegar .zg-ghost-h {
  fill: rgba(215, 38, 61, 0.14);
  stroke: var(--m-hundreds);
}
.mod-zegar .zg-ghost-m {
  fill: rgba(35, 103, 201, 0.12);
  stroke: var(--m-tens);
}

/* hands: amber = the place of the mismatch (rung 1), gold glow = the dragon shows it */
.mod-zegar .zg-hand > path:first-child {
  transition: stroke 0.2s ease;
}
.mod-zegar .zg-hand.zg-err > path:first-child,
.mod-zegar .zg-hand.zg-err > circle {
  stroke: var(--err);
  stroke-width: 6;
}
.mod-zegar .zg-hand.zg-err {
  filter: drop-shadow(0 0 7px rgba(240, 140, 46, 0.95));
}
.mod-zegar .zg-hand.zg-lit,
.mod-zegar .zg-hand.fx-highlight {
  animation: none;
  filter: drop-shadow(0 0 9px rgba(242, 183, 5, 0.95)) drop-shadow(0 0 3px rgba(242, 183, 5, 0.9));
}

.mod-zegar .zg-hand.zg-fadein {
  animation: zg-fadein 0.45s ease-out;
}
@keyframes zg-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* success: the golden ring glows */
.mod-zegar .zg-clock.zg-win .zg-goldring {
  animation: zg-win 1.2s ease-out;
}
@keyframes zg-win {
  0% { stroke-width: 7; stroke: #e8b923; }
  35% { stroke-width: 16; stroke: #ffd84a; }
  100% { stroke-width: 7; stroke: #e8b923; }
}
.mod-zegar .zg-clock.fx-highlight {
  animation: none;
}
.mod-zegar .zg-clock.zg-win {
  filter: drop-shadow(0 0 18px rgba(242, 183, 5, 0.45));
}

/* ---------- hand buttons (+1 godz. / +5 min) ---------- */

.mod-zegar .zg-hands {
  position: absolute;
  left: 676px;
  top: 188px;
  width: 316px;
  display: none;
  flex-direction: column;
  gap: 44px;
  z-index: 4;
}
.mod-zegar.zg-set .zg-hands,
.mod-zegar.zg-elapsed .zg-hands {
  display: flex;
}
.mod-zegar .zg-handbtn {
  width: 316px;
  height: 128px;
  border: 4px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  font-size: 38px;
  font-weight: 700;
  font-family: var(--font);
  color: var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.25s ease;
}
.mod-zegar .zg-handbtn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(42, 34, 56, 0.15);
}
.mod-zegar .zg-handbtn .zg-mini {
  flex: none;
  width: 72px;
  height: 72px;
}
.mod-zegar .zg-handbtn-h {
  border-color: #f2b3bb;
}
.mod-zegar .zg-handbtn-m {
  border-color: #b5cdf0;
}
.mod-zegar .zg-handbtn-h .zg-handbtn-txt {
  color: #b81d32;
}
.mod-zegar .zg-handbtn-m .zg-handbtn-txt {
  color: #1d57ad;
}
.mod-zegar .zg-hands.zg-locked {
  pointer-events: none;
}
.mod-zegar .zg-hands.zg-locked .zg-handbtn {
  opacity: 0.5;
}

/* ---------- the digital watch + keypad ---------- */

.mod-zegar .zg-pad {
  position: absolute;
  left: 676px;
  top: 114px;
  width: 316px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 5;
  pointer-events: none; /* the column reaches into the action bar: only its parts take taps (Dalej stays free) */
}
.mod-zegar .zg-pad > * {
  pointer-events: auto;
}
.mod-zegar.zg-read .zg-pad,
.mod-zegar.zg-elapsed .zg-pad {
  display: flex;
}
.mod-zegar .zg-pad .keypad {
  gap: 12px 14px;
}
.mod-zegar .zg-pad .key.zg-press {
  background: var(--gold-soft);
  transform: translateY(3px);
  box-shadow: 0 0 0 4px var(--gold);
}
.mod-zegar .zg-pad .numin {
  transition: opacity 0.35s ease;
}
.mod-zegar .zg-pad.zg-solved .numin {
  opacity: 0;
  pointer-events: none;
}

.mod-zegar .zg-watch {
  display: inline-flex;
  padding: 7px;
  border-radius: 22px;
  background: linear-gradient(180deg, #4a3d73, #241d3b);
  box-shadow: var(--shadow-sm);
  flex: none;
}
.mod-zegar .zg-w-face {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: #16112a;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.6);
  font-family: var(--font-num);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  line-height: 1;
}
.mod-zegar .zg-w-h {
  color: #ff8d9b;
}
.mod-zegar .zg-w-m {
  color: #8cc6ff;
}
.mod-zegar .zg-w-colon {
  color: #f3eedf;
  padding: 0 2px 6px;
}
.mod-zegar .zg-w-unit {
  display: none;
  color: #c9c2dd;
  font-family: var(--font);
  font-size: 0.5em;
  margin-left: 12px;
}
.mod-zegar .zg-watch-mini .zg-w-face {
  height: 66px;
  padding: 0 16px;
  font-size: 44px;
}
.mod-zegar .zg-watch-mini .zg-w-unit {
  display: inline;
}
.mod-zegar .zg-watch-mini.gold {
  background: linear-gradient(180deg, #ffd84a, #c98f00);
}
.mod-zegar .zg-watch-big {
  width: 316px;
}
.mod-zegar .zg-watch-big .zg-w-face {
  width: 100%;
  height: 92px;
  font-size: 64px;
  padding: 0 10px;
}
.mod-zegar .zg-watch-big .zg-w-h,
.mod-zegar .zg-watch-big .zg-w-m {
  min-width: 96px;
  padding: 6px 8px;
  border-radius: 12px;
  text-align: center;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}
.mod-zegar .zg-watch-big .active {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px var(--gold);
}
.mod-zegar .zg-watch-big .empty {
  opacity: 0.7;
}
.mod-zegar .zg-watch-big .zg-err {
  box-shadow: 0 0 0 4px var(--err);
  text-decoration: line-through;
  text-decoration-thickness: 4px;
}
.mod-zegar .zg-watch-big.zg-err {
  background: linear-gradient(180deg, #f6a65a, #c96b12);
}
.mod-zegar .zg-watch-big .gold {
  color: var(--gold);
  box-shadow: none;
  background: transparent;
}
.mod-zegar .zg-watch-big.gold {
  background: linear-gradient(180deg, #ffd84a, #c98f00);
}
.mod-zegar .zg-watch-big.zg-fixedmin .zg-w-m {
  opacity: 0.6;
}
.mod-zegar .zg-watch-big.zg-minutes .zg-w-colon,
.mod-zegar .zg-watch-big.zg-minutes .zg-w-m {
  display: none;
}
.mod-zegar .zg-watch-big.zg-minutes .zg-w-h {
  color: #8cc6ff;
  min-width: 130px;
}
.mod-zegar .zg-watch-big.zg-minutes .zg-w-unit {
  display: inline;
  font-size: 38px;
}

/* ---------- phrase choices (L2, L3) ---------- */

.mod-zegar .zg-choicebox {
  position: absolute;
  left: 650px;
  top: 110px;
  width: 370px;
  height: 482px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.mod-zegar.zg-choice .zg-choicebox {
  display: flex;
}
.mod-zegar .zg-choicebox.zg-locked {
  pointer-events: none;
}
.mod-zegar .zg-choices {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 30px;
}
.mod-zegar .zg-choices .btn {
  width: 360px;
  min-height: 104px;
  padding: 0 16px;
  font-family: var(--font);
  font-size: 31px;
  line-height: 1.1;
}
.mod-zegar .zg-choices .btn.zg-tried {
  opacity: 0.32;
  filter: grayscale(0.5);
  border-color: var(--err);
}
.mod-zegar .zg-choices .btn.zg-armed {
  border-color: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft), var(--shadow);
}
.mod-zegar .zg-choices .btn.zg-picked {
  border-color: var(--gold);
  background: var(--gold-soft);
  box-shadow: 0 0 0 5px var(--gold), var(--shadow);
  opacity: 1;
}

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

.mod-zegar .zg-bandbox {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
  white-space: nowrap;
}
.mod-zegar .zg-verb {
  font-family: var(--font);
  font-size: 32px;
  font-weight: 700;
  color: var(--ink-soft);
}
.mod-zegar .zg-phrase {
  font-family: var(--font);
  font-size: 44px;
  font-weight: 700;
  color: var(--ink);
}
.mod-zegar .zg-phrase.zg-small {
  font-size: 32px;
  color: var(--ink-soft);
}
.mod-zegar .zg-phrase.zg-res {
  color: var(--gold-deep);
}
.mod-zegar .zg-op,
.mod-zegar .zg-arrow {
  font-family: var(--font-num);
  font-size: 44px;
  font-weight: 700;
  color: var(--ink-soft);
}
.mod-zegar .zg-price {
  font-family: var(--font-num);
  font-size: 30px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 12px;
  background: var(--gold-soft);
  border: 3px dashed var(--gold-deep);
  color: var(--ink);
}
.mod-zegar .zg-sky,
.mod-zegar .zg-story {
  flex: none;
}
.mod-zegar .zg-bookbtn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--line);
  background: var(--panel);
  color: #a8743a;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex: none;
}
.mod-zegar .zg-bookbtn.on {
  border-color: #b6a2f2;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- L6: the clock at full size (she counts minutes on its numbers, §1.4), the hand buttons in a column
   beside it, the keypad on the right. The wings fold away: the rim moves to x 20 (the box overhangs the module
   area on the left and is clipped there) and the buttons take the place of the right wing, 24 px from the keys. */

.mod-zegar .zg-wings {
  transition: opacity 0.35s ease;
}
.mod-zegar.zg-elapsed .zg-wings {
  opacity: 0;
}
.mod-zegar.zg-elapsed .zg-clock {
  left: -44px;
}
.mod-zegar.zg-elapsed .zg-hands {
  left: 496px;
  top: 184px;
  width: 156px;
  gap: 40px;
}
.mod-zegar.zg-elapsed .zg-handbtn {
  width: 156px;
  height: 150px;
  flex-direction: column;
  justify-content: center;
  padding: 10px 6px;
  gap: 8px;
  font-size: 31px;
  border-radius: 28px;
  white-space: nowrap;
}
.mod-zegar.zg-elapsed .zg-handbtn .zg-mini {
  width: 64px;
  height: 64px;
}

/* ---------- sparkles ---------- */

.mod-zegar .zg-spark {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, #fffbe6 0, var(--gold) 45%, rgba(242, 183, 5, 0) 72%);
  animation: zg-spark 0.9s ease-out forwards;
  z-index: 50;
}
@keyframes zg-spark {
  from { transform: translate(0, 0) scale(0.4); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(1.15); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .mod-zegar .zg-clock {
    transition: none;
  }
}
