/* Pickle Arcade: Stack, the sixth cabinet.
 *
 * arcade.css carries the site register and the --arc-* tokens on
 * body[data-app="minigame"]; arena.css carries the pieces every cabinet shares
 * (.arc-band, .arc-tube, .arc-pending, .arc-lamp). This sheet carries what
 * Stack alone asks for: the screen-and-rail table, the tower's canvas, the
 * height over it, the one plate with the one button, and the rail's console.
 * Every class here is prefixed stk- and every class the markup uses must exist
 * here or in a sheet that loads before it, because
 * tests/design-language.test.mjs walks both.
 *
 * NOT ONE HEX IN THIS FILE. Every colour resolves to a shared-ui token or to
 * --arc-stack, the cabinet light arcade.css declares for the hall's ticket.
 *
 * COLOUR IS A GRAMMAR. Ice is the tower and everything that belongs to it:
 * the height, the streak, the pot. White is the reading. Nothing else here is
 * coloured, so a perfect streak lit in ice is the brightest thing on the page.
 *
 * THE ESTATE'S RADIUS IS 2px, AND SO IS EVERY CORNER HERE.
 *
 * MOTION IS A LAYER, NOT THE PICTURE. Every rule with a duration lives inside
 * @media (prefers-reduced-motion: no-preference) at the end of this file.
 */

/* ===================================================================== tokens */
.stk-band {
  --stk-ice: var(--arc-stack);
  --stk-ice-hi: var(--arc-stack-hi);
  --stk-ice-faint: color-mix(in srgb, var(--arc-stack) 16%, transparent);
  --stk-ice-ghost: color-mix(in srgb, var(--arc-stack) 7%, transparent);
  --stk-glass: color-mix(in srgb, var(--pickle-bg) 78%, transparent);
}

/* ====================================================================== table
 * The screen and the rail, the whole viewport under the nav, as Trellis. */
.stk-table {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  grid-template-rows: minmax(0, 1fr);
  height: max(30rem, calc(var(--arc-stage) - 1px));
}

/* The screen: the estate's ground with a pool of the cabinet's light under
   the tower, so it stands on something rather than in a void. */
.stk-screen {
  position: relative;
  isolation: isolate;
  min-width: 0;
  height: 100%;
  overflow: clip;
  background:
    radial-gradient(60% 45% at 50% 88%, var(--stk-ice-faint), transparent 70%),
    linear-gradient(180deg, var(--pickle-surface-2), var(--pickle-bg));
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* While a run is live the whole screen is the button. */
.stk-screen.stk-live { cursor: pointer; }

.stk-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.stk-lost {
  position: absolute;
  inset: auto var(--pickle-space-4) var(--pickle-space-4);
  margin: 0;
  color: var(--pickle-muted);
  font-family: var(--pickle-font-mono);
  font-size: var(--pickle-text-xs);
}

/* ======================================================================== hud
 * The height, set as the page's display figure, top left, where the eye goes
 * first and where the tower never climbs. */
.stk-hud {
  position: absolute;
  top: var(--pickle-space-5);
  left: var(--pickle-space-5);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--pickle-space-2);
  pointer-events: none;
}

.stk-height {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: var(--pickle-space-2);
}

.stk-height-n {
  font-size: clamp(3.4rem, 7vw, 6.5rem);
  color: var(--pickle-text);
}

.stk-height-unit,
.stk-plate-unit {
  color: var(--pickle-subtle);
  font-family: var(--pickle-font-mono);
  font-size: var(--pickle-text-2xs);
  letter-spacing: var(--pickle-tracking-caps);
  text-transform: uppercase;
}

/* A streak is the one thing on the screen lit in the cabinet's own light. */
.stk-streak {
  margin: 0;
  padding: var(--pickle-space-1) var(--pickle-space-3);
  border: 1px solid var(--stk-ice);
  border-radius: 2px;
  background: var(--stk-ice-ghost);
  color: var(--stk-ice-hi);
  font-family: var(--pickle-font-mono);
  font-size: var(--pickle-text-xs);
  font-weight: 600;
  letter-spacing: var(--pickle-tracking-caps);
  text-transform: uppercase;
}

.stk-cut {
  margin: 0;
  color: var(--pickle-muted);
  font-family: var(--pickle-font-mono);
  font-size: var(--pickle-text-xs);
}

/* The chain's speed, said where a player can see it and never in the way. */
.stk-speed {
  position: absolute;
  left: var(--pickle-space-5);
  bottom: var(--pickle-space-4);
  z-index: 2;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--pickle-space-1) var(--pickle-space-2);
  pointer-events: none;
}

.stk-speed-what {
  color: var(--pickle-subtle);
  font-family: var(--pickle-font-mono);
  font-size: var(--pickle-text-2xs);
  letter-spacing: var(--pickle-tracking-caps);
  text-transform: uppercase;
}

.stk-speed-ms {
  color: var(--stk-ice);
  font-family: var(--pickle-font-mono);
  font-size: var(--pickle-text-sm);
  font-variant-numeric: tabular-nums;
}

.stk-hint {
  position: absolute;
  left: 50%;
  bottom: var(--pickle-space-5);
  z-index: 2;
  margin: 0;
  transform: translateX(-50%);
  color: var(--pickle-subtle);
  font-family: var(--pickle-font-mono);
  font-size: var(--pickle-text-2xs);
  letter-spacing: var(--pickle-tracking-caps);
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}

/* ====================================================================== plate
 * Before a run and after one: one plate, one action, over the tower. */
/* Above the middle, so the tower it is about stays in sight under it. */
.stk-plate {
  position: absolute;
  top: 42%;
  left: 50%;
  z-index: 3;
  width: min(24rem, calc(100% - 2 * var(--pickle-space-4)));
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--pickle-space-3);
  padding: var(--pickle-space-5);
  border: 1px solid var(--pickle-line);
  border-top: 2px solid var(--stk-ice);
  border-radius: 2px;
  background: var(--stk-glass);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-align: center;
}

.stk-plate-kicker {
  margin: 0;
  color: var(--stk-ice);
  font-family: var(--pickle-font-mono);
  font-size: var(--pickle-text-2xs);
  letter-spacing: var(--pickle-tracking-caps);
  text-transform: uppercase;
}

.stk-plate-title {
  margin: 0;
  color: var(--pickle-text);
  font-family: var(--pickle-font-display);
  font-size: var(--pickle-text-lg);
  font-weight: 600;
  line-height: 1.2;
}

.stk-plate-figure {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: var(--pickle-space-2);
}

.stk-plate-height {
  font-size: clamp(3rem, 6vw, 4.5rem);
  color: var(--stk-ice-hi);
}

.stk-plate-line {
  margin: 0;
  color: var(--pickle-muted);
  font-size: var(--pickle-text-sm);
  line-height: 1.5;
}

.stk-play {
  min-height: calc(var(--pickle-tap) + 8px);
  font-family: var(--pickle-font-display);
  font-size: var(--pickle-text-md);
  font-weight: 600;
}

/* The run's price in ETH, under the dollar figure on the button. */
.stk-play-eth {
  margin: calc(var(--pickle-space-2) * -1) 0 0;
  color: var(--pickle-subtle);
  font-family: var(--pickle-font-mono);
  font-size: var(--pickle-text-2xs);
  letter-spacing: .04em;
}

.stk-plate-why {
  margin: 0;
  color: var(--pickle-subtle);
  font-family: var(--pickle-font-mono);
  font-size: var(--pickle-text-xs);
}

/* ======================================================================= rail */
.stk-rail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  background: var(--pickle-bg);
  border-left: 1px solid var(--pickle-line);
}

.stk-cabin,
.stk-room,
.stk-how {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--pickle-space-3);
  padding: var(--pickle-space-4);
  border-bottom: 1px solid var(--pickle-line);
  font-family: var(--pickle-font-mono);
  font-size: var(--pickle-text-xs);
  color: var(--pickle-muted);
  flex: 0 0 auto;
}

.stk-how { border-bottom: 0; }

.stk-label,
.stk-h {
  margin: 0;
  color: var(--pickle-subtle);
  font-family: var(--pickle-font-mono);
  font-size: .68rem;
  font-weight: 400;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.stk-pot {
  margin: calc(var(--pickle-space-2) * -1) 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--pickle-space-2) var(--pickle-space-3);
}

.stk-pot-n {
  font-size: clamp(1.6rem, 2.1vw, 2rem);
  color: var(--stk-ice);
}

/* A figure nobody has been given yet is not a zero. */
.stk-pot-n.stk-idle { color: var(--pickle-subtle); }

.stk-pot-eth { color: var(--pickle-subtle); }

.stk-note {
  margin: 0;
  color: var(--pickle-muted);
  font-family: var(--pickle-font-display);
  font-size: var(--pickle-text-xs);
  line-height: 1.55;
}

.stk-purse {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--pickle-space-2);
}

.stk-purse-what {
  color: var(--pickle-subtle);
  font-size: var(--pickle-text-2xs);
  letter-spacing: var(--pickle-tracking-caps);
  text-transform: uppercase;
}

.stk-purse-sum {
  color: var(--pickle-text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.stk-purse-eth { color: var(--pickle-subtle); }

.stk-purse a { margin-left: auto; }

/* The day's tallest: a place, a name and a height, the height in ice. */
.stk-leaders {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}

.stk-leader {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--pickle-space-2);
  padding: var(--pickle-space-2) 0;
  border-bottom: 1px solid var(--pickle-line-soft);
}

.stk-leader:last-child { border-bottom: 0; }

.stk-leader-at { color: var(--pickle-subtle); font-variant-numeric: tabular-nums; }

.stk-leader-who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--pickle-muted);
}

.stk-leader-h {
  color: var(--stk-ice);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Your own row reads as yours without shouting. */
.stk-leader.me .stk-leader-who { color: var(--pickle-text); }
.stk-leader.me { background: var(--stk-ice-ghost); }

.stk-empty,
.stk-best {
  margin: 0;
  color: var(--pickle-muted);
}

.stk-best { color: var(--pickle-text); }

/* ===================================================================== phones */
@media (max-width: 1023px) {
  .stk-table {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    height: auto;
  }

  /* Tall enough that a tower has room to be a tower, short enough that the
     pot and the leaders are a thumb away. */
  .stk-screen { height: min(var(--arc-stage-phone), 64dvh); min-height: 24rem; }

  .stk-rail {
    height: auto;
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--pickle-line);
  }

  .stk-hud { top: var(--pickle-space-4); left: var(--pickle-space-4); }
  .stk-speed { left: var(--pickle-space-4); }

  /* Upright, the plate lies along the bottom of the screen and the tower
     stands above it (stack-gl.js lifts the camera to match), so the call to
     play never hides the thing it is about. */
  .stk-plate {
    top: auto;
    bottom: var(--pickle-space-4);
    transform: translateX(-50%);
    gap: var(--pickle-space-2);
    padding: var(--pickle-space-4);
  }

  .stk-plate-line { font-size: var(--pickle-text-xs); }
}

/* ===================================================================== motion */
@media (prefers-reduced-motion: no-preference) {
  .stk-plate { animation: stk-rise 280ms var(--pickle-ease, ease-out) both; }

  @media (max-width: 1023px) {
    .stk-plate { animation-name: stk-rise-low; }
  }

  @keyframes stk-rise-low {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to { opacity: 1; transform: translate(-50%, 0); }
  }
  .stk-streak { animation: stk-pop 220ms var(--pickle-ease, ease-out) both; }
  .stk-hint { animation: stk-breathe 2.4s ease-in-out infinite; }

  @keyframes stk-rise {
    from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); }
    to { opacity: 1; transform: translate(-50%, -50%); }
  }

  @keyframes stk-pop {
    from { opacity: 0; transform: scale(.86); }
    to { opacity: 1; transform: scale(1); }
  }

  @keyframes stk-breathe {
    0%, 100% { opacity: .45; }
    50% { opacity: 1; }
  }
}
