/* Explosion calculator. #xpl-scoped throughout: css/tool-theme.css loads AFTER this file and
 * re-skins buttons, inputs, tabs and anything whose class contains "result", "-out" or
 * "output", so a plain class rule loses the tie. Where this file must beat the generic
 * `#tool-root button:not(.btn):not([class*="tab"])` rule, which is (1,2,1), it uses two ids —
 * `#tool-root #xpl …` is (2,x,x) — because merely tying loses to the later file. See CLAUDE.md.
 */

#xpl { display: block; }
#xpl [hidden] { display: none !important; }

#xpl .xpl-field { display: block; min-width: 0; }
#xpl .xpl-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .72;
  margin-bottom: 6px;
}
#xpl .xpl-hint { display: block; margin-top: 6px; font-size: 12.5px; line-height: 1.5; opacity: .75; }
#xpl input[type="text"],
#xpl input[type="number"],
#xpl input[type="search"],
#xpl select { width: 100%; }
/* A range input carries a 2px UA margin per side; width:100% is then 4px of overflow. */
#xpl input[type="range"] { width: 100%; margin-left: 0; margin-right: 0; }

/* The source bar ----------------------------------------------------------------------------- */
#xpl .xpl-sourcebar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
#xpl .xpl-sourcepick { flex: 1 1 260px; }
#xpl .xpl-powerfield { flex: 0 1 150px; }
#xpl .xpl-facts {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin: 10px 0 12px; font-size: 13px; line-height: 1.5;
  unicode-bidi: isolate;
}
#xpl .xpl-fact b { font-weight: 800; }
#xpl .xpl-fact code { font-size: 12px; }

#xpl .xpl-rules { margin: 0 0 14px; font-size: 13.5px; }
#xpl .xpl-rules summary { cursor: pointer; font-weight: 700; }
#xpl .xpl-rulegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; margin-top: 10px; }
#xpl .xpl-check { display: flex; align-items: center; gap: 8px; min-width: 0; }
#xpl .xpl-check code { overflow-wrap: anywhere; }

/* Tabs and segmented buttons ---------------------------------------------------------------- */
#xpl .xpl-modes { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 18px; }
#xpl .xpl-tab { padding: 8px 14px; border-radius: 8px; font-weight: 700; font-size: 14px; cursor: pointer; }
#xpl .xpl-segs { display: flex; flex-wrap: wrap; gap: 6px; }
#xpl .xpl-seg { padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; }
/* aria-pressed IS the state; two ids to outrank tool-theme's generic button rule. */
#tool-root #xpl .xpl-seg[aria-pressed="true"] {
  background: var(--grass-deep);
  border-color: var(--line-strong);
  color: var(--grass-bright);
}
#xpl .xpl-edition { margin-bottom: 16px; }

/* Layout -------------------------------------------------------------------------------------- */
#xpl .xpl-simgrid {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
@media (max-width: 860px) {
  #xpl .xpl-simgrid { grid-template-columns: minmax(0, 1fr); }
}
#xpl .xpl-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
#xpl .xpl-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#xpl .xpl-twin { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#xpl .xpl-triple { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
#xpl .xpl-seedrow { display: flex; gap: 8px; }
#xpl .xpl-seedrow input { flex: 1 1 auto; min-width: 0; }
#xpl .xpl-btn { padding: 8px 14px; border-radius: 9px; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap; }

/* The preview --------------------------------------------------------------------------------- */
#xpl .xpl-viewbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#xpl .xpl-stage {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #8fb8de;
  line-height: 0;
}
#xpl .xpl-stage canvas { display: block; width: 100%; height: auto; image-rendering: auto; }
#xpl .xpl-sliderow { margin-top: -4px; }
#xpl .xpl-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; }
#xpl .xpl-key { display: inline-flex; align-items: center; gap: 6px; }
#xpl .xpl-swatch {
  display: inline-block; width: 14px; height: 14px; border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, .35); flex: 0 0 auto;
}

/* Numbers ------------------------------------------------------------------------------------- */
#xpl .xpl-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; unicode-bidi: isolate; }
#xpl .xpl-stat { padding: 11px 13px; border-radius: 10px; background: rgba(127, 127, 127, .10); min-width: 0; }
#xpl .xpl-statlabel {
  display: block; font-size: 10px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; opacity: .7;
}
#xpl .xpl-statvalue { display: block; font-size: 21px; line-height: 1.2; margin-top: 3px; overflow-wrap: anywhere; }
#xpl .xpl-statsub { display: block; margin-top: 3px; font-size: 11.5px; opacity: .7; }

#xpl .xpl-broke { font-size: 13.5px; line-height: 1.6; }
#xpl .xpl-broke ul { margin: 6px 0 0; padding-left: 18px; }

#xpl .xpl-verdict { padding: 14px 16px; border-radius: 12px; background: rgba(127, 127, 127, .10); }
#xpl .xpl-verdict strong { display: block; font-size: 26px; line-height: 1.2; }
#xpl .xpl-verdict span { display: block; margin-top: 4px; font-size: 14px; opacity: .8; }
#xpl .xpl-verdict.xpl-fatal { box-shadow: inset 4px 0 0 #d9463b; }
#xpl .xpl-verdict.xpl-alive { box-shadow: inset 4px 0 0 #3aa45a; }

#xpl .xpl-steps { display: flex; flex-direction: column; gap: 0; border-radius: 10px; overflow: hidden; unicode-bidi: isolate; }
#xpl .xpl-step {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 8px 12px; border-top: 1px solid rgba(127, 127, 127, .22); font-size: 13.5px;
}
#xpl .xpl-step:first-child { border-top: 0; }
#xpl .xpl-step span:first-child { opacity: .8; }
#xpl .xpl-step span:last-child { font-family: var(--font-mono, ui-monospace, monospace); font-weight: 700; text-align: right; }

#xpl .xpl-chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
#xpl .xpl-bar { flex: 1 1 0; min-width: 0; background: var(--grass, #3aa45a); border-radius: 3px 3px 0 0; }
#xpl .xpl-chartaxis { display: flex; justify-content: space-between; font-size: 11px; opacity: .7; margin-top: 4px; }

/* Table --------------------------------------------------------------------------------------- */
#xpl .xpl-tablebar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 8px; }
#xpl .xpl-grow { flex: 1 1 240px; }
#xpl .xpl-tablebar .xpl-field:not(.xpl-grow) { flex: 0 1 190px; }
#xpl .xpl-tablewrap { overflow-x: auto; }
#xpl .xpl-table td, #xpl .xpl-table th { white-space: nowrap; }
#xpl .xpl-table td:nth-child(n+2), #xpl .xpl-table th:nth-child(n+2) { text-align: right; }
#xpl .xpl-table td:nth-child(n+2) { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
#xpl .xpl-blockcell { display: inline-flex; align-items: center; gap: 8px; }
#xpl .xpl-actions { display: flex; gap: 8px; margin-top: 10px; }

/* Knockback ----------------------------------------------------------------------------------- */
#xpl .xpl-kvec { font-family: var(--font-mono, ui-monospace, monospace); font-size: 13.5px; line-height: 1.7; unicode-bidi: isolate; }
#xpl .xpl-knote { font-size: 13.5px; line-height: 1.6; }
#xpl .xpl-knote p { margin: 0 0 8px; }

#xpl .xpl-status { margin: 14px 0 0; min-height: 1.2em; font-size: 13px; opacity: .85; }
#xpl .xpl-help { margin-top: 20px; font-size: 14.5px; line-height: 1.65; max-width: 76ch; }
#xpl .xpl-help p { margin: 0 0 10px; }

/* Right-to-left pages: the numbers, vectors and ids stay left-to-right (CLAUDE.md, bidi). */
[dir="rtl"] #xpl .xpl-facts,
[dir="rtl"] #xpl .xpl-stats,
[dir="rtl"] #xpl .xpl-steps,
[dir="rtl"] #xpl .xpl-kvec { direction: ltr; }
