/* Creature card viewer: the card art (rendered by png/cards/card-viewer.js, a standalone
   component from the Studio tool) sits on the left at its native 703:998 ratio, with the
   equipment effects panel this game itself owns on the right. */

#card-view-modal {
  --card-width: 160px;
  --card-space-x: 1.75;
  --card-space-y: 2.1;
  --card-panel-height: calc(var(--card-width) * var(--card-space-y));
  width: 620px;
}

.card-view-columns {
  display: flex;
  gap: 18px;
  align-items: stretch;
}

.card-view-art {
  /* Every tier shares the back's native frame size and the same room for crystal overflow. */
  flex: 0 0 calc(var(--card-width) * var(--card-space-x));
  width: calc(var(--card-width) * var(--card-space-x));
  height: var(--card-panel-height);
  display: grid;
  place-items: center;
  position: relative;
  perspective: 1100px;
}

/* Card-back shown immediately (no network wait), flipping over to reveal the real art once
   card-viewer.js's own configure() resolves -- see CardViewModal.__loadCardArt. Acts as the
   loading state for however long the art takes to fetch and decode. */
.card-view-flip {
  width: var(--card-width);
  height: calc(var(--card-width) * 998 / 703);
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(.2,.7,.25,1);
}

.card-view-flip.flipped {
  transform: rotateY(180deg);
}

/* The very first time a given card is ever opened, the flip itself runs slower -- a beat of
   suspense before the tier is revealed for good (see CardViewModal.__loadCardArt and its own
   FIRST_REVEAL_SUSPENSE_MS pause). Every reopening of an already-revealed card keeps the
   snappier default above -- there is no mystery left to draw out. */
.card-view-flip.first-reveal {
  transition-duration: 1s;
}

.card-view-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 4%;
  overflow: hidden;
}

/* Shown in place of the artwork when it could not be fetched at all (see the catch in
   CardViewModal.__loadCardArt) -- the card still flips to this, because a card back that
   silently never turns reads as the client being frozen rather than as an error. */
.card-view-art-error {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12%;
  box-sizing: border-box;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: #e8eaf0;
  background: #1c2029;
  border: 1px solid #2c3140;
  border-radius: 4%;
}

.card-view-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-view-front {
  transform: rotateY(180deg);
  overflow: visible;
  border-radius: 0;
}

.card-view-front retebra-card {
  width: 100%;
  height: 100%;
  display: block;
}

.card-view-info {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: var(--card-panel-height);
  overflow: hidden;
  overflow-wrap: anywhere;
}

.card-view-tier {
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 11px;
  line-height: 16px;
  flex: 0 0 auto;
  margin-bottom: 6px;
}

.card-view-tier.tier-bronze { color: #cd8032; }
.card-view-tier.tier-silver { color: #c6c6d0; }
.card-view-tier.tier-gold { color: #f0c33c; }
.card-view-tier.tier-platinum { color: #7fe8e0; }
.card-view-tier.tier-crystal { color: #d38ef0; }

.card-view-bonus {
  flex: 0 0 auto;
  font-size: 12px;
  line-height: 1.4;
  min-height: 2.8em;
  color: #7fe07f;
  border-bottom: 1px solid #333;
  padding-bottom: 6px;
}

.card-view-passives {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(4, minmax(min-content, 1fr));
  min-height: 0;
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.card-view-passive {
  box-sizing: border-box;
  min-width: 0;
  min-height: 58px;
  padding: 8px 0;
  border-bottom: 1px solid #444;
}

.card-view-passive dt {
  font-size: 11px;
  line-height: 14px;
  color: #aeb4b1;
  margin-bottom: 4px;
}

.card-view-passive dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: #ddd;
  overflow-wrap: anywhere;
}

body.mobile-layout #card-view-modal {
  --card-width: clamp(66px, calc((var(--mobile-vh) - 164px) / var(--card-space-y)), 100px);
  width: 620px;
  overflow: visible;
}

body.mobile-layout #card-view-title {
  padding: 5px 36px 5px 10px;
  line-height: 18px;
  overflow-wrap: anywhere;
}

body.mobile-layout #card-view-modal .card-view-columns {
  gap: 12px;
}

body.mobile-layout #card-view-modal .card-view-passives {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(min-content, 1fr));
  column-gap: 12px;
  touch-action: pan-y;
}

body.mobile-layout #card-view-modal hr {
  margin: 4px 8px;
}

body.mobile-layout #card-view-modal .modal-footer button {
  min-width: 64px;
  min-height: 36px;
}

@media (orientation: portrait) {
  body.mobile-layout #card-view-modal {
    --card-width: clamp(74px, calc((var(--mobile-vh) - 302px) / var(--card-space-y)), 110px);
    width: 340px;
  }

  body.mobile-layout #card-view-modal .card-view-columns {
    flex-direction: column;
    gap: 8px;
  }

  body.mobile-layout #card-view-modal .card-view-art {
    flex-basis: auto;
    align-self: center;
  }

  body.mobile-layout #card-view-modal .card-view-info {
    flex-basis: auto;
    height: 184px;
  }
}
