/* ISOBUS Helper — shared UI theme
   A dark instrument-panel look grounded in the subject: neutral gunmetal
   graphite — deliberately neither the warm-brown nor the generic cold
   blue-black this site has already tried — with one signal-blue
   indicator-light accent used sparingly, the way a single "active/engaged"
   telltale lamp reads on a grey equipment cluster rather than a wash of
   colour. Big Shoulders for the wordmark and headlines, IBM Plex Sans for
   reading, IBM Plex Mono reserved for things that are actually data — hex,
   binary, protocol fields. Tailwind (CDN) is still used for layout
   utilities (flex/grid/spacing); this file owns colour, type and the
   component look. */

:root {
  /* Gunmetal ground: kept close to neutral (minimal hue bias) so it reads
     as machined metal, not "branded" black or brown. Panels sit a shade
     lighter than the page, the way a control panel's inset modules read
     against its housing. */
  --bg: #17181a;
  --bg-elevated: #1c1d20;
  --panel: #202124;
  --panel-alt: #19191c;
  --border: #2d2f33;
  --border-strong: #44474c;

  /* Neutral off-white text — no warm or cool tint pulling it toward a hue */
  --text: #e7e8e9;
  --text-muted: #999ca1;
  --text-faint: #64676c;

  /* Signal blue — a dashboard telltale-lamp blue (deeper and more cobalt
     than a generic "SaaS" sky blue), the one cool note against a neutral
     panel. Text/fill share one value here: on this dark ground both read
     cleanly, unlike on white where a single hue couldn't do both jobs. */
  --accent: #4a90d9;
  --accent-hover: #6ba8e6;
  --accent-dim: rgba(74, 144, 217, 0.16);
  --accent-fill: #4a90d9;
  --accent-fill-hover: #6ba8e6;

  /* Semantic colours, kept distinct from the accent hue */
  --good: #7fae6a;
  --bad: #e2685a;

  --font-display: "Big Shoulders Text", var(--font-sans);
  --font-sans: "IBM Plex Sans", -apple-system, "Segoe UI", system-ui, Roboto, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;

  --radius: 4px;
  --radius-lg: 10px;
}

* { box-sizing: border-box; }

html, body { background: var(--bg); }

body {
  font-family: var(--font-sans);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
}

h1, h2, h3 { font-family: var(--font-sans); text-wrap: balance; }

a { color: inherit; }

::selection { background: var(--accent-dim); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; }
}

/* Top navigation */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

/* The wordmark's glyph: a small tractor silhouette — original artwork
   (hand-built from primitive shapes below), not a stock/licensed icon. */
.brand-mark {
  width: 27px;
  height: 20px;
  flex-shrink: 0;
}

.brand-mark .brand-mark-fill { fill: var(--accent); }

/* Wheel hubs are "punched" through the silhouette using the surface colour
   behind the mark, so they read correctly wherever the mark is placed. */
.brand-mark .brand-mark-hub { fill: var(--bg-elevated); }

.brand .brand-sub {
  color: var(--text-faint);
  font-weight: 400;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  font-size: 0.95rem;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.2rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.nav-links a:hover { color: var(--text); }

.nav-links a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Page shell */
.page-shell { max-width: 1080px; margin: 0 auto; padding: 2rem 1.5rem 3rem; width: 100%; }

.page-header { margin-bottom: 1.75rem; }

.page-header h1 {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.005em;
}

.page-header p {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 0.4rem;
  max-width: 62ch;
}

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
}

.card + .card { margin-top: 1.1rem; }

.card h2 {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.card .card-note {
  font-size: 0.88rem;
  color: var(--text-faint);
}

.field-label {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.35rem;
}

/* Inputs — kept monospace: these mostly hold hex/decimal protocol values,
   and tabular monospace digits are genuinely easier to scan and align. */
.input {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  background: var(--panel-alt);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  color: var(--text);
  width: 100%;
  transition: border-color 0.12s ease;
}

.input::placeholder { color: var(--text-faint); font-family: var(--font-sans); }

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

select.input { cursor: pointer; }

.input[type="file"] { font-family: var(--font-sans); padding: 0.45rem 0.6rem; color: var(--text-muted); }

.input[type="file"]::file-selector-button {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  margin-right: 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s ease;
}

.input[type="file"]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }

/* Buttons */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }

.btn:focus-visible, .input:focus-visible, .tool-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: #241a0c;
  font-weight: 700;
}

.btn-primary:hover { background: var(--accent-fill-hover); border-color: var(--accent-fill-hover); color: #241a0c; }

.btn-secondary { background: transparent; }

/* Output panels — genuine data readouts, so the mono/uppercase treatment
   here is functional (a gauge label), not decorative. */
.output {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-top: 0.9rem;
}

.output-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  display: block;
  margin-bottom: 0.5rem;
}

.display-output { white-space: pre-line; font-size: 0.95rem; font-variant-numeric: tabular-nums; }

/* Plain feature list */
.spec-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.spec-list li {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding-left: 0.95rem;
  position: relative;
}

.spec-list li::before {
  content: "\2013";
  position: absolute;
  left: 0;
  color: var(--text-faint);
}

/* Home: tool grid */
.tool-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.55);
}

.tool-tag {
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

.tool-card h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.tool-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-faint);
}

.site-footer a { color: var(--text-faint); text-decoration: none; }
.site-footer a:hover { color: var(--text-muted); text-decoration: underline; }

/* Rate chips (map creator) */
.rate-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rate-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel-alt);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: border-color 0.12s ease, color 0.12s ease;
  user-select: none;
}

.rate-chip:hover { border-color: var(--accent); color: var(--text); }

.rate-chip.active {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--accent);
}

.rate-chip .swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.rate-chip .swatch.eraser {
  background-image: linear-gradient(45deg, var(--border-strong) 25%, transparent 25%, transparent 50%, var(--border-strong) 50%, var(--border-strong) 75%, transparent 75%, transparent);
  background-size: 6px 6px;
  background-color: var(--panel);
}

.rate-chip .remove {
  color: var(--text-faint);
  font-size: 0.95rem;
  line-height: 1;
  padding-left: 0.15rem;
}

.rate-chip .remove:hover { color: var(--accent); }

/* Draggable/editable map text labels (map creator) */
.leaflet-div-icon.text-label-icon {
  background: transparent;
  border: none;
}

.text-label {
  /* Leaflet already makes this element position:absolute (its positioning
     context) — do not override that, only add to it. */
  /* Always a dark chip over the map tiles, independent of the page theme —
     it needs to read over satellite/street imagery, not match the page. */
  display: inline-block;
  cursor: move;
  padding: 7px 16px;
  background: rgba(30, 26, 21, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  transition: border-color 0.12s ease;
}

.text-label:hover,
.text-label:focus-within {
  border-color: var(--accent-fill);
}

.text-label-content {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: #f3ede0;
  white-space: pre;
  outline: none;
  cursor: text;
  min-width: 1.5em;
}

.text-label-content:focus {
  outline: 1px dashed var(--accent-fill);
  outline-offset: 3px;
}

/* Small floating toolbar above the label, revealed on hover/focus so the
   label body itself stays a large, unambiguous drag target. */
.text-label-toolbar {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  white-space: nowrap;
}

.text-label:hover .text-label-toolbar,
.text-label:focus-within .text-label-toolbar {
  opacity: 1;
  pointer-events: auto;
}

.text-label-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.text-label-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.text-label-btn-danger:hover {
  border-color: var(--bad);
  color: var(--bad);
}

/* Legal pages */
.prose h2 { font-family: var(--font-sans); font-size: 1.2rem; font-weight: 700; margin-top: 1.5rem; margin-bottom: 0.6rem; color: var(--text); }
.prose p { color: var(--text-muted); font-size: 1rem; margin-bottom: 0.9rem; max-width: 68ch; }
.prose ul { margin: 0 0 0.9rem 1.1rem; color: var(--text-muted); font-size: 1rem; }
.prose li { margin-bottom: 0.35rem; }
.prose strong { color: var(--text); }
.prose a { color: var(--accent); text-decoration: underline; }
