/* ============================================================
   Fable Chess · boardfx.css (October 15)

   The premium board's look, shared by both apps: the homework and
   classroom app links it after app.css; the academy build puts it
   after the design's own styles. It changes how the board feels,
   not where anything is.

   Layers, bottom to top:
     the squares' paint (the board's background, or each square's)
     last move and selected square (::after), drawings (::before)
     hover and drop target (an inset shadow on the square itself)
     legal-move dots and capture rings (.hint)
     coordinates, then the pieces
     a piece gliding (.moving), then the piece being dragged (.drag)
     the promotion chooser and results (the screens' own, above all)
   ============================================================ */

/* Last move: a soft warm tint on both squares. Selected: a stronger
   tint with a ring, so it never reads as the last move. */
.board .sq.last::after{ content:""; position:absolute; inset:0; z-index:1; pointer-events:none;
  background:var(--sq-last, rgba(255,184,19,.30)); }
.board .sq.sel::after{ content:""; position:absolute; inset:0; z-index:1; pointer-events:none;
  background:var(--sq-sel, rgba(255,184,19,.52)); box-shadow:inset 0 0 0 3px rgba(255,184,19,.85); }

/* Check: a red glow from the king's square, from the position itself.
   Checkmate: deeper, with the king outlined, and said in words by the
   board's label. Nothing flashes. */
.board .sq.chk::after{ content:""; position:absolute; inset:0; z-index:1; pointer-events:none;
  background:radial-gradient(circle, rgba(232,64,40,.95) 0%, rgba(214,74,44,.55) 42%, transparent 72%); }
.board .sq.mate::after{ background:radial-gradient(circle, rgba(190,30,20,1) 0%, rgba(190,30,20,.7) 50%, rgba(190,30,20,.25) 78%); }
.board .sq.mate .pc{ filter:drop-shadow(0 0 3px rgba(255,255,255,.9)); }

/* Hover, for a mouse only, and the square under a dragged piece. */
@media (hover:hover){
  .board.can:not(.dragging) .sq:hover{ box-shadow:inset 0 0 0 999px rgba(255,255,255,.10); }
}
.board .sq.droptgt{ box-shadow:inset 0 0 0 999px rgba(255,255,255,.16), inset 0 0 0 4px rgba(255,255,255,.85); }

/* Legal moves: a small dot on an empty square, a ring round a piece
   that can be taken. Centred, sized with the square, under the
   pieces, never in the way of a tap. */
.board .sq .hint{ position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); z-index:2; pointer-events:none;
  width:27%; height:27%; border-radius:50%; background:rgba(16,24,18,.30); border:0; box-shadow:none; }
.board .sq .hint.cap{ width:92%; height:92%; background:none; border-radius:50%; box-sizing:border-box;
  border:none; box-shadow:none;
  background:radial-gradient(circle, transparent 0 62%, rgba(16,24,18,.28) 63% 100%); }
.board .sq.legal{ cursor:pointer; }

/* A board keeps its layers to itself (October 15, evening): its
   pieces never paint over a popup's header or buttons around it. The
   piece in the hand is on the page itself, so it still flies above. */
.board{ isolation:isolate; }

/* The pieces. */
.board .pc{ position:relative; z-index:3; width:100%; height:100%; line-height:0; }
.board.can .pc{ cursor:grab; }
.board.dragging, .board.dragging .pc, .board.dragging .sq{ cursor:grabbing; }
/* October 30: a phone's board is the whole width, so a swipe on an
   empty square, or on a piece that cannot move now (the bot's, or any
   while the bot thinks), scrolls the page. Only a piece the child may
   pick up keeps the finger, for a drag. */
.board.can{ touch-action:manipulation; -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; }
.board.can .pc.pick, .board.dragging, .board.dragging .pc{ touch-action:none; }
.board .pc svg{ width:100%; height:100%; display:block; pointer-events:none; }
/* Gliding to its square: above the other pieces while it travels. */
.board .pc.moving{ z-index:6; will-change:transform; }
/* Taken: fades and shrinks where it stood; the piece taking it lands on top. */
.board .pc.gone{ position:absolute; inset:0; z-index:2; pointer-events:none; animation:fb-gone .2s ease-out forwards; }
@keyframes fb-gone{ to{ opacity:0; transform:scale(.7); } }
/* New on the board (set up by a coach): fades in. */
.board .pc.arrive{ animation:fb-arrive .18s ease-out; }
@keyframes fb-arrive{ from{ opacity:0; transform:scale(.85); } }
/* Picked up: its square keeps a faint copy where it came from. */
.board .pc.lifted{ opacity:.28; }
/* The piece in the hand: a little bigger, lifted off the board. */
.pc.drag{ position:fixed !important; left:0; top:0; z-index:9999; pointer-events:none; line-height:0;
  will-change:transform; transform-origin:50% 50%;
  filter:drop-shadow(0 10px 12px rgba(0,0,0,.35)) drop-shadow(0 2px 3px rgba(0,0,0,.25)); }
.pc.drag svg{ width:100%; height:100%; display:block; }

/* The selected square's soft pulse when picked, short and once. */
.board .sq.sel .pc:not(.lifted){ animation:fb-pick .14s ease-out; }
@keyframes fb-pick{ from{ transform:scale(.94); } }

/* Coordinates on the small boards of the coach's grid. */
.board.mini.withco .co, .mini.withco .co{ display:block; position:absolute; font-size:clamp(6px, 1.6vw, 9px); font-weight:700; z-index:4; opacity:.8; line-height:1; font-family:var(--mono, monospace); }
.mini.withco .co.f{ right:2px; bottom:1px; } .mini.withco .co.r{ left:2px; top:1px; }
.mini.withco .sq{ position:relative; }
.mini.withco .sq.l .co{ color:var(--co-dark, #5C5C5C); } .mini.withco .sq.d .co{ color:var(--co-light, #fff); }

/* The keyboard's square: clearly outlined. */
.board .sq.kb::before{ content:""; position:absolute; inset:2px; z-index:5; pointer-events:none; border-radius:3px;
  box-shadow:0 0 0 3px #2D6CDF, 0 0 0 5px #fff; }

/* Arrows and highlighted squares on every board, in both apps
   (October 21: the academy's studies draw them too). The same rules as
   the classroom's, plus green, the colour a Lichess study uses most. */
.board:has(> .arrows){ position:relative; }
.board .arrows{ position:absolute; inset:0; width:100%; height:100%; z-index:4; pointer-events:none; }
.board .arrows .al{ stroke:rgba(224,69,58,.85); stroke-width:.16; stroke-linecap:round; }
.board .arrows .ah{ fill:rgba(224,69,58,.85); }
.board .arrows .al-red{ stroke:rgba(224,69,58,.85); }     .board .arrows .ah-red{ fill:rgba(224,69,58,.85); }
.board .arrows .al-yellow{ stroke:rgba(245,190,20,.92); } .board .arrows .ah-yellow{ fill:rgba(245,190,20,.92); }
.board .arrows .al-blue{ stroke:rgba(40,110,235,.85); }   .board .arrows .ah-blue{ fill:rgba(40,110,235,.85); }
.board .arrows .al-purple{ stroke:rgba(140,70,220,.85); } .board .arrows .ah-purple{ fill:rgba(140,70,220,.85); }
.board .arrows .al-pink{ stroke:rgba(232,80,160,.85); }   .board .arrows .ah-pink{ fill:rgba(232,80,160,.85); }
.board .arrows .al-green{ stroke:rgba(21,128,61,.88); }   .board .arrows .ah-green{ fill:rgba(21,128,61,.88); }
.board .sq.hl::before{
  content:""; position:absolute; inset:0; z-index:1; pointer-events:none;
  --hc:224,69,58;
  box-shadow:inset 0 0 0 4px rgba(var(--hc),.9);
  background:repeating-linear-gradient(45deg,rgba(var(--hc),.28) 0 5px,rgba(var(--hc),.12) 5px 11px);
}
.board .sq.hl-yellow::before{ --hc:245,190,20; } .board .sq.hl-blue::before{ --hc:40,110,235; }
.board .sq.hl-purple::before{ --hc:140,70,220; } .board .sq.hl-pink::before{ --hc:232,80,160; }
.board .sq.hl-green::before{ --hc:21,128,61; }
