/* The tile component. One element, driven by --tw (the face width) and data attributes (see ui/tile-view.ts).
   The painted body sprite is 236x289 px with the face rectangle at (21,14) of size 168x224: --s scales it. */
@font-face{font-family:"Cinzel";font-weight:600;font-display:swap;src:url("assets/fonts/cinzel-latin-600-normal.woff2") format("woff2")}
@font-face{font-family:"Cinzel";font-weight:700;font-display:swap;src:url("assets/fonts/cinzel-latin-700-normal.woff2") format("woff2")}

:root{
  /* The one place the tile glyph font is chosen. Bundled fonts carry no CJK glyphs, so the system CJK serifs answer
     for the characters; swap a bundled brush face in here when one is licensed. */
  --ng-glyph-font:"Microsoft JhengHei","PMingLiU","MingLiU","Noto Serif TC","Songti TC","Source Han Serif TC",serif;
  --ng-index-font:"Cinzel",Georgia,serif;
  --ng-body-ivory:url("assets/tiles/tile-face.webp");
  --ng-body-ivory-dim:url("assets/tiles/tile-face-dim.webp");
  --ng-body-red:url("assets/tiles/tile-face-red.webp");
  --ng-body-gold:url("assets/tiles/tile-bonus-gold.webp");
  --ng-body-jade:url("assets/tiles/tile-jade.webp");
  --ng-body-back:url("assets/tiles/tile-back.webp");
  --ng-body-back-dim:url("assets/tiles/tile-back-dim.webp");
  --ng-glow-select:#ffd35c;
  --ng-glow-hint:#5fe3c4;
}

.ng-sprite{position:absolute;width:0;height:0;overflow:hidden}
.ng-glyph{font-family:var(--ng-glyph-font);font-weight:700}
.ng-idx{font-family:var(--ng-index-font);font-weight:700}
body.ng-no-index .ng-idx{display:none}

.ng-tile{
  --tw:56px;
  --s:calc(var(--tw)/168);
  --body:var(--ng-body-ivory);
  position:relative;display:inline-block;flex:none;
  width:var(--tw);height:calc(var(--s)*224);
  pointer-events:none;
  filter:drop-shadow(calc(var(--s)*2) calc(var(--s)*4) calc(var(--s)*3) #0007);
  transition:transform .14s ease,filter .14s ease;
}
.ng-tile__body{
  position:absolute;left:calc(var(--s)*-21);top:calc(var(--s)*-14);width:calc(var(--s)*236);height:calc(var(--s)*289);
  background:var(--body) 0 0/100% 100% no-repeat;
}
.ng-tile__face{
  position:absolute;left:calc(var(--s)*12);top:calc(var(--s)*16);width:calc(var(--s)*141);height:calc(var(--s)*188);
  overflow:visible;
}
.ng-tile[data-body="red"]{--body:var(--ng-body-red)}
.ng-tile[data-body="gold"]{--body:var(--ng-body-gold)}
.ng-tile[data-body="jade"]{--body:var(--ng-body-jade)}
.ng-tile[data-body="back"]{--body:var(--ng-body-back)}

/* states */
.ng-tile[data-state="free"]{}
.ng-tile[data-state="selected"]{
  transform:translateY(calc(var(--s)*-7));
  filter:drop-shadow(0 0 calc(var(--s)*3) var(--ng-glow-select)) drop-shadow(0 0 calc(var(--s)*10) var(--ng-glow-select)) drop-shadow(calc(var(--s)*2) calc(var(--s)*8) calc(var(--s)*4) #0008);
}
.ng-tile[data-state="hint"]{
  filter:drop-shadow(0 0 calc(var(--s)*3) var(--ng-glow-hint)) drop-shadow(0 0 calc(var(--s)*9) var(--ng-glow-hint)) drop-shadow(calc(var(--s)*2) calc(var(--s)*4) calc(var(--s)*3) #0007);
  animation:ng-hint-pulse 1.1s ease-in-out infinite;
}
.ng-tile[data-state="blocked"]{--body:var(--ng-body-ivory-dim)}
.ng-tile[data-state="blocked"][data-body="red"],
.ng-tile[data-state="blocked"][data-body="gold"],
.ng-tile[data-state="blocked"][data-body="jade"]{--body:var(--ng-body-ivory-dim)}
.ng-tile[data-state="blocked"][data-body="back"]{--body:var(--ng-body-back-dim)}
.ng-tile[data-state="blocked"] .ng-tile__face{opacity:.55;filter:saturate(.5)}
.ng-tile[data-state="ghost"]{opacity:.35;filter:none}
@keyframes ng-hint-pulse{50%{transform:translateY(calc(var(--s)*-3))}}

/* a tile standing in a row leaves its thickness visible: neighbours overlap the right edge */
.ng-tile.rotated{transform:rotate(90deg);transform-origin:50% 50%}
.ng-tile.dora{outline:0}

@media (prefers-reduced-motion:reduce){
  .ng-tile{transition:none}
  .ng-tile[data-state="hint"]{animation:none}
}

/* a tile lying flat and turned for another seat (turn = quarter turns clockwise): only the face turns, and for a sideways tile the
   painted body is transposed, so the thickness stays below and to the right and every tile on the felt shares one light */
.ng-tile.turn-2 .ng-tile__face{transform:rotate(180deg)}
.ng-tile.turn-1,.ng-tile.turn-3{width:calc(var(--s)*224);height:var(--tw)}
.ng-tile.turn-1 .ng-tile__body,.ng-tile.turn-3 .ng-tile__body{left:calc(var(--s)*-14);top:calc(var(--s)*-21);transform-origin:0 0;transform:matrix(0,1,1,0,0,0)}
.ng-tile.turn-1 .ng-tile__face,.ng-tile.turn-3 .ng-tile__face{left:calc(var(--s)*41.5);top:calc(var(--s)*-10)}
.ng-tile.turn-1 .ng-tile__face{transform:rotate(90deg)}
.ng-tile.turn-3 .ng-tile__face{transform:rotate(-90deg)}
