/* Results popup: a card dealt onto the table after race day, with the podium
   fanned as a hand of prints, and the way to the replays and results.
   Colours and type come from the deck tokens in deck.css. */

.results-popup {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 10, 16, 0.72);
  animation: results-popup-fade 0.3s ease-out;
}

.results-popup[hidden] {
  display: none;
}

.results-popup-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(420px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 26px 30px 18px;
  text-align: center;
  color: var(--pc-ink, #111823);
  background: var(--pc-stock, #f7f2e7);
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 8px var(--pc-stock, #f7f2e7),
    inset 0 0 0 9px rgba(200, 162, 74, 0.7),
    0 30px 60px -20px rgba(0, 0, 0, 0.95);
  animation: results-popup-deal 0.75s cubic-bezier(0.16, 0.9, 0.24, 1) both;
}

/* The ace's corner indices, the foot one upside down. */
.results-popup-index {
  position: absolute;
  top: 16px;
  left: 18px;
  font-family: var(--pc-numeral);
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.results-popup-index.is-foot {
  top: auto;
  left: auto;
  right: 18px;
  bottom: 16px;
  transform: rotate(180deg);
}

.results-popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--pc-ink-soft, #4a5566);
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
}

/* The podium as a hand of prints: second, first raised, third. */
.results-popup-hand {
  display: flex;
  justify-content: center;
  margin: 6px 0 16px;
  height: 150px;
}

.results-popup-hand img {
  width: 92px;
  height: 122px;
  object-fit: cover;
  border: 5px solid #fff;
  border-radius: 3px;
  box-shadow: 0 10px 18px -8px rgba(0, 0, 0, 0.7);
  animation: results-popup-fan 0.6s cubic-bezier(0.16, 0.9, 0.24, 1) 0.45s both;
}

.results-popup-hand img:nth-child(1) {
  --fan: rotate(-12deg) translate(14px, 18px);
  transform: var(--fan);
}

.results-popup-hand img:nth-child(2) {
  --fan: translateY(-4px);
  z-index: 1;
  transform: var(--fan);
}

.results-popup-hand img:nth-child(3) {
  --fan: rotate(12deg) translate(-14px, 18px);
  transform: var(--fan);
}

.results-popup-title {
  margin: 0 0 8px !important;
  font-family: var(--pc-display) !important;
  font-size: 2rem !important;
  font-style: italic;
  font-weight: 600 !important;
  letter-spacing: 0 !important;
  color: var(--pc-ink, #111823) !important;
}

.results-popup-title::before,
.results-popup-title::after {
  display: none !important;
}

.results-popup-text {
  margin: 0 0 18px;
  font-family: var(--pc-body);
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--pc-ink-soft, #4a5566);
}

.results-popup-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.results-popup-primary,
.results-popup-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 18px;
  font-family: var(--pc-data);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none !important;
  border-radius: 999px;
  transition: background-color 0.2s ease;
}

.results-popup-primary {
  color: var(--pc-stock, #f7f2e7) !important;
  background: var(--pc-felt, #14392c);
  box-shadow: 0 0 0 2px rgba(200, 162, 74, 0.7);
}

.results-popup-primary:hover {
  background: var(--pc-felt-deep, #0b2119);
}

.results-popup-secondary {
  color: var(--pc-ink, #111823) !important;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 35, 0.25);
}

.results-popup-secondary:hover {
  background: rgba(200, 162, 74, 0.2);
}

.results-popup-later {
  margin-top: 10px;
  padding: 6px 12px;
  border: 0;
  background: none;
  color: var(--pc-ink-soft, #4a5566);
  font-family: var(--pc-body);
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
}

.results-popup a:focus,
.results-popup button:focus {
  outline: none;
  box-shadow: none;
}

.results-popup a:focus-visible,
.results-popup button:focus-visible {
  outline: 2px solid var(--pc-gilt, #c8a24a);
  outline-offset: 2px;
}

.results-popup-primary:focus-visible {
  box-shadow: 0 0 0 2px rgba(200, 162, 74, 0.7);
}

@keyframes results-popup-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes results-popup-deal {
  from {
    opacity: 0;
    transform: translate(160px, -120px) rotate(18deg);
  }
  to {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg);
  }
}

@keyframes results-popup-fan {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: var(--fan);
  }
}

@media (max-width: 480px) {
  .results-popup-card {
    padding: 22px 20px 14px;
  }

  .results-popup-title {
    font-size: 1.7rem !important;
  }

  .results-popup-hand {
    height: 128px;
  }

  .results-popup-hand img {
    width: 78px;
    height: 104px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .results-popup,
  .results-popup-card,
  .results-popup-hand img {
    animation: none;
  }
}
