/* Shared styles: page, buttons, tiles and motion. Colours come only from tokens.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  -webkit-text-size-adjust: 100%;
}

html {
  /* No pull-to-refresh or rubber-band on the page itself: a stray swipe mustn't reload a run. */
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior: none;
  /* Taps act at once, and a quick double tap on a key doesn't zoom the page. */
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

/* Every button presses down when tapped and loses its shadow. */
button:active:not(:disabled) {
  translate: 2px 4px;
  box-shadow: none !important;
}
button {
  transition: translate var(--t-press);
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Tiles ----------
   States: plain, locked, wrong, empty, current. Plus two from the demo:
   shown (a real letter marked by the hint) and ghost (a tile that has been placed). */

.tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch);
  min-height: var(--touch);
  padding: 0;
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  border: var(--border) solid var(--ink);
  border-radius: 0;
  box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--ink);
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1;
  text-transform: uppercase;
}

.tile--locked {
  background: var(--part);
  color: var(--on-part);
}

.tile--wrong {
  background: var(--wrong);
  color: var(--wrong-ink);
}

.tile--empty {
  background: var(--surface);
  border-style: dashed;
  border-color: var(--dim);
  box-shadow: none;
}

.tile--current {
  outline: var(--border) solid var(--part);
  outline-offset: 2px;
}

.tile--shown {
  outline: 4px solid var(--part);
  outline-offset: 2px;
}

/* Crossed out: tried, and not the answer. Light red with a cross through it. */
.tile--dead,
.is-dead.is-dead {
  background:
    linear-gradient(to top right, transparent calc(50% - 2px), var(--wrong) calc(50% - 2px), var(--wrong) calc(50% + 2px), transparent calc(50% + 2px)), /* design-ok: a hard-edged line, half of the cross on a struck-out tile */
    linear-gradient(to bottom right, transparent calc(50% - 2px), var(--wrong) calc(50% - 2px), var(--wrong) calc(50% + 2px), transparent calc(50% + 2px)), /* design-ok: a hard-edged line, half of the cross on a struck-out tile */
    var(--wrong-soft);
  box-shadow: none;
}

/* Locked in the letter grid: raised a little and tilted, for good. */
.tile--raised {
  transform: translateY(-4px) rotate(-9deg);
  position: relative;
  z-index: 1;
}

.tile--ghost {
  background: transparent;
  color: transparent;
  border-style: dashed;
  border-color: var(--dim);
  box-shadow: none;
}

/* ---------- Motion ---------- */

.anim-wobble {
  animation: wobble var(--t-wobble) ease both;
}
.anim-pop {
  animation: pop var(--t-pop) ease both;
}

@keyframes wobble {
  0% { transform: none; }
  15% { transform: translateX(-7px) rotate(-4deg); }
  35% { transform: translateX(6px) rotate(3deg); }
  55% { transform: translateX(-4px) rotate(-2deg); }
  75% { transform: translateX(3px) rotate(1deg); }
  100% { transform: none; }
}

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
