/* ============================================================
   Impostor Artist — game-specific styles only. The directory, the room
   namespace and every analytics key still say `draw`: that is the id, not
   the name (#198).
   Everything shared (tokens, buttons, cards, avatars, modals,
   lobby, home fold, FAQ) lives in ../shared/base.css, which
   loads first. Only rules unique to this game belong here.
   ============================================================ */

/* ---- Hero character ------------------------------------------------
   Sketches in bursts, then rests. Same shape as the dance hero: it works
   for 3.75s, winds down, and holds still for 8.25s, blinking twice while
   it waits. One cycle is --dw-burst, default 12s.

   Timeline at the default 12s:
     0.0 - 2.25s   four strokes of the hand, the body rocking with them
     2.25 - 3.75s  wind-down: three decaying strokes onto rest
     3.75 - 12.0s  still. Blinks at 7.3s and 9.9s.

   The screen is never touched. The drawing on the phone is the artwork
   exactly as designed, in every frame, which is why the arm only needs
   about 4 units of travel: its flat shoulder edge sits ~29 units inside
   the body's right edge, and this stays well within that. Reaching far
   enough to trace the strokes on the screen would need geometry added
   under the body, which none of this does.

   The wind-down is not decoration. Cutting the motion at a timer freezes
   the hand mid-stroke, which reads as the animation breaking rather than
   the character finishing. Three decaying strokes cost 1.5s and fix it.

   Rest pose is 0 on every part, so the 8.25s hold is the artwork exactly
   as drawn and the browser stops repainting for the whole of it.

   Inlined here rather than loaded as an <img> because SVG inside <img>
   is sandboxed: nothing outside can style it or receive its pointer
   events, and tap-to-draw needs it in the document.

   Two gates, not one:
     .dw-run    loops forever. Applied on load by app.js.
     .dw-once   runs the cycle a single time. Used when the visitor has
                asked for reduced motion: nothing moves on its own, but a
                deliberate tap is the visitor asking for it, so a tap
                still plays one burst and then stops. */

.hero-drawer {
  display: block;
  margin: 0 auto 8px;
  width: 112px;
  height: auto;
  max-width: 48%;
  /* No pointer cursor on purpose. Tapping is a small reward, not
     navigation, and a pointer cursor would promise a link that isn't
     there. */
}

.hero-drawer #dw-shadow,
.hero-drawer #dw-body,
.hero-drawer #dw-hand,
.hero-drawer #dw-eyes { transform-box: fill-box; }

/* The hand pivots at the shoulder, which is buried under the body, so the
   arm stays attached however it rocks. The body pivots where the legs meet
   it, so the feet stay planted. Percentages are measured against each
   group's own fill-box, not guessed. */

.hero-drawer #dw-body { transform-origin: 50% 100%; }
.hero-drawer #dw-hand { transform-origin: 12% 90%; }
.hero-drawer #dw-eyes { transform-origin: 50% 50%; }
.hero-drawer #dw-shadow { transform-origin: 50% 50%; }

.hero-drawer.dw-run #dw-hand { animation: hdHand var(--dw-burst, 12s) ease-in-out infinite; }
.hero-drawer.dw-run #dw-body { animation: hdBody var(--dw-burst, 12s) ease-in-out infinite; }
.hero-drawer.dw-run #dw-shadow { animation: hdShadow var(--dw-burst, 12s) ease-in-out infinite; }
.hero-drawer.dw-run #dw-eyes { animation: hdBlink var(--dw-burst, 12s) linear infinite; }

.hero-drawer.dw-once #dw-hand { animation: hdHand var(--dw-burst, 12s) ease-in-out 1; }
.hero-drawer.dw-once #dw-body { animation: hdBody var(--dw-burst, 12s) ease-in-out 1; }
.hero-drawer.dw-once #dw-shadow { animation: hdShadow var(--dw-burst, 12s) ease-in-out 1; }
.hero-drawer.dw-once #dw-eyes { animation: hdBlink var(--dw-burst, 12s) linear 1; }

/* Quarter-beat keyframes, 0.375s apart, so 3.125% per step at 12s. Each
   stroke pushes up and to the right, into the phone, and drifts back. The
   asymmetry is deliberate: an even back-and-forth reads as a wobble, not
   as someone drawing. */

@keyframes hdHand {
  0%      { transform: translate(0, 0) rotate(0deg); }
  3.125%  { transform: translate(3.5px, -3px) rotate(-1.6deg); }
  6.25%   { transform: translate(-1.5px, 1.5px) rotate(1deg); }
  9.375%  { transform: translate(4px, -2.5px) rotate(-1.6deg); }
  12.5%   { transform: translate(-1.5px, 1.5px) rotate(1deg); }
  15.625% { transform: translate(3.5px, -3px) rotate(-1.6deg); }
  18.75%  { transform: translate(-1.5px, 1.5px) rotate(1deg); }
  21.875% { transform: translate(2.4px, -1.8px) rotate(-1deg); }
  25%     { transform: translate(-0.9px, 0.9px) rotate(0.6deg); }
  28.125% { transform: translate(1px, -0.8px) rotate(-0.4deg); }
  31.25%  { transform: translate(0, 0) rotate(0deg); }
  100%    { transform: translate(0, 0) rotate(0deg); }
}

/* The legs sit outside #dw-body and never animate, and there is no vertical
   travel, so body and legs never come apart. The scaleY squash lands on the
   return of each stroke, which is where the weight settles. */

@keyframes hdBody {
  0%      { transform: rotate(0deg) scaleY(1); }
  3.125%  { transform: rotate(0.8deg) scaleY(1); }
  6.25%   { transform: rotate(0deg) scaleY(1.01); }
  9.375%  { transform: rotate(0.8deg) scaleY(1); }
  12.5%   { transform: rotate(0deg) scaleY(1.01); }
  15.625% { transform: rotate(0.8deg) scaleY(1); }
  18.75%  { transform: rotate(0deg) scaleY(1.01); }
  21.875% { transform: rotate(0.5deg) scaleY(1); }
  25%     { transform: rotate(0deg) scaleY(1.005); }
  28.125% { transform: rotate(0.25deg) scaleY(1); }
  31.25%  { transform: rotate(0deg) scaleY(1); }
  100%    { transform: rotate(0deg) scaleY(1); }
}

/* Shadow shifts weight with the lean rather than pulsing, since nothing
   leaves the ground. */

@keyframes hdShadow {
  0%      { transform: translateX(0); }
  3.125%  { transform: translateX(2px); }
  6.25%   { transform: translateX(0); }
  9.375%  { transform: translateX(2px); }
  12.5%   { transform: translateX(0); }
  15.625% { transform: translateX(2px); }
  18.75%  { transform: translateX(0); }
  21.875% { transform: translateX(1.2px); }
  31.25%  { transform: translateX(0); }
  100%    { transform: translateX(0); }
}

/* Two blinks during the rest, at 7.3s and 9.9s, deliberately not evenly
   spaced. Even spacing reads as a metronome rather than a living thing. */

@keyframes hdBlink {
  0%, 60% { transform: scaleY(1); }
  61%     { transform: scaleY(0.08); }
  62%     { transform: scaleY(1); }
  82%     { transform: scaleY(1); }
  83%     { transform: scaleY(0.08); }
  84%     { transform: scaleY(1); }
  100%    { transform: scaleY(1); }
}

/* Reduced motion kills .dw-run outright, so nothing moves on its own. It
   deliberately does NOT kill .dw-once: that class is only ever applied by
   a tap, and a tap is the visitor asking for the animation. */

@media (prefers-reduced-motion: reduce) {
  .hero-drawer.dw-run #dw-hand,
  .hero-drawer.dw-run #dw-body,
  .hero-drawer.dw-run #dw-shadow,
  .hero-drawer.dw-run #dw-eyes { animation: none; }
}

/* ---- Lobby header --------------------------------------------------
   The shared rule sizes this by height alone, and this game's character is
   the widest of the three: 441x326 renders 76px across at 56px tall, which
   pushed "Lobby" far enough right to sit under the room code at 320px.

   Capping the width fixes that, but `max-width` on its own would squash the
   art, because the height stays pinned at 56px and the ratio is forced from
   1.353 to 1.000. object-fit lets it letterbox inside the box instead.

   Draw-only on purpose, matching the note in dance.css: .lobby-head-icon is
   shared, and word's artwork is square, so a cap in base.css would do nothing
   for word and would quietly narrow dance's 356x370 character. */

.lobby-head-icon {
  max-width: 56px;
  object-fit: contain;
}

/* The cap is not enough on its own at 320px: the title needs 140px and the
   code chip plus its QR button another 167px, against 272px of usable width,
   so 35px has to go somewhere no matter how small the character gets. Letting
   the header wrap puts the code on its own line rather than under the title,
   which costs one row of height on the narrowest phones and nothing anywhere
   else. Above 360px the two fit side by side and this never applies. */
@media (max-width: 360px) {
  .lobby-head { flex-wrap: wrap; row-gap: 10px; }
  .lobby-head .code-row { margin-left: auto; }
}

/* ---- Word screen --------------------------------------------------
   The role card the word game deals (shared/base.css, #324), so a player
   who knows one game already knows this one. Read the word, then the host
   starts the drawing. */

/* The impostor badge is pinned inside the card, so the card has to be the
   thing it is pinned to. Scoped to this screen on purpose: the Pass the Phone
   card is a .flip-face and is already positioned, and a bare
   `.word-card { position: relative }` would load after base.css and take that
   face out of its absolute placement, collapsing the turn. */
#screen-card .word-card { position: relative; }

/* ---- Play screen -------------------------------------------------
   The canvas is the point, so it gets every pixel left over after the
   turn header and the Done button. This screen never scrolls: the head
   and the footer are fixed-height, .canvas-wrap absorbs the rest. */
.screen-play { gap: 24px; }

/* ---- Turn header --------------------------------------------------
   Round number, then the one thing a player is really looking for: is it
   my turn, and how long have I got. */
/* Turn strip and canvas as one block, held tight together with nothing else
   in between, so a chip reads as a label for the ink on the canvas under it
   rather than as part of the header above. */
.play-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

/* The round number, tucked into the bottom-left of the canvas: there for
   anyone who wants it, quiet enough never to compete with the drawing. */
.turn-round {
  position: absolute;
  left: 14px;
  bottom: 14px;
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  pointer-events: none;
}

.turn-round:empty { display: none; }

/* The turn pill, the top bar and the turn strip moved to shared/base.css
   when the word game's clue board needed the same three (#244). Only the
   ink dot stayed: it is the one part of a chip that is about a canvas. */

/* Room for the dot. The shared chip is evenly padded, because the word
   game's has nothing on its left. */
.pchip { padding-left: 8px; }

/* A player's ink, as a dot. Used in the turn strip, the vote list and the
   tally, so it is deliberately not scoped to any one of them. */
.pdot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex: none;
}

/* ---- Canvas -------------------------------------------------------
   Always square: the drawing is stored in normalised 0-1 coordinates,
   so a fixed aspect ratio is what keeps a phone and a laptop showing
   the same picture instead of a stretched one. JS sizes it to the
   largest square that fits this box. */
.canvas-wrap {
  flex: 1;
  display: flex;
  /* Canvas then chips, stacked and centred in the leftover height: on a tall
     phone the square is limited by width, so the slack splits evenly above the
     canvas and below the chips. That even margin is the breathing space this
     layout is after. */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 180px;
  /* JS resizes the canvas a frame after the viewport changes; clipping here
     means that frame can never push a horizontal scrollbar onto the page.
     The clip margin lets the canvas's drop shadow spread past the edge
     instead of being sliced off at the corners. Browsers without
     overflow-clip-margin fall back to clipping at the edge, as before. */
  overflow: clip;
  overflow-clip-margin: 30px;
}

#draw-canvas {
  display: block;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(42, 37, 32, 0.12);
  /* Stop the browser panning/zooming the page from strokes on the canvas. */
  touch-action: none;
  cursor: crosshair;
}

/* Not your turn (or the round is over): the canvas is a spectator view. */
#draw-canvas.locked { cursor: default; }

/* Your turn: a hair-thin green edge, shown only on the drawer's own screen in
   the room game, echoing the green turn pill. A ring shadow (not a border) so
   it hugs the rounded corners without nudging the canvas size by a pixel.
   Never applied in Pass the Phone, where one screen is everybody's screen. */
#draw-canvas.is-my-turn {
  box-shadow: 0 0 0 1px var(--accent-teal), 0 10px 30px rgba(42, 37, 32, 0.12);
}

/* Shrink-wraps the canvas so the undo button can be pinned to its corner
   rather than to the (wider) box the canvas is centred in. */
.canvas-stage {
  position: relative;
  line-height: 0;
}

/* ---- Undo ---------------------------------------------------------
   Sits on the canvas it acts on. Corner-anchored so it stays clear of
   the middle of the drawing, where the hand tends to be. */
.undo-fab {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fadfd9;
  color: var(--ink);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(42, 37, 32, 0.12);
  transition: transform 0.15s ease, opacity 0.2s;
}

.undo-fab:active:not(:disabled) { transform: scale(0.94); }

/* Faded, not hidden: it sits on white, so it has to stay visible enough to
   read as a button that isn't available yet. */
.undo-fab:disabled { opacity: 0.5; cursor: default; }

/* Not your turn. The button stays put rather than disappearing so the
   footer never changes height mid-round, but it reads as unavailable. */
.btn-done:disabled {
  background: #9c948c;
  color: #fff;
  opacity: 1;
}

/* In Pass the Phone the label names the next player, and a long name wraps the
   pill onto two lines, changing the footer height between turns. That is the
   very thing the disabled state above is careful to avoid, so the label is
   held to one line and cut with an ellipsis instead. The name sits last, so
   it is the part that gives way, and the cut follows the viewport rather than
   a character count guessed in advance. There is 224px of room at 320px and
   279px at 375px, so this only bites on the smallest phones: of 23 real names
   measured at 320px, 21 never reach it. */
.btn-done .done-label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---- Vote screen --------------------------------------------------
   The screen itself is shared/base.css, because the word game votes on the
   same rows (#245). What stays here is what only this game has: the drawing
   that comes to the vote, and the ink every name is tied to. */

.vote-thumb-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.vote-thumb {
  display: block;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(42, 37, 32, 0.12);
}

/* Who drew in which colour, for Pass the Phone, which has no ballot to carry
   that. Shaped like .vote-row so the two read as the same kind of list, but
   deliberately flatter: no shadow, no press state and no pointer cursor,
   because nothing here is tappable and a row that looks like a button people
   cannot press reads as a vote that will not register. It also must not carry
   the .vote-row class itself, which shared/press.js targets for tap feedback. */
.legend-list { display: flex; flex-direction: column; gap: 8px; }

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--card);
  border-radius: 20px;
  padding: 8px 12px;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.legend-row .player-avatar { width: 32px; height: 32px; flex: none; }

.legend-row .legend-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Larger than the turn strip's dot. Here the colour is the whole point of the
   row, rather than a marker beside a name. */
.legend-row .pdot { width: 15px; height: 15px; }

/* Sits right after the name rather than in front of it: you look for who,
   then for what colour they drew in. The margin-right pushes the Voted tag
   out to the far edge. */
.vote-row .pdot { width: 12px; margin-right: auto; }

/* ---- Deadline countdowns ------------------------------------------
   The word card and the ballot both sit on a clock. Same block on both so
   the wait reads identically wherever it turns up. */
.phase-count { text-align: center; flex: none; }

.phase-num {
  font-family: 'Literata', Georgia, serif;
  font-size: 48px;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.phase-num:empty { display: none; }

/* ---- Reveal ------------------------------------------------------- */
.reveal-word {
  font-family: 'Literata', Georgia, serif;
  font-size: 40px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.1;
  margin-top: 10px;
  text-align: center;
}

.reveal-extras { margin-top: 28px; text-align: center; }

.track-section { margin-top: 22px; text-align: center; }

