/* Legacy CSS aliases backed by the shared klang-ui theme.
 * Import this on every page.
 *
 * The --mui-* variables come from KlangThemeProvider (rendered once in
 * BaseLayout) and swap with <html data-theme>. Geist and Material Symbols
 * Rounded are registered by klang-ui's font stylesheets, also imported in
 * BaseLayout. Any token defined here that differs between themes must be set
 * under both :root and [data-theme='dark'].
 */

:root {
  /* ── Brand primary (Klang blue) ───────────────────────── */
  --klang-blue:          var(--mui-palette-primary-main);
  --klang-blue-light:    var(--mui-palette-primary-light);
  --klang-blue-dark:     var(--mui-palette-primary-dark);

  /* ── Brand secondary (Klang orange) ───────────────────── */
  --klang-orange:        var(--mui-palette-secondary-main);
  --klang-orange-light:  var(--mui-palette-secondary-light);
  --klang-orange-dark:   var(--mui-palette-secondary-dark);

  /* ── Surfaces ─────────────────────────────────────────── */
  --klang-warm-gray:     var(--mui-palette-background-default);
  --docs-canvas:         var(--mui-palette-background-paper);
  --docs-surface:        color-mix(in srgb, var(--mui-palette-background-default) 40%, var(--mui-palette-background-paper));
  --docs-raised:         var(--mui-palette-background-paper);
  --klang-warm-gray-light: var(--docs-surface);
  --docs-fill:           var(--mui-palette-action-hover);
  --docs-header-bg:      color-mix(in srgb, var(--docs-canvas) 90%, transparent);
  /* The sample terminal output stays dark in both themes. */
  --docs-terminal-bg:    #1a1a1a;
  --docs-terminal-fg:    #e0e0e0;

  /* ── Semantic ─────────────────────────────────────────── */
  --mui-info:            var(--mui-palette-info-main);
  --mui-success:         var(--mui-palette-success-main);
  --mui-warning:         var(--mui-palette-warning-main);
  --mui-error:           var(--mui-palette-error-main);

  /* ── Text ─────────────────────────────────────────────── */
  --text-primary:        var(--mui-palette-text-primary);
  --text-secondary:      var(--mui-palette-text-secondary);
  --text-disabled:       var(--mui-palette-text-disabled);
  --text-on-primary:     var(--mui-palette-primary-contrastText);

  /* ── Borders / dividers ───────────────────────────────── */
  --divider:             var(--mui-palette-divider);
  --border-subtle:       var(--klang-border-subtle);
  --border-strong:       var(--klang-border-input);

  /* ── Syntax highlighting for hand-written samples ─────── */
  --code-keyword:        #b3306f;
  --code-string:         var(--mui-palette-success-main);
  --code-method:         var(--mui-palette-primary-main);
  --code-comment:        var(--mui-palette-text-secondary);
  --code-line-number:    var(--mui-palette-text-disabled);

  /* ── Elevation ────────────────────────────────────────── */
  --elev-1: var(--mui-shadows-1);
  --elev-2: var(--mui-shadows-2);
  --elev-4: var(--mui-shadows-4);
  --elev-8: var(--mui-shadows-8);

  /* ── Motion ───────────────────────────────────────────── */
  --ease-standard: cubic-bezier(.4, 0, .2, 1);
  --ease-out:      cubic-bezier(0, 0, .2, 1);
  --dur-fast:      120ms;
  --dur-base:      200ms;

  /* ── Type family ──────────────────────────────────────── */
  --font-sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  color-scheme: light;
}

/* Dark paper equals the default background (#121212), so surfaces get their
   lift from a white overlay, matching MUI's 1dp and 4dp elevation tints. */
[data-theme='dark'] {
  --docs-surface:        color-mix(in srgb, var(--mui-palette-common-white) 5%, var(--mui-palette-background-paper));
  --docs-raised:         color-mix(in srgb, var(--mui-palette-common-white) 9%, var(--mui-palette-background-paper));
  --code-keyword:        #f48fb1;

  color-scheme: dark;
}

/* ── Base ──────────────────────────────────────────────── */
html, body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--docs-canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── Typography scale ─────────────────────────────────── */
.k-heading-xl { font-weight: 300; font-size: 48px; line-height: 53px; letter-spacing: -0.01em; }
.k-heading-l  { font-weight: 300; font-size: 48px; line-height: 56px; letter-spacing: -0.01em; }
.k-heading-m  { font-weight: 400; font-size: 32px; line-height: 40px; }
.k-heading-s  { font-weight: 600; font-size: 16px; line-height: 24px; }
.k-body       { font-weight: 400; font-size: 16px; line-height: 24px; }
.k-body-bold  { font-weight: 600; font-size: 16px; line-height: 24px; }
.k-caption    { font-weight: 400; font-size: 12px; line-height: 16px; color: var(--text-secondary); }

/* Apply the scale by default to semantic tags */
h1 { font-weight: 300; font-size: 48px; line-height: 53px; letter-spacing: -0.01em; margin: 0; }
h2 { font-weight: 300; font-size: 48px; line-height: 56px; letter-spacing: -0.01em; margin: 0; }
h3 { font-weight: 400; font-size: 32px; line-height: 40px; margin: 0; }
h4 { font-weight: 600; font-size: 16px; line-height: 24px; margin: 0; }
p, li { font-weight: 400; font-size: 16px; line-height: 24px; margin: 0; }
strong, b { font-weight: 600; }
