/* Party cards are dealt face down, then turned together on the guild table. */
.casting-intro {
  position: absolute;
  z-index: 8;
  inset: 0;
  overflow: hidden;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(9px, 3vmin, 24px);
  padding: clamp(10px, 3vmin, 26px);
  border: 2px solid #af864d;
  border-radius: inherit;
  color: #f8e2ad;
  background: radial-gradient(ellipse at 50% 44%, #50604450, #0a1713e8 81%), linear-gradient(#243c2ddf, #17251cda), url("./assets/table.webp") center / cover;
  box-shadow: inset 0 0 0 5px #141d18, inset 0 0 0 6px #b5985b57;
  isolation: isolate;
  animation: casting-room-in 260ms ease-out both;
}

.casting-intro::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: min(65%, 58dvh);
  aspect-ratio: 1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: url("./assets/crest.svg") center / contain no-repeat;
  opacity: .15;
}

.casting-title {
  margin: 0;
  text-align: center;
  color: #f9e0a8;
  font: 700 clamp(16px, 4.2vmin, 32px)/1.15 Cinzel, Georgia, serif;
  text-shadow: 0 2px 6px #0d1713;
}

.casting-fan {
  --card-width: min(25vw, 29dvh, 166px);
  display: flex;
  gap: clamp(4px, 2.8vmin, 24px);
  justify-content: center;
  perspective: 750px;
}

.casting-slot {
  width: var(--card-width);
  aspect-ratio: 4 / 5.6;
  perspective: 700px;
}

.casting-dealt,
.casting-flip {
  height: 100%;
  position: relative;
  border-radius: 7px;
  transform-style: preserve-3d;
}

.casting-dealt {
  box-shadow: 0 9px 15px #10130ebb;
  animation: casting-deal 590ms cubic-bezier(.18,.72,.34,1) calc(90ms + 160ms * var(--slot)) both;
}

.casting-flip {
  animation: casting-turn-over 520ms cubic-bezier(.23,.56,.28,1.13) calc(820ms + 175ms * var(--slot)) both;
}

.casting-back,
.casting-face {
  display: grid;
  height: 100%;
  min-width: 0;
  border: 3px double #aa7840;
  border-radius: 7px;
  box-sizing: border-box;
  overflow: hidden;
  background: #f2dfb3;
  color: #3d2417;
}

.casting-flip > * {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}

.casting-flip > .casting-face { transform: rotateY(180deg); }

.casting-back {
  place-items: center;
  color: #e4b766;
  background: repeating-conic-gradient(from 45deg, #192e23 0 25%, #273b2b 0 50%) center / 17px 17px;
  box-shadow: inset 0 0 0 4px #2d3222, inset 0 0 0 5px #ad884ec4, inset 0 0 30px #070c09c9;
}

.casting-back svg {
  width: 45%;
  height: auto;
  padding: 7%;
  border: 1px solid #b5955f;
  border-radius: 50%;
  background: #1d3024;
  box-shadow: 0 0 0 5px #1d3024, 0 4px 12px #0f130dea;
}

.casting-face {
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  justify-items: center;
  gap: clamp(2px, .75vmin, 5px);
  padding: clamp(3px, 1vmin, 7px);
  text-align: center;
}

.casting-portrait {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
  object-position: 50% 27%;
  border: 1px solid #a97a4a;
  border-radius: 3px;
}

.casting-name {
  font: 700 clamp(13px, 3.2vmin, 23px)/1 Crimson, Georgia, serif;
}

.casting-power {
  display: grid;
  align-items: center;
  justify-items: center;
  grid-template-columns: auto 1fr;
  gap: 3px;
  min-height: 2.25em;
  padding-inline: 2px;
  color: #5c3925;
  font: 700 clamp(9px, 1.9vmin, 14px)/1.1 Crimson, Georgia, serif;
}

.casting-limit {
  color: #62452d;
  font: 700 clamp(8px, 1.45vmin, 11px)/1.1 system-ui, sans-serif;
}

.casting-power svg,
.casting-power img { width: clamp(12px, 2.8vmin, 20px); height: auto; }

.casting-intro .casting-skip {
  min-height: 40px;
  color: #f5e0b4;
  background: #17251f;
  border-color: #be9659;
}

.casting-intro .casting-skip:focus-visible { outline-color: #ffe39e; }

@keyframes casting-room-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes casting-deal {
  0% { opacity: 0; transform: translate(-30px, -94px) rotate(-21deg) scale(.86); }
  20% { opacity: 1; }
  77% { transform: translate(0, 4px) rotate(2deg) scale(1.02); }
  100% { transform: none; }
}

@keyframes casting-turn-over {
  from { transform: rotateY(0); }
  to { transform: rotateY(180deg); }
}

.casting-effect {
  pointer-events: none;
  position: fixed;
  z-index: 120;
  inset: 0;
  overflow: hidden;
}

.casting-mark,
.casting-caption,
.casting-bike,
.casting-guest-flight { position: absolute; }

.casting-mark {
  border-radius: 7px;
  animation: casting-hit 900ms ease-out both;
}

.casting-effect[data-effect="nathan"] .casting-mark { animation-delay: 1350ms; }
.casting-effect[data-effect="kirsty"] .casting-mark { animation-delay: 470ms; }

.casting-caption {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(204px, calc(100vw - 24px));
  box-sizing: border-box;
  padding: 6px 8px;
  border: 2px solid #c18c49;
  border-radius: 6px;
  background: #2a231aeF;
  color: #f8e2b4;
  box-shadow: 0 3px 14px #142019b0;
  font: 700 14px/1.1 Crimson, Georgia, serif;
  animation: casting-caption-in 1950ms ease-out both;
}

.casting-caption small {
  display: block;
  margin-top: 3px;
  color: #f1d69e;
  font: 500 10px/1.15 system-ui, sans-serif;
}

.casting-effect[data-effect="nathan"] .casting-caption {
  animation-duration: 1280ms;
  animation-delay: 850ms;
}

.casting-emblem { width: 31px; height: 31px; object-fit: contain; }

.casting-bike-art {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 4px #251b14b9);
}

.casting-bike::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 42%;
  height: 16%;
  left: 48%;
  bottom: 1%;
  border-radius: 50%;
  background: radial-gradient(ellipse, #edd3a699, #bd986b00 70%);
  animation: casting-brake 600ms 450ms ease-out both;
}

.casting-guest {
  width: clamp(43px, 11vmin, 71px);
  height: clamp(51px, 13vmin, 83px);
  grid-template-rows: minmax(0, 1fr) auto;
  transform: translate(-50%, -50%) rotate(10deg);
  box-shadow: 0 4px 10px #1c140ed9;
}

.casting-guest .casting-name { font-size: clamp(9px, 1.8vmin, 13px); }

.casting-effect[data-effect="gezelle"] .casting-mark {
  overflow: visible;
  animation-duration: 1750ms;
}

.casting-print {
  position: absolute;
  display: grid;
  inset: 10%;
  overflow: hidden;
  border: 2px solid #d5aa58;
  border-radius: 5px;
  animation: casting-print-exit 1750ms ease-in-out both;
}

.casting-print-art { width: 100%; height: 100%; min-height: 0; object-fit: cover; }

.casting-print::after {
  content: "";
  position: absolute;
  inset: -32%;
  background: linear-gradient(105deg, #9a4f0a00 23%, #ffc74d33 38%, #fff0abcc 50%, #ffc75b77 57%, #9a4f0a00 74%);
  animation: casting-gold-sweep 1450ms ease-out both;
}

.casting-ember {
  position: absolute;
  width: clamp(7px, 2vmin, 14px);
  aspect-ratio: 1;
  left: calc(10% + var(--ember) * 18%);
  bottom: 10%;
  border-radius: 50% 50% 28% 50%;
  background: #ffe4a1;
  box-shadow: 0 0 8px 3px #ff9249;
  animation: casting-ember 850ms ease-out calc(470ms + 45ms * var(--ember)) both;
}

@keyframes casting-hit {
  0%, 100% { box-shadow: 0 0 0 0 #f5b64e00; }
  22%, 58% { box-shadow: 0 0 0 2px #ffe7a7, 0 0 14px 4px #ffae487f, inset 0 0 12px #ffd86d80; }
}

@keyframes casting-caption-in {
  0% { opacity: 0; transform: translateY(5px) scale(.97); }
  18%, 79% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-4px); }
}

@keyframes casting-brake {
  0% { opacity: 0; transform: translateX(-14px) scale(.6); }
  30% { opacity: .9; }
  100% { opacity: 0; transform: translateX(35px) scale(1.5); }
}

@keyframes casting-print-exit {
  0% { opacity: 0; transform: rotate(-4deg) scale(.94); }
  25%, 70% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: scale(.91); }
}

@keyframes casting-gold-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes casting-ember {
  0%, 100% { opacity: 0; }
  25% { opacity: .88; transform: translateY(-8px) rotate(45deg) scale(1.2); }
  100% { transform: translateY(-53px) rotate(75deg) scale(.3); }
}

@media (max-height: 420px) and (orientation: landscape) {
  .casting-fan { --card-width: min(25vw, 27dvh, 166px); }
  .casting-intro { gap: 6px; padding-block: 7px; }
  .casting-intro .casting-skip { min-height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .casting-intro *,
  .casting-effect * { animation-duration: 0s !important; }
}

.casting-result-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 3px 7px;
  padding: 4px 6px;
  margin-top: 7px;
  border-top: 1px solid #bb956b6b;
  color: #f9deb1;
  text-align: center;
  font: 600 11px/1.2 system-ui, sans-serif;
}

.casting-result-note .casting-emblem { width: 19px; height: 19px; }
.casting-result-note strong { font: 700 13px/1.1 Crimson, Georgia, serif; }
.casting-result-note span { color: #f2dfc4; }

.casting-skill-dock {
  display: grid;
  justify-items: center;
  gap: 2px;
  align-self: start;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin-top: 3px;
  padding: 3px 1px;
  border: 1px solid #82a891;
  border-radius: 3px;
  background: #2f4841;
  color: #f5ecd2;
  font: 600 9px/1.05 Crimson, Georgia, serif;
  text-align: center;
  overflow-wrap: anywhere;
}

.casting-dock-pending { visibility: hidden; }
.casting-dock-portrait { width: 21px; height: 19px; object-fit: cover; object-position: 50% 27%; border-radius: 2px; }
.casting-skill-dock strong { color: #b6dfc4; }
.casting-print-art { grid-area: 1 / 1; }
.casting-print-gold {
  filter: sepia(.8) saturate(1.75) brightness(1.19);
  animation: casting-gild 1050ms 250ms ease both;
}

.casting-roll-odds,
.casting-recovery-amount {
  position: absolute;
  z-index: 1;
  right: 4px;
  bottom: 4px;
  border: 1px solid #e9bb66;
  border-radius: 3px;
  padding: 2px 4px;
  background: #392517;
  color: #fff0bf;
  font: 700 clamp(10px, 2vmin, 17px)/1.15 Georgia, serif;
  animation: casting-stamp-in 300ms 740ms ease-out both;
}

.casting-holy-photo {
  position: absolute;
  width: clamp(42px, 9vmin, 68px);
  aspect-ratio: 1.22;
  left: 50%;
  bottom: 52%;
  overflow: hidden;
  border: 2px solid #f7ba72;
  border-radius: 4px;
  background: #3e2920;
  transform: translateX(-50%);
  animation: casting-holy-flash 1250ms 310ms ease-out both;
}

.casting-holy-photo .casting-recovery-amount { animation-delay: 380ms; }

@keyframes casting-gild {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0); }
}

@keyframes casting-stamp-in {
  from { opacity: 0; transform: scale(.75); }
  to { opacity: 1; transform: none; }
}

@keyframes casting-holy-flash {
  0% { opacity: 0; transform: translate(-50%, 6px) rotate(-9deg) scale(.8); }
  22% { opacity: 1; box-shadow: 0 0 19px 8px #ffa564a6; filter: brightness(1.6); transform: translate(-50%, -3px) rotate(2deg); }
  39%, 80% { opacity: 1; box-shadow: 0 0 10px 2px #ffa56490; transform: translate(-50%, -8px); }
  100% { opacity: 0; transform: translate(-50%, 12px) scale(.7); }
}


@media (max-height: 420px) and (orientation: landscape) {
  .casting-skill-dock {
    margin-top: 1px;
    padding: 2px 1px;
    gap: 1px;
  }
  .casting-dock-portrait { display: none; }
  .casting-result-note { margin-top: 3px; padding: 2px 4px 0; }
  .casting-result-note > .casting-emblem,
  .casting-result-note > strong { display: none; }
}
