/* Styles for the Spire model stats page (spire/index.html). */

/* Quiet tones mixed from the theme, so both modes follow: a tinted panel
   behind headers and figures, hairline rules, and grey secondary text. */
.spire {
  --spire-panel: color-mix(in srgb, var(--text-color) 6%, var(--background-color));
  --spire-line: color-mix(in srgb, var(--text-color) 18%, var(--background-color));
  --spire-muted: color-mix(in srgb, var(--text-color) 60%, var(--background-color));
  --spire-sans: "ff-tisa-sans-web-pro", Arial, sans-serif;
}

.spire {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.spire[hidden],
.spire [hidden] {
  display: none;
}

.spire-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.spire-section h2 {
  margin: 1rem 0 0 0;
}

.spire-note {
  margin: 0;
  font-size: 0.9rem;
}

.spire-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: flex-end;
}

.spire-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  min-width: 0;
  max-width: 100%;
}

.spire-field select,
.spire-field input,
.spire-buttons button {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-color);
  background-color: var(--background-color);
  border: 1px solid var(--spire-line);
  border-radius: 4px;
  padding: 4px 8px;
  max-width: 100%;
}

.spire-field input[type="search"] {
  width: 14rem;
}

.spire-buttons {
  display: inline-flex;
}

.spire-buttons button {
  cursor: pointer;
  border-radius: 0;
  margin-left: -1px;
}

.spire-buttons button:first-child {
  border-radius: 4px 0 0 4px;
  margin-left: 0;
}

.spire-buttons button:last-child {
  border-radius: 0 4px 4px 0;
}

.spire-buttons button {
  color: var(--spire-muted);
}

.spire-buttons button[aria-pressed="true"] {
  color: var(--text-color);
  background-color: var(--spire-panel);
}

/* Wider than the page's 650px column when the window allows, centered on
   it; a table wider still scrolls sideways. A fixed width, not the
   content's, so filtering rows doesn't resize the box. A block holds a
   table's controls and the table (or tables) they filter, sharing one
   left edge. */
.spire-block,
.spire-table-wrap {
  width: min(1000px, 100vw - 48px);
  min-width: 100%;
  max-width: min(1000px, 100vw - 48px);
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

.spire-table-wrap {
  overflow: auto;
  border: 1px solid var(--spire-line);
  border-radius: 4px;
}

.spire-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Inside a block, the block does the sizing. */
.spire-block .spire-table-wrap {
  width: auto;
  min-width: 0;
  max-width: none;
  left: 0;
  transform: none;
}

/* The count of rows shown, at the far end of the controls. */
.spire-count {
  margin-left: auto;
  padding-bottom: 5px;
  font-size: 0.85rem;
  color: var(--spire-muted);
  font-variant-numeric: tabular-nums lining-nums;
}

/* Tables that don't filter can be as wide as their content: still
   centered (snug), or flush with the text (fit). */
.spire-table-wrap.snug,
.spire-table-wrap.fit {
  width: max-content;
}

/* A small table: only as wide as it is, flush with the text. */
.spire-table-wrap.fit {
  min-width: 0;
  left: 0;
  transform: none;
}

/* Long tables scroll inside a box of their own. */
.spire-table-wrap.tall {
  max-height: 36rem;
}

.loading .spire-table-wrap {
  opacity: 0.5;
}

.spire-table {
  width: 100%;
  font-family: var(--spire-sans);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums lining-nums;
}

.spire-table th,
.spire-table td {
  padding: 6px 10px;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--spire-line);
}

.spire-table .text {
  text-align: left;
}

.spire-table tbody tr:last-child td {
  border-bottom: 0;
}

.spire-table th {
  position: sticky;
  top: 0;
  background-color: var(--spire-panel);
  vertical-align: bottom;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--spire-muted);
}

/* The first column stays put while the rest scroll sideways. */
.spire-table td:first-child {
  position: sticky;
  left: 0;
  background-color: var(--background-color);
}

.spire-table th:first-child {
  position: sticky;
  left: 0;
}

.spire-table th:first-child {
  z-index: 1;
}

.spire-table th button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}

.spire-table th[aria-sort="ascending"] button::after {
  content: " ▲";
}

.spire-table th[aria-sort="descending"] button::after {
  content: " ▼";
}

.spire-table .muted {
  color: var(--spire-muted);
}

.spire-table .good {
  color: var(--blue);
}

.spire-table .bad {
  color: var(--orange-highlight);
}

/* A table read across: names over values, as wide as it needs. */
.spire-table.across {
  width: auto;
}

.spire-table.across th,
.spire-table.across td {
  text-align: left;
  padding-right: 28px;
}

.spire-table .hint {
  display: block;
  max-width: 34ch;
  white-space: normal;
  font-size: 0.75rem;
  color: var(--spire-muted);
}

/* Events: a row per event, then its screens and options indented. */
.spire-table tr.event td {
  font-weight: 600;
  background-color: var(--spire-panel);
}

.spire-table tr.screen td {
  font-size: 0.75rem;
  color: var(--spire-muted);
  padding-left: 22px;
}

.spire-table td.option {
  padding-left: 22px;
}

.spire-table td.option.deep {
  padding-left: 34px;
}

.spire-lede {
  margin: 0;
}

.spire-section h3 {
  margin: 0.5rem 0 0 0;
  font-size: 1rem;
}

.spire-error {
  margin: 0;
  color: var(--orange-highlight);
}

.spire-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.spire-figure {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1 1 10rem;
  padding: 0.75rem 1rem;
  background-color: var(--spire-panel);
  border: 1px solid var(--spire-line);
  border-radius: 4px;
  font-variant-numeric: tabular-nums lining-nums;
}

.spire-figure > span,
.spire-figure > small {
  font-size: 0.8rem;
  color: var(--spire-muted);
}

.spire-figure > b {
  font-size: 1.6rem;
  font-weight: normal;
}

/* The pass and act stay in view while the tables below scroll by. */
.spire-sticky {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.5rem 0;
  background-color: var(--background-color);
  border-bottom: 1px solid var(--spire-line);
}

.spire-defs {
  font-size: 0.85rem;
}

.spire-defs summary {
  cursor: pointer;
}

.spire-defs dt {
  font-weight: bold;
  margin-top: 0.5rem;
}

.spire-defs dd {
  margin: 0;
}

/* Icons beside names (icons.ts). The hint under a name lines up with the
   name, not the icon. */
.spire-icon {
  width: 24px;
  height: 24px;
  margin-right: 6px;
  vertical-align: middle;
}

.spire-table .has-icon .hint {
  padding-left: 30px;
}

/* The nav between the /spire/ pages. */
.spire-nav {
  display: flex;
  gap: 1.25rem;
  margin: 0 0 1rem 0;
  font-family: var(--spire-sans, "ff-tisa-sans-web-pro", Arial, sans-serif);
  font-size: 0.95rem;
  border-bottom: 1px solid color-mix(in srgb, var(--text-color) 18%, var(--background-color));
}

.spire-nav a {
  padding: 4px 0 6px 0;
  text-decoration: none;
  color: color-mix(in srgb, var(--text-color) 60%, var(--background-color));
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.spire-nav a[aria-current="page"] {
  color: var(--text-color);
  border-bottom-color: var(--blue);
}

/* The learning curve (about/curve.ts). */
.spire-curve-plot {
  position: relative;
  width: 100%;
}

.spire-curve-plot svg {
  display: block;
  font-family: var(--spire-sans);
  font-size: 11px;
}

.curve-grid line {
  stroke: var(--spire-line);
  stroke-width: 1;
}

.curve-grid text,
.curve-changes text {
  fill: var(--spire-muted);
}

.curve-changes line {
  stroke: var(--spire-line);
  stroke-dasharray: 3 3;
}

.curve-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
}

.spire-legend line {
  stroke-width: 2;
}

/* A line's colour, by slot (curve.ts gives each line one): the reference
   categorical palette, validated against each mode's background. Marks
   take it as currentColor. The kinds' legend is in the text colour. */
.spire-curve {
  --curve-1: #257de0;
  --curve-2: #f47230;
  --curve-3: #00b894;
  --curve-4: #f2a600;
  --curve-5: #ee7fac;
  --curve-6: #008a17;
  --curve-7: #6a4ce2;
  --curve-8: #ec4647;
  color: var(--text-color);
}

[data-color-theme="dark"] .spire-curve {
  --curve-1: #338ced;
  --curve-2: #e76624;
  --curve-3: #00a888;
  --curve-4: #d28e05;
  --curve-5: #e24d8b;
  --curve-6: #0aac23;
  --curve-7: #9887ef;
  --curve-8: #eb6263;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-color-theme]) .spire-curve {
    --curve-1: #338ced;
    --curve-2: #e76624;
    --curve-3: #00a888;
    --curve-4: #d28e05;
    --curve-5: #e24d8b;
    --curve-6: #0aac23;
    --curve-7: #9887ef;
    --curve-8: #eb6263;
  }
}

.curve-series.s1 { color: var(--curve-1); }
.curve-series.s2 { color: var(--curve-2); }
.curve-series.s3 { color: var(--curve-3); }
.curve-series.s4 { color: var(--curve-4); }
.curve-series.s5 { color: var(--curve-5); }
.curve-series.s6 { color: var(--curve-6); }
.curve-series.s7 { color: var(--curve-7); }
.curve-series.s8 { color: var(--curve-8); }
.curve-series.minor { color: var(--spire-muted); }

.curve-greedy {
  stroke: currentColor;
  fill: currentColor;
}

.curve-line.curve-greedy {
  fill: none;
}

.curve-series.minor .curve-line.curve-greedy {
  stroke-width: 1.25;
}

circle.curve-greedy {
  stroke: var(--background-color);
  stroke-width: 2;
}

.curve-training {
  stroke: currentColor;
  fill: none;
}

.curve-line.curve-training {
  stroke-width: 1.25;
  opacity: 0.55;
}

.curve-lines .muted {
  color: var(--spire-muted);
}

.spire-curve .spire-controls {
  margin-bottom: 0.75rem;
}

.spire-curve .spire-legend + .spire-legend {
  margin-top: 0.35rem;
}

.curve-label {
  fill: var(--text-color);
}

.curve-label.muted {
  fill: var(--spire-muted);
}

.curve-cross {
  stroke: var(--spire-muted);
  stroke-width: 1;
  pointer-events: none;
}

.curve-hit {
  fill: transparent;
  outline: none;
}

.curve-hit:focus-visible {
  stroke: var(--blue);
  stroke-width: 1;
}

.spire-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--spire-sans);
  font-size: 0.8rem;
}

.spire-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.spire-tooltip {
  position: absolute;
  pointer-events: none;
  padding: 6px 10px;
  font-family: var(--spire-sans);
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: nowrap;
  background-color: var(--background-color);
  border: 1px solid var(--spire-line);
  border-radius: 4px;
}

.spire-tooltip .tip-head {
  font-weight: 600;
}

.spire-tooltip .tip-sub {
  color: var(--spire-muted);
}

.spire-changes {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

.spire-changes li {
  padding-left: 1.75rem;
  text-indent: -1.75rem;
}

.spire-changes .change-number {
  display: inline-block;
  width: 1.75rem;
  text-indent: 0;
  font-family: var(--spire-sans);
  color: var(--spire-muted);
}

.spire-changes li + li {
  margin-top: 0.35rem;
}

/* The replays page: the list of runs. */
.replay-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.replay-cards a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text-color);
  border: 1px solid var(--spire-line);
  border-radius: 6px;
}

.replay-cards a:hover,
.replay-cards a:focus-visible {
  background-color: var(--spire-panel);
}

.replay-card-head {
  font-weight: 600;
  color: var(--blue);
}

.replay-card-caption {
  font-size: 0.9rem;
}

.replay-card-meta {
  font-family: var(--spire-sans);
  font-size: 0.75rem;
  color: var(--spire-muted);
}

/* One run. */
.replay-header h2 {
  margin: 0.25rem 0;
}

.replay-header p {
  margin: 0.25rem 0;
}

.replay-back {
  font-family: var(--spire-sans);
  font-size: 0.85rem;
}

.replay-caption {
  font-style: italic;
}

/* The summary, wider than the column like the stats tables: three
   columns on a wide window, two on a middling one, one on a phone. */
.replay-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem 2rem;
  width: min(1000px, 100vw - 48px);
  min-width: 100%;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  margin: 1rem 0;
}

@media (min-width: 640px) {
  .replay-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .replay-block.wide {
    grid-column: span 2;
  }
}

.replay-block.full {
  grid-column: 1 / -1;
}

@media (min-width: 960px) {
  .replay-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.replay-block {
  min-width: 0;
  overflow-x: auto;
}

.replay-block h3 {
  margin: 0 0 0.4rem 0;
  font-size: 1rem;
}

.replay-table {
  width: auto;
}

.replay-table th img {
  display: block;
  margin: 0 auto 2px;
}

/* Neow, the bosses and the Ancients: each boss, then the choices after
   it, every option with the policy's probability, the chosen one bold. */
.replay-milestones {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--spire-sans);
  font-size: 0.85rem;
}

.replay-boss .who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.6em;
}

.replay-boss {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--spire-line);
}

.replay-boss .spire-icon {
  margin-right: 0;
}

.replay-boss .hp {
  color: var(--spire-muted);
}

.replay-choice .options {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 1.25em;
}

.replay-choice .option {
  white-space: nowrap;
}

.replay-choice .option.chosen {
  color: var(--blue);
  font-weight: 600;
}

.replay-choice .p {
  margin-left: 0.5em;
  font-weight: normal;
  font-size: 0.75rem;
  color: var(--spire-muted);
  font-variant-numeric: tabular-nums;
}

.replay-choice .win {
  margin-left: 0.5em;
  font-size: 0.75rem;
  color: var(--spire-muted);
  white-space: nowrap;
}

/* Relics: a grid of icons, each named on hover; one without an icon
   shows its name. */
.replay-relics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--spire-sans);
  font-size: 0.75rem;
}

.replay-relic {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  box-sizing: border-box;
  border-radius: 4px;
  background-color: var(--spire-panel);
  cursor: default;
}

.replay-relic .spire-icon {
  width: 32px;
  height: 32px;
  margin: 0;
}

.replay-relic:not(.has-icon) {
  padding: 0 6px;
}

.replay-relic.has-icon .name {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The deck: a row per card type, the cards comma-separated. */
.replay-deck {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--spire-sans);
  font-size: 0.8rem;
}

.replay-cards-row {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  align-items: baseline;
}

.replay-cards-row .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0.4em;
}

.replay-cards-row .group {
  font-weight: 600;
  color: var(--spire-muted);
}

.replay-cards-row .chip {
  white-space: nowrap;
}

.replay-cards-row .chip:not(:last-child)::after {
  content: ",";
}

.replay-cards-row .count {
  color: var(--spire-muted);
}

/* One run's play-by-play. */
.replay-plays {
  margin-top: 2rem;
}

.replay-plays > h3 {
  margin: 0 0 0.25rem 0;
}

.replay-floors {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--background-color);
  font-family: var(--spire-sans);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.replay-floors b {
  margin-left: 6px;
  color: var(--spire-muted);
  font-weight: 600;
}

.replay-floors b:first-child {
  margin-left: 0;
}

/* Sans, like the tables; structure from indentation and weight. Lines
   hang, so a wrapped line stays under its own start. */
.replay-log {
  font-family: var(--spire-sans);
  font-size: 0.88rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.replay-log h4 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 0.75em;
  margin: 1.25rem 0 0.25rem 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--spire-line);
  font-family: var(--spire-sans);
  font-size: 0.95rem;
  scroll-margin-top: 3rem;
}

.replay-log h4 a {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.replay-log h4 .room {
  font-weight: 600;
}

.replay-log h4 .status {
  font-weight: normal;
  font-size: 0.85rem;
  color: var(--spire-muted);
}

.replay-log h4.act {
  margin-top: 2rem;
  border-top: none;
  font-size: 1.05rem;
}

.replay-log .line {
  padding-left: calc(var(--depth, 1) * 1.25em + 1.25em);
  text-indent: -1.25em;
}

.replay-log .turn {
  margin-top: 0.5rem;
  font-weight: 600;
}

.replay-log .hand,
.replay-log .action {
  --depth: 2;
}

.replay-log .hand {
  font-size: 0.8rem;
  color: var(--blue);
}

.replay-log .offer {
  margin-top: 0.35rem;
  color: var(--spire-muted);
}

.replay-log .effect {
  color: var(--spire-muted);
}

.replay-log .note {
  --depth: 0;
  margin-top: 1rem;
  font-weight: 600;
}

.replay-log .win {
  margin-left: 0.6em;
  font-size: 0.8rem;
  color: var(--spire-muted);
  white-space: nowrap;
}

/* A potion or relic named in a line, its icon before it. */
.replay-log .item {
  white-space: nowrap;
  text-indent: 0;
}

.replay-log .item .spire-icon,
.replay-log h4 .spire-icon {
  width: 20px;
  height: 20px;
  margin-right: 3px;
}

.replay-log h4 a .spire-icon {
  width: 24px;
  height: 24px;
  margin-right: 6px;
}
