/* Interactive sizing calculator (web/static-js/sizing-calculator.js). */

.exaba-calc {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.exaba-calc-flags {
  display: flex;
  gap: 0.45em;
  align-items: baseline;
  font-size: 0.8rem;
  margin: 0.55rem 0 0;
  color: var(--text-muted);
}

.exaba-calc-flags code {
  overflow-x: auto;
}

.exaba-calc-field input:disabled {
  opacity: 0.45;
}

.exaba-calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.9rem 1.1rem;
  margin-bottom: 0.9rem;
}

.exaba-calc-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* Direct children only: the goal switch nests its own labels and inputs
   inside a field, and they carry the control's styling, not the caption's. */
.exaba-calc-field > label {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem;
}

.exaba-calc-info {
  flex: 0 0 auto;
}

.exaba-calc-field > input,
.exaba-calc-field > select {
  background: var(--bg-page);
  color: var(--text-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.55rem;
  font: inherit;
  font-size: 0.9rem;
  min-width: 0;
  height: 2.25rem;
  box-sizing: border-box;
  /* Anchor inputs to the field bottom so a wrapping label doesn't push
     its input out of line with the rest of the row. */
  margin-top: auto;
}

.exaba-calc-field > input:focus,
.exaba-calc-field > select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.exaba-calc-results {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

/* Headline stats: hero value over a muted label. */
.exaba-calc-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.9rem 1.1rem;
  margin-bottom: 0.9rem;
}

.exaba-calc-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
}

.exaba-calc-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-heading);
  font-variant-numeric: tabular-nums;
}

.exaba-calc-stat-badge {
  background: var(--accent);
  color: #0A0A0A;
  align-self: flex-start;
  padding: 0.05rem 0.5rem;
  border-radius: var(--radius-sm);
}

.exaba-calc-stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.exaba-calc-stat-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.exaba-calc-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.28rem 0;
  font-size: 0.92rem;
}

.exaba-calc-row-label {
  flex: 0 0 15rem;
  color: var(--text-muted);
}

.exaba-calc-row-value {
  font-weight: 600;
  color: var(--text-heading);
  font-variant-numeric: tabular-nums;
}

.exaba-calc-row-extra {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.exaba-calc-rec {
  border: 1px solid var(--border-strong, var(--border));
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin: 0.55rem 0;
}

/* Black-on-yellow badge in the theme's accent pairing, readable in both
   light and dark because --accent is the same yellow in each. */
.exaba-calc-rec .exaba-calc-row-value {
  background: var(--accent);
  color: #0A0A0A;
  padding: 0.1rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
}

/* Efficiency-by-node-count chart in the details section. */
.exaba-calc-chart-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.6rem 0 0.3rem;
}

.exaba-calc-chart-wrap {
  display: flex;
  gap: 0.45rem;
  position: relative;
}

.exaba-calc-chart-tip {
  position: absolute;
  top: -6px;
  transform: translate(-50%, -100%);
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  color: var(--text-body);
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
}

.exaba-calc-chart-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 2.4rem;
  flex: 0 0 auto;
  text-align: right;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.exaba-calc-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 110px;
  flex: 1 1 auto;
  min-width: 0;
}

.exaba-calc-bar {
  flex: 1 1 0;
  min-width: 0;
  background: linear-gradient(180deg, var(--accent),
    color-mix(in srgb, var(--accent) 30%, transparent));
  border-radius: 3px 3px 0 0;
}

.exaba-calc-bar-miss {
  background: linear-gradient(180deg, var(--border),
    color-mix(in srgb, var(--border) 30%, transparent));
}

.exaba-calc-bar-pick {
  outline: 2px solid var(--text-heading);
  outline-offset: -2px;
}

.exaba-calc-chart-labels {
  display: flex;
  gap: 2px;
  margin-left: 2.85rem;
  margin-bottom: 0.4rem;
}

.exaba-calc-chart-labels span {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-muted);
  overflow: hidden;
}

/* Goal switch: which target the cluster is sized for. Sized like an
   input so it sits level with the fields either side of it. */
.exaba-calc-segment {
  display: flex;
  margin-top: auto;
  height: 2.25rem;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.exaba-calc-seg {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
}

.exaba-calc-seg + .exaba-calc-seg {
  border-left: 1px solid var(--border);
}

.exaba-calc-seg:hover {
  color: var(--text-heading);
}

.exaba-calc-seg-on {
  background: var(--accent);
  color: #0A0A0A;
  font-weight: 600;
}

.exaba-calc-seg-on:hover {
  color: #0A0A0A;
}

/* The radio itself is only there for keyboard and form semantics. The
   label is the control, so the focus ring belongs on the label. */
.exaba-calc-seg input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

.exaba-calc-seg input:focus {
  outline: none;
}

.exaba-calc-seg:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* A field wide enough for the switch, keeping the grid's column rhythm. */
.exaba-calc-field-wide {
  grid-column: span 2;
}

/* Details / Math toggle chips under the results. */
.exaba-calc-togglewrap {
  margin-top: 1.1rem;
}

.exaba-calc-togglewrap .exaba-calc-divider {
  margin-bottom: 1rem;
}

.exaba-calc-toggles {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
}

.exaba-calc-toggle {
  background: none;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-heading);
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.75rem;
}

.exaba-calc-toggle:hover {
  border-color: var(--accent);
}

.exaba-calc-toggle-on {
  border-color: var(--accent);
}

/* The winning constraint's tag, in the same accent language as the badge. */
.exaba-calc-deciding {
  background: var(--accent);
  color: #0A0A0A;
  padding: 0 0.45rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Preset buttons: one click fills the sizing inputs. */
.exaba-calc-presets {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.exaba-calc-preset {
  background: var(--bg-page);
  color: var(--text-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.exaba-calc-preset:hover {
  border-color: var(--accent);
}

.exaba-calc-preset-active {
  border-color: var(--accent);
  color: var(--text-heading);
  font-weight: 600;
}

/* Math section: one full-width block per formula. Each block is a
   two-row table, symbolic row over substituted row, with the answer
   column on the right so the expressions align. */
.exaba-calc-math-grid {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.4rem;
}

.exaba-calc-math-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  min-width: 0;
}

.exaba-calc-math-name {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.exaba-calc-math-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.exaba-calc-math-table td {
  padding: 0.05rem 0;
  border: none;
}

.exaba-calc-math-expr {
  width: 100%;
}

.exaba-calc-math-answer {
  text-align: right;
  white-space: nowrap;
  padding-left: 0.9rem;
}

.exaba-calc-math-formula code {
  color: var(--text-body);
}

.exaba-calc-math-values code {
  color: var(--text-muted);
}


/* One color per variable, consistent across formula and values. */
.exaba-calc-var { font-weight: 600; }
.exaba-calc-var-nodes { color: #5B9BD5; }
.exaba-calc-var-span { color: #7E9FD8; }
.exaba-calc-var-drives { color: #AB7DF6; }
.exaba-calc-var-ideal { color: #26A69A; }
.exaba-calc-var-width { color: #E0A93B; }
.exaba-calc-var-frags { color: #4DB6AC; }
.exaba-calc-var-parity { color: #EF5350; }
.exaba-calc-var-minparity { color: #B968C7; }
.exaba-calc-var-t { color: #F2994A; }
.exaba-calc-var-e { color: #A98274; }
.exaba-calc-var-k { color: #66BB6A; }
.exaba-calc-var-eff { color: #4FC3F7; }
.exaba-calc-var-raw { color: #90A4AE; }
.exaba-calc-var-usable { color: #FFB74D; }
.exaba-calc-var-floor { color: var(--text-heading); }
.exaba-calc-var-nines { color: var(--text-heading); }
.exaba-calc-var-afrd { color: #90A4AE; }
.exaba-calc-var-afrn { color: #BCAAA4; }
.exaba-calc-var-window { color: #9FA8DA; }
.exaba-calc-var-pd { color: #4DD0E1; }
.exaba-calc-var-pn { color: #F48FB1; }
.exaba-calc-var-p { color: var(--text-heading); }

.exaba-calc-divider {
  border-top: 1px solid var(--border);
  margin: 0 0 0.9rem;
}

.exaba-calc-hidden {
  display: none;
}

.exaba-calc-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0.55rem 0 0;
  display: flex;
  gap: 0.45em;
  align-items: baseline;
}

.exaba-calc-note-icon {
  flex: 0 0 auto;
}

.exaba-calc-note-warn .exaba-calc-note-icon {
  color: var(--accent);
}

@media (max-width: 40rem) {
  .exaba-calc-row {
    flex-wrap: wrap;
  }
  .exaba-calc-row-label {
    flex-basis: 100%;
  }
}
