/*
 * SlavBot.com: a Calamity Card in 3D (js/card3d.js, src/features/card3d.js). The dialog fills the screen in the deal's black, with
 * the card on a stage in the middle and its tools under it. The faces, their rounded corners, their light and the shadow under the
 * card are canvases the script paints (the bot's own picture, and a back painted as the bot's dashboard paints it): this sheet only
 * places them in space. Kept: no gradient, no rounding, no shadow and no motion of its own (the card moves because the script
 * turns it), and every colour and type size from the tokens.
 */

/* The button over a card. The script shows it; the whole card is the target, and the 3D mark sits in the art's lower right,
   clear of the rating, the badge, the name and a copy's stars. */
.c3d-open {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.c3d-open[hidden] {
  display: none;
}

.c3d-mark {
  position: absolute;
  right: 6%;
  bottom: 25%;
  padding: 5px 8px 3px;
  background: var(--ink);
  color: var(--cream);
  font: 400 var(--fs-small)/1 var(--display);
  letter-spacing: var(--ls-wide);
}

.c3d-open:hover .c3d-mark,
.c3d-open:focus-visible .c3d-mark {
  background: var(--gold);
  color: var(--ink);
}

/* The home page's fan overlaps its three cards: a mark on each would sit on the next card. There the cards are still buttons, and
   the mark shows on the one a pointer is over or the keyboard is on. */
.fan-card .c3d-mark {
  display: none;
}

.fan-card .c3d-open:hover .c3d-mark,
.fan-card .c3d-open:focus-visible .c3d-mark {
  display: block;
}

/* The dialog: the whole screen, nothing of the page behind it. It is laid out only while it is open. */
dialog.c3d {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
}

dialog.c3d[open] {
  display: flex;
  flex-direction: column;
}

dialog.c3d::backdrop {
  background: var(--ink);
}

.c3d-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px 10px 20px;
  border-bottom: 3px solid currentColor;
}

.c3d-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font: 400 var(--fs-4)/1.1 var(--display);
  letter-spacing: var(--ls-tight);
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c3d-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 3px solid currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.c3d-close:hover {
  border-color: var(--cream);
  background: var(--cream);
  color: var(--ink);
}

/* The stage: a finger on it turns the card and never scrolls the page; nothing on it can be selected. The card and its shadow
   share one cell, centred; the script moves them from there. */
.c3d-stage {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  place-items: center;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  perspective: 1100px;
}

.c3d-stage:active {
  cursor: grabbing;
}

.c3d-card,
.c3d-shadow {
  grid-area: 1 / 1;
}

.c3d-card {
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}

.c3d-shadow {
  pointer-events: none;
}

.c3d-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.c3d-front {
  transform: translateZ(var(--c3d-t, 2px));
}

.c3d-back {
  transform: rotateY(180deg) translateZ(var(--c3d-t, 2px));
}

.c3d-edges {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform-style: preserve-3d;
}

.c3d-piece {
  position: absolute;
  top: 0;
  left: 0;
}

.c3d-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px 4px;
}

/* .btn lays a button out as a flex box, which would show Tilt where the script hid it (no tilt on a desktop). */
.c3d-tools .btn[hidden] {
  display: none;
}

/* Reset and Tilt are the site's outlined buttons (.btn.line), so Flip is the one filled one; Tilt switched on is filled the way
   an outlined button is on hover in a black area. */
.ink .btn.line[aria-pressed='true'] {
  border-color: var(--cream);
  background: var(--cream);
  color: var(--ink);
}

.ink.c3d .c3d-hint {
  margin: 0;
  padding: 4px 16px 16px;
  color: var(--muted-on-ink);
  font: 400 var(--fs-small)/1.4 var(--body);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .c3d-card {
    will-change: auto;
  }
}
