/*
 * What goes inside a Terminal page: a setting with its line of explanation,
 * a switch, an upgrade card, and the buttons that act on units. Built by
 * src/client/js/match/terminal-parts.js.
 */

/* One setting: its name, its control, and a line that says what it does now. */
.setting {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
}

.setting__name {
  font-weight: 600;
}

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

/* Room for the longest note at a column's width (four lines), so nothing
   below it moves as the choice changes. */
.setting--choice .setting__about {
  min-height: 5.6em;
}

.terminal .segment {
  min-height: var(--target);
  white-space: normal;
  font-size: var(--text-sm);
}

/* A switch is one large button: text on the left, the switch on the right. */
.setting--switch {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  text-align: left;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color var(--dur-quick) var(--ease-standard);
}

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

/* The control the Terminal was opened at, outlined for a moment. */
.tpointed {
  outline: 2px solid var(--warn);
  outline-offset: 2px;
}

/* Waiting for the second click that turns it off for good. */
.setting--armed,
.setting--armed:hover {
  border-color: var(--danger);
}

.setting__text {
  display: grid;
  gap: var(--space-1);
}

.setting__control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* On and Off are written out, so the state never rests on color alone. */
.switch__state {
  min-width: 2.2ch;
  font: 600 var(--text-sm) / 1 var(--font-mono);
  color: var(--text-dim);
}

.switch {
  position: relative;
  width: 2.75rem;
  height: 1.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  background: var(--bg-0);
  transition:
    background-color var(--dur-quick) var(--ease-standard),
    border-color var(--dur-quick) var(--ease-standard);
}

.switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.5rem - 6px);
  height: calc(1.5rem - 6px);
  border-radius: 50%;
  background: var(--text-dim);
  transition:
    transform var(--dur-quick) var(--ease-standard),
    background-color var(--dur-quick) var(--ease-standard);
}

.setting--switch[aria-checked='true'] .switch {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.setting--switch[aria-checked='true'] .switch__knob {
  transform: translateX(1.25rem);
  background: var(--accent);
}

.setting--switch[aria-checked='true'] .switch__state {
  color: var(--text);
}

/* An upgrade card: name and standing, what it gives, what you are short, the price. */
.upgrade {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 0.375rem;
  padding: 0.625rem var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
}

.upgrade__head .unit-icon {
  flex: none;
}

.upgrade__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* What an unlock gives, drawn in the player's own look (blueprint.js). */
.blueprint {
  display: block;
  width: 100%;
  height: 6.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-inner);
}

.upgrade:has(.blueprint) {
  grid-template-rows: auto auto auto 1fr auto;
}

/* Among the upgrades, where three cards share a column, it stays small. */
.tcol .blueprint {
  height: 2.5rem;
}

/* A fighter type's column holds its unlock and its ammo: room for a fuller drawing. */
.tcol--fighter .blueprint {
  height: 5rem;
}

/* Now, then next: two tags and an arrow between them. */
.upgrade__path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.upgrade__arrow {
  color: var(--accent);
  font-weight: 700;
}

.upgrade__path [hidden] {
  display: none;
}

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

.upgrade__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.upgrade__short {
  flex: 1;
  min-width: 0;
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--text-dim);
}

/* Buying would leave little energy. The words carry it; the color only backs them up. */
.upgrade__short[data-thin='true'] {
  color: var(--warn);
}

.upgrade__buy {
  flex: none;
  min-width: 8.5rem;
  min-height: 1.875rem;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.upgrade__buy:not([aria-disabled='true']) {
  border-color: var(--accent);
}

.upgrade[data-done='true'] {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
}

.upgrade[data-done='true'] .upgrade__buy {
  border-color: transparent;
  color: var(--ok);
}

/* Units: a table, one row a kind, its counts beside the actions on them. */
.tgroup--units {
  gap: 0;
}

.tgroup--units > .setting__about {
  margin: 0 0 var(--space-2);
}
.tunits__row {
  display: grid;
  grid-template-columns: minmax(9rem, 14rem) 6rem 10rem 5rem 7rem;
  gap: var(--space-3);
  align-items: center;
  max-width: 50rem;
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
}

.tunits__row[data-all='true'] .tunits__name {
  font-weight: 600;
}

.tunits__head {
  font: 600 var(--text-xs) / 1.2 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.tunits__count,
.tunits__headcount {
  text-align: right;
}

.tunits__stays {
  font-size: var(--text-sm);
  color: var(--text-dim);
  text-align: center;
}

.tunit {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 2.25rem;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  white-space: nowrap;
}
