/* Infinite UI theme — the design tokens of the Infinite Script sites.
   Source of truth: infinite-services/src/assets/theme.css. Infinite Servers,
   Infinite Gateway and Infinite Visitors keep verbatim copies; edit this one
   and run scripts/sync-shared-css.sh (--check to only compare).
   Only tokens and page-level rules belong here. Component styles live in each
   app's own stylesheets and consume these tokens, never the other way round.

   The palette applies wherever data-theme is set (the root, which the theme
   boot script stamps, and an app's .app root), and again on the shared header
   and footer (.appbar, .site-footer; site-chrome.css) so they keep it whatever
   a page defines. ui.css holds the components built on these tokens. */
:root {
  /* The brand colour, declared once and only here, so a site can override it
     on the root (Infinite Servers' branding sets its theme colour there) and
     have it reach every element. Everything red derives from it: the text and
     fill twins and the backdrop's glow, per scheme, below. */
  --accent: #e74c3c;
  /* Google Sans, as on the other Infinite Script sites; each app self-hosts
     it (see its @font-face). CJK, which its Latin subsets leave out, falls
     back per character to the platform's own font. */
  --font:
    "Google Sans", Roboto, "Segoe UI", "Helvetica Neue", Arial, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  /* Only for code: commands, tokens, URLs, paths. The platform's own, so
     nothing to download. Numbers and labels use --font. */
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r: 16px;
  --r-control: 10px;
  --r-small: 8px;
  --page-gutter: 30px;
  --glass-blur: 20px;
}

[data-theme="dark"],
[data-theme="dark"] :is(.appbar, .site-footer) {
  color-scheme: dark;
  /* --accent where it carries text, lightened, and behind white text (a
     primary button, a selected chip), darkened. Without relative colours a
     fixed mix; with them (below) a lightness bound that holds 4.5:1 for any
     brand colour. */
  --accent-text: color-mix(in oklch, var(--accent), white 18%);
  --accent-fill: color-mix(in oklch, var(--accent), black 22%);
  --bg: oklch(0.165 0.008 255);
  --bg-grad: oklch(0.27 0.026 265);
  --bg-glow: oklch(0.25 0.025 25 / 0.32);
  --surface: oklch(0.225 0.01 255);
  --surface-2: oklch(0.275 0.012 255);
  --inset: oklch(0.185 0.008 255);
  --appbar: oklch(0.205 0.012 255 / 0.76);
  --glass-panel: oklch(0.225 0.01 255 / 0.9);
  --glass-float: oklch(0.255 0.012 255 / 0.92);
  --glass-control: oklch(0.3 0.012 255 / 0.5);
  --glass-highlight: oklch(1 0 0 / 0.055);
  --border: oklch(1 0 0 / 0.1);
  --border-2: oklch(1 0 0 / 0.18);
  --text: oklch(0.97 0.004 255);
  --dim: oklch(0.77 0.012 255);
  --faint: oklch(0.66 0.012 255);
  --bar: oklch(0.72 0.02 255);
  --track: oklch(1 0 0 / 0.08);
  --ok: oklch(0.78 0.16 155);
  --ok-soft: oklch(0.78 0.16 155 / 0.14);
  --warn: oklch(0.82 0.15 80);
  /* The status colours where they carry text (same as above here: 8:1 or
     more on every dark background). */
  --ok-text: oklch(0.78 0.16 155);
  --warn-text: oklch(0.82 0.15 80);
  --down: oklch(0.66 0.012 255);
  --c2: oklch(0.74 0.1 232);
  --chart-grid: oklch(1 0 0 / 0.06);
  --chart-cross: oklch(1 0 0 / 0.26);
  --shadow:
    inset 0 1px 0 var(--glass-highlight), 0 2px 4px oklch(0 0 0 / 0.18),
    0 12px 32px oklch(0 0 0 / 0.2);
  --shadow-sm:
    inset 0 1px 0 var(--glass-highlight), 0 1px 3px oklch(0 0 0 / 0.2);
  --shadow-float:
    inset 0 1px 0 var(--glass-highlight), 0 16px 40px oklch(0 0 0 / 0.32);
}

[data-theme="light"],
[data-theme="light"] :is(.appbar, .site-footer) {
  color-scheme: light;
  /* --accent where it carries text and behind white text, darkened: #e74c3c
     itself is only 3.5-3.8:1 here. A fixed mix, or with relative colours
     (below) a lightness bound that holds 4.5:1 for any brand colour. */
  --accent-text: color-mix(in oklch, var(--accent), black 22%);
  --accent-fill: color-mix(in oklch, var(--accent), black 22%);
  --bg: oklch(0.967 0.006 255);
  --bg-grad: oklch(0.91 0.025 265);
  --bg-glow: oklch(0.92 0.025 25 / 0.34);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.967 0.006 255);
  --inset: oklch(0.948 0.006 255);
  --appbar: oklch(1 0 0 / 0.76);
  --glass-panel: oklch(1 0 0 / 0.9);
  --glass-float: oklch(1 0 0 / 0.94);
  --glass-control: oklch(1 0 0 / 0.58);
  --glass-highlight: oklch(1 0 0 / 0.75);
  --border: oklch(0.3 0.012 255 / 0.12);
  --border-2: oklch(0.3 0.012 255 / 0.2);
  --text: oklch(0.26 0.012 260);
  --dim: oklch(0.44 0.012 260);
  --faint: oklch(0.52 0.012 260);
  --bar: oklch(0.55 0.02 255);
  --track: oklch(0 0 0 / 0.065);
  --ok: oklch(0.57 0.14 155);
  --ok-soft: oklch(0.57 0.14 155 / 0.12);
  --warn: oklch(0.59 0.14 65);
  /* The status colours where they carry text: --ok and --warn are only
     3.6-4.3:1 here; these are 4.8:1 or more on every light background. */
  --ok-text: oklch(0.5 0.13 155);
  --warn-text: oklch(0.52 0.12 65);
  --down: oklch(0.52 0.012 260);
  --c2: oklch(0.55 0.13 245);
  --chart-grid: oklch(0 0 0 / 0.07);
  --chart-cross: oklch(0 0 0 / 0.28);
  --shadow:
    inset 0 1px 0 var(--glass-highlight), 0 2px 4px oklch(0.3 0.02 255 / 0.03),
    0 12px 32px oklch(0.3 0.02 255 / 0.055);
  --shadow-sm:
    inset 0 1px 0 var(--glass-highlight), 0 1px 3px oklch(0.3 0.02 255 / 0.06);
  --shadow-float:
    inset 0 1px 0 var(--glass-highlight), 0 16px 40px oklch(0.3 0.02 255 / 0.14);
}

/* The brand-derived colours, exactly: --accent's hue and chroma at a bounded
   lightness. Text and fills keep 4.5:1 whatever the brand colour; the glow
   keeps its depth and takes the brand's hue. */
@supports (color: oklch(from red l c h)) {
  [data-theme="dark"],
  [data-theme="dark"] :is(.appbar, .site-footer) {
    --accent-text: oklch(from var(--accent) max(l, 0.72) c h);
    --accent-fill: oklch(from var(--accent) min(l, 0.5) c h);
    --bg-glow: oklch(from var(--accent) 0.25 0.025 h / 0.32);
  }
  [data-theme="light"],
  [data-theme="light"] :is(.appbar, .site-footer) {
    --accent-text: oklch(from var(--accent) min(l, 0.5) c h);
    --accent-fill: oklch(from var(--accent) min(l, 0.5) c h);
    --bg-glow: oklch(from var(--accent) 0.92 0.025 h / 0.34);
  }
}

/* Materials. Components take their glass from these tokens:
   --appbar / --panel-bg / --glass-float / --glass-control for the background,
   --glass-filter for backdrop-filter (chrome, sidebar and floating surfaces
   only, never every card). */
[data-theme],
.appbar,
.site-footer {
  --panel-bg:
    linear-gradient(145deg, var(--glass-highlight), transparent 45%),
    var(--glass-panel);
  --glass-filter: blur(var(--glass-blur)) saturate(1.2);

  /* Type settings. */
  font-family: var(--font);
  /* Google Sans's x-height (0.51 em, from the font file): a no-op for Google
     Sans itself, but a fallback drawn while it loads takes the same space, so
     the swap does not shift the layout. Change it with --font. */
  font-size-adjust: 0.51;
  /* Figures of one width, so numbers line up and live values do not jitter. */
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* The page's backdrop. */
.app {
  background:
    radial-gradient(
      1100px 640px at 85% -140px,
      var(--bg-grad),
      transparent 70%
    ),
    radial-gradient(800px 560px at -15% 440px, var(--bg-glow), transparent 75%),
    var(--bg);
}

/* Opaque fallbacks: swap the material tokens, so no component needs its own. */
@supports not ((backdrop-filter: none) or (-webkit-backdrop-filter: none)) {
  [data-theme],
  [data-theme] :is(.appbar, .site-footer) {
    --appbar: var(--surface);
    --panel-bg: var(--surface);
    --glass-float: var(--surface);
    --glass-control: var(--surface);
    --glass-filter: none;
  }
}
@media (prefers-reduced-transparency: reduce) {
  [data-theme],
  [data-theme] :is(.appbar, .site-footer) {
    --appbar: var(--surface);
    --panel-bg: var(--surface);
    --glass-float: var(--surface);
    --glass-control: var(--surface);
    --glass-filter: none;
  }
}

@media (max-width: 720px) {
  :root {
    --page-gutter: 16px;
    --glass-blur: 12px;
  }
}
