/* Office Tech Health Check: shared design tokens and base styles. Loaded FIRST on every page,
   before the page's own stylesheets. Screens are dark everywhere; print resets the tokens to light
   paper at the bottom of this file.
   Colours are plain hex values: test/branding.test.js reads them from this file and checks every
   text/background pair for WCAG 2.2 AA contrast (screen and print). */

:root {
  color-scheme: dark;
  --bg: #0b1324;
  --surface: #111c33;
  --surface-2: #17243f;
  --border: #24324f; /* decorative card edges only */
  --control-border: #64769a; /* inputs and outline buttons: >= 3:1 against bg, surface and surface-2 */
  --text: #e6ebf5;
  --muted: #9aa7bd;
  --accent: #4c8dff;
  --accent-hover: #6ea2ff;
  --accent-ink: #0b1324;
  --code-bg: #0b1324;
  --code-text: #e6ebf5;
  /* Status colours and their tints (the tint is the colour at 16% over --surface). */
  --pass: #4ac26b;
  --pass-bg: #1a373c;
  --warn: #e3b341;
  --warn-bg: #333435;
  --fail: #ff7b7b;
  --fail-bg: #372b3f;
  --info: #9aa7bd;
  --info-bg: #273249;
  /* Grade badges: navy letter on the grade colour. */
  --grade-ink: #0b1324;
  --grade-a: #4ac26b;
  --grade-b: #3fae6a;
  --grade-c: #e3b341;
  --grade-d: #f0883e;
  --grade-f: #ff7b7b;
  --grade-none: #9aa7bd;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: none;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*,
*::before,
*::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code, pre { font-family: var(--mono); }

/* Skip link: first Tab stop on every page */
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 10;
  background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 8px; font-weight: 650; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* Buttons. Disabled buttons are dimmed and keep their label (WCAG exempts them from contrast). */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 18px; min-height: 44px; font-weight: 650; white-space: nowrap; text-decoration: none;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; color: var(--text); border: 1px solid var(--control-border); border-radius: 8px;
  padding: 7px 14px; min-height: 36px; font-size: 14px; font-weight: 600; text-decoration: none;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-2); }
.btn-primary:disabled, .btn-ghost:disabled { opacity: 0.55; }

/* Form fields */
input:not([type]), input[type="text"], input[type="password"], input[type="search"], select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--control-border); border-radius: var(--radius-sm);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"] { accent-color: var(--accent); }

/* Consent checkbox on every scan form (text in public/legal.js; the button stays disabled until ticked) */
.consent-check { margin: 8px 0 0; font-size: 0.9375rem; color: var(--text); }
.consent-check label { display: inline-flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 0; cursor: pointer; }
.consent-note { max-width: 62ch; margin: 0 0 4px 30px; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
.consent-check input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); cursor: pointer; }

/* Results disclaimer (public/legal.js): lander preview, tool reports and Fix Plans, on screen and in print */
.results-disclaimer { margin: 18px 0 0; padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); font-size: 0.875rem; line-height: 1.5; }
.results-disclaimer p { margin: 0; }
.results-disclaimer .results-disclaimer-plan { margin-top: 8px; color: var(--text); font-weight: 600; }

/* Shared header (same markup on every page; see scripts/site-chrome.js) */
.site-header { background: var(--bg); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text); text-decoration: none; }
.brand-mark { display: block; flex: none; color: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 700; }
.brand-sub { font-size: 0.8125rem; color: var(--muted); }
.header-home { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; font-weight: 600; }
.header-inner { position: relative; }
.tech-nav { display: flex; align-items: center; gap: 2px; }
.tech-nav > a,
.tech-nav > button,
.tools-menu > summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font-weight: 600; font-size: 0.9375rem; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.tech-nav > a:hover, .tools-menu > summary:hover { color: var(--text); background: var(--surface); }
.tech-nav > a[aria-current="page"],
.tools-menu:has([aria-current="page"]) > summary { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.tech-nav .nav-signout { margin-left: 6px; color: var(--text); border: 1px solid var(--control-border); }
.tech-nav .nav-signout:hover { border-color: var(--accent); }

/* Tools menu: a <details> dropdown listing "All tools" and every live tool by category (from tools.js) */
.tools-menu { position: relative; }
.tools-menu > summary { list-style: none; }
.tools-menu > summary::-webkit-details-marker { display: none; }
.tools-menu > summary::after {
  content: ""; width: 7px; height: 7px; margin: -3px 2px 0 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
}
.tools-menu[open] > summary { color: var(--text); background: var(--surface); }
.tools-menu[open] > summary::after { margin-top: 4px; transform: rotate(225deg); }
.tools-menu-panel {
  position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; width: 300px;
  max-height: min(70vh, 560px); overflow-y: auto; padding: 8px;
  background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--radius-sm);
  box-shadow: 0 16px 40px rgba(3, 7, 18, 0.6);
}
.tools-menu-panel a {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.tools-menu-panel a:hover { background: var(--surface-2); }
.tools-menu-panel a[aria-current="page"] { background: var(--surface-2); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.tools-menu-panel a[aria-current="page"]::after { content: "Current"; margin-left: auto; padding-left: 12px; font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.tools-menu-panel .tools-menu-all { font-weight: 650; border-bottom: 1px solid var(--border); border-radius: 8px 8px 0 0; margin-bottom: 4px; }
.tools-menu-heading { margin: 10px 12px 2px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.tools-menu-panel ul { list-style: none; margin: 0; padding: 0; }
/* A tool behind a feature switch that's off: shown, but not a link (see tech-session.js applyFeatures). */
.tools-menu-soon { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; color: var(--muted); }
.tools-menu-soon .soon-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--info); background: var(--info-bg); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }

/* Shared footer */
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.9375rem; padding: 28px 0 36px; margin-top: 24px; }
.site-footer p { margin: 4px 0; }
.site-footer a { display: inline-block; padding: 8px 0; }
.footer-note { font-size: 0.875rem; }

@media (max-width: 760px) {
  /* One row under the brand (Tools, Fix Plan, Sign out); the Tools menu opens full width. No JS needed. */
  .header-inner { padding-top: 10px; padding-bottom: 6px; }
  .tech-nav { width: 100%; margin-left: -12px; }
  .tech-nav .nav-signout { margin-left: auto; }
  .tools-menu { position: static; }
  .tools-menu-panel { left: 16px; right: 16px; width: auto; top: calc(100% + 2px); }
}
@media (max-width: 420px) {
  .brand-sub { font-size: 0.75rem; }
  .header-inner { min-height: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Print: light paper. Status colours become dark text on a light tint (with a border, so they
   still read when backgrounds are not printed); grade badges get a border and dark text. */
@media print {
  :root {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f3f4f6;
    --border: #bbbbbb;
    --control-border: #767676;
    --text: #111111;
    --muted: #444444;
    --accent: #1f5fc8;
    --accent-hover: #1f5fc8;
    --accent-ink: #ffffff;
    --code-bg: #f3f4f6;
    --code-text: #111111;
    --pass: #1a6b34;
    --pass-bg: #e6f4ea;
    --warn: #7a5200;
    --warn-bg: #fff4d6;
    --fail: #b42318;
    --fail-bg: #fdeaea;
    --info: #444444;
    --info-bg: #eef1f4;
    --grade-ink: #111111;
    --grade-a: #ffffff;
    --grade-b: #ffffff;
    --grade-c: #ffffff;
    --grade-d: #ffffff;
    --grade-f: #ffffff;
    --grade-none: #ffffff;
  }
  body { background: #fff; color: var(--text); }
  .no-print, .skip-link { display: none !important; }
  a { color: inherit; text-decoration: none; }
  .grade, .grade-chip { border: 3px solid var(--text); }
  .pill, .status, .possible, .badge, .action { border: 1px solid currentColor; }
  /* Tints that carry meaning (status pills, check edges, risk box) print as they are. */
  .pill, .status, .possible, .check, .risk, .grade-cap, .verdict, .safety, .term, .diff-value code { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  pre, code { white-space: pre-wrap; }
  .results-disclaimer { break-inside: avoid; border-color: var(--border); }
}
