/* Board cells and tiles, sized by view.js (--cell, --pad on the board) and
   positioned with --r / --c; slide, appear and merge animations; the calm
   tile palette (also used by the start screen logo). */
.t2-tiles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.t2-cell,
.t2-tile {
  position: absolute;
  top: var(--pad);
  left: var(--pad);
  width: var(--cell);
  height: var(--cell);
  border-radius: calc(var(--cell) * 0.14);
  transform: translate(
    calc(var(--c) * (var(--cell) + var(--pad))),
    calc(var(--r) * (var(--cell) + var(--pad)))
  );
}

.t2-cell {
  background: rgba(255, 255, 255, 0.38);
}

/* Keep the duration in step with SLIDE_MS in view.js. */
.t2-tile {
  z-index: 1;
  transition: transform 130ms cubic-bezier(0.25, 0.8, 0.35, 1);
}

.t2-tile.is-absorbed {
  z-index: 0;
}

.t2-tile-face {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--tile-bg);
  color: var(--tile-ink);
  font-size: calc(var(--cell) * 0.42);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 calc(var(--cell) * 0.03) 0 rgba(74, 85, 96, 0.1);
}

[data-digits="3"] .t2-tile-face {
  font-size: calc(var(--cell) * 0.36);
}

[data-digits="4"] .t2-tile-face {
  font-size: calc(var(--cell) * 0.29);
}

[data-digits="5"] .t2-tile-face,
[data-digits="6"] .t2-tile-face {
  font-size: calc(var(--cell) * 0.23);
}

.is-spawned .t2-tile-face {
  animation: t2-appear 220ms ease-out 110ms both;
}

.is-merged .t2-tile-face {
  animation: t2-pop 260ms ease-out;
}

@keyframes t2-appear {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes t2-pop {
  45% {
    transform: scale(1.1);
  }
}

/* Calm palette: sand, peach, rose, lavender, sky, sea, sage, then gold. */
[data-value] {
  --tile-bg: #fbf8f1;
  --tile-ink: #5b6770;
}
[data-value="4"] {
  --tile-bg: #f4ecda;
}
[data-value="8"] {
  --tile-bg: #f3dac6;
}
[data-value="16"] {
  --tile-bg: #efc8bc;
}
[data-value="32"] {
  --tile-bg: #e5bccd;
}
[data-value="64"] {
  --tile-bg: #d0c1e3;
}
[data-value="128"] {
  --tile-bg: #bac9e7;
}
[data-value="256"] {
  --tile-bg: #a9d2dd;
}
[data-value="512"] {
  --tile-bg: #a8d8c5;
}
[data-value="1024"] {
  --tile-bg: #bad7a7;
}
[data-value="2048"] {
  --tile-bg: #ecd28e;
  --tile-ink: #5b4a22;
}
[data-value="big"] {
  --tile-bg: #7f97aa;
  --tile-ink: #ffffff;
}

[data-value="2048"] > .t2-tile-face {
  box-shadow: 0 0 calc(var(--cell) * 0.3) rgba(236, 210, 142, 0.9);
}

@media (prefers-reduced-motion: reduce) {
  .t2-tile {
    transition: none;
  }

  .t2-tile-face {
    animation: none !important;
  }
}
