/* Snake. Functional layout before the design pass; existing tokens only (spec D1). The board is a
   canvas in the vermilion swatch (render.js reads --field, --deep and --light from it), square and
   as wide as the card. New UI for design review (docs/follow-ups.md): the board's look, the start
   hint, the arrow pad, the pause and end panels over the board; Phase 2: the mode choice, the
   statistics table. */

.g-snake { padding-block: var(--s3) var(--s7); }
.g-snake__intro { margin-bottom: var(--s3); }
.g-snake__intro h1 { font-size: 24px; }
.g-snake__intro p { margin-top: var(--s1); max-width: 60ch; }
.g-snake__note { margin-bottom: var(--s3); }

/* ---------- game card ---------- */
.g-snake__game { max-width: 520px; display: grid; gap: var(--s3); padding: var(--s3); }
@media (min-width: 400px) { .g-snake__game { padding: var(--s4); } }
.g-snake__game:focus { outline: none; }
.g-snake__bar { display: flex; align-items: end; gap: var(--s2) var(--s4); }
.g-snake__bar .stat { min-width: 56px; }
.g-snake__bar-actions { margin-left: auto; display: flex; gap: var(--s2); }
.g-snake__bar-actions .btn { touch-action: manipulation; }
.g-snake__action { min-width: 112px; } /* Start, Pause, Resume and Play again keep one width */
.g-snake__options { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s2) var(--s3); }
.g-snake__choice input:disabled + span { opacity: .5; }
.g-snake__choice input:disabled { cursor: default; }
.g-snake__tools { display: flex; gap: var(--s2); }
.g-snake__speed-note { flex-basis: 100%; text-align: center; font-size: 14px; }

/* ---------- board ---------- */
.g-snake__stage { position: relative; }
.g-snake__board {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--deep);
  /* D5: swipes on the board never scroll the page. The board only; the page still zooms. */
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.g-snake__board:focus { outline: none; }
.g-snake__board:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.g-snake__canvas { display: block; width: 100%; height: 100%; }
.g-snake__hint {
  position: absolute; left: 0; right: 0; bottom: var(--s4); margin: 0 auto; width: max-content; max-width: calc(100% - 2 * var(--s4));
  padding: 6px var(--s3); border-radius: var(--r-pill); background: var(--light); color: var(--deep);
  font-size: 14px; font-weight: 600; text-align: center; pointer-events: none;
}
.g-snake__hint[hidden] { display: none; }

/* ---------- pause and end panels, over the board ---------- */
.g-snake__panel { inset: 0; align-content: center; padding: var(--s5); }
.g-snake__panel[hidden] { display: none; }
.g-snake__over { justify-items: stretch; text-align: left; }
.g-snake__over .fig dd { font-size: 24px; }
.g-snake__over .figs { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: var(--s3); }
.g-snake__over h2:focus { outline: none; }
.g-snake__over p { font-size: 15px; font-weight: 500; font-stretch: 100%; margin-top: var(--s3); }

/* ---------- arrow pad (a setting, D5) ---------- */
.g-snake__pad {
  --key: 56px;
  display: grid; justify-content: center; gap: var(--s1);
  grid-template-columns: repeat(3, var(--key)); grid-template-rows: repeat(3, var(--key));
  grid-template-areas: ". up ." "left . right" ". down .";
}
.g-snake__pad[hidden] { display: none; }
.g-snake__dir { width: var(--key); height: var(--key); padding: 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.g-snake__dir .ico { width: 24px; height: 24px; }
.g-snake__dir--up { grid-area: up; } .g-snake__dir--up .ico { rotate: -90deg; }
.g-snake__dir--left { grid-area: left; } .g-snake__dir--left .ico { rotate: 180deg; }
.g-snake__dir--right { grid-area: right; }
.g-snake__dir--down { grid-area: down; } .g-snake__dir--down .ico { rotate: 90deg; }

/* ---------- play mode (docs/done-specs/20261011-game-play-mode.md): phones; /css/play-mode.css ---------- */
.g-snake__stage .play-start { border-radius: 12px; }
@media (max-width: 719px), (max-height: 599px) {
  .g-snake__game:not(.is-play-mode) .g-snake__pad { display: none; } /* in the page the board is a preview */
  .g-snake__game.is-play-mode { grid-template-rows: auto minmax(0, 1fr) auto; align-content: stretch; }
  /* the board as large as the space allows, square */
  .is-play-mode .g-snake__stage { container-type: size; min-height: 0; display: grid; place-items: center; }
  .is-play-mode .g-snake__board { width: min(100cqw, 100cqh); }
  .is-play-mode .g-snake__panel { inset: 0; }
  .is-play-mode .g-snake__pad { --key: min(56px, 12svh); }
}
/* a phone held sideways: the board on the left at full height, the bar and the pad beside it */
@media (orientation: landscape) and (max-height: 599px) {
  .g-snake__game.is-play-mode { grid-template-columns: minmax(0, 1fr) minmax(200px, .6fr); grid-template-rows: auto minmax(0, 1fr); }
  .is-play-mode .g-snake__stage { grid-column: 1; grid-row: 1 / 3; }
  .is-play-mode .g-snake__bar { grid-column: 2; grid-row: 1; align-self: start; flex-wrap: wrap; }
  .is-play-mode .g-snake__pad { grid-column: 2; grid-row: 2; align-self: center; --key: min(56px, 22svh); }
}

/* ---------- dialogs ---------- */
.g-snake__settings { display: grid; }
.g-snake__settings label { display: flex; align-items: center; gap: var(--s3); min-height: 44px; cursor: pointer; }
.g-snake__settings input { flex: none; width: 20px; height: 20px; accent-color: var(--ink); margin: 0; }
.g-snake__hint-text { display: block; font-size: 14px; }
.g-snake__radios { border: 0; padding: 0; margin: var(--s3) 0 0; }
.g-snake__radios legend { font-weight: 600; padding: 0; }
.g-snake__stats-modes { margin-bottom: var(--s3); }
.g-snake__stats { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.g-snake__stats th, .g-snake__stats td { text-align: right; padding: 8px 0 8px var(--s3); border-bottom: 1px solid var(--line); }
.g-snake__stats th:first-child { text-align: left; padding-left: 0; }
.g-snake__stats thead th { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.g-snake__stats tbody td { font-weight: 700; }
.g-snake__reset { margin-top: var(--s5); }
.g-snake__reset p { font-weight: 600; }

/* ---------- text below the game ---------- */
.g-snake__about { max-width: 62ch; margin-top: var(--s6); }
.g-snake__about h2 { margin: var(--s6) 0 var(--s3); }
.g-snake__about h2:first-child { margin-top: 0; }
.g-snake__about ol { padding-left: 1.25em; margin: var(--s3) 0; }
.g-snake__about li + li { margin-top: 6px; }
.g-snake__keys { border-collapse: collapse; font-size: 15px; }
.g-snake__keys th, .g-snake__keys td { text-align: left; padding: 6px var(--s4) 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.g-snake__keys th { font-weight: 600; white-space: nowrap; }
