/* Mahjong. */

/* --mj-side: a tile's side, the sign of which tile lies on which: 3:1 against the page */
.mj { padding: 0.5rem 0 0.25rem; --mj-side: #948E7F; }
/* the faces, drawn once and shown by every tile */
.board .mj-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.mj-wide { margin: 0 0 0.5rem; font: 400 1rem/1.4 var(--sans); color: var(--stone); }

/* The board fills its frame's width. A full layout on a phone keeps tiles 24px wide and scrolls
   sideways inside the frame; the page itself never does. */
/* 6px kept clear all round (play.js PAD), reaching into the page gutter, so a focus ring on an edge tile shows whole */
.mj-frame { overflow: hidden; padding: 6px; margin: 0 -6px; }
.mj-frame.scroll { overflow-x: auto; overscroll-behavior-x: contain; }
.mj-field {
  position: relative; margin: 0 auto;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

/* A tile: sheet on paper with a hairline edge, and a solid side below and to the right that
   gives it its thickness (a flat band, not a shadow). */
.mj-tile {
  position: absolute; display: block; padding: 0; border: 1px solid var(--rule); border-radius: 4px;
  background: var(--sheet); box-shadow: 1px 1px 0 0 var(--hair), var(--mj-d, 3px) var(--mj-d, 3px) 0 0 var(--mj-side);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.mj-tile[hidden] { display: none; }
.board .mj-tile svg { display: block; width: 100%; height: 100%; }
/* the keyboard's focus ring is drawn by .mj-ring, above every tile, so the tile in focus stays under any tile on it */
.mj-tile:focus-visible { outline: none; }
.mj-ring { position: absolute; pointer-events: none; border-radius: 4px; outline: 3px solid var(--ink); outline-offset: 2px; }
.mj-ring[hidden] { display: none; }
/* picked up: the game's olive round the edge and through the side, and a tinted face */
.mj-tile.on { background: #F4F5EC; border-color: var(--c); box-shadow: inset 0 0 0 2px var(--c), var(--mj-d, 3px) var(--mj-d, 3px) 0 0 var(--c); }
/* a hint: a dashed edge, so it is told apart from a tile picked up without colour; drawn as an
   outline so the face is never made smaller (its numeral stays at least 15px) */
.mj-tile.hint { border-color: var(--c); outline: 2px dashed var(--c); outline-offset: -2px; }
.mj-tile.leaving { pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .mj-tile.leaving { opacity: 0; transition: opacity 150ms ease-out; }
}

/* what happened, in words */
/* two lines kept for it, so a message never pushes the buttons down under a finger */
.mj-note { min-height: 2.8em; margin: 0.625rem 0 0; text-align: center; font: 400 1rem/1.4 var(--sans); color: var(--ink); }

.mj-actions { display: flex; flex-wrap: wrap; gap: 0.625rem; padding-top: 0.625rem; }
.mj-actions .btn { flex: 1 1 auto; padding: 0 0.5rem; }

@media (forced-colors: active) {
  .mj-tile.on { outline: 3px solid Highlight; outline-offset: -3px; }
  .mj-tile.hint { outline: 3px dashed Highlight; outline-offset: -3px; }
}


/* While the board loads, what follows it waits and comes in with the drawn board (game.css keeps
   the caption's line). This board's size changes with the day's puzzle (its layout), so no room kept
   for it would hold. Only where scripts run: without them the page shows as it is, and a script
   that cannot be fetched turns the line into a notice, which lets the page show. */
@media (scripting: enabled) {
  #main:has(> #board > .loading) > #board ~ *,
  .wrap:has(#board > .loading) > .foot { display: none; }
}
