/* Eon Home theme layer. The ONLY file in the dashboard that holds raw colour values: everything else (styles.css, the
   per-area sheets in css/, the JavaScript, the Chart.js palette) reads these custom properties.

   Three layers, each pointing at the one before: the design system's scales (names and values are Eon Home's, verbatim
   from tokens.json), a semantic layer for every meaning the interface has (surface, text, accent, status, energy, plan
   mode), and the names the older stylesheets and the charts use. Dark is the semantic layer re-pointed: at the foot of
   this file, under the system setting and under data-theme="dark" (public/theme-boot.js sets it before first paint).
   Light and dark are both first class; light is the reference. Every token Chart.js reads resolves to a plain hex value in
   both. No inline styles anywhere (CSP style-src 'self'); the fonts are served from /fonts (CSP font-src 'self'). */

@font-face {
  font-family: 'Inter Display';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/InterDisplay-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter Display';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/InterDisplay-Medium.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter Display';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/InterDisplay-SemiBold.woff2') format('woff2');
}

:root {
  color-scheme: light;

  /* The design system's palette: every scale, exactly as in tokens.json. */
  --white: #ffffff;
  --black: #000000;

  /* neutral */
  --gray-25: #fdfdfd;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #e9eaeb;
  --gray-300: #d5d7da;
  --gray-400: #a4a7ae;
  --gray-500: #717680;
  --gray-600: #535862;
  --gray-700: #414651;
  --gray-800: #252b37;
  --gray-900: #181d27;

  /* brand: Eon green */
  --brand-25: #f6fffa;
  --brand-50: #deede5;
  --brand-100: #c5dcd1;
  --brand-200: #adcabc;
  --brand-300: #95b9a8;
  --brand-400: #64957e;
  --brand-500: #347255;
  --brand-600: #034f2c;
  --brand-700: #023f23;
  --brand-800: #022f1a;
  --brand-900: #012012;

  /* blue: informational, and the grid */
  --blue-25: #f5faff;
  --blue-50: #eff8ff;
  --blue-100: #d1e9ff;
  --blue-200: #b2ddff;
  --blue-300: #84caff;
  --blue-400: #53b1fd;
  --blue-500: #2e90fa;
  --blue-600: #1570ef;
  --blue-700: #175cd3;
  --blue-800: #1849a9;
  --blue-900: #194185;

  /* success */
  --success-25: #f6fef9;
  --success-50: #ecfdf3;
  --success-100: #d1fadf;
  --success-200: #a6f4c5;
  --success-300: #6ce9a6;
  --success-400: #32d583;
  --success-500: #12b76a;
  --success-600: #039855;
  --success-700: #027a48;
  --success-800: #05603a;
  --success-900: #054f31;

  /* warning, and solar */
  --warning-25: #fffcf5;
  --warning-50: #fffaeb;
  --warning-100: #fef0c7;
  --warning-200: #fedf89;
  --warning-300: #fec84b;
  --warning-400: #fdb022;
  --warning-500: #f79009;
  --warning-600: #dc6803;
  --warning-700: #b54708;
  --warning-800: #93370d;
  --warning-900: #7a2e0e;

  /* error */
  --error-25: #fffbfa;
  --error-50: #fef3f2;
  --error-100: #fee4e2;
  --error-200: #fecdca;
  --error-300: #fda29b;
  --error-400: #f97066;
  --error-500: #f04438;
  --error-600: #d92d20;
  --error-700: #b42318;
  --error-800: #912018;
  --error-900: #7a271a;

  /* ---------- surfaces ---------- */
  --bg: var(--white); /* the page */
  --surface: var(--white); /* cards, tiles */
  --surface-2: var(--gray-50); /* inset: input fills, table heads, hover */
  --surface-raised: var(--white); /* sheets, buttons, toasts, the active tab */
  --surface-2-raised: var(
    --gray-50
  ); /* inset inside a sheet (styles.css rebinds --surface-2 to it in dialog) */
  --fill: var(--gray-100); /* subtle fills: neutral badges, chips, hover on glass, disabled controls */
  --fill-raised: var(--gray-100); /* the same inside a sheet */
  --border: var(--gray-200); /* default 1px stroke */
  --border-strong: var(--gray-300); /* unselected control edges, scroll shadows */
  --border-raised: var(--gray-200); /* default stroke inside a sheet */
  --control-border: var(--gray-500); /* an input's edge, or any control with only a border: 4.6:1 */
  --btn-border: var(--gray-100); /* secondary button edge */
  --btn-hover: var(--gray-50); /* secondary button hover */
  --scrim: rgb(0 0 0 / 40%); /* behind a bottom sheet */

  /* ---------- text and icons ---------- */
  --text: var(--gray-900); /* primary text */
  --text-2: var(--gray-600); /* captions, labels, timestamps: 6.5:1 or better on every light fill */
  --text-2-strong: var(--gray-600); /* supporting copy that needs more weight */
  --text-3: var(--gray-400); /* decoration only (bullets); never text a person must read */
  --text-faint: var(--gray-600); /* placeholders and other quiet text that is still read */
  --text-disabled: var(--gray-500); /* text of a disabled control: quieter than --text-faint */
  --text-strong: var(--gray-700); /* button text, neutral badges, active icons */
  --icon: var(--gray-700); /* default icon colour */
  --text-on-accent: var(--white); /* text on a solid brand or status fill */

  /* ---------- accent (Eon green) ---------- */
  --accent: var(--brand-600); /* links, key figures, active items, icons, progress */
  --accent-hover: var(--brand-700); /* hover on accent text */
  --accent-weak: var(--brand-50); /* tinted fill: info badge, selected, track */
  --accent-weak-text: var(--brand-700); /* text on accent-weak */
  --accent-solid: var(--brand-600); /* solid fills: primary button, live chip */
  --accent-solid-hover: var(--brand-700); /* hover on a solid fill */
  --accent-solid-edge: var(--brand-600); /* edge of a solid fill (lifts it off a dark card) */
  --strip-bg: var(--brand-600); /* the brand strip */
  --strip-text: var(--white); /* text on the brand strip */
  --strip-text-2: var(--brand-100); /* captions on the brand strip */

  /* ---------- status ---------- */
  --ok: var(--success-600); /* icon and line */
  --ok-weak: var(--success-50); /* tinted fill */
  --ok-text: var(--success-700); /* text */
  --warn: var(--warning-600); /* icon and line */
  --warn-weak: var(--warning-50); /* tinted fill */
  --warn-text: var(--warning-700); /* text */
  --crit: var(--error-600); /* icon and line, destructive text */
  --crit-weak: var(--error-50); /* tinted fill */
  --crit-text: var(--error-700); /* text */
  --crit-solid: var(--error-600); /* solid destructive fill */
  --crit-solid-hover: var(--error-700); /* hover on it */
  --info: var(--blue-600); /* icon and line */
  --info-weak: var(--blue-50); /* tinted fill */
  --info-text: var(--blue-700); /* text */
  --focus-ring: var(--brand-600); /* focus outline */

  /* ---------- energy: one colour per actor, the same everywhere (plain hex: Chart.js reads these) ---------- */
  --energy-solar: var(--warning-600); /* solar lines and icons */
  --energy-solar-text: var(--warning-700); /* solar figures */
  --energy-solar-weak: var(--warning-100); /* solar fills */
  --energy-home: var(--gray-900); /* home lines and icons */
  --energy-home-text: var(--gray-900); /* home figures */
  --energy-home-weak: var(--gray-100); /* home fills */
  --energy-battery: var(--brand-500); /* battery lines and icons */
  --energy-battery-text: var(--brand-600); /* battery figures */
  --energy-battery-weak: var(--brand-50); /* battery fills */
  --energy-grid: var(--blue-600); /* grid lines and icons, both directions */
  --energy-grid-text: var(--blue-700); /* grid figures */
  --energy-grid-weak: var(--blue-100); /* grid fills */
  --energy-grid-export: var(--blue-300); /* exporting bars (below the axis) */

  /* ---------- plan modes: a band takes the colour of its source (the legacy --band-charge / --band-export stay until the plan is redrawn) ---------- */
  --band-grid-charge: var(--blue-100); /* Grid charge band */
  --band-force-export: var(--brand-50); /* Force export band */
  --band-hold: var(--gray-100); /* Hold band (hatched where it is drawn) */
  --mode-self-use: var(--gray-700); /* Self-use rail and icon */
  --mode-grid-charge: var(--blue-600); /* Grid charge rail and icon */
  --mode-force-export: var(--brand-600); /* Force export rail and icon */
  --mode-hold: var(--gray-500); /* Hold rail and icon */

  /* ---------- inverter mode chip ---------- */
  --mode-shadow-bg: var(--gray-100); /* Shadow */
  --mode-shadow-text: var(--gray-700);
  --mode-live-bg: var(--brand-600); /* Live */
  --mode-live-text: var(--white);
  --mode-paused-bg: var(--warning-50); /* Paused */
  --mode-paused-text: var(--warning-700);

  /* ---------- chart tokens (Chart.js reads these: each must resolve to a plain hex) ---------- */
  --series-import: var(--brand-600); /* grid import price, SoC */
  --series-export: var(--gray-500); /* export price */
  --series-pv: var(--success-600); /* solar generation */
  --series-load: var(--gray-900); /* household load */
  --series-soc: var(--brand-600); /* state of charge */
  --band-charge: var(--brand-50); /* legacy Grid charge band */
  --band-export: var(--warning-50); /* legacy Force export band */
  --chart-grid: var(--gray-200); /* gridlines */
  --chart-now: var(--gray-600); /* the now marker */
  --chart-text: var(--gray-500); /* axes and ticks */

  /* ---------- chrome ---------- */
  --navbar-glass: rgb(255 255 255 / 85%); /* frosted white in light: icons keep 7:1 over any card */
  --navbar-pill: var(--accent-weak); /* the selected tab's pill: a brand tint on the white glass */
  --logo-ink: var(--brand-600); /* the logomark has one ink and no reversed version */
  --logo-tile: transparent; /* so in dark it sits on a white tile */
  --logo-pad: 0px; /* tile padding */
  --logo-radius: 0px; /* tile corners */
  --grain-opacity: 0.6; /* the fine grain on summary cards */

  --navbar-blur: 20px;

  /* ---------- the names the stylesheets and the charts already use, now pointing at the semantic layer ---------- */
  --text-primary: var(--text);
  --text-label: var(--text-2);

  /* ---------- type ---------- */
  --font-sans: 'Inter Display', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  --display-xs-size: 24px; /* hero figures */
  --display-xs-line: 32px;
  --text-xl-size: 20px; /* section titles */
  --text-xl-line: 30px;
  --text-lg-size: 18px; /* card titles, tile values */
  --text-lg-line: 28px;
  --text-md-size: 16px; /* body */
  --text-md-line: 24px;
  --text-sm-size: 14px; /* default UI text */
  --text-sm-line: 20px;
  --text-xs-size: 12px; /* captions, axes, badges */
  --text-xs-line: 18px;

  /* ---------- spacing ---------- */
  --space-2: 2px;
  --space-4: 4px;
  --space-6: 6px;
  --space-8: 8px;
  --space-10: 10px;
  --space-12: 12px;
  --space-14: 14px;
  --space-16: 16px;
  --space-18: 18px;
  --space-20: 20px;
  --space-24: 24px;
  --space-32: 32px;
  --space-40: 40px;

  /* ---------- radius ---------- */
  --radius-4: 4px;
  --radius-6: 6px;
  --radius-8: 8px; /* inputs */
  --radius-10: 10px;
  --radius-12: 12px; /* default: buttons, cards, tiles */
  --radius-16: 16px; /* navbar */
  --radius-24: 24px; /* top corners of bottom sheets */
  --radius-full: 999px;

  /* ---------- shadows (dark: see below; elevation there comes from a lighter surface) ---------- */
  --shadow-xs: 0 1px 2px #0a0d120d;
  --shadow-sm: 0 1px 3px #0a0d121a, 0 1px 2px #0a0d120f;
  --shadow-md: 0 4px 8px -2px #0a0d121a, 0 2px 4px -2px #0a0d120f;
  --shadow-lg: 0 12px 16px -4px #0a0d1214, 0 4px 6px -2px #0a0d1208;
  --focus-ring-brand: 0 0 0 4px #e7f3ed;

  /* ---------- motion ---------- */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;
}

/* Dark theme. Two selectors carry the same declarations: the OS preference (unless the person chose Light) and an
   explicit choice (theme-boot.js sets data-theme before first paint). Keep the two blocks identical; a test checks it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;

    /* surfaces */
    --bg: #0a0d12;
    --surface: var(--gray-900);
    --surface-2: var(--gray-800);
    --surface-raised: var(--gray-800);
    --surface-2-raised: var(--gray-900);
    --fill: var(--gray-800);
    --fill-raised: var(--gray-700);
    --border: var(--gray-800);
    --border-strong: var(--gray-700);
    --border-raised: var(--gray-700);
    --control-border: var(--gray-500);
    --btn-border: var(--gray-700);
    --btn-hover: var(--gray-700);
    --scrim: rgb(0 0 0 / 60%);

    /* text and icons */
    --text: var(--gray-50);
    --text-2: var(--gray-300);
    --text-2-strong: var(--gray-200);
    --text-faint: var(--gray-400);
    --text-disabled: var(--gray-400);
    --text-strong: var(--gray-200);
    --icon: var(--gray-300);

    /* accent (Eon green) */
    --accent: var(--brand-300);
    --accent-hover: var(--brand-200);
    --accent-weak: #213836;
    --accent-weak-text: var(--brand-100);
    --accent-solid-hover: var(--brand-500);
    --accent-solid-edge: var(--brand-500);
    --strip-bg: var(--brand-800);
    --strip-text: var(--brand-100);
    --strip-text-2: var(--brand-200);

    /* status */
    --ok: var(--success-400);
    --ok-weak: #173632;
    --ok-text: var(--success-300);
    --warn: var(--warning-400);
    --warn-weak: #3c2f22;
    --warn-text: var(--warning-300);
    --crit: var(--error-400);
    --crit-weak: #3f242a;
    --crit-text: var(--error-300);
    --crit-solid-hover: var(--error-500);
    --info: var(--blue-400);
    --info-weak: #1c324d;
    --info-text: var(--blue-300);
    --focus-ring: var(--brand-300);

    /* energy: one colour per actor, the same everywhere (plain hex: Chart.js reads these) */
    --energy-solar: var(--warning-400);
    --energy-solar-text: var(--warning-300);
    --energy-solar-weak: #372d23;
    --energy-home: var(--gray-200);
    --energy-home-text: var(--gray-50);
    --energy-home-weak: var(--gray-800);
    --energy-battery: var(--brand-300);
    --energy-battery-text: var(--brand-300);
    --energy-battery-weak: #213836;
    --energy-grid: var(--blue-400);
    --energy-grid-text: var(--blue-300);
    --energy-grid-weak: var(--blue-900);
    --energy-grid-export: var(--blue-200);

    /* plan modes: a band takes the colour of its source (the legacy --band-charge / --band-export stay until the plan is redrawn) */
    --band-grid-charge: var(--info-weak); /* a tint of the info fill, not blue-900 (too heavy) */
    --band-force-export: var(--brand-900);
    --band-hold: var(--gray-800);
    --mode-self-use: var(--gray-300);
    --mode-grid-charge: var(--blue-400);
    --mode-force-export: var(--brand-300);
    --mode-hold: var(--gray-400);

    /* inverter mode chip */
    --mode-shadow-bg: var(--gray-800);
    --mode-shadow-text: var(--gray-200);
    --mode-paused-bg: #3c2f22;
    --mode-paused-text: var(--warning-300);

    /* chart tokens (Chart.js reads these: each must resolve to a plain hex) */
    --series-import: var(--brand-300);
    --series-export: var(--gray-400);
    --series-pv: var(--success-400);
    --series-load: var(--gray-200);
    --series-soc: var(--brand-300);
    --band-charge: #233d38;
    --band-export: #493620;
    --chart-grid: var(--gray-800);
    --chart-now: var(--gray-300);
    --chart-text: var(--gray-400);

    /* chrome */
    --navbar-glass: rgb(37 43 55 / 72%);
    --navbar-pill: var(--surface-raised);
    --logo-tile: var(--white);
    --logo-pad: 4px 5px;
    --logo-radius: 8px;
    --grain-opacity: 0.1;
    --shadow-xs: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 40%), 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-md: 0 4px 8px -2px rgb(0 0 0 / 40%), 0 2px 4px -2px rgb(0 0 0 / 30%);
    --shadow-lg: 0 12px 16px -4px rgb(0 0 0 / 50%), 0 4px 6px -2px rgb(0 0 0 / 40%);
    --focus-ring-brand: 0 0 0 4px var(--brand-800);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;

  /* surfaces */
  --bg: #0a0d12;
  --surface: var(--gray-900);
  --surface-2: var(--gray-800);
  --surface-raised: var(--gray-800);
  --surface-2-raised: var(--gray-900);
  --fill: var(--gray-800);
  --fill-raised: var(--gray-700);
  --border: var(--gray-800);
  --border-strong: var(--gray-700);
  --border-raised: var(--gray-700);
  --control-border: var(--gray-500);
  --btn-border: var(--gray-700);
  --btn-hover: var(--gray-700);
  --scrim: rgb(0 0 0 / 60%);

  /* text and icons */
  --text: var(--gray-50);
  --text-2: var(--gray-300);
  --text-2-strong: var(--gray-200);
  --text-faint: var(--gray-400);
  --text-disabled: var(--gray-400);
  --text-strong: var(--gray-200);
  --icon: var(--gray-300);

  /* accent (Eon green) */
  --accent: var(--brand-300);
  --accent-hover: var(--brand-200);
  --accent-weak: #213836;
  --accent-weak-text: var(--brand-100);
  --accent-solid-hover: var(--brand-500);
  --accent-solid-edge: var(--brand-500);
  --strip-bg: var(--brand-800);
  --strip-text: var(--brand-100);
  --strip-text-2: var(--brand-200);

  /* status */
  --ok: var(--success-400);
  --ok-weak: #173632;
  --ok-text: var(--success-300);
  --warn: var(--warning-400);
  --warn-weak: #3c2f22;
  --warn-text: var(--warning-300);
  --crit: var(--error-400);
  --crit-weak: #3f242a;
  --crit-text: var(--error-300);
  --crit-solid-hover: var(--error-500);
  --info: var(--blue-400);
  --info-weak: #1c324d;
  --info-text: var(--blue-300);
  --focus-ring: var(--brand-300);

  /* energy: one colour per actor, the same everywhere (plain hex: Chart.js reads these) */
  --energy-solar: var(--warning-400);
  --energy-solar-text: var(--warning-300);
  --energy-solar-weak: #372d23;
  --energy-home: var(--gray-200);
  --energy-home-text: var(--gray-50);
  --energy-home-weak: var(--gray-800);
  --energy-battery: var(--brand-300);
  --energy-battery-text: var(--brand-300);
  --energy-battery-weak: #213836;
  --energy-grid: var(--blue-400);
  --energy-grid-text: var(--blue-300);
  --energy-grid-weak: var(--blue-900);
  --energy-grid-export: var(--blue-200);

  /* plan modes: a band takes the colour of its source (the legacy --band-charge / --band-export stay until the plan is redrawn) */
  --band-grid-charge: var(--info-weak); /* a tint of the info fill, not blue-900 (too heavy) */
  --band-force-export: var(--brand-900);
  --band-hold: var(--gray-800);
  --mode-self-use: var(--gray-300);
  --mode-grid-charge: var(--blue-400);
  --mode-force-export: var(--brand-300);
  --mode-hold: var(--gray-400);

  /* inverter mode chip */
  --mode-shadow-bg: var(--gray-800);
  --mode-shadow-text: var(--gray-200);
  --mode-paused-bg: #3c2f22;
  --mode-paused-text: var(--warning-300);

  /* chart tokens (Chart.js reads these: each must resolve to a plain hex) */
  --series-import: var(--brand-300);
  --series-export: var(--gray-400);
  --series-pv: var(--success-400);
  --series-load: var(--gray-200);
  --series-soc: var(--brand-300);
  --band-charge: #233d38;
  --band-export: #493620;
  --chart-grid: var(--gray-800);
  --chart-now: var(--gray-300);
  --chart-text: var(--gray-400);

  /* chrome */
  --navbar-glass: rgb(37 43 55 / 72%);
  --navbar-pill: var(--surface-raised);
  --logo-tile: var(--white);
  --logo-pad: 4px 5px;
  --logo-radius: 8px;
  --grain-opacity: 0.1;
  --shadow-xs: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow-sm: 0 1px 3px rgb(0 0 0 / 40%), 0 1px 2px rgb(0 0 0 / 30%);
  --shadow-md: 0 4px 8px -2px rgb(0 0 0 / 40%), 0 2px 4px -2px rgb(0 0 0 / 30%);
  --shadow-lg: 0 12px 16px -4px rgb(0 0 0 / 50%), 0 4px 6px -2px rgb(0 0 0 / 40%);
  --focus-ring-brand: 0 0 0 4px var(--brand-800);
}
