/*
 * The administrator's panel. The night of the game, quieter: figures in the sans, ledger lines
 * instead of cards, the charts' colours chosen for telling apart (checked for colour blindness
 * on this background): a good outcome blue, a middle one amber, a bad one rose.
 */
:root {
  --viz-win: #3d8fd6;
  --viz-partial: #b08a26;
  --viz-loss: #d0567a;
  --viz-new: #6cc7b6;
  --viz-back: #2f7d71;
  --viz-ink: #10111c;
}

.admin {
  max-width: 82.5rem;
  margin: 0 auto;
  padding: 2rem max(var(--gutter), var(--safe-r)) calc(4rem + var(--safe-b))
    max(var(--gutter), var(--safe-l));
  transition: opacity 0.2s;
}

/* While the numbers are fetched again, the old ones stay, dimmed: nothing jumps. */
.admin.refreshing {
  opacity: 0.6;
}

.admin-loading {
  margin: 4rem auto;
  text-align: center;
  color: var(--muted);
}

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}

.admin-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2rem;
  color: var(--ink);
}

.admin-fresh {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0;
  font-size: 0.85rem;
  color: var(--faint);
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.2rem;
  margin: 1rem 0 0;
  font-size: 0.88rem;
}

.admin-nav a {
  color: var(--muted);
  text-underline-offset: 3px;
}

@media (hover: hover) {
  .admin-nav a:hover {
    color: var(--wanderer);
  }
}

#admin-error {
  margin: 1.2rem 0 0;
}

.admin-section {
  margin-top: 2.4rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--veil-line);
  scroll-margin-top: calc(var(--bar-h) + 0.8rem);
}

.admin-section h2 {
  margin: 0 0 1rem;
  font-size: 1.45rem;
  color: var(--ink);
}

.admin-section h3 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  color: var(--text);
}

.admin-section .hint {
  max-width: 44rem;
  font-size: 0.88rem;
}

/* ---------- figures ---------- */

.now-grid {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 1.5rem 3rem;
  align-items: start;
}

/* The one number the panel leads with: who is playing now. */
.hero-figure {
  display: grid;
  gap: 0.3rem;
  margin: 0;
}

.hero-value {
  font-size: 4rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}

.hero-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 1.1rem 1.6rem;
  margin: 0;
}

.tile {
  padding-top: 0.5rem;
  border-top: 1px solid var(--veil-line);
}

.tile dt {
  font-size: 0.84rem;
  color: var(--muted);
}

.tile dd {
  margin: 0.15rem 0 0;
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}

.tiles.compact dd {
  font-size: 1.25rem;
}

.tile-note {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--faint);
}

.split {
  display: grid;
  gap: 2rem;
  margin-top: 1.6rem;
}

/* A wide table scrolls inside its column; the page never goes sideways. */
.split > * {
  min-width: 0;
}

.outcome-table {
  min-width: 30rem;
}

@media (min-width: 56.3125em) {
  .split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3rem;
  }
}

.note-line {
  margin: 0.7rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

/* ---------- charts ---------- */

.chart {
  width: 100%;
}

.chart-bar,
.fair-bar,
.mini {
  width: 100%;
  min-height: 1rem;
}

.chart svg,
.fair-bar svg,
.mini svg {
  display: block;
  overflow: visible;
}

.seg.win {
  fill: var(--viz-win);
}

.seg.partial {
  fill: var(--viz-partial);
}

.seg.loss {
  fill: var(--viz-loss);
}

.seg.new {
  fill: var(--viz-new);
}

.seg.back {
  fill: var(--viz-back);
}

.track {
  fill: var(--veil);
}

/* A share written inside its part: dark ink on the mid-light fills. */
.seg-label {
  fill: var(--viz-ink);
  font: 600 12px var(--sans);
  pointer-events: none;
}

/* The hover and focus target of a mark: bigger than the mark, a faint wash when pointed at. */
.hit {
  fill: transparent;
}

@media (hover: hover) {
  .hit:hover {
    fill: rgba(255, 255, 255, 0.08);
  }
}

.hit:focus-visible {
  outline: 2px solid var(--wanderer);
  outline-offset: 1px;
}

/* What the chance promised: an ink line across the bar. */
.promise {
  stroke: var(--ink);
  stroke-width: 2;
}

.columns-svg .grid {
  stroke: var(--veil-line);
  stroke-width: 1;
}

.columns-svg .baseline {
  stroke: #3d4160;
  stroke-width: 1;
}

.columns-svg .tick {
  fill: var(--faint);
  font: 11px var(--sans);
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.3rem;
  margin: 0.6rem 0 0.4rem;
  font-size: 0.86rem;
}

.key {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
}

.swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 3px;
}

.swatch.win {
  background: var(--viz-win);
}

.swatch.partial {
  background: var(--viz-partial);
}

.swatch.loss {
  background: var(--viz-loss);
}

.swatch.new {
  background: var(--viz-new);
}

.swatch.back {
  background: var(--viz-back);
}

.swatch.promise-key {
  width: 2px;
  height: 0.95rem;
  border-radius: 0;
  background: var(--ink);
}

.key-num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.viz-tip {
  position: fixed;
  z-index: 50;
  max-width: 17rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--veil-line);
  border-radius: 8px;
  background: var(--void-deep);
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.9);
  font-size: 0.84rem;
  pointer-events: none;
}

.tip-head {
  margin: 0 0 0.2rem;
  color: var(--muted);
}

.tip-row {
  margin: 0;
  color: var(--muted);
}

.tip-row strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- tables ---------- */

.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  /* Words stay whole in a table: it scrolls in its column instead (the page's phone rule lets a
     long word break anywhere, which would squeeze a column to a letter). */
  overflow-wrap: normal;
}

.data th,
.data td {
  overflow-wrap: normal;
}

.outcome-table tbody th {
  min-width: 7.5rem;
}

.data th,
.data td {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--veil-line);
  text-align: left;
  vertical-align: baseline;
}

.data thead th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.data tbody th {
  font-weight: 400;
  color: var(--ink);
}

.data .number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data .bar-cell {
  width: 32%;
  min-width: 6rem;
  vertical-align: middle;
}

.table-view {
  margin-top: 0.8rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.table-view summary {
  cursor: pointer;
  width: fit-content;
}

.table-view .data {
  max-width: 26rem;
  margin-top: 0.5rem;
}

.players .tiles,
#player-tiles {
  margin-top: 1.4rem;
}

/* ---------- fairness ---------- */

.fair-legend {
  margin-bottom: 1rem;
}

.fair-rows {
  display: grid;
  gap: 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fair-row {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 0.2rem 1.4rem;
  align-items: center;
}

.fair-head {
  display: grid;
  margin: 0;
}

.fair-tier {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink);
}

.fair-chance {
  font-size: 0.8rem;
  color: var(--faint);
}

.fair-meta {
  grid-column: 2;
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.fair-flag,
.fair-few {
  display: inline-block;
  margin-left: 0.6rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  font-size: 0.76rem;
  line-height: 1.5;
}

.fair-flag {
  border: 1px solid color-mix(in srgb, var(--viz-loss) 70%, transparent);
  color: color-mix(in srgb, var(--viz-loss) 70%, var(--ink));
}

.fair-few {
  border: 1px solid var(--veil-line);
  color: var(--faint);
}

/* ---------- feedback ---------- */

.latest {
  display: grid;
  gap: 0;
  margin: 1.2rem 0 0.8rem;
  padding: 0;
  list-style: none;
  max-width: 52rem;
}

.latest-one {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--veil-line);
}

.latest-head {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.latest-head b {
  color: var(--text);
}

.latest-text {
  margin: 0.25rem 0 0;
  color: var(--text);
}

/* ---------- games ---------- */

.games-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.8rem;
  margin: 0.4rem 0 0.8rem;
}

.games-tools label {
  color: var(--muted);
  font-size: 0.9rem;
}

.games-filter {
  flex: 0 1 22rem;
  min-width: 0;
  font: inherit;
  font-size: max(0.95rem, 16px);
  color: var(--ink);
  background: var(--veil);
  border: 1px solid var(--veil-line);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}

.table-scroll {
  overflow-x: auto;
}

.games-table {
  min-width: 52rem;
}

.story-link {
  cursor: pointer;
  padding: 0;
  border: none;
  background: none;
  font-family: var(--serif);
  font-size: 1rem;
  text-align: left;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--ink) 30%, transparent);
  text-underline-offset: 3px;
}

@media (hover: hover) {
  .story-link:hover {
    color: var(--wanderer);
  }
}

.game-where {
  color: var(--muted);
  max-width: 22rem;
}

.game-state {
  white-space: nowrap;
  color: var(--text);
}

.game-state.running {
  color: var(--wanderer);
}

.game-owner {
  white-space: nowrap;
}

.game-owner code {
  margin-right: 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.game-when {
  white-space: nowrap;
  color: var(--faint);
}

.tag-select {
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--veil);
  border: 1px solid var(--veil-line);
  border-radius: 6px;
  padding: 0.1rem 0.3rem;
}

/* A player marked an agent: his games are out of the figures, and look it. */
.games-table tr.tag-agent td,
.games-table tr.tag-agent th {
  opacity: 0.55;
}

.games-table tr.tag-agent .game-owner {
  opacity: 1;
}

/* The whole text of a story: a page, as the game shows one. */
.transcript {
  margin-top: 1.6rem;
  padding: 1.4rem 1.6rem 1.2rem;
  font-family: var(--serif);
  color: var(--ink);
  background: var(--page);
  border: 1px solid var(--page-line);
  border-radius: 3px;
  scroll-margin-top: calc(var(--bar-h) + 0.8rem);
}

.transcript:focus {
  outline: none;
}

.transcript-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.transcript-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.5rem;
  color: var(--ink);
}

.transcript .note-line,
.transcript-open {
  font-family: var(--sans);
}

.transcript-turn {
  max-width: 46rem;
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--page-line);
}

.transcript-turn h4 {
  margin: 0 0 0.4rem;
  font-family: var(--sans);
  color: var(--wanderer);
}

.transcript-order {
  font-style: italic;
}

.transcript-attempts {
  margin: 0.3rem 0 0.6rem;
  padding-left: 1.2rem;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: color-mix(in srgb, var(--ink) 75%, var(--page));
}

.transcript-story {
  line-height: 1.65;
}

.export-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* ---------- not the administrator ---------- */

.admin-missing {
  max-width: 34rem;
  margin: 5rem auto;
  padding: 0 var(--gutter);
  text-align: center;
}

.missing-code {
  margin: 0;
  font-family: var(--serif);
  font-size: 4.5rem;
  line-height: 1;
  color: var(--wanderer);
}

.admin-missing h1 {
  margin: 0.6rem 0 0.8rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.7rem;
  color: var(--ink);
}

/* ---------- a phone ---------- */

@media (max-width: 56.25em) {
  .admin {
    padding-top: 1.2rem;
  }

  .admin-head h1 {
    font-size: 1.6rem;
  }

  .admin-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.4rem;
    white-space: nowrap;
    scrollbar-width: none;
  }

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

  .tiles {
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    gap: 0.9rem 1.2rem;
  }

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

  .fair-meta {
    grid-column: 1;
  }

  .data .bar-cell {
    min-width: 4.5rem;
  }

  .transcript {
    padding: 1.1rem 1rem 1rem;
  }
}

@media (pointer: coarse) {
  .admin-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .tag-select,
  .story-link {
    min-height: 44px;
  }
}

/* ---------- the first impression (stage 3c): rows of bars in one hue ---------- */

.meter-rows {
  list-style: none;
  margin: 0.4rem 0 0.8rem;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.meter-row {
  display: grid;
  /* The number column is as wide in every row: the tracks end together and compare. */
  grid-template-columns: minmax(8rem, 15rem) minmax(4rem, 1fr) 6.5rem;
  gap: 0.7rem;
  align-items: center;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  font-size: 0.86rem;
}

@media (hover: hover) {
  .meter-row:hover {
    background: rgba(255, 255, 255, 0.05);
  }
}

.meter-row:focus-visible {
  outline: 2px solid var(--wanderer);
  outline-offset: 1px;
}

.meter-word {
  color: var(--text);
}

.meter-track {
  display: block;
  height: 0.8rem;
  border-radius: 4px;
  background: var(--veil);
  overflow: hidden;
}

/* Square at the baseline, its data end rounded (4px). */
.meter-fill {
  display: block;
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--viz-win);
}

.meter-num {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 40rem) {
  .meter-row {
    grid-template-columns: 1fr 6.5rem;
  }

  .meter-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
