/* ══════════════════════════════════════════════════════════════════════════════════════
   CODE SAVANT — THE STANDARD STYLESHEET
   The one place the design system is defined. Every frontend loads this file first, then
   adds only what is specific to itself.

     site/     marketing pages   <link rel="stylesheet" href="codesavant.css">  (before style.css)
     portal/   tenant portal     <link rel="stylesheet" href="codesavant.css">  (before style.css)
     web/      operator console  @import in web/src/style.css

   `shared/codesavant.css` is the only real copy. `portal/codesavant.css` and
   `site/codesavant.css` are symlinks to it, and the deploy scripts rsync with -L so each
   docroot gets a materialized file — there is no second copy to drift.

   RULES
   1. Design tokens (the `:root` block) live HERE and nowhere else. An app that redefines
      one is a bug: the values below drifted into three copies once already, and the
      operator console spent months on a `--muted` that failed WCAG AA because nothing
      tied it back to the corrected value.
   2. Anything a second page could reasonably want — a button, a card, a form control —
      belongs here. App files are for layouts and one-off components.
   3. Extend with a modifier class, don't fork the base: `.btn.small`, not `.my-btn`.
   4. Changing a token or a component here changes all three frontends. Their Playwright
      suites (`npm run test:e2e:all`) are the check that it was intended.

   TENANTS OVERRIDE SOME OF THIS AT RUNTIME — DO NOT BREAK IT
   White-label branding repaints `--orange` (accent) and `--ink` (primary) per tenant, set
   as INLINE properties on documentElement (`applyBranding` in portal/app.js, `paintTheme`
   in site/tenant.js). Inline wins over every stylesheet, so this file cannot clobber a
   tenant's brand — but two rules follow from it:
     • Anything that should follow the brand must reference var(--orange) / var(--ink).
       A literal hex freezes it at Code Savant orange on a tenant who chose blue. The few
       literals below are neutrals (greys, the chevron, the focus halo) that stay put on
       purpose, or spots where a var cannot go — inside a data: URI or an rgba().
     • Do not add `!important` to a branded property. That beats the inline override and
       silently un-brands every white-label tenant.
   The customer-facing tenant site (site/tenant.html + tenant.css) is deliberately NOT on
   this stylesheet: its tokens are the tenant's to theme, not the house system's.

   The look is a dispatch office: paper gray, gunmetal, safety orange. Barlow Condensed
   for display, Archivo for text, IBM Plex Mono for data.
   ══════════════════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── surfaces ── */
  --paper: #eef0ef;
  --paper-2: #eef1f2;
  --card: #ffffff;
  --line: #c9d2d5;
  --line-soft: #dfe5e7;

  /* ── text ── */
  --ink: #1c262b;
  --ink-soft: #55666e;
  /* Was #8d999e — 2.92:1 on white, well under AA. #667378 is 4.9:1 and reads as the
     same soft grey. */
  --muted: #667378;

  /* ── accents ──
     --orange and --ink are the two tenants repaint (see the header note); everything else
     is house-neutral and stays as-is on every account. */
  --orange: #d95d0e;
  --orange-deep: #b04a06;
  --steel: #2c5f7c;
  --steel-tint: #e3ecf1;
  --amber: #9a6700;
  --danger: #c0392b;
  /* --lamp is bright enough for the indicator dot but only hits 4.25:1 as text, under the
     4.5:1 WCAG AA floor. --lamp-text is the same green darkened to 5.7:1 on white, for
     status wording low-vision readers have to actually read. */
  --lamp: #2e8b57;
  --lamp-text: #26744a;

  /* ── type ── */
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;

  /* ── shape ──
     --radius is the plain-panel corner; --radius-lg is for controls and cards the user
     types into, which read softer at 10-12px. */
  --radius: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(28, 38, 43, 0.05);
  --shadow-2: 0 1px 2px rgba(28, 38, 43, 0.12);
  --gutter: 20px;
  --measure: 1080px; /* max line-length of the page body */
}

/* ────────── base ────────── */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
  text-transform: uppercase;
}

a { color: var(--steel); }

:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
main:focus { outline: none; }

/* The `hidden` attribute must always win over component `display` rules — without this a
   `display: grid` panel renders even when hidden. */
[hidden] { display: none !important; }

/* ────────── layout + utilities ────────── */
.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 var(--gutter); }
.mono { font-family: var(--mono); }

/* Reachable by screen readers, invisible on screen. Not display:none — that would hide it
   from assistive tech too, which is the opposite of the point. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

/* Off-screen until focused, then it drops into view as the first tab stop. */
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: #fff; font-family: var(--display); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; padding: 10px 16px;
  border-radius: 0 0 4px 4px; text-decoration: none; transition: top 0.15s ease-in-out;
}
.skip-link:focus { top: 0; }
@media (prefers-reduced-motion: reduce) { .skip-link { transition: none; } }

/* ────────── components ────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }

.eyebrow {
  font-family: var(--display); font-weight: 600; font-size: 14px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--orange-deep);
  margin: 0 0 12px;
}

.btn {
  display: inline-block; font-family: var(--display); font-weight: 600; font-size: 15px;
  letter-spacing: 0.06em; text-transform: uppercase; background: var(--ink); color: #fff;
  border: 1px solid var(--ink); border-radius: 4px; padding: 9px 16px; cursor: pointer;
  text-decoration: none; line-height: 1.1;
}
.btn:hover { background: #2c3a41; }
.btn:disabled { background: var(--muted); border-color: var(--muted); cursor: default; }
.btn.big { font-size: 18px; padding: 12px 22px; background: var(--orange-deep); border-color: var(--orange-deep); width: 100%; }
.btn.big:hover { background: var(--orange); border-color: var(--orange); }
.btn.small { font-size: 13px; padding: 6px 12px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--steel-tint); border-color: var(--steel); }

.lamp {
  width: 10px; height: 10px; border-radius: 50%; background: var(--lamp);
  box-shadow: 0 0 0 3px #e4f1e9; flex: none;
}

/* ────────── form controls ──────────
   The standard input family. Softer than a native control: --radius-lg corners, a
   hairline, a hint of lift, and for selects a drawn chevron instead of the OS arrow —
   that arrow, plus 4px corners, is what made the older screens read "boxy".

     .inp   text / date / number inputs
     .sel   select
     .ta    textarea
     .sel-sm compact variant, for filters sitting in a section header

   16px is the floor for anything typed into: iOS zooms the page on focus below that. */
.inp, .sel, .ta {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 9px 12px;
  box-shadow: var(--shadow-1);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.ta { width: 100%; line-height: 1.5; resize: vertical; }
.sel {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 34px; line-height: 1.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.6 6 6.4l5-4.8' fill='none' stroke='%2355666e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 11px 7px;
}
.inp:hover, .sel:hover, .ta:hover { border-color: #a4b3b9; }
.inp:focus, .sel:focus, .ta:focus {
  border-color: var(--steel); box-shadow: 0 0 0 3px rgba(44, 95, 124, 0.15); outline: none;
}
/* Keyboard users keep the house focus ring. This must sit after the :focus rule above,
   which has equal specificity and would otherwise win and swallow the outline. */
.inp:focus-visible, .sel:focus-visible, .ta:focus-visible {
  outline: 2px solid var(--orange); outline-offset: 2px;
}
.inp:disabled, .sel:disabled, .ta:disabled { background: #f4f6f6; color: var(--muted); cursor: not-allowed; }
.inp::placeholder, .ta::placeholder { color: #93a2a8; }
.sel-sm { padding: 5px 30px 5px 11px; font-size: 13px; border-radius: 8px; background-position: right 10px center; }

/* ────────── touch ──────────
   Phones are a first-class target on every screen: these are worked from a truck, not a
   desk. Anything tappable clears ~44px so a mis-tap can't fire a destructive action. */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; }
}
