/* Runwell's theme: runeui's tokens (shadcn/ui's names and meanings, runeui/tokens.css) as
/* Settings > Appearance sets them. Linked first, so its layer order is the page's:
/*
/*   ui-sdk, runeui.tokens, runeui.base, runeui.rune (the compatibility layer's classes, until
/*   7.0: runwell/compat.css), runeui.components, runeui.utilities, then runwell.theme (this).
/*
/* runeui's defaults are shadcn's neutral theme; this layer sits over them, so Appearance's
/* choices (attributes on <html>: data-scheme, data-radius, data-font, data-text-size; light and
/* dark are runeui's .dark, set before the first paint) win over runeui's, and a custom theme
/* (Settings > Appearance > Custom CSS, unlayered and linked last: docs/theming.md) wins over
/* both, whatever its selectors. Runwell's own stylesheets read only these tokens. */

@layer ui-sdk, runeui.tokens, runeui.base, runeui.rune, runeui.components, runeui.utilities, runwell.theme;

@layer runwell.theme {
  :root {
    /* Inter, bundled (font-face.css), so the app looks the same everywhere. */
    --font-sans: "Inter", "Adwaita Sans", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Runwell", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

    /* runeui's status colours (badges, alerts, toasts), Runwell's: a deeper green and an amber
       that read as text on the page; information in the brand's colour. */
    --success: oklch(55% 0.162 147);
    --warning: oklch(58% 0.156 60);
    --info: var(--primary);

    /* The nav's current item and focus in the brand's colour, as everything chosen is. */
    --sidebar-primary: var(--primary);
    --sidebar-primary-foreground: var(--primary-foreground);
    --sidebar-ring: var(--ring);

    /* Runwell's additions, derived from the theme so any scheme or custom theme carries them:
       a third step of text under --muted-foreground (hints, meta), and the brand's tints behind
       what's chosen, current or under the keys (shadcn's quiet --accent fill in the neutral
       scheme, the scheme's hue in the others). */
    --faint-foreground: light-dark(color-mix(in oklab, var(--muted-foreground) 80%, transparent), color-mix(in oklab, var(--muted-foreground) 72%, transparent));
    --brand-tint: light-dark(color-mix(in oklab, var(--primary) 4%, var(--background)), color-mix(in oklab, var(--primary) 16%, var(--background)));
    --brand-tint-strong: light-dark(color-mix(in oklab, var(--primary) 7.5%, var(--background)), color-mix(in oklab, var(--primary) 22.5%, var(--background)));
  }

  .dark {
    --success: oklch(62% 0.1261 146);
    --warning: oklch(62.1% 0.146 70);
    /* Cards and popovers on the page's own ground in dark (shadcn's are a step lighter). */
    --card: var(--background);
    --popover: var(--background);
  }

  /* Colour schemes: shadcn's idea of a theme, the greys neutral and the primary coloured (buttons,
     links, switches, the focus ring, the current item), light and dark. Neutral ("fizzy", the
     default) is runeui's own. Each colour is a Tailwind step that reads as text on the page and
     under its own foreground (4.5:1 or better). Setting#brand_color is each light primary in hex,
     for email. */
  :root[data-scheme="indigo"] { --primary: oklch(51.1% 0.262 276.966); --primary-foreground: oklch(96.2% 0.018 272.314); }
  :root[data-scheme="forest"] { --primary: oklch(52.7% 0.154 150.069); --primary-foreground: oklch(98.2% 0.018 155.826); }
  :root[data-scheme="plum"] { --primary: oklch(55.8% 0.288 302.321); --primary-foreground: oklch(97.7% 0.014 308.299); }
  :root[data-scheme="ocean"] { --primary: oklch(52% 0.105 223.128); --primary-foreground: oklch(98.4% 0.019 200.873); }
  :root[data-scheme="graphite"] { --primary: oklch(37.2% 0.044 257.287); --primary-foreground: oklch(98.4% 0.003 247.858); }
  :root.dark[data-scheme="indigo"] { --primary: oklch(67.3% 0.182 276.935); --primary-foreground: oklch(25.7% 0.09 281.288); }
  :root.dark[data-scheme="forest"] { --primary: oklch(72.3% 0.219 149.579); --primary-foreground: oklch(26.6% 0.065 152.934); }
  :root.dark[data-scheme="plum"] { --primary: oklch(71.4% 0.203 305.504); --primary-foreground: oklch(29.1% 0.149 302.717); }
  :root.dark[data-scheme="ocean"] { --primary: oklch(71.5% 0.143 215.221); --primary-foreground: oklch(30.2% 0.056 229.695); }
  :root.dark[data-scheme="graphite"] { --primary: oklch(86.9% 0.022 252.894); --primary-foreground: oklch(20.8% 0.042 265.755); }
  /* A coloured scheme's focus ring is its colour. */
  :root[data-scheme]:not([data-scheme="fizzy"]) { --ring: var(--primary); }

  /* Corners: --radius, from which runeui derives every corner (--ui-radius-sm…xl). Soft is
     shadcn's 0.625rem. */
  :root[data-radius="sharp"] { --radius: 0.25rem; }
  :root[data-radius="round"] { --radius: 1rem; }

  /* Fonts: local stacks only, nothing downloaded. */
  :root[data-font="humanist"] { --font-sans: Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", source-sans-pro, sans-serif; }
  :root[data-font="rounded"] { --font-sans: ui-rounded, "Hiragino Maru Gothic ProN", Quicksand, Comfortaa, Manjari, "Arial Rounded MT", "Arial Rounded MT Bold", Calibri, source-sans-pro, sans-serif; }
  :root[data-font="serif"] { --font-sans: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, Georgia, serif; }
  :root[data-font="mono"] { --font-sans: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace; }

  /* Text size (the install's, or a person's own): the root's size, which every rem scales from
     (Default is the browser's, 16px). */
  :root[data-text-size="small"] { font-size: 87.5%; }
  :root[data-text-size="large"] { font-size: 112.5%; }
  :root[data-text-size="larger"] { font-size: 125%; }
}
