/*
 * The deck: the list of units down the left side, and beside it the panel
 * for the unit that is picked. Nothing here scrolls and nothing here moves:
 * every button in the list has a fixed place and a fixed size, the hint has
 * its room kept for it, and the panel opens to the side instead of pushing
 * the list longer. The frame around them lets clicks through to the map.
 */
.deck {
  /* The whole width of the middle row: the columns are sized by the bars
     above and below, and the panel must not be squeezed by them. */
  grid-area: 2 / 1 / 3 / 4;
  align-self: start;
  justify-self: start;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  max-width: 100%;
}

.deck__list {
  flex: none;
  display: grid;
  gap: var(--space-1);
  width: 14.5rem;
  padding: var(--space-2);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-inner);
  transition:
    border-color var(--dur-instant) var(--ease-standard),
    background-color var(--dur-instant) var(--ease-standard),
    box-shadow var(--dur-quick) var(--ease-standard);
}

.card:hover {
  border-color: var(--accent-line);
}

.card[data-picked='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Two fixed lines: the unit and its price, then how many are out or waiting. */
.card__pick {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: var(--space-2);
  row-gap: 0.125rem;
  align-items: baseline;
  width: 100%;
  height: 3rem;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--dur-instant) var(--ease-standard);
}

.card__pick:active {
  transform: scale(0.985);
}

.card__key {
  display: inline-grid;
  place-items: center;
  width: 1.375rem;
  height: 1.375rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-inner);
  font-size: var(--text-xs);
  color: var(--text-dim);
}

.card[data-picked='true'] .card__key {
  border-color: var(--accent);
  color: var(--accent);
}

/* Under the key: the unit's own shape, so the name and the map match up. */
.card__icon {
  grid-column: 1;
  grid-row: 2;
  justify-self: center;
  align-self: center;
}

.card__name {
  font: 600 var(--text-sm) / 1.3 var(--font-mono);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__cost {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--node);
}

/* The cost carries a small energy mark so the number is never a bare digit. */
.card__cost::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.3rem;
  border-radius: 50%;
  background: var(--node);
}

.card[data-affordable='false'] .card__cost {
  color: var(--danger);
}

.card[data-affordable='false'] .card__cost::before {
  background: var(--danger);
}

/* Locked cards: styles/deck-locked.css. */

/* How many are out, and beside it what is waiting to be built. */
.card__status {
  grid-column: 2 / 4;
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-xs);
  line-height: 1.35;
  white-space: nowrap;
  color: var(--text-dim);
}

.card__queue {
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  color: var(--node);
}

/* The queue's progress, along the bottom edge of the button. */
.card__track {
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: color-mix(in srgb, var(--node) 22%, transparent);
}

.card__track[hidden] {
  display: none;
}

.card__fill {
  display: block;
  height: 100%;
  background: var(--node);
  transform-origin: left center;
  transform: scaleX(0);
  /* Steady progress, so a steady pace. */
  transition: transform 220ms linear;
}

.card__fill[data-snap='true'] {
  transition: none;
}

/* Room for three lines, so the list is the same height whatever the hint says. */
.deck__hint {
  height: 3.3rem;
  padding: var(--space-1) var(--space-2) 0;
  overflow: hidden;
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--text-dim);
}

/* The picked unit: what it is, and what an order for it can carry. It is
   opened many times a match, so it arrives fast and plainly. */
.deck__panel {
  display: grid;
  gap: var(--space-2);
  width: 18.5rem;
  min-width: 0;
  padding: var(--space-3);
  animation: panel-in var(--dur-quick) var(--ease-enter) both;
}

.deck__panel[hidden] {
  display: none;
}

@keyframes panel-in {
  from {
    opacity: 0;
  }
}

.deck__about {
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--text-dim);
}

.card__options {
  display: grid;
  gap: var(--space-2);
}

.card__options[hidden] {
  display: none;
}

/* In the panel a label sits beside its control, to keep the panel short. */
.deck__panel .option__label {
  flex: 0 0 4rem;
}

.deck__panel .segments {
  flex: 1 1 0;
  min-width: 0;
}

.deck__panel .segment,
.deck__panel .stepper__button,
.deck__panel .option__pick {
  min-height: 2rem;
}

.deck__panel .segment {
  padding: 0 var(--space-1);
}

/* A choice that names itself needs no label beside it. */
.deck__panel .option--bare .option__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/*
 * Narrow screens: the list becomes a row along the bottom, six equal
 * buttons across the full width, and the panel sits above it.
 */
@media (max-width: 48rem) {
  .deck {
    grid-area: 6 / 1;
    align-self: end;
    justify-self: stretch;
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .deck__list {
    width: auto;
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .card__pick {
    grid-template-columns: minmax(0, 1fr);
    height: 3.5rem;
    padding: var(--space-1) var(--space-2);
  }

  .card__key,
  .card__icon,
  .card__queue,
  .deck__hint {
    display: none;
  }

  .card__status {
    grid-column: 1;
  }

  .deck__panel {
    width: auto;
  }
}
