/* Poker Bot: a dark table at the end of the night. Four glass aces deal down
   into the band as you scroll, black suits lit ice blue, red suits lit red,
   over the name in the reel's Gotham Black. */
@font-face {
  font-family: 'PB Mono';
  src: url('/fonts/signoffs/poker-bot-jbm-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

[data-signoff='poker-bot'] {
  --pb-night: #05070b;
  --pb-ice: #9fb6ff;
  --pb-red: #ff4a5c;
  --pb-hud: #46e3ff;
  --pb-felt: rgb(23 112 58 / 0.38);
  --pb-ground: var(--pb-night);
  --pb-ink: #f2f4f8;
  --b-height: clamp(210px, 23vw, 330px);
  --pb-card-h: clamp(96px, 10vw, 144px);
  --pb-fall: calc(var(--b-height) + var(--pb-card-h) * 2);
}
/* Light mode is the same table under daylight: the page's own white, the
   name in night ink, frosted glass cards lit in deeper blue and red. A dark
   table on a white page would fade through grey. */
:root:not(.dark) [data-signoff='poker-bot'] {
  --pb-ice: #5470ff;
  --pb-red: #f2304a;
  --pb-felt: rgb(23 140 70 / 0.12);
  --pb-ground: transparent;
  --pb-ink: var(--pb-night);
}

[data-signoff='poker-bot'] .pb-scene {
  background:
    radial-gradient(55% 70% at 78% 118%, var(--pb-felt), transparent 70%),
    radial-gradient(
      40% 60% at 20% 120%,
      rgb(70 227 255 / 0.08),
      transparent 70%
    ),
    var(--pb-ground);
  /* Eased, so the table's top edge never shows as a line. */
  -webkit-mask-image: linear-gradient(
    transparent,
    rgb(0 0 0 / 0.03) 14%,
    rgb(0 0 0 / 0.12) 26%,
    rgb(0 0 0 / 0.3) 38%,
    rgb(0 0 0 / 0.56) 50%,
    rgb(0 0 0 / 0.8) 62%,
    rgb(0 0 0 / 0.94) 74%,
    #000 86%
  );
  mask-image: linear-gradient(
    transparent,
    rgb(0 0 0 / 0.03) 14%,
    rgb(0 0 0 / 0.12) 26%,
    rgb(0 0 0 / 0.3) 38%,
    rgb(0 0 0 / 0.56) 50%,
    rgb(0 0 0 / 0.8) 62%,
    rgb(0 0 0 / 0.94) 74%,
    #000 86%
  );
}

[data-signoff='poker-bot'] .pb-name {
  --b-fit: 0.094;
  --b-crop: 9%;
  --b-ink: var(--pb-ink);
  --b-ink-dark: var(--pb-ink);
}
[data-signoff='poker-bot'] .pb-name svg {
  overflow: visible;
}

/* The hand: every card turns about one pivot below the deck, so the four
   settle into a fan whose right edge sits on the gutter. */
[data-signoff='poker-bot'] .pb-deck {
  position: absolute;
  z-index: 2;
  --pb-fan-x: calc(100% - var(--f-gutter) - var(--pb-card-h) * 1.26);
  --pb-fan-y: calc(var(--pb-card-h) * -0.12);
  inset: 0;
  pointer-events: none;
  /* A falling card fades in from the page instead of being cut by the band's
     top edge. It ends above the settled hand. */
  -webkit-mask-image: linear-gradient(
    transparent 4%,
    rgb(0 0 0 / 0.5) 24%,
    #000 var(--pb-mask-end, 46%)
  );
  mask-image: linear-gradient(
    transparent 4%,
    rgb(0 0 0 / 0.5) 24%,
    #000 var(--pb-mask-end, 46%)
  );
}
[data-signoff='poker-bot'] .pb-slot {
  --e: 1;
  position: absolute;
  left: calc(var(--pb-fan-x) - var(--pb-card-h) * 0.35);
  bottom: var(--pb-fan-y);
  width: calc(var(--pb-card-h) * 0.7);
  height: var(--pb-card-h);
  transform-origin: 50% 260%;
  translate: 0 calc((var(--e) - 1) * var(--pb-fall));
  rotate: calc(var(--r) + (1 - var(--e)) * var(--spin));
  opacity: calc(var(--e) * 1.6);
  will-change: translate, rotate;
}

[data-signoff='poker-bot'] .pb-card {
  --glow: var(--pb-ice);
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--glow);
  cursor: pointer;
  pointer-events: auto;
  transform-style: preserve-3d;
  transition:
    transform 0.6s cubic-bezier(0.3, 1.3, 0.5, 1),
    translate 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
[data-signoff='poker-bot'] .pb-card[data-red] {
  --glow: var(--pb-red);
}
[data-signoff='poker-bot'] .pb-card:hover {
  translate: 0 -6%;
}
[data-signoff='poker-bot'] .pb-card[data-flipped] {
  transform: rotateY(180deg);
}
[data-signoff='poker-bot'] .pb-card:focus-visible {
  outline: 2px solid var(--pb-hud);
  outline-offset: 4px;
  border-radius: 10px;
}

[data-signoff='poker-bot'] .pb-face {
  position: absolute;
  inset: 0;
  border-radius: 9% / 6.4%;
  backface-visibility: hidden;
  background:
    radial-gradient(
      120% 80% at 30% 0%,
      rgb(255 255 255 / 0.1),
      transparent 55%
    ),
    linear-gradient(165deg, rgb(30 36 50 / 0.72), rgb(6 8 13 / 0.9));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.22),
    inset 0 0 0 1px rgb(255 255 255 / 0.08),
    0 0 22px -4px color-mix(in srgb, var(--glow) 55%, transparent),
    0 14px 28px -8px rgb(0 0 0 / 0.7);
}
:root:not(.dark) [data-signoff='poker-bot'] .pb-front {
  background:
    radial-gradient(
      120% 80% at 30% 0%,
      rgb(255 255 255 / 0.9),
      transparent 60%
    ),
    linear-gradient(165deg, rgb(255 255 255 / 0.62), rgb(232 236 246 / 0.5));
  -webkit-backdrop-filter: blur(8px) saturate(1.4);
  backdrop-filter: blur(8px) saturate(1.4);
  box-shadow:
    inset 0 1px 0 #fff,
    inset 0 0 0 1px rgb(15 23 42 / 0.07),
    0 0 26px -6px color-mix(in srgb, var(--glow) 55%, transparent),
    0 18px 30px -14px rgb(15 23 42 / 0.4);
}
:root:not(.dark) [data-signoff='poker-bot'] .pb-index,
:root:not(.dark) [data-signoff='poker-bot'] .pb-pip {
  fill: var(--glow);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--glow) 45%, transparent));
}

/* Rim light: a thin edge that burns bright on two corners. */
[data-signoff='poker-bot'] .pb-face::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 1.5px;
  border-radius: inherit;
  background: linear-gradient(
    150deg,
    var(--glow),
    transparent 32%,
    transparent 68%,
    color-mix(in srgb, var(--glow) 70%, transparent)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
}

[data-signoff='poker-bot'] .pb-index {
  position: absolute;
  top: 8%;
  left: 10%;
  width: 17%;
  fill: color-mix(in srgb, var(--glow) 65%, #fff);
  filter: drop-shadow(0 0 3px var(--glow));
}
[data-signoff='poker-bot'] .pb-index-end {
  top: auto;
  left: auto;
  bottom: 8%;
  right: 10%;
  rotate: 180deg;
}
[data-signoff='poker-bot'] .pb-pip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40%;
  translate: -50% -50%;
  fill: color-mix(in srgb, var(--glow) 55%, #fff);
  filter: drop-shadow(0 0 4px var(--glow)) drop-shadow(0 0 12px var(--glow));
}

/* The back is the bot's read of the card, inside the reel's cyan HUD
   brackets. */
[data-signoff='poker-bot'] .pb-back {
  --glow: var(--pb-hud);
  display: grid;
  place-items: center;
  transform: rotateY(180deg);
}
[data-signoff='poker-bot'] .pb-back i {
  position: absolute;
  inset: 16% 14%;
  background:
    linear-gradient(var(--pb-hud) 0 0) top left / 22% 2px,
    linear-gradient(var(--pb-hud) 0 0) top left / 2px 22%,
    linear-gradient(var(--pb-hud) 0 0) top right / 22% 2px,
    linear-gradient(var(--pb-hud) 0 0) top right / 2px 22%,
    linear-gradient(var(--pb-hud) 0 0) bottom left / 22% 2px,
    linear-gradient(var(--pb-hud) 0 0) bottom left / 2px 22%,
    linear-gradient(var(--pb-hud) 0 0) bottom right / 22% 2px,
    linear-gradient(var(--pb-hud) 0 0) bottom right / 2px 22%;
  background-repeat: no-repeat;
  opacity: 0.85;
}
[data-signoff='poker-bot'] .pb-back code {
  font:
    700 calc(var(--pb-card-h) * 0.15) / 1 'PB Mono',
    'JetBrains Mono',
    ui-monospace,
    monospace;
  color: var(--pb-hud);
  text-shadow: 0 0 10px rgb(70 227 255 / 0.6);
}

/* Phones have no room beside the name, so the hand is dealt onto it: the
   fan is centred on the band and rests on the name's cap line. */
@media (max-width: 640px) {
  [data-signoff='poker-bot'] {
    --b-height-m: 236px;
    --pb-card-h: 74px;
    --pb-fall: calc(var(--b-height-m) + var(--pb-card-h) * 2);
  }
  [data-signoff='poker-bot'] .pb-name {
    --b-fit: 0.128;
    --b-crop: 8%;
    --b-align: center;
  }
  [data-signoff='poker-bot'] .pb-deck {
    --pb-fan-x: 50%;
    --pb-fan-y: calc(13cqw + 20px);
    --pb-mask-end: 36%;
  }
}
