/* Fleetmark's design tokens (04, 4.1; docs/fleet/brand/README.md). Every colour in the
   portal comes from here: components and globals.css only use var(--token). The names
   and structure are og-power-app's (ported at 206ba12, see PORTED.md), so nothing that
   reads a token had to change; the palette, the type and the shapes are Fleetmark's.

   Light by default, dark supported: the same colour tokens are redefined for dark mode
   below, and tests/portal-tokens.test.ts checks that both blocks define the same set
   and that every text colour reads at 4.5:1 or better on the surfaces it sits on
   (WCAG 2.2 AA). Colour is rationed: Paper and Tarmac for the ground and the words,
   one Fleet Blue for the main action, Plate Yellow for a registration and nothing else,
   and red, amber and green only for status, always with a word and an icon. */

:root {
  color-scheme: light dark;

  /* Type: two families, served by the app itself (src/fonts, loaded in src/app/layout.tsx
     with next/font/local, which sets --fm-sans, --fm-sans-italic and --fm-mono on <html>).
     Atkinson Hyperlegible Next for words; Atkinson Hyperlegible Mono for registrations,
     card numbers and references. The names after the variable are the same faces if a
     device has them installed, then the nearest wide, open system faces while ours load. */
  --font-sans: var(--fm-sans, "Atkinson Hyperlegible Next"), "Atkinson Hyperlegible", Verdana, "Segoe UI", sans-serif;
  --font-sans-italic: var(--fm-sans-italic, "Atkinson Hyperlegible Next"), var(--font-sans);
  --font-rounded: var(--font-sans);
  --font-mono: var(--fm-mono, "Atkinson Hyperlegible Mono"), ui-monospace, Menlo, Consolas, monospace;

  /* The scale, in rem so the device's text size setting scales everything (1rem = 16px).
     Phones read at arm's length: body 17. A desk steps down to 15 from 960px (below). */
  --text-figure:      2.125rem;   /* 34 / 800 - the one number a tile is about */
  --text-large-title: 1.75rem;    /* 28 / 800 - the page's title */
  --text-title1:      1.5rem;     /* 24 / 800 */
  --text-title2:      1.25rem;    /* 20 / 800 - a card's or a dialog's title */
  --text-title3:      1.125rem;   /* 18 / 700 */
  --text-headline:    1.0625rem;  /* 17 / 700 - section headings, row titles */
  --text-body:        1.0625rem;  /* 17 / 400 */
  --text-callout:     1rem;       /* 16 - buttons */
  --text-subhead:     0.9375rem;  /* 15 - row subtitles */
  --text-footnote:    0.8125rem;  /* 13 - labels, helper text */
  --text-caption:     0.75rem;    /* 12 - eyebrows, chips */
  --text-caption2:    0.6875rem;  /* 11 - table headings, tab labels */
  --text-input:       max(1rem, var(--text-body)); /* a box's own text: never under 16px on a phone, where iOS zooms smaller inputs */
  --tracking-eyebrow: 0.09em;
  --tracking-title:   -0.025em;   /* headings are extra bold and set tight */
  --tracking-figure:  -0.03em;
  --tracking-mono:    0.04em;     /* references: a little air between look-alike characters */
  --weight-title:     800;
  --weight-heading:   700;
  --weight-label:     600;

  /* Shape: 10 on panels, 6 on controls, round only on status chips. */
  --radius-card:      10px;
  --radius-control:   6px;
  --radius-pill:      999px;
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --gutter:           16px;       /* side padding on phones */
  --gutter-left:      max(var(--gutter), env(safe-area-inset-left));
  --gutter-right:     max(var(--gutter), env(safe-area-inset-right));
  --tap-min:          44px;       /* minimum tap target on a phone (04, 4.6) */
  --tabbar-height:    52px;       /* plus env(safe-area-inset-bottom) */
  --control-h:        44px;       /* a button or a box: 44 to tap on a phone, 36 at a desk */
  --row-min:          56px;       /* a list row */
  --sidebar-width:    232px;      /* the desk's sidebar, from 960px */
  --nav-row:          34px;       /* a sidebar row */
  --page-max:         720px;      /* a phone or reading column; a desk page is 1040, .wide 1240, .desk full */
  --ease:             120ms ease-out; /* colour and border only; nothing moves */
}

/* The desk step: 15px body, 13px labels, wider gutters. The driver's shell
   keeps the phone's sizes at every width (globals.css, "The driver's shell"). */
@media (min-width: 960px) {
  :root {
    --text-body:      0.9375rem;  /* 15 */
    --text-callout:   0.9375rem;  /* 15 */
    --text-subhead:   0.875rem;   /* 14 */
    --gutter:         32px;
    --page-max:       1040px;
  }
}
/* With a mouse, controls and rows tighten; a tablet on its side keeps the 44px targets. */
@media (min-width: 960px) and (pointer: fine) {
  :root {
    --control-h:      36px;
    --row-min:        48px;
    --text-input:     var(--text-body);
  }
}

/* ---------- Colour: light (the default) ---------- */
:root {
  /* Surfaces. --bg (Paper) doubles as the browser theme colour: BRAND.themeColor.light in
     src/lib/brand.ts must equal it (a test checks). */
  --bg:               #F4F5F7;    /* Paper */
  --surface:          #FFFFFF;
  --surface-raised:   #ECEEF2;    /* the current sidebar row, pressed rows, tracks */
  --border:           #D9DDE4;    /* the one pixel line that depth comes from */
  --border-control:   #808A98;    /* a form control's edge: 3:1 on every surface it sits on (WCAG 1.4.11); --border stays for panels and dividers */
  --separator:        #E6E9EE;    /* between rows inside a panel */
  --bar-bg:           #FFFFFF;    /* the phone's tab bar and compact title: solid, no glass */
  --shadow-toast:     none;       /* nothing casts a shadow */
  --glow:             none;

  /* Text */
  --text:             #0D1117;    /* Tarmac */
  --text-secondary:   #465162;
  --text-tertiary:    #5D6878;

  /* Fleet Blue: the main action, links and focus only. One blue button a screen. */
  --brand:            #0B4FD8;
  --brand-pressed:    #083FB0;
  --brand-soft:       #E3EBFC;
  --on-brand-soft:    #083FB0;
  --brand-deep:       #D9DDE4;    /* progress track */
  --brand-tint:       #E3EBFC;    /* a chosen filter, the selected day */
  --on-brand:         #FFFFFF;

  /* The registration plate (the Plate component): yellow as on the rear of a vehicle,
     white as on the front, black characters, the same in both themes. Never used for
     anything that is not a registration. */
  --plate-rear:       #FFD21F;
  --plate-front:      #FFFFFF;
  --plate-ink:        #111111;
  --plate-edge:       rgba(0, 0, 0, 0.28);
  /* Fleet Blue as a floor (the sign-in pages' band, the app icon): the same blue in both themes. */
  --fleet-blue:       #0B4FD8;
  --on-fleet-blue:    #FFFFFF;

  /* Status (04, 4.1): red overdue, amber due soon, green done, grey not applicable.
     Each colour is text-safe on --bg, --surface, --surface-raised and its own -bg. */
  --status-red:       #B42318;
  --status-red-bg:    #FDECEA;
  --status-amber:     #9A4A00;
  --status-amber-bg:  #FDF0DC;
  --status-green:     #1B6E3A;
  --status-green-bg:  #E3F4E8;
  --status-grey:      #465162;
  --status-grey-bg:   #ECEEF2;
  --info:             #0B4FD8;    /* information is said in the blue: there is no fifth colour */
  --info-bg:          #E3EBFC;

  /* og-power-app's names, kept for the ported components. */
  --success:          var(--status-green);
  --warning:          var(--status-amber);
  --danger:           var(--status-red);
  --badge:            #B42318;    /* filled count badge on tabs */
  --on-badge:         #FFFFFF;
  --knob:             #FFFFFF;    /* switch thumb */
  --qr-dark:          #000000;    /* QR codes stay black on white in both modes, for scanners */
  --qr-light:         #FFFFFF;
  --page-paper:       #FFFFFF;    /* an uploaded document's page images sit on white in both modes, as on paper (H11) */
}

/* ---------- Colour: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:               #0A0D12;
    --surface:          #12161D;
    --surface-raised:   #1A2029;
    --border:           #28303C;
    --border-control:   #626D7D;
    --separator:        #1F2630;
    --bar-bg:           #12161D;
    --shadow-toast:     none;
    --glow:             none;

    --text:             #F1F4F8;
    --text-secondary:   #A8B3C2;
    --text-tertiary:    #8793A3;

    --brand:            #7FB0FF;
    --brand-pressed:    #5E9BFA;
    --brand-soft:       #14284A;
    --on-brand-soft:    #D5E4FF;
    --brand-deep:       #28303C;
    --brand-tint:       #14284A;
    --on-brand:         #04142E;

    --plate-rear:       #FFD21F;
    --plate-front:      #FFFFFF;
    --plate-ink:        #111111;
    --plate-edge:       rgba(0, 0, 0, 0.28);
    --fleet-blue:       #0B4FD8;
    --on-fleet-blue:    #FFFFFF;

    --status-red:       #FF7B72;
    --status-red-bg:    #3A1614;
    --status-amber:     #F5A524;
    --status-amber-bg:  #33240C;
    --status-green:     #4ACF7A;
    --status-green-bg:  #11301D;
    --status-grey:      #A8B3C2;
    --status-grey-bg:   #1F2630;
    --info:             #7FB0FF;
    --info-bg:          #14284A;

    --success:          var(--status-green);
    --warning:          var(--status-amber);
    --danger:           var(--status-red);
    --badge:            #FF7B72;
    --on-badge:         #12161D;
    --knob:             #FFFFFF;
    --qr-dark:          #000000;
    --qr-light:         #FFFFFF;
    --page-paper:       #FFFFFF;
  }
}

/* The site's own layout. Colour comes only from the portal's tokens (var(--token)); no colour is written here. */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  src: url("/fonts/atkinson-hyperlegible-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.5;
}
.wrap { width: 100%; max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter-left) 0 var(--gutter-right); }
main { flex: 1; padding-top: var(--space-8); padding-bottom: var(--space-8); }
h1 { font-size: var(--text-large-title); font-weight: var(--weight-title); letter-spacing: var(--tracking-title); line-height: 1.2; margin: 0 0 var(--space-4); }
a { color: var(--brand); }
a:hover { color: var(--brand-pressed); }
a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: var(--space-2) var(--space-4); }
.skip:focus { left: var(--space-2); top: var(--space-2); z-index: 1; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; min-height: 64px; }
.home-link { display: inline-flex; }
.lockup { display: block; height: 28px; width: auto; }
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: var(--space-6) 0; color: var(--text-secondary); font-size: var(--text-subhead); }
.site-footer p, .site-footer address { margin: 0 0 var(--space-3); font-style: normal; }
.company strong { color: var(--text); font-weight: var(--weight-heading); }
/* A marked placeholder: the production build refuses to run while it is in the footer. */
.placeholder { background: var(--status-amber-bg); color: var(--status-amber); font-weight: var(--weight-label); padding: 0 var(--space-1); }

/* Pages (MK1-2). No inline style anywhere: the site's Content-Security-Policy is style-src 'self'. */
h2 { font-size: var(--text-title2); font-weight: var(--weight-heading); line-height: 1.25; margin: var(--space-8) 0 var(--space-3); }
h3 { font-size: var(--text-headline); font-weight: var(--weight-heading); margin: var(--space-6) 0 var(--space-2); }
main p, main ul, main address { max-width: 68ch; }
main address { font-style: normal; margin: 0 0 var(--space-4); }
.lead { font-size: var(--text-title3); line-height: 1.45; }
.strap { font-weight: var(--weight-heading); }
.updated { color: var(--text-secondary); font-size: var(--text-subhead); }
.button {
  display: inline-flex; align-items: center; min-height: var(--control-h); padding: 0 var(--space-5);
  border-radius: var(--radius-control); background: var(--brand); color: var(--on-brand);
  font-weight: var(--weight-label); text-decoration: none;
}
.button:hover { background: var(--brand-pressed); color: var(--on-brand); }

/* The legal drafts' marker and notes for the adviser: a production build refuses a page that has either. */
.draft-marker, .adviser-note { background: var(--status-amber-bg); color: var(--status-amber); padding: var(--space-2) var(--space-4); border-radius: var(--radius-control); }
.draft-marker { font-weight: var(--weight-heading); }

/* The enquiry form. */
.enquiry { max-width: 36rem; margin-top: var(--space-6); }
.field { margin: 0 0 var(--space-4); }
fieldset.field { border: 0; padding: 0; }
.field label, .field legend { display: block; font-weight: var(--weight-label); margin-bottom: var(--space-1); padding: 0; }
.field-row { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.field-row .field { flex: 1 1 10rem; }
.field input:not([type="checkbox"]), .field textarea {
  width: 100%; min-height: var(--control-h); padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-control); border-radius: var(--radius-control);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-input);
}
.field input:focus-visible, .field textarea:focus-visible, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.choice { display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap-min); }
.choice input { width: 1.25rem; height: 1.25rem; margin: 0; }
.choice label { font-weight: normal; margin: 0; }
.form-note { color: var(--text-secondary); font-size: var(--text-subhead); }
.enquiry button {
  min-height: var(--control-h); padding: 0 var(--space-5); border: 0; border-radius: var(--radius-control);
  background: var(--brand); color: var(--on-brand); font: inherit; font-weight: var(--weight-label); cursor: pointer;
}
/* The honeypot: off screen, never display:none (some robots skip hidden fields). */
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }

/* The walkaround check sheet (MK1-4). On screen: a paper-like panel. In print: one A4 page per sheet, ink on paper. */
.sheet { border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); padding: var(--space-4); margin: var(--space-6) 0; }
.sheet h2 { margin: 0 0 var(--space-3); font-size: var(--text-title3); }
.sheet-fields { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin: 0 0 var(--space-3); }
.sheet-fields div { display: flex; align-items: flex-end; gap: var(--space-2); flex: 1 1 12rem; }
.sheet-fields dt { font-weight: var(--weight-label); white-space: nowrap; }
.sheet-fields dd { margin: 0; flex: 1; min-height: 1.6em; border-bottom: 1px solid currentColor; }
.sheet-fields dd.plain { border-bottom: 0; }
.sheet-legs { columns: 2 22rem; column-gap: var(--space-6); }
.sheet table { width: 100%; border-collapse: collapse; font-size: var(--text-subhead); }
.sheet-leg { break-inside: avoid; margin: 0 0 var(--space-2); }
.sheet caption { text-align: left; font-weight: var(--weight-heading); padding: var(--space-1) 0; }
.sheet th, .sheet td { border-bottom: 1px solid var(--border); padding: 2px var(--space-1); text-align: left; vertical-align: top; }
.sheet thead th { font-size: var(--text-caption); font-weight: var(--weight-label); color: var(--text-secondary); }
.sheet tbody th { font-weight: normal; }
.sheet .tick { width: 3.2em; text-align: center; }
.sheet .when { display: block; font-size: var(--text-caption); color: var(--text-secondary); font-style: italic; }
.box { display: inline-block; width: 0.9em; height: 0.9em; border: 1px solid currentColor; vertical-align: middle; }
.sheet-defects { margin-top: var(--space-3); }
.sheet-defects tbody td { height: 1.8em; border: 1px solid var(--border); }
.sheet-sign { margin-top: var(--space-3); }
.sheet-office { margin-top: var(--space-3); }
.sheet-office th { width: 11em; }
.sheet-rectified { margin-top: var(--space-2); }
.sheet-office td { height: 1.8em; border: 1px solid var(--border); }
.sheet-key { font-size: var(--text-caption); margin: var(--space-1) 0 0; }
.extra { font-weight: var(--weight-heading); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sheet-source { font-size: var(--text-caption); color: var(--text-secondary); margin: var(--space-2) 0 0; }
.sheet-controls .choice { display: inline-flex; margin-right: var(--space-5); }
button.button { border: 0; font: inherit; font-weight: var(--weight-label); cursor: pointer; }

@media print {
  @page { size: A4; margin: 10mm; }
  :root { color-scheme: light; }
  body { display: block; min-height: 0; background: Canvas; color: CanvasText; font-size: 8pt; line-height: 1.2; }
  .site-header, .site-footer, .skip, .no-print { display: none; }
  main, .wrap { padding: 0; margin: 0; max-width: none; }
  .sheet { border: 0; border-radius: 0; padding: 0; margin: 0; background: Canvas; color: CanvasText; }
  .sheet[hidden] { display: none; }
  .sheet:not([hidden]) ~ .sheet:not([hidden]) { break-before: page; }
  .sheet h2 { font-size: 13pt; margin: 0 0 2mm; }
  .sheet-fields { gap: 1.5mm 4mm; margin: 0 0 2mm; }
  .sheet-fields div { flex: 1 1 40mm; }
  .sheet-fields dd { min-height: 5mm; }
  .sheet-legs { columns: 2; column-gap: 4mm; }
  .sheet table { font-size: 8pt; }
  .sheet-leg { margin: 0 0 1.5mm; }
  .sheet caption { padding: 0.5mm 0; font-size: 8.5pt; }
  .sheet th, .sheet td { border-color: currentColor; border-bottom-width: 0.5pt; padding: 0.3mm 0.8mm; color: CanvasText; }
  .sheet thead th { font-size: 6.5pt; padding-top: 0; padding-bottom: 0; }
  .sheet .when { display: inline; font-size: 6.5pt; color: CanvasText; }
  .sheet .tick { width: 7.5mm; padding-left: 0; padding-right: 0; }
  .box { width: 3mm; height: 3mm; }
  .sheet-defects { margin-top: 2mm; }
  .sheet-defects tbody td { height: 6.5mm; border: 0.5pt solid currentColor; }
  .sheet-sign { margin-top: 2mm; }
  .sheet-sign dd { min-height: 7mm; }
  .sheet-office { margin-top: 2mm; }
  .sheet-office th { width: 32mm; }
  .sheet-rectified { margin: 1mm 0 0; }
  .sheet-office td { height: 5mm; border: 0.5pt solid currentColor; }
  .sheet-key { font-size: 6.5pt; margin: 1mm 0 0; }
  .sheet-source { font-size: 6.5pt; color: CanvasText; }
}

/* The PMI interval calculator (MK1-5). */
.tool-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 var(--space-4); max-width: 44rem; }
.tool-form[hidden] { display: none; }
.tool-form .field { flex: 1 1 14rem; }
.tool-form button { margin-bottom: var(--space-4); }
.form-error { background: var(--status-red-bg); color: var(--text); padding: var(--space-3) var(--space-4); border-radius: var(--radius-control); font-weight: var(--weight-label); }
.notice { background: var(--status-amber-bg); color: var(--text); padding: var(--space-3) var(--space-4); border-radius: var(--radius-control); }
.result-summary { font-weight: var(--weight-heading); }
.pmi-table { border-collapse: collapse; margin: var(--space-3) 0 var(--space-4); min-width: min(100%, 32rem); }
.pmi-table caption { text-align: left; font-weight: var(--weight-heading); padding: var(--space-1) 0; }
.pmi-table th, .pmi-table td { border-bottom: 1px solid var(--border); padding: var(--space-2) var(--space-3); text-align: left; }
.pmi-table thead th { font-size: var(--text-subhead); color: var(--text-secondary); font-weight: var(--weight-label); }
.pmi-table tbody th { font-weight: var(--weight-label); }
