/* Nearfield Tools — shared design system */
/* Colour tokens. Two families on purpose:
   --s1/--s2 and --accent are MARK colours (chart marks, fills, borders) validated for the
   3:1 graphics threshold; --*-text variants are the TEXT colours, validated at 4.5:1 against
   the surface they actually sit on. Verified by site/tools/contrast_check.py — run it after
   any change here. */
:root {
  --bg: #fcfcfb; --surface: #ffffff; --ink: #1c1e21; --ink-2: #5a5f66; --ink-3: #6f757e;
  --line: #e5e4e0; --accent: #0d9488; --accent-text: #0f766e; --accent-contrast: #ffffff;
  --s1: #0d9488; --s2: #7c3aed; --s1-text: #115e59; --s2-text: #6d28d9;
  --warn: #92400e; --warn-bg: #fef3c7; --ok-bg: #ecfdf5; --ok-text: #047857;
  --danger: #b91c1c; --danger-bg: #fef2f2;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --surface: #1b1e24; --ink: #e8eaed; --ink-2: #a6adb5; --ink-3: #7d848c;
    --line: #2a2e35; --accent: #2dd4bf; --accent-text: #2dd4bf; --accent-contrast: #0b2f2b;
    --s1: #0d9488; --s2: #8b5cf6; --s1-text: #2dd4bf; --s2-text: #a78bfa;
    --warn: #fbbf24; --warn-bg: #3a2e10; --ok-bg: #10312a; --ok-text: #34d399;
    --danger: #f87171; --danger-bg: #3a1414;
  }
}
* { box-sizing: border-box; }
a { color: var(--accent-text); }
a:hover { text-decoration-thickness: 2px; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }

/* header / footer */
header.site { border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: baseline; gap: 14px; padding: 14px 20px; }
.wordmark { font-weight: 750; letter-spacing: .04em; text-decoration: none; color: var(--ink); font-size: 15px; }
.wordmark span { color: var(--accent-text); }
header.site nav { margin-left: auto; font-size: 13.5px; }
header.site nav a { color: var(--ink-2); text-decoration: none; margin-left: 14px; }
header.site nav a:hover { color: var(--accent-text); }
footer.site { border-top: 1px solid var(--line); margin-top: 56px; }
footer.site .wrap { padding: 22px 20px 34px; font-size: 13.5px; color: var(--ink-3); }
footer.site a { color: var(--ink-2); }
main { padding-top: 8px; }

h1 { font-size: 1.7rem; line-height: 1.25; margin: 26px 0 6px; letter-spacing: -.01em; }
.tagline { color: var(--ink-2); margin: 0 0 26px; max-width: 62ch; }

/* tool layout */
.tool { display: grid; grid-template-columns: 330px 1fr; gap: 30px; align-items: start; }
@media (max-width: 880px) { .tool { grid-template-columns: 1fr; } }
/* Grid items default to min-width:auto, which refuses to shrink below their own
   content -- so one table with more columns than a phone can hold widens the
   whole page instead of scrolling inside its .table-scroll box. */
.tool > * { min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

/* inputs */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
label { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); }
/* Units are case-significant and the label above is uppercased: "(µs)" becomes
   "(MS)" — a different unit, a thousand times out. Wrap any unit whose prefix
   carries meaning in lower case. Table headers are uppercased by the same house
   rule further down, so the opt-out has to reach them too, or a header reading
   "(m/s)" renders as mega-per-second. `tools/check_unit_labels.mjs` is the gate
   that keeps the markup side of this honest across all 17 pages. */
label .unit, table.data th .unit { text-transform: none; }
input[type="number"], input[type="text"], select {
  width: 100%; padding: 9px 11px; font-size: 16px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { all: unset; padding: 6px 14px; font-size: 13.5px; cursor: pointer; color: var(--ink-2); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + label { background: var(--accent); color: var(--accent-contrast); }
.btn {
  display: inline-block; padding: 9px 16px; font-size: 14.5px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-contrast); border: none; border-radius: 8px;
}
.btn.ghost { background: transparent; color: var(--accent-text); border: 1px solid var(--accent); }

/* results */
.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; }
.stat .v small { font-size: .9rem; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
/* A range is two numbers in the space of one. Measured in the browser: three
   significant figures caps a range at nine characters, which is 107 px at 1.15rem
   against a 102 px budget at the grid's 130 px minimum column — it wrapped at the
   dash. 1.05rem is 98 px and fits at every column width the grid produces. */
.stat .v.wide { font-size: 1.05rem; }
.stat .v.wide small { font-size: .85rem; }
.stat .k { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.data td { padding: 6.5px 10px; border-bottom: 1px solid var(--line); }
table.data td.num, table.data th.num { text-align: right; }
table.data tr:last-child td { border-bottom: none; }
/* row matching the current inputs — a 10% tint keeps body text far above 4.5:1 */
table.data tr.sel td { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--ink); }
table.data tr.sel td:first-child { font-weight: 600; }
/* A results table with more columns than a phone can hold scrolls inside its own
   box. Without this the table's min-content width widens the layout viewport and
   the WHOLE page scrolls sideways -- found on the port velocity calculator, whose
   six columns pushed a 375 px viewport out to 415. */
.table-scroll { overflow-x: auto; }

.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.badge.axial { background: color-mix(in srgb, var(--s1) 14%, transparent); color: var(--s1-text); }
.badge.tangential { background: color-mix(in srgb, var(--s2) 14%, transparent); color: var(--s2-text); }
.badge.oblique { background: color-mix(in srgb, var(--ink-3) 18%, transparent); color: var(--ink-2); }
.badge.safe { background: var(--ok-bg); color: var(--ok-text); }
.badge.marginal { background: var(--warn-bg); color: var(--warn); }
.badge.unsafe { background: var(--danger-bg); color: var(--danger); }

.callout { border-radius: var(--radius); padding: 12px 14px; font-size: 14px; margin: 14px 0; }
.callout.warn { background: var(--warn-bg); color: var(--warn); }
.callout.note { background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }

/* charts */
.chart-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 18px; }
.chart-box svg { width: 100%; height: auto; display: block; }
.chart-box .legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); padding: 6px 4px 0; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
svg text { font: 11px system-ui, sans-serif; fill: var(--ink-2); }
svg .grid { stroke: var(--line); stroke-width: 1; }
svg .axis { stroke: var(--ink-3); stroke-width: 1; }

/* prose / SEO content */
.prose { max-width: 70ch; margin-top: 44px; }
.prose h2 { font-size: 1.22rem; margin: 30px 0 8px; }
.prose h3 { font-size: 1.02rem; margin: 22px 0 6px; }
.prose p, .prose li { color: var(--ink-2); font-size: 15px; }
.prose code, .formula { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .92em; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.formula.block { display: inline-block; padding: 10px 14px; margin: 6px 0; }

/* index cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; margin: 26px 0; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--ink); transition: border-color .12s; }
.card:hover { border-color: var(--accent); }
.card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.card p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.toolbar { display: flex; gap: 10px; align-items: center; margin: 10px 0 18px; }
.toolbar .spacer { flex: 1; }
.copied { font-size: 13px; color: var(--accent-text); }
