/* AXLE CHECKER, BRIDGE CALCULATOR AND SOLVER: presentation fixes from the 1440 / 1024 / 390 audit.
   Linked after builder.css. Tokens only: no colour literals, spacing on the 4/8/12/16/24 ramp.
   Nothing here touches a figure or a verdict. */

/* ── 1. A result that no longer matches the inputs is dimmed and says so ─────────────────────────────────────────── */
.axc-results.is-stale,
#qt-static.is-stale,
#stats.is-stale,
#axs-results.is-stale { opacity: 0.45; transition: opacity 0.15s ease; }
.axc-status, .axs-stale { margin: 0 0 8px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-2); color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.5; }
.axc-status[data-mode="invalid"], .axc-status[data-mode="throttled"] { border-color: var(--warn); background: var(--warn-bg); }
.axc-fail { display: grid; gap: 8px; justify-items: start; }
.axc-fail .button { min-height: 44px; padding: 0 16px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }

/* ── 2. Invalid input: outline, a sentence that says why ─────────────────────────────────────────────────────────── */
.axc #axle-units input[aria-invalid="true"],
.axc.axs .setup-bar input[aria-invalid="true"] { outline: 2px solid var(--error) !important; outline-offset: 1px; border-color: var(--error) !important; background: var(--error-bg) !important; }
.axc-field-err, .axc.axs .axs-err { margin: 8px 0 0; padding: 8px 12px; border: 1px solid var(--error); border-radius: 6px; background: var(--error-bg); color: color-mix(in srgb, var(--error) 70%, var(--ink)); font-size: 13px; font-weight: 600; line-height: 1.5; }
.axc.axs .axs-err { flex: 1 1 100%; width: 100%; box-sizing: border-box; margin: 0; }

/* ── 4. Only the drawing scales; the controls keep their real size ───────────────────────────────────────────────── */
.axc #axle-units { --axc-k: 1; --axc-inv: 1; }
.axc #axle-units .axc-weights { height: calc((52px + (var(--rows, 1) - 1) * 48px) * var(--axc-inv)); }
.axc #axle-units .axc-weight { width: var(--axc-w, 56px); transform: translate(-50%, calc(var(--row, 0) * 48px * var(--axc-inv))) scale(var(--axc-inv)); transform-origin: 50% 0; }
.axc #axle-units .axc-weight input { font-size: 12px; min-width: 0; text-overflow: clip; }
.axc #axle-units .axc-gap { transform: translateX(-50%) scale(var(--axc-inv)); transform-origin: 50% 100%; }
.axc #axle-units .axle-unit header { min-height: calc(32px * var(--axc-inv)); }
.axc #axle-units .axle-count button { position: relative; transform: scale(var(--axc-inv)); transform-origin: 50% 50%; margin: 0 calc((var(--axc-inv) - 1) * 16px); }
@media (pointer: coarse) {
  .axc #axle-units .axle-unit header { min-height: calc(44px * var(--axc-inv)); }
  .axc #axle-units .axle-count button { width: 36px; height: 36px; margin: 0 calc(22px * var(--axc-inv) - 22px); }
  .axc #axle-units .axle-count button::after { content: ""; position: absolute; inset: -4px; }
  .axc #axle-units .axc-weight, .axc #axle-units .axc-gap { position: absolute; }
  .axc #axle-units .axc-weight::after, .axc #axle-units .axc-gap::after { content: ""; position: absolute; inset: -8px 0; }
  .axc .axc-marks-toggle { min-height: 44px; }
}

/* ── 6. Status colour: text that passes AA, a word and an icon for every state ──────────────────────────────────── */
.axc-results .axl-card.is-at { --axl-c: var(--warn); }
.axc-results .axl-card .axl-room,
.axc-results .axl-sl .axl-sl-b { display: inline-flex; align-items: center; gap: 4px; border: 1px solid currentColor; white-space: normal; text-align: left; }
.axc-results .axl-room .hh-r3-ico, .axc-results .axl-sl-b .hh-r3-ico { width: 14px; height: 14px; flex: none; }
.axc-results .axl-room.is-ok, .axc-results .axl-sl-b.is-ok { background: var(--success-bg); color: color-mix(in srgb, var(--success) 60%, var(--ink)) !important; }
.axc-results .axl-room.is-at, .axc-results .axl-room.is-near, .axc-results .axl-sl-b.is-at, .axc-results .axl-sl-b.is-unknown { background: var(--warn-bg); color: color-mix(in srgb, var(--warn) 60%, var(--ink)) !important; }
.axc-results .axl-room.is-over, .axc-results .axl-sl-b.is-over { background: var(--error-bg); color: color-mix(in srgb, var(--error) 70%, var(--ink)) !important; }
.axc-results .axl-figs .axl-pct.is-ok { color: color-mix(in srgb, var(--success) 60%, var(--ink)); }
.axc-results .axl-figs .axl-pct.is-at, .axc-results .axl-figs .axl-pct.is-near { color: color-mix(in srgb, var(--warn) 60%, var(--ink)); }
.axc-results .axl-figs .axl-pct.is-over { color: color-mix(in srgb, var(--error) 70%, var(--ink)); }
.qt-vd--ok { color: color-mix(in srgb, var(--success) 60%, var(--ink)); }
.qt-vd--at, .qt-vd--no { color: color-mix(in srgb, var(--warn) 60%, var(--ink)); }
.qt-unit-note { margin: 0 0 8px; font-size: 12px; color: var(--muted); }

/* ── 3 + 8. Ladders: the arithmetic is a full-width row; below 600px every row is a card with its verdict beside the name ─── */
.qt-work-row td { padding-top: 0; }
.qt-work-row .qt-work-x { max-width: none; }
@media (max-width: 600px) {
  #qt-ladder .qh-tablewrap, #qt-permits .qh-tablewrap { overflow: visible; border: 0; background: none; }
  .qt-ltable, .qt-ltable tbody { display: block; width: 100%; }
  .qt-ltable colgroup { display: none; }
  .qt-ltable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .qt-ltable tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; margin: 0 0 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
  .qt-ltable tbody tr.is-over { border-color: var(--warn); background: var(--warn-bg); }
  .qt-ltable tbody tr.is-clears { border-color: var(--success); background: var(--success-bg); }
  .qt-ltable tbody td { display: block; min-width: 0; padding: 0; border: 0 !important; box-shadow: none !important; background: none !important; text-align: left; white-space: normal; }
  .qt-ltable td.qh-st { grid-column: 1; grid-row: 1; }
  .qt-ltable td.qt-vcell { grid-column: 2; grid-row: 1; justify-self: end; text-align: right; }
  .qt-ltable td[data-label] { grid-column: 1 / -1; font-size: 13px; }
  .qt-ltable td[data-label]::before { content: attr(data-label) ": "; font-family: var(--font-sans, inherit); font-size: 12px; font-weight: 600; color: var(--muted); }
  .qt-ltable td.num { font-family: inherit; text-align: left; white-space: normal; }
  .qt-ltable tbody tr:has(+ .qt-work-row) { margin-bottom: 0; border-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .qt-ltable tbody tr.qt-work-row { display: block; margin: 0 0 8px; padding: 0 12px 4px; border-top: 0; border-radius: 0 0 12px 12px; }
  .qt-ltable tbody tr.qt-work-row td { padding: 0; }
}

/* ── 5. Solver: label above the input on a phone, so the value is never hidden under it ──────────────────────────── */
@media (max-width: 720px) {
  .axc.axs .setup-bar label.axs-field { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
  .axc.axs .axs-field .vis-prefix { position: static; transform: none; }
  .axc.axs .setup-bar label.axs-field input[type="number"] { height: 44px; padding-left: 12px; font-size: 16px; }
}

/* ── 8. Scroll cue on the rig picker, cards that do not stretch their neighbour ──────────────────────────────────── */
.axc .axc-pop-list { scrollbar-width: thin;
  background:
    linear-gradient(var(--axp-bg), var(--axp-bg)) bottom / 100% 24px local no-repeat,
    linear-gradient(to top, color-mix(in srgb, var(--ink) 22%, transparent), transparent) bottom / 100% 24px scroll no-repeat,
    var(--axp-bg); }
.axc-results .hh-r3-groups { align-items: start; }

/* ── 10. Focus rings on the drag handles, the foldable group list, the bridge title ─────────────────────────────── */
.axc #axle-units .diagram-wheel:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.axc #axle-units .axc-cpl-handle:focus-visible { outline: 2px solid var(--accent) !important; outline-offset: 2px; }
.axc .axc-marks-toggle { position: absolute; left: 8px; min-height: 32px; padding: 4px 12px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; pointer-events: auto; }
.axc .axc-marks-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body:has(.axc) .qtt-band.qtt-band h1 { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }

/* ── Batch 2 · F15: axle labels on the solver cards. The drawing scales with its card, so the label size is set per card width to render at 10px or more;
   8+ axles show one average line instead of per-axle weights (the weights stay in the figure's aria-label). ────────────── */
.axs-draw .ax-w { font-size: 16px; }
.axs-draw .ax-n { font-size: 14px; }
.axs-draw .ax-avg { font-weight: 700; }
@media (max-width: 1100px) {
  .axs-draw { max-width: 360px; margin-inline: auto; }
  .axs-draw .ax-w { font-size: 11px; }
  .axs-draw .ax-n { font-size: 10px; }
}

/* ── Batch 2 · F16: the breakdown cards in one row share a height and put their bars at the same y; the rig stage no longer leaves a 24px margin
   (plus the stats' own 12px) between the drawing and the figures. ─────────────────────────────────────────────────────── */
.axc-results .hh-r3-groups { align-items: stretch; }
.axc-results .axl-card { align-content: start; }
.axc-results .axl-card .axl-head { min-height: 68px; }
.axc #axle-units { margin-bottom: 0; }
.axc[data-mode="bridge"] #stats { margin-top: 0; }

/* ── Batch 2 · F17: bridge formula on a phone. One column of controls with the same label-in-field look as the other pickers; the stats rule runs the
   full width of the panel; the check ladder drops its middle card, and each row's verdict sits under its title instead of squeezing it. ─── */
@media (max-width: 720px) {
  .axc[data-mode="bridge"] .heading-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; width: 100%; }
  .axc[data-mode="bridge"] .heading-actions .setup-bar { display: contents; }
  .axc[data-mode="bridge"] .heading-actions .units-field { grid-column: 1; grid-row: 1; }
  .axc[data-mode="bridge"] .heading-actions .history-actions { grid-column: 2; grid-row: 1; justify-self: end; }
  .axc[data-mode="bridge"] .heading-actions .setup-bar .vis-field { grid-column: 1 / -1; width: 100%; }
  .axc[data-mode="bridge"] .heading-actions .setup-bar .vis-field select { width: 100%; height: 44px; padding-left: 120px; font-size: 13px; }
  .axc[data-mode="bridge"] .heading-actions .setup-bar .vis-field .vis-prefix .vis-word { display: inline; }
  .axc[data-mode="bridge"] .heading-actions .setup-bar .vis-field .vis-prefix svg { display: none; }
  .axc[data-mode="bridge"] #stats { margin-inline: 0; }
  #qt-ladder.qt-note { padding: 0; border: 0; background: none; }
}
@media (max-width: 600px) {
  .qt-ltable td.qt-vcell { grid-column: 1 / -1; grid-row: 2; justify-self: start; text-align: left; }
}
