/* Engineering tools: matrix calculator, equation solver, scientific calculator, base converter, lead time.
   Loaded only on those pages via @push('head'). Uses the colour tokens from toolnest.css. */

/* ---- Matrix input / output ---- */
.mx-block { margin-bottom: 8px; }
.mx-block > .mx-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.mx-block h3 { margin: 0; font-size: 1.05rem; }
.mx-size { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); font-weight: 600; }
.mx-size select.input { width: auto; flex: none; padding: 6px 8px; }
.mx-scroll { overflow-x: auto; padding: 4px 2px 8px; }
.mx-grid {
  display: inline-grid; gap: 6px; padding: 8px 12px; position: relative;
  border-left: 3px solid var(--text); border-right: 3px solid var(--text); border-radius: 6px;
}
.mx-grid .input { width: 72px; min-width: 0; text-align: center; padding: 9px 6px; }
.mx-out { display: inline-grid; gap: 6px 14px; padding: 10px 16px; border-left: 3px solid var(--primary); border-right: 3px solid var(--primary); border-radius: 6px; }
.mx-out span { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 48px; color: var(--text); overflow-wrap: anywhere; }
.mx-out small { display: block; font-weight: 500; color: var(--muted); font-size: .72rem; }
.mx-ops { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.mx-ops .btn { padding: 10px 12px; font-size: .92rem; }
.mx-ops .btn.is-on { background: var(--primary); color: #fff; border-color: var(--primary); }
:root[data-theme="dark"] .mx-ops .btn.is-on { color: #0d0f1f; }
.ops-label { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; }
.result-box { margin-top: 18px; padding: 16px 18px; border-radius: var(--radius-sm); background: var(--primary-soft); overflow-x: auto; }
.result-box:empty { display: none; }
.result-box h3 { margin: 0 0 10px; font-size: 1rem; color: var(--primary); }
.result-box p { margin: 6px 0; color: var(--text); }
.result-big { font-size: 1.5rem; font-weight: 800; color: var(--text); overflow-wrap: anywhere; }
.dec-toggle { display: inline-flex; gap: 14px; flex-wrap: wrap; align-items: center; }

/* ---- Equation solver ---- */
.eq-grid { display: inline-grid; gap: 8px 6px; align-items: center; }
.eq-grid .input { width: 76px; text-align: center; padding: 9px 6px; }
.eq-grid .eq-var { font-weight: 700; color: var(--muted); white-space: nowrap; font-size: .95rem; }
.eq-grid .eq-eq { font-weight: 700; color: var(--muted); }
.sol-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.sol-item { background: var(--surface); border-radius: var(--radius-sm); padding: 10px 14px; border: 1px solid var(--border); }
.sol-item b { display: block; font-size: 1.25rem; color: var(--text); overflow-wrap: anywhere; }
.sol-item span { font-size: .8rem; color: var(--muted); font-weight: 600; }

/* ---- Scientific calculator ---- */
.sci { max-width: 520px; margin: 0 auto; }
.sci-screen { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px 12px; margin-bottom: 14px; }
.sci-screen .sci-expr { width: 100%; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 1.25rem; padding: 6px 0; outline: none; }
.sci-screen .sci-res { min-height: 2.6rem; font-size: 2rem; font-weight: 800; text-align: right; color: var(--primary); overflow-x: auto; white-space: nowrap; letter-spacing: -.02em; }
.sci-screen .sci-res.is-err { font-size: 1rem; font-weight: 600; color: #e11d48; white-space: normal; text-align: left; }
:root[data-theme="dark"] .sci-screen .sci-res.is-err { color: #fb7185; }
.sci-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.seg button { font: inherit; font-weight: 700; font-size: .85rem; border: 0; background: var(--surface-2); color: var(--muted); padding: 7px 16px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--primary); color: #fff; }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { color: #0d0f1f; }
.keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.key { font: inherit; font-weight: 700; font-size: 1rem; padding: 13px 4px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; transition: background .12s, transform .08s; }
.key:hover { background: var(--primary-soft); }
.key:active { transform: scale(.95); }
.key.fn { font-size: .88rem; color: var(--muted); }
.key.num { background: var(--surface); }
.key.op { color: var(--primary); }
.key.eq { background: var(--primary); color: #fff; border-color: var(--primary); }
:root[data-theme="dark"] .key.eq { color: #0d0f1f; }
.key.clr { color: #e11d48; }
:root[data-theme="dark"] .key.clr { color: #fb7185; }
.sci-history { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 6px; max-height: 200px; overflow-y: auto; }
.sci-history li { display: flex; justify-content: space-between; gap: 12px; font-size: .92rem; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; cursor: pointer; }
.sci-history li:hover { background: var(--primary-soft); }
.sci-history li span:first-child { color: var(--muted); overflow-wrap: anywhere; }
.sci-history li span:last-child { font-weight: 800; color: var(--text); white-space: nowrap; }

/* ---- Base converter ---- */
.base-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 16px; }
.base-card { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.base-card .bc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.base-card .bc-head b { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.base-card .bc-val { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.1rem; font-weight: 700; color: var(--text); overflow-wrap: anywhere; min-height: 1.5em; }
.copy-mini { font: inherit; font-size: .75rem; font-weight: 700; border: 1px solid var(--border); background: var(--surface); color: var(--primary); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.copy-mini:hover { background: var(--primary-soft); }
.bits { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.05rem; font-weight: 700; }
.bits .nib { letter-spacing: .08em; color: var(--text); }
.bits .nib.dim { color: var(--muted); }

/* ---- Lead time ---- */
.stage-table { width: 100%; border-collapse: collapse; }
.stage-table td { padding: 6px 8px 6px 0; vertical-align: middle; }
.stage-table td:first-child { font-weight: 650; white-space: nowrap; }
.dow { display: flex; gap: 6px; flex-wrap: wrap; }
.dow label { display: inline-flex; align-items: center; gap: 4px; font-size: .88rem; font-weight: 600; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; background: var(--surface-2); }
.dow input { accent-color: var(--primary); }
.timeline { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: flex; gap: 14px; padding: 8px 0; border-bottom: 1px dashed var(--border); align-items: baseline; }
.timeline li:last-child { border-bottom: 0; }
.timeline .tl-date { min-width: 150px; font-weight: 700; color: var(--text); }
.timeline .tl-what { color: var(--muted); }
.lt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.lt-grid .panel { margin-bottom: 0; }

@media (max-width: 560px) {
  .mx-grid .input, .eq-grid .input { width: 58px; padding: 8px 4px; }
  .key { padding: 11px 2px; font-size: .95rem; }
  .keys { gap: 6px; }
  .timeline li { flex-direction: column; gap: 0; }
}

/* Long names such as "Binary/Hexadecimal/Decimal Converter" must wrap on phones */
.tool-hero h1 { overflow-wrap: anywhere; }
