/* Infinite Automatic Catan — the castaway's rails (alone-panels.js).
 *
 * One bot alone on the island, played to an expected yield. The page is the
 * table's page with some panels swapped: `.table-only` panels go while a
 * castaway is on the island, `.alone-only` ones come. Everything here is in
 * the table's vocabulary — the same sheet, hairlines, ladder of type sizes
 * and resource colors — so the two read as one exhibit in two modes.
 */

body:not(.is-alone) .alone-only,
body.is-alone .table-only { display: none; }

/* The left rail is the table's, with the ledger where the standings were. */
.is-alone #panel-ledger { flex: 0 0 auto; }

/* The right rail: one card, then the panels that fill the room three more
   cards would have taken, then the log in whatever is left. */
.is-alone #panel-pace,
.is-alone #panel-flow { flex: 0 0 auto; }

/* ============================================================ the card */

/* Always the castaway's turn, so the card says nothing about whose turn it
   is: a panel's hairline and ground, like every other panel. The name and
   the bar carry the leaning's color. */
.pcard.acard {
  border-color: var(--hair);
  background: var(--sheet);
}

.acard .pcard-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acard-yield small { letter-spacing: 0.02em; }

.acard-lean {
  margin-top: 2px;
  font-size: var(--fs-n4);
  letter-spacing: 0.04em;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acard-bar { height: 5px; }
.acard-bar span { transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.acard .chiprow + .chiprow { margin-top: 3px; }

/* ========================================================== the ledger */

/* The name column is as wide as the longest name (the rows share one
   width, --ledger-name, which alone-panels.js measures), and the three
   numbers share the rest evenly, centred in their columns, so the figures
   sit across the panel rather than piled against its right edge. */
.ledger-row {
  display: grid;
  grid-template-columns: var(--ledger-name, minmax(0, 1.5fr)) repeat(3, minmax(0, 1fr));
  gap: 6px;
  align-items: baseline;
  padding: 2px 0;
  font-size: var(--fs-n4);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.ledger-row > span:not(.ledger-name) { text-align: center; }
.ledger-head {
  font-size: var(--fs-n5);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  border-bottom: 1px solid var(--hair);
  margin-bottom: 2px;
}
.ledger-name {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ledger-best { color: var(--ink); font-weight: 700; }
/* The best and the worst of each sortable column, in the splits' green and
   red: fewer turns is ahead, more is behind. */
.ledger-row .is-lo { color: #3FD27A; font-weight: 700; }
.ledger-row .is-hi { color: var(--robber-lit, #ff9b7a); font-weight: 700; }

/* Median and best are buttons in the head: a click sorts best first, the
   next worst first, the next back to the ledger's own order. */
.ledger-sort {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.ledger-sort:hover,
.ledger-sort.is-on { color: var(--ink); }
.ledger-sort.is-on::after { margin-left: 3px; color: var(--gold); }
.ledger-sort[data-dir="best"]::after { content: '\25B2'; }
.ledger-sort[data-dir="worst"]::after { content: '\25BC'; }

/* Every result kept, newest last, as tall as it was long. */
.ledger-strip {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 34px;
  margin-top: 7px;
  padding-top: 5px;
  border-top: 1px solid var(--hair);
}
.ledger-strip i {
  display: block;
  flex: none;
  width: 7px;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 1px 1px 0 0;
  opacity: 0.85;
}
.ledger-strip i:last-child { opacity: 1; outline: 1px solid var(--gold); outline-offset: 1px; }

/* =========================================================== the cards */

.flow { display: flex; flex-direction: column; gap: 2px; }
.flow-row {
  display: grid;
  grid-template-columns: 7.4em minmax(0, 1fr) 2.6em;
  gap: 6px;
  align-items: center;
  font-size: var(--fs-n4);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.flow-row.is-zero { opacity: 0.4; }
.flow-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-track {
  display: block;
  height: 5px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.32);
  overflow: hidden;
}
.flow-track i { display: block; height: 100%; width: 0; transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.flow-row.is-in .flow-track i { background: var(--gold); }
.flow-row.is-out .flow-track i { background: var(--ink-3); }
.flow-n { text-align: right; color: var(--ink); font-weight: 700; }
/* Where cards came in and where they went out are one list with a seam. */
.flow-row.is-in + .flow-row.is-out {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--hair);
}

/* ========================================================== room to fit */

/* The log keeps a floor; what gives first on a short window is where the
   cards went, then the chart. The card and the splits always stay. */
.is-alone #panel-log { min-height: 110px; }

/* 820 tall */
:root.max-h-820 .is-alone #panel-flow { display: none; }
:root.max-h-820 .climb-chart { height: 48px; }

/* 700 tall */
:root.max-h-700 .is-alone .climb-chart,
:root.max-h-700 .is-alone .climb-axis,
:root.max-h-700 .is-alone .climb-key { display: none; }

@media (prefers-reduced-motion: reduce) {
  .acard-bar span, .flow-track i { transition: none; }
}

/* ============================================================ the title */

/* "castaway" stands where "catan" stood; "mega" still opens in front of it
   on the big island. */
.title-alone { display: none; }
.is-alone .title-cat { display: none; }
.is-alone .title-alone { display: inline; }

/* A row or strip told to hide hides, whatever display it was given. */
.ledger-row[hidden],
.ledger-strip[hidden] { display: none; }
