/* Dunk the Chunk: the görev of Kalıp Gezegeni (js/tasks/dunk.js).
   Shared task classes (.pill, .task-note) and the shake keyframes stay in
   base.css; everything dunk-only lives here. */

/* The court covers the screen but takes no taps, only the balls do, so the
   counter and the map orb stay reachable through it. */
.dunk-court {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  touch-action: none;
}
.dunk-court .dunk-ball, .dunk-court .dunk-ball.shot { pointer-events: auto; }

.dunk-hoop {
  position: absolute;
  left: var(--hoop-x, 50%);
  top: var(--hoop-y, 12%);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
  pointer-events: none;
}
/* The lit backboard: the moment you must answer. */
.dunk-board {
  max-width: 13em;
  padding: 0.55em 0.95em;
  font-family: var(--serif);
  font-size: clamp(0.95rem, 2.3vw, 1.15rem);
  line-height: 1.45;
  color: var(--cream);
  text-align: center;
  border: 1px solid rgba(232, 193, 106, 0.35);
  border-radius: 12px;
  background: rgba(20, 12, 6, 0.62);
  box-shadow: 0 0 22px rgba(232, 162, 74, 0.18);
}
.dunk-board.panic { animation: shake 0.4s ease; }
/* The rim: an ellipse seen at a slant, its front edge the brighter gold. */
.dunk-rim {
  height: 15px;
  border: 3px solid rgba(232, 193, 106, 0.55);
  border-bottom-color: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(232, 193, 106, 0.4);
}
.dunk-net {
  width: 52px;
  height: 34px;
  margin-top: -4px;
  background:
    repeating-linear-gradient(60deg, rgba(232, 193, 106, 0.3) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-60deg, rgba(232, 193, 106, 0.3) 0 1px, transparent 1px 7px);
  clip-path: polygon(6% 0, 94% 0, 74% 100%, 26% 100%);
  transform-origin: top center;
}
.dunk-hoop.swish .dunk-net { animation: net-sway 0.6s ease; }
.dunk-hoop.swish .dunk-rim { box-shadow: 0 0 26px rgba(232, 193, 106, 0.85); }
@keyframes net-sway {
  0%, 100% { transform: scaleY(1) skewX(0deg); }
  30% { transform: scaleY(1.28) skewX(5deg); }
  65% { transform: scaleY(0.92) skewX(-4deg); }
}

/* The aim canvas: sling band, power arc, and flight arc, all one layer. */
.dunk-aim {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* The rack: each phrase is a label with a real ball resting under it. You
   grab the ball, not the phrase. */
.dunk-rack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em 1.4em;
  justify-content: center;
  align-content: flex-end;
  max-width: 40em;
}
.dunk-court .dunk-rack {
  position: absolute;
  left: 0; right: 0;
  bottom: 18vh; /* room to pull the ball back beneath it */
  margin: 0 auto;
  pointer-events: none;
}
.dunk-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4em;
  pointer-events: none;
}
.ball-label {
  font-family: var(--serif);
  font-size: clamp(0.85rem, 2vw, 1.05rem);
  color: var(--gold);
  text-align: center;
}
/* A basketball: orange, with a dark seam crossing it. */
.dunk-ball {
  width: 46px;
  height: 46px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  background:
    linear-gradient(rgba(58, 24, 6, 0.6), rgba(58, 24, 6, 0.6)) center / 2px 100% no-repeat,
    linear-gradient(rgba(58, 24, 6, 0.6), rgba(58, 24, 6, 0.6)) center / 100% 2px no-repeat,
    radial-gradient(circle at 36% 30%, #F2B066, #C9691F 62%, #944711);
  box-shadow: inset -3px -4px 9px rgba(0, 0, 0, 0.38), 0 3px 6px rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.2s ease, transform 0.1s ease;
}
.dunk-ball:hover { box-shadow: inset -3px -4px 9px rgba(0, 0, 0, 0.38), 0 0 14px rgba(232, 193, 106, 0.55); }
.dunk-ball.armed { cursor: grabbing; }
.dunk-ball.thrown { opacity: 0.35; }
.dunk-ball.correct-reveal {
  box-shadow: inset -3px -4px 9px rgba(0, 0, 0, 0.38), 0 0 18px 3px rgba(232, 193, 106, 0.85);
}
/* The flying clone: the rAF owns its transform, so nothing eases it. */
.dunk-ball.shot {
  position: absolute;
  left: 0; top: 0;
  will-change: transform;
  transition: none;
  box-shadow: inset -3px -4px 9px rgba(0, 0, 0, 0.35), 0 0 16px rgba(232, 193, 106, 0.5);
}
/* A missed shot dims as it falls, then fades out where it lands. */
.dunk-ball.shot.missed { opacity: 0.6; box-shadow: none; }
.dunk-ball.shot.landed { opacity: 0; transition: opacity 0.5s ease; }
/* Clang off the rim: a quick cream flash. */
.dunk-ball.shot.clank { animation: dunk-clank 0.24s ease; }
@keyframes dunk-clank {
  0% { box-shadow: 0 0 22px 4px rgba(243, 234, 216, 0.85); border-color: var(--cream); }
  100% { box-shadow: 0 0 16px rgba(232, 193, 106, 0.5); border-color: var(--gold); }
}

.dunk-court .task-note {
  position: absolute;
  left: 50%;
  top: 60%;
  transform: translateX(-50%);
  margin: 0;
}
