/* =====================================================================
 * MonkeyPatch design tokens  ·  canonical source: design-system/tokens.css
 * ---------------------------------------------------------------------
 * Copies (keep identical — run `node scripts/sync-design-tokens.mjs`):
 *   api/wwwroot/tokens.css                 (Stash portal + marketing site)
 *   MonkeyPatch/src/popup/styles/tokens.css (extension side panel)
 *
 * Layers:
 *   1. ColorRamp export (verbatim)  — raw ramps, fixed + `-ld` responsive
 *   2. Theme mechanics              — data-theme, inversion helpers
 *   3. Semantic tokens              — what components use
 *   4. Legacy aliases               — the original `--mp-*` API (patches use it)
 *   5. Type, space, radius, size, motion
 *
 * Rule of thumb: components reference layer 3/4 only. Never a hex.
 * Cream = environment · Amber = interaction · Green/Coral = information ·
 * Crimson = special emphasis.
 * ===================================================================== */


/* ---------------------------------------------------------------------
 * 1. ColorRamp v1.2.2 export — DO NOT EDIT BY HAND
 * Generated at: https://www.colorramp.com/?banana-cream=%23FFF2D8&crisp-amber=%23FFCC16&dusk-crimson=%2330030E&vivid-coral=%23FF9214&stem-green=%236F9E18
 * Shades invert symmetrically in `-ld` tokens: 0↔1000, 50↔950, 100↔900,
 * 200↔800, 300↔700, 400↔600, 500↔500.
 * ------------------------------------------------------------------- */
:root {
  color-scheme: light dark;
  /* HEX Values */

  /* Ready Colors */
  --color-banana-cream-0: #FFFEFC;
  --color-banana-cream-0-ld: light-dark(#FFFEFC, #000000);
  --color-banana-cream-50: #FFF9EE;
  --color-banana-cream-50-ld: light-dark(#FFF9EE, #090703);
  --color-banana-cream-100: #FFF2D8;
  --color-banana-cream-100-ld: light-dark(#FFF2D8, #1C1912);
  --color-banana-cream-200: #EDE1C9;
  --color-banana-cream-200-ld: light-dark(#EDE1C9, #38342D);
  --color-banana-cream-300: #D5CBB6;
  --color-banana-cream-300-ld: light-dark(#D5CBB6, #4F4B43);
  --color-banana-cream-400: #ADA595;
  --color-banana-cream-400-ld: light-dark(#ADA595, #67635B);
  --color-banana-cream-500: #868076;
  --color-banana-cream-500-ld: light-dark(#868076, #868076);
  --color-banana-cream-600: #67635B;
  --color-banana-cream-600-ld: light-dark(#67635B, #ADA595);
  --color-banana-cream-700: #4F4B43;
  --color-banana-cream-700-ld: light-dark(#4F4B43, #D5CBB6);
  --color-banana-cream-800: #38342D;
  --color-banana-cream-800-ld: light-dark(#38342D, #EDE1C9);
  --color-banana-cream-900: #1C1912;
  --color-banana-cream-900-ld: light-dark(#1C1912, #FFF2D8);
  --color-banana-cream-950: #090703;
  --color-banana-cream-950-ld: light-dark(#090703, #FFF9EE);
  --color-banana-cream-1000: #000000;
  --color-banana-cream-1000-ld: light-dark(#000000, #FFFEFC);

  --color-crisp-amber-0: #FFFDF9;
  --color-crisp-amber-0-ld: light-dark(#FFFDF9, #000000);
  --color-crisp-amber-50: #FFFAEB;
  --color-crisp-amber-50-ld: light-dark(#FFFAEB, #0B0700);
  --color-crisp-amber-100: #FFF09D;
  --color-crisp-amber-100-ld: light-dark(#FFF09D, #281700);
  --color-crisp-amber-200: #FFE04B;
  --color-crisp-amber-200-ld: light-dark(#FFE04B, #433406);
  --color-crisp-amber-300: #FFCC16;
  --color-crisp-amber-300-ld: light-dark(#FFCC16, #5C4B1E);
  --color-crisp-amber-400: #CFA620;
  --color-crisp-amber-400-ld: light-dark(#CFA620, #7A6323);
  --color-crisp-amber-500: #A08123;
  --color-crisp-amber-500-ld: light-dark(#A08123, #A08123);
  --color-crisp-amber-600: #7A6323;
  --color-crisp-amber-600-ld: light-dark(#7A6323, #CFA620);
  --color-crisp-amber-700: #5C4B1E;
  --color-crisp-amber-700-ld: light-dark(#5C4B1E, #FFCC16);
  --color-crisp-amber-800: #433406;
  --color-crisp-amber-800-ld: light-dark(#433406, #FFE04B);
  --color-crisp-amber-900: #281700;
  --color-crisp-amber-900-ld: light-dark(#281700, #FFF09D);
  --color-crisp-amber-950: #0B0700;
  --color-crisp-amber-950-ld: light-dark(#0B0700, #FFFAEB);
  --color-crisp-amber-1000: #000000;
  --color-crisp-amber-1000-ld: light-dark(#000000, #FFFDF9);

  --color-dusk-crimson-0: #FFFDFD;
  --color-dusk-crimson-0-ld: light-dark(#FFFDFD, #010000);
  --color-dusk-crimson-50: #FFF8F8;
  --color-dusk-crimson-50-ld: light-dark(#FFF8F8, #170003);
  --color-dusk-crimson-100: #FFEEF1;
  --color-dusk-crimson-100-ld: light-dark(#FFEEF1, #30030E);
  --color-dusk-crimson-200: #F3DDDF;
  --color-dusk-crimson-200-ld: light-dark(#F3DDDF, #4C252C);
  --color-dusk-crimson-300: #DCC6C8;
  --color-dusk-crimson-300-ld: light-dark(#DCC6C8, #613E44);
  --color-dusk-crimson-400: #B49FA1;
  --color-dusk-crimson-400-ld: light-dark(#B49FA1, #76585C);
  --color-dusk-crimson-500: #90797C;
  --color-dusk-crimson-500-ld: light-dark(#90797C, #90797C);
  --color-dusk-crimson-600: #76585C;
  --color-dusk-crimson-600-ld: light-dark(#76585C, #B49FA1);
  --color-dusk-crimson-700: #613E44;
  --color-dusk-crimson-700-ld: light-dark(#613E44, #DCC6C8);
  --color-dusk-crimson-800: #4C252C;
  --color-dusk-crimson-800-ld: light-dark(#4C252C, #F3DDDF);
  --color-dusk-crimson-900: #30030E;
  --color-dusk-crimson-900-ld: light-dark(#30030E, #FFEEF1);
  --color-dusk-crimson-950: #170003;
  --color-dusk-crimson-950-ld: light-dark(#170003, #FFF8F8);
  --color-dusk-crimson-1000: #010000;
  --color-dusk-crimson-1000-ld: light-dark(#010000, #FFFDFD);

  --color-vivid-coral-0: #FFFCFA;
  --color-vivid-coral-0-ld: light-dark(#FFFCFA, #000000);
  --color-vivid-coral-50: #FFF8F3;
  --color-vivid-coral-50-ld: light-dark(#FFF8F3, #100400);
  --color-vivid-coral-100: #FFEDCD;
  --color-vivid-coral-100-ld: light-dark(#FFEDCD, #311100);
  --color-vivid-coral-200: #FFD9A7;
  --color-vivid-coral-200-ld: light-dark(#FFD9A7, #512E0B);
  --color-vivid-coral-300: #FFBE74;
  --color-vivid-coral-300-ld: light-dark(#FFBE74, #74420F);
  --color-vivid-coral-400: #FF9214;
  --color-vivid-coral-400-ld: light-dark(#FF9214, #985712);
  --color-vivid-coral-500: #C77214;
  --color-vivid-coral-500-ld: light-dark(#C77214, #C77214);
  --color-vivid-coral-600: #985712;
  --color-vivid-coral-600-ld: light-dark(#985712, #FF9214);
  --color-vivid-coral-700: #74420F;
  --color-vivid-coral-700-ld: light-dark(#74420F, #FFBE74);
  --color-vivid-coral-800: #512E0B;
  --color-vivid-coral-800-ld: light-dark(#512E0B, #FFD9A7);
  --color-vivid-coral-900: #311100;
  --color-vivid-coral-900-ld: light-dark(#311100, #FFEDCD);
  --color-vivid-coral-950: #100400;
  --color-vivid-coral-950-ld: light-dark(#100400, #FFF8F3);
  --color-vivid-coral-1000: #000000;
  --color-vivid-coral-1000-ld: light-dark(#000000, #FFFCFA);

  --color-stem-green-0: #FDFFFB;
  --color-stem-green-0-ld: light-dark(#FDFFFB, #000000);
  --color-stem-green-50: #F3FFE5;
  --color-stem-green-50-ld: light-dark(#F3FFE5, #040900);
  --color-stem-green-100: #E7FDB9;
  --color-stem-green-100-ld: light-dark(#E7FDB9, #161E00);
  --color-stem-green-200: #D6EFA3;
  --color-stem-green-200-ld: light-dark(#D6EFA3, #2A4003);
  --color-stem-green-300: #C0DD86;
  --color-stem-green-300-ld: light-dark(#C0DD86, #3F5C08);
  --color-stem-green-400: #98BD53;
  --color-stem-green-400-ld: light-dark(#98BD53, #54790F);
  --color-stem-green-500: #6F9E18;
  --color-stem-green-500-ld: light-dark(#6F9E18, #6F9E18);
  --color-stem-green-600: #54790F;
  --color-stem-green-600-ld: light-dark(#54790F, #98BD53);
  --color-stem-green-700: #3F5C08;
  --color-stem-green-700-ld: light-dark(#3F5C08, #C0DD86);
  --color-stem-green-800: #2A4003;
  --color-stem-green-800-ld: light-dark(#2A4003, #D6EFA3);
  --color-stem-green-900: #161E00;
  --color-stem-green-900-ld: light-dark(#161E00, #E7FDB9);
  --color-stem-green-950: #040900;
  --color-stem-green-950-ld: light-dark(#040900, #F3FFE5);
  --color-stem-green-1000: #000000;
  --color-stem-green-1000-ld: light-dark(#000000, #FDFFFB);

}

/* Automatic Light/Dark Mode Switching */

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* Utility Class to invert color-scheme */

.invert-color-scheme { color-scheme: light-dark(dark, light); }
/* ---------------- end of ColorRamp export ---------------- */


/* ---------------------------------------------------------------------
 * 2. Theme mechanics
 * - No data-theme      → follows the OS (`color-scheme: light dark`).
 * - data-theme="light" / "dark" on <html> → explicit user preference.
 * - `.mp-invert`       → flips one component to the opposite scheme.
 *   (ColorRamp's `.invert-color-scheme` uses light-dark() inside
 *   color-scheme, which browsers reject, so it is re-implemented here.)
 * - `.mp-scheme-dark` / `.mp-scheme-light` → force a scheme on an island.
 * Every `-ld` token resolves against the color-scheme of the element that
 * USES it, so all of this cascades with zero extra palette definitions.
 * ------------------------------------------------------------------- */
:root { --mp-scheme-inverse: dark; }
@media (prefers-color-scheme: dark) {
  :root { --mp-scheme-inverse: light; }
}
:root[data-theme="light"] { --mp-scheme-inverse: dark; }
:root[data-theme="dark"]  { --mp-scheme-inverse: light; }

.mp-invert, .invert-color-scheme { color-scheme: var(--mp-scheme-inverse); }
.mp-scheme-dark  { color-scheme: dark; }
.mp-scheme-light { color-scheme: light; }

/* Chrome does not re-resolve light-dark() on properties that have a running
 * or declared transition when color-scheme flips at runtime. theme.js /
 * theme.ts add this class for two frames around every switch. */
.mp-theme-switching *, .mp-theme-switching *::before, .mp-theme-switching *::after { transition: none !important; }


/* ---------------------------------------------------------------------
 * 3. Semantic tokens
 * `-ld` tokens for anything that sits in the environment (flips with theme).
 * Fixed shades only for brand fills that must look identical in both
 * themes (amber button, crimson callout) and their on-colors.
 * ------------------------------------------------------------------- */
:root {
  /* Surfaces — Banana Cream ramp */
  --mp-surface-base:     var(--color-banana-cream-100-ld); /* page / app background  #FFF2D8 · #1C1912 */
  --mp-surface-card:     var(--color-banana-cream-50-ld);  /* cards, list groups     #FFF9EE · #090703 */
  --mp-surface-overlay:  var(--color-banana-cream-0-ld);   /* menus, sheets, dialogs, toasts */
  --mp-surface-input:    var(--color-banana-cream-0-ld);   /* inputs, code wells */
  --mp-surface-sunken:   var(--color-banana-cream-200-ld); /* nav track, segmented track, context strip */
  --mp-surface-muted:    var(--color-banana-cream-200-ld); /* hover, tiles, neutral badges */
  --mp-surface-strong:   var(--color-banana-cream-300-ld); /* pressed neutral, scrollbar thumb */

  /* Borders */
  --mp-border-subtle:    var(--color-banana-cream-200-ld); /* card edges, dividers */
  --mp-border-default:   var(--color-banana-cream-300-ld); /* inputs, secondary buttons */
  --mp-border-strong:    var(--color-banana-cream-500-ld); /* checkbox / switch-off outlines (≥3:1) */

  /* Text */
  --mp-text-primary:     var(--color-banana-cream-900-ld); /* names, headings, values */
  --mp-text-secondary:   var(--color-banana-cream-700-ld); /* descriptions, labels */
  --mp-text-tertiary:    var(--color-banana-cream-600-ld); /* metadata, inactive nav, placeholders */
  --mp-text-inverse:     var(--color-banana-cream-100-ld); /* text on a text-primary fill */

  /* Interaction — Crisp Amber */
  --mp-action-primary:         var(--color-crisp-amber-300); /* fixed: primary fill in both themes */
  --mp-action-primary-hover:   var(--color-crisp-amber-200);
  --mp-action-primary-pressed: var(--color-crisp-amber-400);
  --mp-action-primary-edge:    var(--color-crisp-amber-500); /* 1px edge so amber reads on cream */
  --mp-action-on-primary:      var(--color-crisp-amber-950); /* text/icons on amber (12.9:1) */
  --mp-action-subtle:          var(--color-crisp-amber-100-ld); /* selected tab / nav fill */
  --mp-action-subtle-hover:    var(--color-crisp-amber-50-ld);
  --mp-action-subtle-edge:     var(--color-crisp-amber-300-ld);
  --mp-action-ink:             var(--color-crisp-amber-700-ld); /* amber-family text & icons on cream */
  --mp-action-ink-strong:      var(--color-crisp-amber-800-ld); /* text on --mp-action-subtle */
  --mp-focus:                  var(--color-crisp-amber-600-ld); /* focus ring (≥5:1 both themes) */

  /* Status — Stem Green (positive) */
  --mp-status-success:         var(--color-stem-green-700-ld); /* text */
  --mp-status-success-icon:    var(--color-stem-green-600-ld); /* dots, icons */
  --mp-status-success-surface: var(--color-stem-green-100-ld);
  --mp-status-success-border:  var(--color-stem-green-300-ld);

  /* Status — Vivid Coral (updates, attention, warnings) */
  --mp-status-attention:         var(--color-vivid-coral-700-ld);
  --mp-status-attention-icon:    var(--color-vivid-coral-500);
  --mp-status-attention-surface: var(--color-vivid-coral-100-ld);
  --mp-status-attention-border:  var(--color-vivid-coral-300-ld);
  --mp-status-attention-fill:    var(--color-vivid-coral-400);  /* update pip, badges on toolbar art */

  /* Status — errors (Dusk Crimson ramp, always with icon + words) */
  --mp-status-error:         var(--color-dusk-crimson-700-ld);
  --mp-status-error-icon:    var(--color-dusk-crimson-700-ld);
  --mp-status-error-surface: var(--color-dusk-crimson-100-ld);
  --mp-status-error-border:  var(--color-dusk-crimson-300-ld);
  --mp-status-error-fill:    var(--color-dusk-crimson-900);    /* confirm-destructive button */
  --mp-status-on-error-fill: var(--color-banana-cream-100);

  /* Callout — Dusk Crimson (inverted, scarce, intentional) */
  --mp-callout-surface:     var(--color-dusk-crimson-900);
  --mp-callout-surface-2:   var(--color-dusk-crimson-950);
  --mp-callout-border:      var(--color-dusk-crimson-800);
  --mp-callout-text:        var(--color-banana-cream-100);
  --mp-callout-text-2:      var(--color-dusk-crimson-300);
  --mp-callout-glow:        color-mix(in srgb, var(--color-crisp-amber-300) 22%, transparent);
  --mp-callout-gradient:    radial-gradient(120% 140% at 100% 0%, var(--mp-callout-glow), transparent 55%),
                            linear-gradient(160deg, var(--mp-callout-surface), var(--mp-callout-surface-2));

  /* Atmosphere (large surfaces only) */
  --mp-warm-gradient: radial-gradient(90% 70% at 85% 0%, var(--color-crisp-amber-100-ld), transparent 60%),
                      radial-gradient(70% 60% at 0% 100%, var(--color-vivid-coral-50-ld), transparent 70%);

  /* Elevation — warm, restrained */
  --mp-shadow-sm:     0 1px 2px light-dark(color-mix(in srgb, var(--color-banana-cream-900) 8%, transparent), color-mix(in srgb, #000 40%, transparent));
  --mp-shadow-menu:   0 12px 32px light-dark(color-mix(in srgb, var(--color-banana-cream-900) 14%, transparent), color-mix(in srgb, #000 55%, transparent));
  --mp-shadow-dialog: 0 20px 48px light-dark(color-mix(in srgb, var(--color-banana-cream-900) 20%, transparent), color-mix(in srgb, #000 65%, transparent));
  --mp-scrim:         light-dark(color-mix(in srgb, var(--color-banana-cream-900) 40%, transparent), color-mix(in srgb, #000 65%, transparent));

  /* Syntax (code blocks, editors) */
  --mp-syntax-comment: var(--color-banana-cream-600-ld);
  --mp-syntax-keyword: var(--color-dusk-crimson-700-ld);
  --mp-syntax-string:  var(--color-vivid-coral-700-ld);
  --mp-syntax-func:    var(--color-crisp-amber-700-ld);
  --mp-syntax-number:  var(--color-stem-green-700-ld);
}


/* ---------------------------------------------------------------------
 * 4. Legacy aliases — the original `--mp-*` API.
 * Cloud patches and the portal reference these names; keep them stable.
 * ------------------------------------------------------------------- */
:root {
  --mp-bg:               var(--mp-surface-base);
  --mp-surface:          var(--mp-surface-card);
  --mp-surface-raised:   var(--mp-surface-muted);
  --mp-surface-hover:    var(--mp-surface-muted);
  --mp-surface-code:     var(--mp-surface-input);
  --mp-border:           var(--mp-border-default);
  --mp-divider:          var(--mp-border-subtle);

  --mp-text:             var(--mp-text-primary);
  --mp-text-2:           var(--mp-text-secondary);
  --mp-text-3:           var(--mp-text-tertiary);
  --mp-text-placeholder: var(--mp-text-tertiary);

  --mp-accent:           var(--mp-action-primary);       /* FILL only — use --mp-accent-ink for text */
  --mp-accent-hover:     var(--mp-action-primary-hover);
  --mp-accent-tint:      var(--mp-action-subtle);
  --mp-accent-line:      var(--mp-action-subtle-edge);
  --mp-accent-ink:       var(--mp-action-ink);
  --mp-on-accent:        var(--mp-action-on-primary);

  --mp-success:          var(--mp-status-success);
  --mp-success-tint:     var(--mp-status-success-surface);
  --mp-success-line:     var(--mp-status-success-border);
  --mp-warning:          var(--mp-status-attention);
  --mp-warning-tint:     var(--mp-status-attention-surface);
  --mp-warning-line:     var(--mp-status-attention-border);
  --mp-error:            var(--mp-status-error);
  --mp-error-tint:       var(--mp-status-error-surface);
  --mp-error-line:       var(--mp-status-error-border);
  --mp-error-fill:       var(--mp-status-error-fill);

  /* Retired: Brain Pink. Kept so old patches don't break; maps to Crimson ink. */
  --mp-brain-pink:       var(--color-dusk-crimson-700-ld);

  --mp-focus-ring: 0 0 0 2px var(--mp-surface-base), 0 0 0 4px var(--mp-focus);
}


/* ---------------------------------------------------------------------
 * 5. Type, spacing, radius, size, motion
 * ------------------------------------------------------------------- */
:root {
  --mp-font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mp-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --mp-font-display: Poppins, Inter, system-ui, sans-serif; /* marketing + rare product moments */

  --mp-fs-title: 20px;    --mp-lh-title: 26px;   /* 600 */
  --mp-fs-heading: 16px;  --mp-lh-heading: 22px; /* 600 */
  --mp-fs-body: 14px;     --mp-lh-body: 20px;    /* 400; names use 500 */
  --mp-fs-label: 13px;    --mp-lh-label: 18px;   /* 600 group labels, buttons */
  --mp-fs-meta: 12px;     --mp-lh-meta: 16px;    /* 400 */
  --mp-fs-code: 12px;     --mp-lh-code: 20px;
  --mp-fs-badge: 11px;

  --mp-space-1: 4px;
  --mp-space-2: 8px;
  --mp-space-3: 12px;
  --mp-space-4: 16px;   /* screen gutter, card padding */
  --mp-space-5: 20px;   /* between list groups */
  --mp-space-6: 24px;   /* major sections */

  --mp-radius-badge: 6px;
  --mp-radius-xs: 6px;
  --mp-radius-sm: 8px;       /* small buttons, chips */
  --mp-radius-control: 10px; /* buttons, inputs */
  --mp-radius-card: 12px;    /* menus, alerts, toasts */
  --mp-radius-group: 14px;   /* list groups, cards */
  --mp-radius-sheet: 18px;
  --mp-radius-pill: 999px;

  --mp-header-h: 52px;
  --mp-nav-tab-h: 38px;
  --mp-row-h: 60px;
  --mp-control-h: 40px;
  --mp-control-h-sm: 32px;
  --mp-hit: 44px;
  --mp-icon: 18px;
  --mp-icon-sm: 14px;
  --mp-icon-stroke: 1.75;

  --mp-dur-fast: 120ms;   /* hover, press */
  --mp-dur-base: 150ms;   /* switch, disclosure */
  --mp-dur-slow: 200ms;   /* menu, sheet, toast */
  --mp-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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