/*
 * Tool pages (TOOLS-01): the box value calculator and the provably fair checker. Loaded only on
 * those two pages, after rb.css. Colors come from the theme tokens in rb.css; nothing here sets
 * a color of its own.
 */

.rb-tool-intro { padding-bottom: 32px; }

.rb-tool-grid {
  display: grid;
  gap: 24px;
  align-items: start;
}
@media (min-width: 960px) {
  .rb-tool-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 32px; }
}

.rb-tool-panel {
  min-width: 0;
  padding: 24px;
  background: var(--rb-white);
  border: 1px solid var(--rb-n200);
}
@media (max-width: 759px) {
  .rb-tool-panel { padding: 20px 16px; }
}

.rb-tool-h { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; line-height: 1.2; }

/* ---------- Fields ---------- */

.rb-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rb-field label { font-size: 13px; font-weight: 800; }
.rb-field input,
.rb-field select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--rb-n500);
  border-radius: var(--rb-radius);
  background: var(--rb-white);
  color: var(--rb-ink);
}
.rb-field input[aria-invalid="true"] { border: 2px solid var(--rb-red-text); }
.rb-field-help { font-size: 13px; line-height: 1.45; color: var(--rb-n600); }

.rb-calc-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}
.rb-calc-top .rb-field--wide { grid-column: 1 / -1; }

.rb-calc-items { margin: 24px 0 0; padding: 0; border: 0; min-width: 0; }
.rb-calc-items legend { padding: 0; font-size: 16px; font-weight: 900; }
.rb-calc-rows { list-style: none; margin: 8px 0 0; padding: 0; }
.rb-calc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 12px;
  align-items: end;
  padding: 14px 0;
  border-bottom: 1px solid var(--rb-n200);
}
.rb-calc-row .rb-field--name { grid-column: 1 / -1; }
.rb-calc-remove {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--rb-red-text);
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}
.rb-calc-remove[hidden] { display: none; }
@media (min-width: 600px) {
  .rb-calc-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; }
  .rb-calc-row .rb-field--name { grid-column: auto; }
  .rb-calc-remove { grid-column: auto; }
}
.rb-calc-add { margin-top: 16px; }
.rb-calc-add[hidden] { display: none; }

/* ---------- Results ---------- */

.rb-tool-example {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--rb-disclosure);
  border-left: 4px solid var(--rb-red);
  font-size: 14px;
  font-weight: 600;
}
.rb-tool-link {
  margin-top: 8px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--rb-red-text);
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}
.rb-tool-link[hidden] { display: none; }
.rb-tool-warn,
.rb-tool-error {
  margin-top: 12px;
  padding: 10px 12px;
  border: 2px solid var(--rb-red-text);
  color: var(--rb-red-text);
  font-size: 14px;
  font-weight: 700;
}
.rb-tool-warn[hidden], .rb-tool-error[hidden] { display: none; }

.rb-tool-stats { margin: 16px 0 0; }
.rb-tool-stats > div { padding: 12px 0; border-bottom: 1px solid var(--rb-n200); }
.rb-tool-stats dt { font-size: 13px; font-weight: 700; color: var(--rb-n600); }
.rb-tool-stats dd { margin: 4px 0 0; font-size: 20px; font-weight: 900; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.rb-tool-stats > div[hidden] { display: none; }
[data-rb-fair-state="differ"] [data-rb-fair="hash"] { color: var(--rb-red-text); }
[data-rb-fair="hash"] { font-size: 16px; font-weight: 800; }

.rb-tool-empty, .rb-tool-small { margin-top: 12px; font-size: 14px; line-height: 1.5; color: var(--rb-n700); }
.rb-tool-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.rb-fair .rb-field + .rb-field { margin-top: 16px; }
.rb-fair .rb-field:first-of-type { margin-top: 16px; }

.rb-tool-details { margin-top: 16px; font-size: 14px; }
.rb-tool-details summary { min-height: 44px; display: flex; align-items: center; font-weight: 800; cursor: pointer; }
.rb-tool-working dt { margin-top: 10px; font-weight: 700; color: var(--rb-n600); }
.rb-tool-working dd { margin: 2px 0 0; }
.rb-tool-working code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; word-break: break-all; }

/* Without JavaScript the results stay empty: say so, and hide what would stay blank. */
.rb-tool-nojs { margin-top: 12px; font-size: 14px; font-weight: 700; }
.rb-js .rb-tool-nojs { display: none; }
html:not(.rb-js) .rb-tool-stats,
html:not(.rb-js) .rb-tool-example,
html:not(.rb-js) .rb-tool-empty,
html:not(.rb-js) .rb-tool-actions,
html:not(.rb-js) .rb-calc-add,
html:not(.rb-js) .rb-calc-remove { display: none; }

/* ---------- The 100 openings charts ---------- */

.rb-tool-charts { display: grid; gap: 24px; margin-top: 24px; min-height: 320px; }
@media (min-width: 960px) {
  .rb-tool-charts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.rb-chart-figure { margin: 0; padding: 20px; background: var(--rb-white); border: 1px solid var(--rb-n200); min-width: 0; }
.rb-chart-title { font-size: 16px; font-weight: 900; }
.rb-chart { display: block; width: 100%; height: auto; margin-top: 12px; overflow: visible; }
.rb-chart text { font-family: var(--rb-font); font-size: 13px; font-weight: 700; fill: var(--rb-n700); }
.rb-chart-bar { fill: var(--rb-ink); }
.rb-chart-bar--loss { fill: var(--rb-n500); }
.rb-chart-axis { stroke: var(--rb-n600); stroke-width: 1; }
.rb-chart-zero { stroke: var(--rb-red-text); stroke-width: 2; stroke-dasharray: 4 3; }
.rb-chart-summary { margin-top: 12px; font-size: 14px; line-height: 1.5; color: var(--rb-n700); }
.rb-chart-wait { align-self: start; font-size: 15px; font-weight: 700; color: var(--rb-n700); }

.rb-tool-proves .rb-pair { margin-top: 24px; }
.rb-tool-content { padding-top: 56px; }
