/**
 * Mysto brand tokens — single source of truth for CSS.
 * Keep values in sync with ../../brand-tokens.js
 *
 * Load this before home-v4, marketing-v4, and builder Tailwind.
 *
 * Color usage:
 * - --myst-primary / --myst-action → primary CTAs only (.btn-primary)
 * - --myst-chrome → selection chrome (nav, tabs, outline, chips, focus)
 * - --myst-ink → default text / strong UI
 * - Surfaces (cream / paper / line) flip under html[data-myst-theme="dark"]
 *
 * Font usage:
 * - --myst-font-sans / --myst-font-display → all Mysto UI (builder + marketing)
 * - --myst-font-mono → code / mono
 * - --myst-font-serif → storefront demo mock brands only (not Mysto chrome)
 */
:root,
html {
  /*
   * Always light browser chrome. Dark UI is our tokens only — never let
   * color-scheme:dark paint a black status / address bar over theme-color.
   * Light surface tokens stay on :root/html only — dark overrides below.
   */
  color-scheme: only light;

  /* ── Fonts ───────────────────────────────────────── */
  --myst-font-sans: "Open Sauce One", system-ui, sans-serif;
  --myst-font-display: "Open Sauce One", system-ui, sans-serif;
  --myst-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  --myst-font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;

  /* ── Primary action — CTAs only (matches header glow) ─ */
  --myst-primary: #7c3aed;
  --myst-primary-press: #6d28d9;
  --myst-primary-rgb: 124 58 237;
  --myst-primary-press-rgb: 109 40 217;
  --myst-primary-50: #f5f3ff;
  --myst-primary-100: #ede9fe;
  --myst-primary-200: #ddd6fe;

  --myst-action: var(--myst-primary);
  --myst-action-press: var(--myst-primary-press);
  --myst-action-rgb: var(--myst-primary-rgb);
  --myst-action-press-rgb: var(--myst-primary-press-rgb);

  /* ── Selection / chrome — dark, not primary ──────── */
  --myst-chrome: #222222;
  --myst-chrome-press: #14101c;
  --myst-chrome-rgb: 34 34 34;
  --myst-chrome-press-rgb: 20 16 28;

  /* ── Text ────────────────────────────────────────── */
  --myst-ink: #14101c;
  --myst-ink-rgb: 20 16 28;
  --myst-muted: #5c5569;
  --myst-muted-rgb: 92 85 105;

  /* ── Surfaces ────────────────────────────────────── */
  --myst-cream: #f5f5fa;
  --myst-cream-rgb: 245 245 250;
  --myst-paper: #ffffff;
  --myst-paper-rgb: 255 255 255;
  --myst-line: #e8e4ef;
  --myst-line-rgb: 232 228 239;

  /*
   * Type scale — one standard for all builder pages (shell + mobile).
   * Prefer .myst-heading-* / .myst-body* over one-off text-[Npx].
   * Marketing hero display stays on --v3-title / --v3-title-hero.
   * xs=meta 11 · caption 12 · body/sm 13 · subtitle/base 14 · title/lg 16 · display 17
   */
  --myst-text-display: 1.0625rem; /* 17 — page title */
  --myst-text-display-lh: 1.4375rem;
  --myst-text-title: 1rem; /* 16 — h2 / sheet title */
  --myst-text-title-lh: 1.375rem;
  --myst-text-subtitle: 0.875rem; /* 14 — list / card title */
  --myst-text-subtitle-lh: 1.1875rem;
  --myst-text-body: 0.8125rem; /* 13 — paragraphs / UI body */
  --myst-text-body-lh: 1.125rem;
  --myst-text-caption: 0.75rem; /* 12 — captions / labels */
  --myst-text-caption-lh: 1rem;
  --myst-text-meta: 0.6875rem; /* 11 — meta / helpers */
  --myst-text-meta-lh: 0.9375rem;
  --myst-text-lede: 1.125rem; /* 18 — marketing lede */
  --myst-text-lede-lh: 1.625rem;
  --myst-fw-heading: 600;
  --myst-fw-body: 400;
  --myst-fw-medium: 500;

  /*
   * Builder shell (mobile + desktop) — black outer canvas under purple header wash.
   * Occasion promos can override via .myst-shell-promo-on (solid chrome).
   */
  --myst-shell-canvas: #0a0a0a;
  --myst-shell-surface: #f4f4f5; /* sidebar + main (one continuous card) */
  /*
   * Dotted canvas — same language as the marketing home page
   * (body.page-home-v4::before). Tile size kept on a separate token so
   * shell surfaces can `background-repeat: repeat` correctly.
   */
  --myst-shell-surface-dot: rgb(var(--myst-chrome-rgb, 34 34 34) / 0.07);
  --myst-shell-surface-dot-size: 20px 20px;
  --myst-shell-surface-wash: radial-gradient(
    circle,
    var(--myst-shell-surface-dot) 1px,
    transparent 1.15px
  );
  --myst-shell-glow: var(--myst-primary);
  --myst-shell-glow-core: #a78bfa;
  --myst-shell-glow-deep: var(--myst-primary-press);
  --myst-shell-glow-width: 38%;
  --myst-shell-gap: 0.75rem;
  --myst-shell-radius: 1.5rem;
  /* Header bar row (below safe-area). Keep in sync with main#swup top. */
  --myst-shell-header: 3.25rem;
  --myst-shell-nav: 15.5rem;
  /*
   * Mobile floating dock.
   * Tight inset pill; home-indicator safe-area sits outside the pill (not
   * padded inside) so all four corners stay rounded. Workspace card is
   * main#swup only — main padding clears the dock.
   */
  --myst-shell-content-inset: 1rem;
  --myst-shell-dock-bar: 4.85rem;
  --myst-shell-nav-inset: 0.45rem;
  --myst-shell-mobile-dock: calc(
    var(--myst-shell-dock-bar) + var(--myst-shell-nav-inset, 0.45rem)
  );

  /*
   * Legacy alias: older CSS expected “purple” for selection.
   * Builder Tailwind maps myst-purple → chrome so utilities stay consistent.
   */
  --myst-purple: var(--myst-chrome);
  --myst-purple-hover: var(--myst-chrome-press);

  /*
   * Control sizes — buttons, inputs, selects share one height.
   * Use --myst-btn-h-sm only for icon-only / dense chrome.
   * Inputs keep 16px text (iOS zoom); buttons use --myst-btn-fs.
   */
  --myst-btn-h: 2.25rem;
  --myst-control-h: var(--myst-btn-h);
  --myst-btn-h-sm: 2rem;
  --myst-btn-px: 0.875rem;
  --myst-btn-px-sm: 0.625rem;
  --myst-btn-radius: 0.625rem;
  --myst-btn-fs: 0.8125rem;
  --myst-btn-fs-sm: 0.75rem;

  /* Marketing / home — larger CTAs than builder controls */
  --v3-primary: var(--myst-primary);
  --v3-primary-press: var(--myst-primary-press);
  --v3-ink: #222222;
  --v3-btn-h: 3rem;
  --v3-btn-h-sm: 2.25rem;
  --v3-header-ctrl: var(--v3-btn-h-sm);
  --v3-lede: var(--myst-text-lede);
  --v3-lede-lh: var(--myst-text-lede-lh);

  /* Legal / legacy pages — CTA purple */
  --mysto-purple: var(--myst-primary);
}

/**
 * Builder dark theme — toggled via html[data-myst-theme="dark"].
 * Marketing pages should not set this attribute.
 */
html[data-myst-theme="dark"] {
  color-scheme: only light;

  --myst-chrome: #e8e4ef;
  --myst-chrome-press: #ffffff;
  --myst-chrome-rgb: 232 228 239;
  --myst-chrome-press-rgb: 255 255 255;

  /* Soft off-white — avoid harsh pure white on dark surfaces */
  --myst-ink: #d4d4d8;
  --myst-ink-rgb: 212 212 216;
  --myst-muted: #8b8b92;
  --myst-muted-rgb: 139 139 146;

  /*
   * Soft gray shell canvas. Paper / line sit a step above so drawers,
   * cards, and inputs stay readable — not gray-on-gray mud.
   */
  --myst-cream: #121212;
  --myst-cream-rgb: 18 18 18;
  --myst-paper: #1a1a1a;
  --myst-paper-rgb: 26 26 26;
  /* Soft edge — visible on paper/canvas without reading as a hard grid */
  --myst-line: #2e2e2e;
  --myst-line-rgb: 46 46 46;

  --myst-shell-canvas: #0a0a0a;
  --myst-shell-surface: #121212;
  /* Soft white dots on #121212 — keep quieter than chrome text */
  --myst-shell-surface-dot: rgb(255 255 255 / 0.08);
  --myst-shell-surface-dot-size: 20px 20px;
  --myst-shell-surface-wash: radial-gradient(
    circle,
    var(--myst-shell-surface-dot) 1px,
    transparent 1.15px
  );

  --myst-purple: var(--myst-chrome);
  --myst-purple-hover: var(--myst-chrome-press);

  --myst-primary-50: #111111;
  --myst-primary-100: #1a1a1a;
  --myst-primary-200: #262626;
}

/**
 * Dark surface + ink remaps — kept HERE (not in input.css / Tailwind).
 * Tailwind was exploding `.dashboard-widget > section` / `.bg-myst-paper\/95`
 * into thousands of broken selectors, leaving Overview cards white and
 * text stuck on light-theme ink (#14101c) over dark fills.
 */
html[data-myst-theme="dark"] .bg-myst-paper,
html[data-myst-theme="dark"] .bg-myst-paper\/95,
html[data-myst-theme="dark"] .bg-myst-paper\/90,
html[data-myst-theme="dark"] .bg-myst-paper\/80 {
  background-color: #1a1a1a !important;
}

html[data-myst-theme="dark"] .bg-myst-cream,
html[data-myst-theme="dark"] .bg-myst-cream\/80,
html[data-myst-theme="dark"] .bg-myst-cream\/70,
html[data-myst-theme="dark"] .bg-myst-cream\/55,
html[data-myst-theme="dark"] .bg-myst-cream\/50,
html[data-myst-theme="dark"] .bg-myst-cream\/40,
html[data-myst-theme="dark"] .bg-myst-cream\/25 {
  background-color: #121212 !important;
}

html[data-myst-theme="dark"] .border-myst-line,
html[data-myst-theme="dark"] .border-myst-line\/80,
html[data-myst-theme="dark"] .border-myst-line\/70,
html[data-myst-theme="dark"] .border-myst-line\/65,
html[data-myst-theme="dark"] .border-myst-line\/60 {
  border-color: #2e2e2e !important;
}

html[data-myst-theme="dark"] .text-myst-ink,
html[data-myst-theme="dark"] .myst-page-title,
html[data-myst-theme="dark"] .myst-heading-1,
html[data-myst-theme="dark"] .myst-heading-2,
html[data-myst-theme="dark"] .myst-heading-3,
html[data-myst-theme="dark"] .myst-row-title,
html[data-myst-theme="dark"] .myst-section-title,
html[data-myst-theme="dark"] .myst-stat-value,
html[data-myst-theme="dark"] .myst-order-push-banner__title {
  color: #d4d4d8 !important;
}

html[data-myst-theme="dark"] .text-myst-muted,
html[data-myst-theme="dark"] .myst-order-push-banner__desc {
  color: #8b8b92 !important;
}

html[data-myst-theme="dark"] .myst-order-push-banner {
  border-color: rgb(124 58 237 / 0.35) !important;
  background: linear-gradient(
    135deg,
    rgb(124 58 237 / 0.16) 0%,
    #1a1a1a 55%,
    #161616 100%
  ) !important;
}

html[data-myst-theme="dark"] .dashboard-widget > section,
html[data-myst-theme="dark"] .dashboard-widget > .live-visitors-card,
html[data-myst-theme="dark"] .dashboard-widget > .stat-card,
html[data-myst-theme="dark"] .dashboard-widget .live-visitors-card,
html[data-myst-theme="dark"] .dashboard-widget .stat-card {
  background-color: #1a1a1a !important;
  border-color: #2e2e2e !important;
  box-shadow: none !important;
}

html[data-myst-theme="dark"] .myst-dashboard-quick-actions {
  background-color: #2e2e2e !important;
}

html[data-myst-theme="dark"] .myst-dashboard-quick-action {
  background-color: #1a1a1a !important;
  color: #d4d4d8 !important;
}

html[data-myst-theme="dark"] .myst-dashboard-quick-action:hover,
html[data-myst-theme="dark"] .myst-dashboard-quick-action:active {
  background-color: #222222 !important;
}

html[data-myst-theme="dark"]
  [data-dashboard-widget="quick_actions"]
  > section
  > .border-b {
  background-color: #161616 !important;
  border-color: #2e2e2e !important;
}

html[data-myst-theme="dark"] .myst-dashboard-quick-action__label {
  color: #d4d4d8 !important;
}

html[data-myst-theme="dark"] .myst-dashboard-quick-action__chevron {
  color: #8b8b92 !important;
}

html[data-myst-theme="dark"]
  nav[data-swup-preload-all]
  a[data-nav-mobile-tab].myst-nav-item--active,
html[data-myst-theme="dark"]
  nav[data-swup-preload-all]
  a[data-nav-mobile-tab].myst-nav-item--active
  svg,
html[data-myst-theme="dark"]
  nav[data-swup-preload-all]
  a[data-nav-mobile-tab].myst-nav-item--active
  .myst-nav-label {
  color: #e8e4ef !important;
}

html[data-myst-theme="dark"]
  nav[data-swup-preload-all]
  a[data-nav-mobile-tab].myst-nav-item--active
  .nav-indicator {
  background-color: #7c3aed !important;
  box-shadow: 0 0 0 2px #161616 !important;
}

/*
 * Primary CTAs — Tailwind dark remaps were painting these #1a1a1a (gone on
 * dark drawers). Force solid purple + white label back.
 */
html[data-myst-theme="dark"] .btn-primary,
html[data-myst-theme="dark"] .myst-popup-footer__primary,
html[data-myst-theme="dark"] .myst-app-detail-btn--primary,
html[data-myst-theme="dark"] .add-btn.btn-primary {
  background: #7c3aed !important;
  background-image: none !important;
  border-color: transparent !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  box-shadow: none !important;
}

/* Order push enable = text link under copy (not a filled CTA). */
html[data-myst-theme="dark"] .myst-order-push-banner__cta {
  background: transparent !important;
  background-image: none !important;
  border-color: transparent !important;
  color: #d4d4d8 !important;
  -webkit-text-fill-color: #d4d4d8 !important;
  box-shadow: none !important;
}

/* Setup guide CTAs stay ink/black (light label on dark paper). */
html[data-myst-theme="dark"] .myst-setup-guide-cta {
  background: #fafafa !important;
  background-image: none !important;
  border-color: transparent !important;
  color: #111111 !important;
  -webkit-text-fill-color: #111111 !important;
  box-shadow: none !important;
}

/*
 * Ink-solid CTAs forced via !bg-myst-ink (theme Use / template detail).
 * Keep them readable on dark paper — light fill, dark label.
 */
html[data-myst-theme="dark"] .\!bg-myst-ink {
  background-color: #fafafa !important;
  color: #111111 !important;
  -webkit-text-fill-color: #111111 !important;
}

html[data-myst-theme="dark"] .hover\:\!bg-myst-ink\/90:hover {
  background-color: #e4e4e7 !important;
}

html[data-myst-theme="dark"] .btn-primary:hover,
html[data-myst-theme="dark"] .btn-primary:active,
html[data-myst-theme="dark"] .myst-popup-footer__primary:hover,
html[data-myst-theme="dark"] .myst-popup-footer__primary:active,
html[data-myst-theme="dark"] .myst-app-detail-btn--primary:hover,
html[data-myst-theme="dark"] .myst-app-detail-btn--primary:active,
html[data-myst-theme="dark"] .add-btn.btn-primary:hover {
  background: #6d28d9 !important;
  background-image: none !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

html[data-myst-theme="dark"] .myst-order-push-banner__cta:hover,
html[data-myst-theme="dark"] .myst-order-push-banner__cta:active {
  background: transparent !important;
  background-image: none !important;
  color: #e4e4e7 !important;
  -webkit-text-fill-color: #e4e4e7 !important;
}

html[data-myst-theme="dark"] .myst-setup-guide-cta:hover,
html[data-myst-theme="dark"] .myst-setup-guide-cta:active {
  background: #e4e4e7 !important;
  background-image: none !important;
  color: #111111 !important;
  -webkit-text-fill-color: #111111 !important;
}

html[data-myst-theme="dark"] .myst-design-guide-card__cta {
  background: #fafafa !important;
  background-image: none !important;
  border-color: transparent !important;
  color: #111111 !important;
  -webkit-text-fill-color: #111111 !important;
  box-shadow: none !important;
}

/* Animated hero / Start-free CTAs — keep gradient; chrome flips light in dark */
html[data-myst-theme="dark"] .btn-mysto-cta,
html[data-myst-theme="dark"] .btn-mysto-dark,
html[data-myst-theme="dark"] .page-mobile-sticky-cta__btn--primary {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  background: linear-gradient(
    125deg,
    #24104a 0%,
    #222222 14%,
    #5a28b8 28%,
    #7c3aed 42%,
    #c4b5fd 52%,
    #962fbf 62%,
    #222222 78%,
    #5a28b8 90%,
    #24104a 100%
  ) !important;
  background-size: 320% 320% !important;
}
