/* Snake (wave 7, P17): the balance card, the board, its overlay, the record
   cards and the d-pad. Loaded after components.css.

   Geometry and type are README Part 3 and the prototype's, value for value.
   Every colour is a token from tokens.css, so dark mode, reduced
   transparency and increased contrast arrive with no rule here. The neon of
   the dark board itself is drawn by snake.js on the canvas; the play button
   is neon through --save-*.

   Round 7.3 W8 owns this file. */

/* ---- What shows with and without the script ------------------------------

   snake.js sets [data-snake-ready] on the root once it is bound. Without it
   the game cannot run, and the start form sits in the overlay: hiding the
   board hides the form too, so a no-JS browser cannot pay for a game it
   cannot play. It sees the balance, the price, the records and the
   "needs JavaScript" line instead (README Part 3, "No-JS fallback"). */

.snake-board,
.snake-dpad,
.snake-footnote {
  display: none;
}

[data-snake-ready] .snake-board {
  display: block;
}

[data-snake-ready] .snake-dpad {
  display: grid;
}

[data-snake-ready] .snake-footnote {
  display: block;
}

[data-snake-ready] .snake-noscript,
[data-snake-ready] .snake-refused {
  /* With the script the overlay's own line says the same. */
  display: none;
}

.snake {
  padding-top: 8px;
}

/* ---- Balance and price --------------------------------------------------- */

.snake-money {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.snake-money__cell {
  flex: 1;
  min-width: 0;
}

.snake-money__cell--end {
  flex: none;
  text-align: right;
}

.snake-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snake-number {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.snake-noscript,
.snake-refused {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted-foreground);
}

.snake-refused {
  color: var(--foreground);
  font-weight: 500;
}

/* ---- The board ----------------------------------------------------------- */

.snake-board {
  position: relative;
  width: 330px;
  height: 330px;
  margin: 12px auto 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow-xs);
  /* A swipe steers the snake; it must not scroll the page (snake.js sets
     the same on the canvas). */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.snake-board canvas {
  display: block;
  width: 330px;
  height: 330px;
}

.snake-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  /* Thick glass, as the prototype draws it: the thick tint over the regular
     blur, so the board's dots still read through it. */
  background: var(--glass-sheen), var(--glass-thick-bg);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
}

.snake-overlay[hidden] {
  display: none;
}

.snake-overlay__headline {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.snake-overlay__line {
  max-width: 28ch;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted-foreground);
}

.snake-overlay form {
  margin: 6px 0 0;
}

/* The solid, save-style button: "Spielen · −5". */
.snake-play {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: 99px;
  background: var(--save-bg);
  color: var(--save-fg);
  box-shadow: var(--save-shadow);
  font: inherit;
  cursor: pointer;
  transition: transform 0.18s var(--ease), opacity 0.18s var(--ease);
}

.snake-play:active {
  transform: scale(1.04);
}

.snake-play .icon {
  flex: none;
  fill: currentColor;
  stroke: none;
}

.snake-play__text {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

/* Short of the price: the design's .5 fade. The button stays focusable, so
   the reason (the line above it) is still reachable; snake.js marks it
   aria-disabled and ignores the press. */
[data-snake-need] .snake-play,
.snake-play[aria-disabled='true'] {
  opacity: 0.5;
  cursor: default;
}

.snake-play[aria-disabled='true']:active {
  transform: none;
}

.snake-play[aria-busy='true'] {
  cursor: progress;
}

/* ---- Records ------------------------------------------------------------- */

.snake-records {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 330px;
  max-width: 100%;
  margin: 12px auto 0;
}

.snake-record {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-xs);
}

.snake-record--house {
  border-color: var(--primary);
}

/* Two lines at a fixed 25px, so all three values line up whether a label
   wraps or not; German breaks "Haushalts-/rekord" at its soft hyphen. */
.snake-record__label {
  display: -webkit-box;
  height: 25px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted-foreground);
  overflow-wrap: anywhere;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.snake-record__value {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.snake-record__sub {
  font-size: 11px;
  color: var(--muted-foreground);
}

/* ---- D-pad --------------------------------------------------------------- */

.snake-dpad {
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(2, 52px);
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.snake-dpad__key {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.12s var(--ease), background 0.12s var(--ease);
}

.snake-dpad__key:active {
  transform: scale(0.94);
  background: var(--muted);
}

/* One chevron in the sprite, turned four ways. */
.snake-dpad__key--up .icon    { transform: rotate(180deg); }
.snake-dpad__key--left .icon  { transform: rotate(90deg); }
.snake-dpad__key--right .icon { transform: rotate(-90deg); }

.snake-footnote {
  margin: 12px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  text-align: center;
  color: var(--muted-foreground);
}

@media (prefers-reduced-motion: reduce) {
  .snake-play,
  .snake-dpad__key {
    transition: none;
  }

  .snake-play:active,
  .snake-dpad__key:active {
    transform: none;
  }
}
