/* ============================================================================================================
   The design system's tokens.  teams/crm/design/system/tokens.md explains every value and wins if the two ever
   differ; this is its reference tokens.css (crm-designer, 2026-10-30) with the self-hosted fonts added at the top.
   Picked by Noah on 2026-10-30 (DECISIONS.md): Drafting, Jobsite's sun mode on phones, compact rows in the office.

   Order matters: every block below has the same specificity as the one it overrides, so later wins (light, dark,
   touch, sun, compact; /ui/brand.css comes right after this file with the company's colors; homeowner pages last).
   Components use these tokens only: no hex color anywhere but here and in /ui/brand.css.
   ============================================================================================================ */

/* 0. Fonts: self-hosted woff2, Latin subset (it covers Spanish), OFL 1.1 (static/ui/fonts/README.md) ----------- */
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/instrument-sans-latin-wght-normal.fa41c43a3d8e.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;      /* optical sizes 6 to 72 in the same file */
  font-display: swap;
  src: url("fonts/newsreader-latin-opsz-normal.f94a697b1650.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;        /* the homeowner's quoted words, the sidebar's Views heading */
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/newsreader-latin-wght-italic.94402255a099.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* 1. Light (default) ---------------------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Surfaces and lines */
  --bg: #EEF1EC;              /* the page: vellum */
  --surface: #FBFCF9;         /* cards, rows, panels */
  --raised: #FFFFFF;          /* popovers, sheets, bulk bar */
  --sunken: #E5E9E3;          /* wells, tracks, skeletons, tags */
  --border: #D3D9D0;          /* hairline dividers: decorative only */
  --border-strong: #7E887B;   /* control edges: 3.58 on surface, 3.24 on bg */
  --hover: #F2F4F0;           /* row and quiet-button hover */

  /* Text */
  --text: #1E2723;            /* 14.89 on surface, 13.45 on bg, 12.48 on sunken */
  --muted: #55605A;           /* 6.36 on surface, 5.75 on bg, 5.33 on sunken */
  --on-text: #FBFCF9;         /* words on a --text fill (Present mode's lock bar) */

  /* Accent: the app's own ink blue, computed by the accent rule from #27508F. The company block replaces these. */
  --accent: #27508F;          /* fills: the one primary button, +, selected chip, current phase */
  --on-accent: #FFFFFF;       /* 7.98 */
  --accent-ink: #27508F;      /* accent as words, links, icons, bars, rings: 7.75 on surface, 6.49 on soft */
  --accent-soft: #E3E8F0;     /* selected rows, current nav item */
  --accent-edge: #27508F;     /* the 1 px edge on every accent fill (the ring rule) */
  --accent-hover: #204377;
  --focus: #27508F;

  /* Status: fixed, never from the company color; always with an icon and a word */
  --ok: #2E6B41;     --ok-soft: #E4F0E6;
  --warn: #8A5800;   --warn-soft: #F6ECD8;
  --danger: #A8352B; --danger-soft: #F7E3E0;
  --info: #2D5F8B;   --info-soft: #E2ECF5;

  --scrim: rgba(30, 39, 35, .42);

  /* Map and photo placeholders (later components) */
  --map-land: #E7EBE4; --map-block: #D9DFD5; --map-road: #FBFCF9; --map-road-edge: #C5CCC2;
  --map-swath: #27508F; --map-label: #55605A;
  /* Knock map (spec 12a): keyed to the map's style, not the theme; repeated on [data-map-style] below */
  --pin-ring: #FFFFFF; --pin-ring-w: 2px; --pin-edge: transparent; --pin-none: #6B7A90;
  --pin-dnk: #A8352B; --on-pin-dnk: #FFFFFF;
  --map-name: #1E2723; --map-name-halo: rgba(255, 255, 255, .95);
  --map-me: #2D5F8B; --map-cluster: #1E2723; --on-map-cluster: #FBFCF9;
  --job-done: #1E2723; --job-edge: #1E2723;
  --hail-1: #D4A106; --hail-2: #EA8A0C; --hail-3: #C2410C; --hail-4: #7F1D1D;
  --wind-1: #5B7DB1; --wind-2: #3B5B8C; --wind-3: #22395E;
  /* Door result tiles (spec 12a): fills are the statuses' own, worked out by the knocker */
  --on-result: #FFFFFF; --result-edge: transparent; --result-edge-w: 0px;
  --photo-1: #6C6A64; --photo-2: #8A867D; --photo-3: #B5B0A6;

  /* Type */
  --font-ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --fw-body: 400; --fw-medium: 500; --fw-strong: 600; --fw-display: 500;
  --fs-xs: 13px;   /* the smallest text anywhere */
  --fs-sm: 14px;
  --fs-md: 15px;   /* body */
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 26px;
  --fs-3xl: 34px;
  --lh-body: 1.5; --lh-tight: 1.2; --track-display: -0.01em;

  /* Space */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 48px;

  /* Shape */
  --r-sm: 3px;      /* chips, inputs, tags */
  --r-md: 5px;      /* buttons, panels inside cards */
  --r-lg: 8px;      /* cards, sheets */
  --r-pill: 999px;  /* sync pill, avatars, count badges */
  --bw: 1px;        /* every border */
  --bw-strong: 1px; /* the primary button and the Now panel (2 and 3 px in sun) */
  --bar: 3px;       /* "the active one": current nav, selected row, Now panel */

  /* Elevation: no card shadows; one float shadow for sheets, the +, the bulk bar, menus and popovers */
  --shadow-card: none;
  --shadow-float: 0 8px 28px rgba(30, 39, 35, .14);

  /* Focus */
  --focus-w: 2px; --focus-offset: 2px;

  /* Density: comfortable desktop */
  --ctl-h: 34px;      /* buttons, inputs, selects */
  --ctl-h-sm: 28px;
  --chip-h: 28px;
  --row-h: 48px;      /* list and table rows */
  --tap: 24px;        /* smallest hit area (mouse) */
  --pad-card: 20px;
  --pad-page: 32px;
  --topbar-h: 56px;
  --tab-h: 64px;      /* phone tab bar, without the safe area */
  --sidebar-w: 232px; --sidebar-w-folded: 64px;
  --icon-size: 18px; --icon-stroke: 1.5;
  --meter-h: 8px;

  /* Layout */
  --content-max: 1440px; --form-max: 720px;
  --sheet-w: 480px; --sheet-w-lg: 720px; --sheet-w-xl: 960px;

  /* Layers */
  --z-sticky: 10; --z-tabbar: 20; --z-fab: 30; --z-bulk: 30; --z-scrim: 39; --z-sheet: 40; --z-dialog: 50; --z-cmd: 60;

  /* Motion (prefers-reduced-motion: reduce sets both to 0ms) */
  --dur-fast: 120ms; --dur-sheet: 200ms; --ease: cubic-bezier(.2, .7, .2, 1);
}

/* 2. Dark: colors only --------------------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161B19; --surface: #1D2320; --raised: #252C28; --sunken: #121614;
  --border: #36403B; --border-strong: #6E7B73;   /* 3.61 on surface, 3.94 on bg */
  --hover: #232A26;
  --text: #E6EAE5;   /* 13.14 on surface */
  --muted: #A3ADA7;  /* 6.92 on surface */
  --on-text: #161B19;
  --accent: #9EBAE4; --on-accent: #161B19; --accent-ink: #9EBAE4; --accent-soft: #374147;
  --accent-edge: #9EBAE4; --accent-hover: #B6CBEB; --focus: #9EBAE4;
  --ok: #7CC492;     --ok-soft: #1E3326;
  --warn: #E2B35A;   --warn-soft: #3A2F1A;
  --danger: #F0897D; --danger-soft: #3E2421;
  --info: #8DBBE3;   --info-soft: #1D3040;
  --scrim: rgba(0, 0, 0, .6);
  --map-land: #1A201D; --map-block: #2A322E; --map-road: #36403B; --map-road-edge: #121614;
  --map-swath: #9EBAE4; --map-label: #A3ADA7;
  --result-edge: var(--border-strong); --result-edge-w: 1px;
  --photo-1: #4C4A46; --photo-2: #66625C; --photo-3: #878279;
  --shadow-float: 0 10px 30px rgba(0, 0, 0, .5);
}

/* The Knock map's own style wins over the theme (the knocker sets data-map-style on its map element) */
[data-map-style="streets"], [data-map-style="satellite"] {
  --map-name: #1E2723; --map-name-halo: rgba(255, 255, 255, .95);
}
[data-map-style="dark"] {
  --map-name: #E6EAE5; --map-name-halo: rgba(22, 27, 25, .95);
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0ms; --dur-sheet: 0ms; }
}

/* 3. Touch: phone and tablet sizes ---------------------------------------------------------------------------- */
@media (max-width: 767px), (pointer: coarse) {
  :root {
    --fs-md: 16px;   /* 16 px inputs: iOS doesn't zoom */
    --fs-lg: 18px; --fs-xl: 21px; --fs-2xl: 26px; --fs-3xl: 30px;
    --ctl-h: 48px; --ctl-h-sm: 44px; --chip-h: 40px;   /* chips get a 44 px hit area */
    --row-h: 64px;
    --tap: 44px;
    --pad-card: 16px; --pad-page: 16px;
    --icon-size: 22px; --icon-stroke: 1.75;
  }
}

/* 4. Sun: Jobsite's sizes and black edges in Drafting's ink and the company's color (touch devices only) ------- */
@media (max-width: 767px), (pointer: coarse) {
  :root[data-sun="1"] {
    color-scheme: light;
    --bg: #FFFFFF; --surface: #FFFFFF; --raised: #FFFFFF; --sunken: #EEF1EC;
    --border: #3A433E;          /* 10.23 on white: cards still separate in glare */
    --border-strong: #000000;
    --hover: #F4F6F2;
    --text: #000000;            /* 21.0 */
    --muted: #2E3631;           /* 12.44 */
    --on-text: #FFFFFF;
    --accent: #27508F; --on-accent: #FFFFFF; --accent-ink: #244983; --accent-soft: #E3E8F0;
    --accent-edge: #000000; --accent-hover: #204377; --focus: #244983;
    --ok: #1F5530;     --ok-soft: #E4F0E6;
    --warn: #6E4600;   --warn-soft: #F6ECD8;
    --danger: #8E2016; --danger-soft: #F7E3E0;
    --info: #1F4A70;   --info-soft: #E2ECF5;
    --scrim: rgba(0, 0, 0, .55);
    --map-land: #F4F6F2; --map-block: #C9D0C5; --map-road: #FFFFFF; --map-road-edge: #3A433E;
    --map-swath: #244983; --map-label: #000000;
    --pin-ring-w: 3px; --pin-edge: #000000; --pin-none: #4E5868; --pin-dnk: #8E2016;
    --map-name: #000000; --map-name-halo: #FFFFFF;
    --map-cluster: #000000; --on-map-cluster: #FFFFFF; --job-done: #000000; --job-edge: #000000;
    --result-edge: #000000; --result-edge-w: 2px;
    --photo-1: #5E5C57; --photo-2: #7D7970; --photo-3: #A9A499;

    --fw-body: 500; --fw-medium: 600; --fw-strong: 700; --fw-display: 600;
    --fs-xs: 15px; --fs-sm: 16px; --fs-md: 18px; --fs-lg: 20px; --fs-xl: 24px; --fs-2xl: 28px; --fs-3xl: 32px;
    --ctl-h: 64px; --ctl-h-sm: 52px; --chip-h: 52px;   /* small controls and chips get a 64 px hit area */
    --row-h: 72px;
    --tap: 64px;
    --tab-h: 76px;
    --bw: 2px; --bw-strong: 3px;
    --icon-size: 24px; --icon-stroke: 2.25;
    --meter-h: 12px;
    --focus-w: 3px;
    --shadow-float: 0 0 0 2px #000000;   /* a hard black edge instead of a blur */
  }
  /* the map container's own style would beat the root's sun names, so sun restates them on it */
  :root[data-sun="1"] [data-map-style] {
    --map-name: #000000; --map-name-halo: #FFFFFF;
  }
}

/* 5. Compact: Dispatch's row and control heights; type sizes don't change ------------------------------------- */
@media (min-width: 1024px) and (pointer: fine) {
  :root[data-density="compact"] {
    --ctl-h: 28px; --ctl-h-sm: 24px; --chip-h: 24px;
    --row-h: 34px;
    --pad-card: 12px; --pad-page: 24px;
    --sidebar-w: 208px;
    --icon-size: 16px; --icon-stroke: 1.75;
    --meter-h: 6px;
  }
}

/* 6. The company's colors: /ui/brand.css, served after this file. Example for Kettle Ridge Roofing (demo), plum
   (the --brand-* tokens of tokens.md 11.5 go in the same :root block):
   :root{--accent:#6B3FA0;--on-accent:#FFFFFF;--accent-ink:#6B3FA0;--accent-soft:#ECE6F3;--accent-edge:#6B3FA0;
         --accent-hover:#5C368A;--focus:#6B3FA0;--map-swath:#6B3FA0}
   :root[data-theme="dark"]{--accent:#C4ADDF;--on-accent:#161B19;--accent-ink:#C4ADDF;--accent-soft:#3E3F46;
         --accent-edge:#C4ADDF;--accent-hover:#D4C3E8;--focus:#C4ADDF;--map-swath:#C4ADDF}
   @media (max-width:767px),(pointer:coarse){:root[data-sun="1"]{--accent:#6B3FA0;--on-accent:#FFFFFF;
         --accent-ink:#5F388E;--accent-soft:#ECE6F3;--accent-edge:#000000;--accent-hover:#5C368A;--focus:#5F388E;
         --map-swath:#5F388E}}
   ------------------------------------------------------------------------------------------------------------ */

/* 7. Homeowner pages: always light, the company's brand, no theme, sun or compact ----------------------------- */
:root[data-page="homeowner"] {
  color-scheme: light;
  --bg: #F4F5F2;              /* the margin around the paper */
  --surface: #FFFFFF;         /* the paper */
  --raised: #FFFFFF;
  --sunken: #EBEDE8;
  --border: #D5D9D2;
  --border-strong: #7A8377;   /* 3.93 on surface, 3.59 on bg */
  --hover: #F4F5F2;
  --text: #1E2723;            /* 15.33 on surface */
  --muted: #545E58;           /* 6.73 on surface, 6.15 on bg */
  --on-text: #FFFFFF;
  --ok: #2E6B41;     --ok-soft: #E4F0E6;
  --warn: #8A5800;   --warn-soft: #F6ECD8;
  --danger: #A8352B; --danger-soft: #F7E3E0;
  --info: #2D5F8B;   --info-soft: #E2ECF5;
  /* --brand, --brand-ink, --brand-soft, --brand-fill, --on-brand, --brand-edge, --brand-cta, --on-brand-cta,
     --brand-cta-edge, --brand-cta-hover, --brand-focus, --brand-font-heading, --brand-font-body:
     ONLY from /ui/brand.css, worked out by the server from the company's brand settings.
     Shared components (buttons, links, chips, focus) read the accent slots, so on homeowner pages the accent
     slots point at the brand. This block outranks brand.css's :root accent (one more attribute). */
  --accent: var(--brand-cta);
  --on-accent: var(--on-brand-cta);
  --accent-ink: var(--brand-ink);
  --accent-soft: var(--brand-soft);
  --accent-edge: var(--brand-cta-edge);
  --accent-hover: var(--brand-cta-hover);
  --focus: var(--brand-focus);
  --font-ui: var(--brand-font-body);
  --font-display: var(--brand-font-heading);
}
