/*
 * Game-specific overrides for the "ordenar" drill (drag 20 sets of numbers
 * into order, smallest -> largest, one set after another). Shared look and
 * background live in shared/shell.css - only ordering-specific bits here.
 */

/* --- deliberately portrait-only, vertically centred ------------------
 * This game reads as a vertical number line: pick an ice cream from the
 * tray at the bottom and drag it UP into the ordered slots. Side-by-side
 * would break that "up = into place" spatial cue, so we opt out of the
 * shell.css landscape variant and keep hud / stage / pad stacked at every
 * size. The block wants a fixed height and is centred in the viewport, so
 * on a short screen it fills the space and on a tall/wide one it sits in
 * the middle instead of stuck to the bottom edge.                        */
#screen-game {
  display: flex;
  padding-right: 52px; /* gutter for the rocket rail on the right */
}
.game-screen {
  position: relative;
  margin: auto;              /* flexbox auto-margins => centred both axes */
  width: 100%;
  max-width: 540px;
  height: auto;
  max-height: 100%;
  min-height: min(100%, 560px); /* fills a short screen; a compact centred block on a tall one */
  /* pack hud/stage/pad together and centre the group vertically, rather
     than letting a 1fr row blow a big gap between the HUD and the slots */
  grid-template-rows: auto auto auto;
  align-content: center;
  gap: clamp(10px, 3vh, 20px);
}
/* override shell.css's landscape side-by-side variant - this game stays
   stacked (see the note above) */
@media (min-width: 640px) and (orientation: landscape) {
  .game-screen {
    grid-template-areas: "hud" "stage" "pad";
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .hud-area { flex-direction: column; align-items: stretch; gap: 8px; }
  .hud { width: 100%; }
  .timebar-track { flex: none; }
}

.stage-area {
  justify-content: center;
  gap: clamp(8px, 2.5vh, 18px);
  padding-bottom: 4px;
}

/* very short (landscape phone): claw back vertical space so the tray isn't
   clipped */
@media (max-height: 430px) {
  #screen-game { padding-top: 8px; padding-bottom: 8px; }
  .feedback { min-height: 32px; }
  .game-screen { gap: 8px; }
}

/* The rocket-progress rail hugs the right edge of the centred block (it's
   a direct child of .game-screen), so on a wide screen it stays next to
   the game instead of stranded at the far screen edge. */
.rocket-track {
  position: absolute;
  left: 100%;
  right: auto;
  margin-left: 12px;
  top: 6%;
  bottom: 6%;
  width: 30px;
}

.order-prompt {
  font-size: clamp(19px, 4.4vw, 28px);
  color: var(--purple-dark);
  text-shadow: 2px 2px 0 #fff;
  line-height: 1.15;
  margin: 2px 0;
}

/* The slot row and the tray are grids with one column per number this
   round (2-5, set from game.js via --count) so 3 slots sit centred rather
   than spread across the whole width. The tray is a touch wider than the
   slot row to account for its own padding, keeping ice/slot roughly aligned. */
.slots,
.ice-tray {
  display: grid;
  grid-template-columns: repeat(var(--count, 5), minmax(0, 1fr));
  margin-inline: auto;
}
.slots     { width: min(100%, calc(var(--count, 5) * 82px)); }
.ice-tray  { width: min(100%, calc(var(--count, 5) * 82px + 24px)); }

/* ---- the row of target positions (left = smallest, right = largest) ---- */
.slots {
  gap: clamp(5px, 1.8vw, 12px);
  align-items: end;
  justify-items: center;
}
.slot {
  position: relative;
  width: 100%;
  max-width: 84px;
  /* min() of vw and vh so a short landscape screen doesn't overflow */
  min-height: clamp(64px, min(22vw, 13vh), 116px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .45) center 8px / 28px no-repeat url("assets/slot.png");
  border: 3px dashed rgba(255, 255, 255, .9);
  transition: background-color .15s, border-color .15s, transform .12s;
}
.slot.filled {
  background-image: none;
  background-color: rgba(255, 255, 255, .7);
  border-style: solid;
}
.slot.drop-hover {
  background-color: #d7ecff;
  border-color: var(--purple);
  border-style: solid;
  transform: translateY(-4px) scale(1.05);
}
.slot.good { background-color: #cdeccf; border-color: var(--green); }
.slot.bad  { background-color: #f6cccc; border-color: var(--red); animation: slotShake .35s; }
@keyframes slotShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---- an ice cream (in the tray, in a slot, or the drag ghost) ---- */
.ice {
  font-family: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.ice img {
  height: clamp(40px, min(16vw, 11vh), 78px);
  max-width: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .18));
}
.ice .ice-num {
  font-size: clamp(20px, 6vw, 32px);
  font-weight: bold;
  color: var(--key-text);
  background: #fff;
  border-radius: 999px;
  padding: 2px 12px;
  line-height: 1.15;
  text-align: center;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .14);
  pointer-events: none;
}
.slot .ice { gap: 3px; }
.slot .ice img { height: clamp(36px, min(12vw, 8.5vh), 60px); }
.slot .ice .ice-num { font-size: clamp(17px, 5vw, 26px); padding: 1px 9px; }

.ice.drag-source { visibility: hidden; }

/* the wrong-answer "watch it sort itself" glide (FLIP, driven from game.js) */
.ice.sliding {
  transition-property: transform;
  transition-timing-function: cubic-bezier(.34, .07, .28, 1);
  position: relative;
  z-index: 2;
  will-change: transform;
}

#drag-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}
.ice.ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: auto;
  transform: scale(1.14) rotate(-3deg);
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, .32));
}
.ice.ghost img { filter: none; }
body.dragging, body.dragging .ice { cursor: grabbing; }

/* ---- the tray of not-yet-placed ice creams (pad area, bottom) ---- */
.ice-tray {
  background: var(--purple);
  border-radius: 22px;
  padding: 14px 10px;
  gap: 6px;
  align-items: center;
  justify-items: center;
  box-shadow: 0 8px 0 var(--purple-dark);
}
.ice-tray .ice-slot {
  width: 100%;
  min-height: clamp(60px, min(20vw, 13vh), 104px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ice-tray .ice-slot.empty { visibility: hidden; }

.scale-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  color: var(--purple-dark);
  opacity: .85;
}
.scale-hint .arrow { font-size: 20px; }
