/* Oswald's Card Exchange: same skin and size as the Store (store.css), two tabs drawn with the
   same flat gray button image as the Spellbook's, lists scrolled by TibiaScrollbar (modal.css). */

.card-exchange-modal {
  background: #444 url("../png/bg.png") repeat;
  border: 1px solid #111;
  box-shadow: inset 0 0 0 1px #777, 0 4px 18px #000;
  color: #dedede;
  font-family: Verdana, Arial, sans-serif;
  font-size: 11px;
  height: min(620px, calc(100% - 20px));
  left: 50%;
  min-height: 420px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, calc(100% - 24px));
  z-index: 40000;
  flex-direction: column;
}

.card-exchange-modal[style*="display: block"] {
  display: flex !important;
}

.card-exchange-modal button {
  background: url("../png/button_gray.png") no-repeat left center / 200% 100%;
  border: 0;
  box-shadow: none;
  outline: none;
  filter: none;
  color: #ddd;
  font: 11px Verdana, Arial, sans-serif;
  height: 24px;
  margin: 0;
  padding: 0 12px;
  cursor: pointer;
}

.card-exchange-modal button:active,
.card-exchange-modal .cx-tab.selected {
  background-position: right center;
}

.card-exchange-modal button:disabled {
  color: #777;
  cursor: default;
}

.card-exchange-modal button:focus-visible {
  outline: 1px solid #fff;
  outline-offset: 1px;
}

.card-exchange-modal .close-button-transparent {
  background: none;
  height: auto;
  padding: 0 4px;
}

.cx-npc {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 0;
}

.cx-npc-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  image-rendering: pixelated;
}

.cx-speech {
  flex: 1 1 auto;
  min-height: 26px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #000;
  box-shadow: inset 0 0 6px #000;
  padding: 6px 8px;
  color: #5fb7ff;
}

.cx-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 10px 0;
}

.cx-tabs .cx-tab {
  flex: 1 1 0;
  height: 26px;
}

.cx-body {
  flex: 1 1 auto;
  min-height: 0;
  margin: 8px 10px 0;
  padding: 10px;
  background-image: url("../png/bg2.png");
  border: 1px solid #000;
  box-shadow: inset 0 0 6px #000;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 10px;
}

.cx-panel {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cx-panel[hidden] {
  display: none;
}

.cx-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* TibiaScrollbar wraps these in place: the wrapper takes the room, the content inside it scrolls */
.cx-main.cx-scroll.tibia-scroll-wrapper {
  gap: 0;
}

.cx-main.cx-scroll.tibia-scroll-content {
  padding-right: 4px;
}

.cx-box {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid #000;
  box-shadow: inset 0 0 6px #000;
  padding: 8px;
}

.cx-box-title {
  margin: 0 0 6px;
  color: #bbb;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cx-hint,
.cx-hint-inline {
  color: #9a9a9a;
  text-transform: none;
  letter-spacing: 0;
}

.cx-hint {
  margin: 6px 0 0;
}

.cx-item {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: url("../png/clean-button.png") left center / 200% 100%;
  position: relative;
}

.cx-item canvas {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.cx-count {
  position: absolute;
  right: 2px;
  bottom: 0;
  color: #fff;
  font-size: 10px;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.cx-tier-bronze { color: #cd8032; }
.cx-tier-silver { color: #c6c6d0; }
.cx-tier-gold { color: #f0c33c; }
.cx-tier-platinum { color: #7fe8e0; }

/* ---- Dust Exchange ---- */

.cx-dust-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cx-dust-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid #000;
}

.cx-dust-name {
  font-size: 12px;
}

.cx-dust-sub {
  margin-top: 2px;
  color: #9a9a9a;
  font-variant-numeric: tabular-nums;
}

.cx-stepper {
  display: flex;
  align-items: center;
  gap: 2px;
}

.card-exchange-modal .cx-stepper button {
  width: 22px;
  height: 22px;
  padding: 0;
}

.cx-stepper output {
  width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.cx-buy {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cx-cost {
  min-width: 70px;
  text-align: right;
  color: #9a9a9a;
  font-variant-numeric: tabular-nums;
}

.cx-cost.short {
  color: #ff7a6b;
}

.cx-received {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 40px;
  align-items: center;
  color: #9a9a9a;
}

.cx-pool {
  color: #9a9a9a;
  line-height: 1.6;
}

/* ---- Card Upgrade ---- */

.cx-recipes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.card-exchange-modal .cx-recipe {
  height: 28px;
}

.card-exchange-modal .cx-recipe.selected {
  background-position: right center;
}

.cx-forge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cx-slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.cx-slot {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: url("../png/clean-button.png") left center / 200% 100%;
  position: relative;
}

.card-exchange-modal button.cx-slot {
  padding: 0;
  height: 40px;
  background: url("../png/clean-button.png") left center / 200% 100%;
}

.cx-slot canvas {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.cx-forge-arrow {
  color: #9a9a9a;
  font-size: 18px;
}

.cx-result-slot canvas {
  opacity: 0.35;
}

.cx-result-slot.ready canvas {
  opacity: 1;
}

.cx-forge-status {
  margin-top: 6px;
  text-align: center;
  color: #9a9a9a;
  font-variant-numeric: tabular-nums;
}

.cx-forge-status.ready {
  color: #6fd36f;
}

.cx-forge-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
}

.cx-inventory {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.cx-inv-grid.tibia-scroll-wrapper {
  flex: 1 1 auto;
  min-height: 0;
}

.cx-inv-grid.tibia-scroll-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  align-content: start;
  gap: 4px;
  padding-right: 4px;
}

.card-exchange-modal .cx-inv-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  height: auto;
  padding: 2px;
  text-align: left;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid #000;
}

.card-exchange-modal .cx-inv-card:hover {
  background: rgba(255, 255, 255, 0.06);
}

.card-exchange-modal .cx-inv-card:disabled {
  opacity: 0.35;
}

.cx-inv-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cx-inv-tier {
  font-size: 10px;
}

.cx-empty {
  color: #9a9a9a;
}

/* ---- Right column: the big card ---- */

/* Its own layer, below the burst canvas: the turning card is 3D and would otherwise be
   drawn on top of the burst */
.cx-showcase {
  position: relative;
  z-index: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

/* The frame the card stands in: its padding counted inside the column's width, so the
   column no longer cuts its sides off and the frame is the same all the way round */
.cx-stage-box {
  width: 100%;
  box-sizing: border-box;
}

.cx-stage {
  width: 100%;
  aspect-ratio: 703 / 998;
  max-height: 100%;
  display: grid;
  place-items: center;
}

.cx-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px #000);
}

.cx-stage retebra-card {
  display: block;
  width: 100%;
  max-width: 100%;
}

/* A new card being made (CardExchangeModal.__reveal): the sealed card trembles, turns over,
   and lets go of a few particles in its tier colour */
.cx-reveal {
  --cx-tier: #cd8032;
  position: relative;
  width: 100%;
  height: 100%;
  perspective: 900px;
}

.cx-reveal-silver { --cx-tier: #c6c6d0; }
.cx-reveal-gold { --cx-tier: #f0c33c; }
.cx-reveal-platinum { --cx-tier: #7fe8e0; }

/* The suspense glow, breathing round the card. Kept to the 9px of frame around it, so it
   fades out before the frame's edge instead of being cut off there */
.cx-reveal-glow {
  position: absolute;
  inset: 0;
  border-radius: 5%;
  box-shadow: 0 0 7px 2px var(--cx-tier), 0 0 3px 1px color-mix(in srgb, var(--cx-tier) 60%, #fff);
  opacity: 0;
}

.cx-reveal-card,
.cx-reveal-flipper {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.cx-reveal-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}

.cx-reveal-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cx-reveal-front {
  transform: rotateY(180deg);
}

.cx-reveal-front retebra-card {
  display: block;
  width: 100%;
}

/* The light sweeping the card face once it turns over. Lifted off the card: the turned card
   lives in 3D and would otherwise be drawn over it */
.cx-reveal-sheen {
  position: absolute;
  inset: 2.2% 3.2% 3.8% 3.6%;
  overflow: hidden;
  border-radius: 4%;
  z-index: 2;
  transform: translateZ(40px);
  pointer-events: none;
}

.cx-reveal-sheen-bar {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 34%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.38), transparent);
  transform: translateX(-160%) skewX(-14deg);
}

/* The burst canvas lies over the whole window body, centred on the card by __burst */
.cx-body {
  position: relative;
}

.cx-burst-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

.cx-caption {
  min-height: 30px;
  text-align: center;
}

.cx-caption-sub {
  margin-top: 2px;
  color: #9a9a9a;
}

.cx-flip {
  animation: cx-flip 0.6s ease-in-out;
}

.cx-pop {
  animation: cx-pop 0.45s ease-out;
}

@keyframes cx-flip {
  50% { transform: rotateY(90deg); }
}

@keyframes cx-pop {
  from { transform: scale(0.4); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cx-flip,
  .cx-pop {
    animation: none;
  }
}

.cx-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
}

.cx-balances {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.cx-balance {
  display: flex;
  align-items: center;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.cx-balance canvas {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

/* Narrow screens: the card art goes away and every row stacks */
@media (max-width: 760px) {
  .cx-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .cx-showcase {
    display: none;
  }

  .cx-recipes {
    grid-template-columns: minmax(0, 1fr);
  }

  .cx-dust-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .cx-stepper,
  .cx-buy {
    grid-column: 2;
  }
}
