/*
 * Where each piece of the match sits on a phone, upright and sideways. The
 * looks are in phone-match.css; this file only places things.
 */

/* ---- Upright ---- */
:root[data-phone='true'][data-orient='portrait'] .touch-tools {
  top: var(--phone-top);
  left: 0;
}

:root[data-phone='true'][data-orient='portrait'] .hud__overview {
  top: var(--phone-top);
  right: 0;
  width: calc(8.25rem + 2 * var(--space-1) + 2px);
}

:root[data-phone='true'][data-orient='portrait'] .hud__view-buttons .hud__center {
  flex: 1 0 100%;
}

:root[data-phone='true'][data-orient='portrait'] .hud__view-buttons .hud__small:not(.hud__center) {
  flex: 1;
}

:root[data-phone='true'][data-orient='portrait'] .deck__list {
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  height: var(--phone-deck-row);
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

/* Three short lines: the name, the price, how many are out. */
:root[data-phone='true'][data-orient='portrait'] .card__pick {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(3, auto);
  row-gap: 0.125rem;
  /* Six cards across: a narrow side padding keeps a seven-letter name whole. */
  padding: var(--space-1) 0.125rem;
}

:root[data-phone='true'][data-orient='portrait'] .card__short {
  grid-area: 1 / 1;
  font-size: var(--text-xs);
  letter-spacing: 0;
}

:root[data-phone='true'][data-orient='portrait'] .card__cost {
  grid-area: 2 / 1;
  font-size: var(--text-xs);
  line-height: 1.2;
}

:root[data-phone='true'][data-orient='portrait'] .card__cost::before {
  width: 0.375rem;
  height: 0.375rem;
  margin-right: 0.2rem;
}

:root[data-phone='true'][data-orient='portrait'] .card__status {
  grid-area: 3 / 1;
  line-height: 1.2;
}

/* Just above the deck, the whole width, clear of the middle where your base
   sits. The formation bar uses the same spot (see below). */
:root[data-phone='true'][data-orient='portrait'] .deck__panel {
  bottom: calc(var(--phone-deck-row) + var(--phone-gap));
  left: 0;
  right: 0;
}

:root[data-phone='true'][data-orient='portrait'] .formation-bar {
  left: 0;
  right: 0;
  bottom: calc(var(--phone-deck-row) + var(--phone-gap));
}

/* ---- Sideways ---- */
:root[data-phone='true'][data-orient='landscape'] .hud__identity {
  left: calc(var(--phone-deck-column) + var(--phone-gap));
  right: auto;
  min-width: 14rem;
}

:root[data-phone='true'][data-orient='landscape'] .hud__out {
  right: calc(8.25rem + 3.5rem + 4 * var(--space-1) + var(--phone-gap));
}

:root[data-phone='true'][data-orient='landscape'] .deck__list {
  top: 0;
  left: 0;
  /* Two rows of touch tools under it. */
  bottom: calc(2 * var(--target) + 3 * var(--space-1) + 2px + var(--phone-gap));
  width: var(--phone-deck-column);
  /* One column, whatever the narrow-screen rule in deck.css says for a phone under 768 px wide. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(6, minmax(0, 1fr));
}

:root[data-phone='true'][data-orient='landscape'] .touch-tools {
  left: 0;
  bottom: 0;
  width: var(--phone-deck-column);
  flex-direction: row;
  flex-wrap: wrap;
}

/* Two to a row: Send and Box, then Fighters and Path. */
:root[data-phone='true'][data-orient='landscape'] .touch-tools .button {
  flex: 1 1 calc(50% - var(--space-1));
  width: auto;
  padding: 0 0.125rem;
}

/* The panel and the formation bar share the bottom middle, between the
   deck and the overview. */
:root[data-phone='true'][data-orient='landscape'] .deck__panel {
  left: calc(var(--phone-deck-column) + var(--phone-gap));
  right: calc(8.25rem + 3.5rem + 4 * var(--space-1) + var(--phone-gap));
  bottom: 0;
  max-height: calc(100% - var(--phone-top));
}

/* The overview with its buttons in a column beside it. */
:root[data-phone='true'][data-orient='landscape'] .hud__overview {
  right: 0;
  bottom: 0;
  grid-template-columns: auto 3.5rem;
}

:root[data-phone='true'][data-orient='landscape'] .hud__view-buttons {
  flex-direction: column;
  flex-wrap: nowrap;
}

:root[data-phone='true'][data-orient='landscape'] .hud__view-buttons .button {
  width: 100%;
  padding: 0 var(--space-1);
  font-size: var(--text-xs);
}

:root[data-phone='true'][data-orient='landscape'] .formation-bar {
  left: calc(var(--phone-deck-column) + var(--phone-gap));
  right: calc(8.25rem + 3.5rem + 4 * var(--space-1) + var(--phone-gap));
  bottom: 0;
}

/* Sideways the panel is kept short, so the middle of the map stays in view:
   the options sit two to a row, and the longer descriptions are left out. */
:root[data-phone='true'][data-orient='landscape'] .deck__about,
:root[data-phone='true'][data-orient='landscape'] .deck__panel .option__note {
  display: none;
}

:root[data-phone='true'][data-orient='landscape'] .deck__panel {
  padding: var(--space-2);
}

:root[data-phone='true'][data-orient='landscape'] .card__options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--space-3);
}

:root[data-phone='true'][data-orient='landscape'] .card__options .option--bare,
:root[data-phone='true'][data-orient='landscape'] .card__options .option--wide {
  grid-column: 1 / -1;
}

:root[data-phone='true'][data-orient='landscape'] .deck__panel .option__label {
  flex-basis: 3.5rem;
  font-size: var(--text-xs);
}

/* A unit with no options to set keeps its description, so the panel is never empty. */
:root[data-phone='true'][data-orient='landscape']
  .deck__panel:not(:has(.card__options:not([hidden]) > *))
  .deck__about {
  display: block;
}

/* Sideways the formation bar keeps the upright layout (phone-match.css): the
   count with Clear, then the four pages on their own row, since at phone width
   they do not fit beside the count, and then the shapes. */
:root[data-phone='true'][data-orient='landscape'] .formation-bar__about {
  display: none;
}

:root[data-phone='true'][data-orient='landscape'] .formation-bar {
  padding: var(--space-2);
}
