/* DocRemaster Design System — Canonical CSS Token Authority
 * Apple Light-First dual-theme token table shared by Studio Workbench (studio.css)
 * and Partner Share Reader (share.css). All text & solid button pairs are WCAG AA/AAA verified.
 */

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

  /* Surface & Border Colors (Light-First Default) */
  --color-bg: #f5f5f7;
  --color-surface: #ffffff;
  --color-surface-elevated: #fbfbfd;
  --color-surface-subtle: #efeff4;
  --color-glass: rgba(255, 255, 255, 0.82);
  --color-border: rgba(0, 0, 0, 0.09);
  --color-border-subtle: rgba(0, 0, 0, 0.06);
  --color-segment-track: #e8e8ed;
  --color-segment-active: #ffffff;

  /* Text Colors (WCAG AA/AAA verified on #ffffff and #f5f5f7) */
  --color-text-primary: #1d1d1f;
  --color-text-secondary: #515154;
  --color-text-muted: #6e6e73;

  /* Action & Semantic Solid Colors (WCAG AA >= 4.5:1 with #ffffff) */
  --color-primary: #0066cc;
  --color-primary-hover: #0052a3;
  --color-primary-text: #ffffff;
  --color-accent-text: #0066cc;
  --color-success: #1a7f37;
  --color-success-hover: #146c2e;
  --color-warning: #b25000;
  --color-warning-hover: #944200;
  --color-danger: #d70015;
  --color-danger-hover: #b80012;

  /* Semantic Badge Foreground Colors (WCAG AAA on light tints) */
  --color-primary-badge-text: #004c99;
  --color-success-badge-text: #14532d;
  --color-warning-badge-text: #7c3500;
  --color-danger-badge-text: #9e0010;

  /* Semantic Translucent Tints */
  --color-primary-tint: rgba(0, 102, 204, 0.10);
  --color-success-tint: rgba(26, 127, 55, 0.11);
  --color-warning-tint: rgba(178, 80, 0, 0.11);
  --color-danger-tint: rgba(215, 0, 21, 0.10);
  --color-backdrop: rgba(0, 0, 0, 0.32);

  /* Paper-Float & Popover Shadows */
  --color-shadow-ambient: rgba(0, 0, 0, 0.08);
  --color-shadow-key: rgba(0, 0, 0, 0.05);

  /* Typography (capped at 2 families: sans + mono) */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Body Type Scale (3 disciplined steps >= 12px) */
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;

  /* Motion */
  --motion-fast: 150ms cubic-bezier(0.22, 1, 0.36, 1);
  --motion-normal: 220ms cubic-bezier(0.22, 1, 0.36, 1);
  --motion-popover: 160ms cubic-bezier(0.22, 1, 0.36, 1);
  --motion-spin: 900ms;
}

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

  --color-bg: #000000;
  --color-surface: #1c1c1e;
  --color-surface-elevated: #2c2c2e;
  --color-surface-subtle: #242426;
  --color-glass: rgba(28, 28, 30, 0.84);
  --color-border: rgba(255, 255, 255, 0.12);
  --color-border-subtle: rgba(255, 255, 255, 0.08);
  --color-segment-track: #2c2c2e;
  --color-segment-active: #3a3a3c;

  --color-text-primary: #f5f5f7;
  --color-text-secondary: #d1d1d6;
  --color-text-muted: #a1a1a6;

  /* Dark Solid Primary #0070e0 + #ffffff = 4.78:1 AA; Accent Text #409cff = 6.01:1 AA */
  --color-primary: #0070e0;
  --color-primary-hover: #005ec4;
  --color-primary-text: #ffffff;
  --color-accent-text: #409cff;
  --color-success: #1e7e34;
  --color-success-hover: #18682b;
  --color-warning: #b25000;
  --color-warning-hover: #944200;
  --color-danger: #d70015;
  --color-danger-hover: #b80012;

  --color-primary-badge-text: #409cff;
  --color-success-badge-text: #30d158;
  --color-warning-badge-text: #ff9f0a;
  --color-danger-badge-text: #ff6961;

  --color-primary-tint: rgba(10, 132, 255, 0.18);
  --color-success-tint: rgba(48, 209, 88, 0.16);
  --color-warning-tint: rgba(255, 159, 10, 0.16);
  --color-danger-tint: rgba(255, 69, 58, 0.16);
  --color-backdrop: rgba(0, 0, 0, 0.64);

  --color-shadow-ambient: rgba(0, 0, 0, 0.52);
  --color-shadow-key: rgba(0, 0, 0, 0.36);
}

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

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --color-bg: #000000;
    --color-surface: #1c1c1e;
    --color-surface-elevated: #2c2c2e;
    --color-surface-subtle: #242426;
    --color-glass: rgba(28, 28, 30, 0.84);
    --color-border: rgba(255, 255, 255, 0.12);
    --color-border-subtle: rgba(255, 255, 255, 0.08);
    --color-segment-track: #2c2c2e;
    --color-segment-active: #3a3a3c;

    --color-text-primary: #f5f5f7;
    --color-text-secondary: #d1d1d6;
    --color-text-muted: #a1a1a6;

    --color-primary: #0070e0;
    --color-primary-hover: #005ec4;
    --color-primary-text: #ffffff;
    --color-accent-text: #409cff;
    --color-success: #1e7e34;
    --color-success-hover: #18682b;
    --color-warning: #b25000;
    --color-warning-hover: #944200;
    --color-danger: #d70015;
    --color-danger-hover: #b80012;

    --color-primary-badge-text: #409cff;
    --color-success-badge-text: #30d158;
    --color-warning-badge-text: #ff9f0a;
    --color-danger-badge-text: #ff6961;

    --color-primary-tint: rgba(10, 132, 255, 0.18);
    --color-success-tint: rgba(48, 209, 88, 0.16);
    --color-warning-tint: rgba(255, 159, 10, 0.16);
    --color-danger-tint: rgba(255, 69, 58, 0.16);
    --color-backdrop: rgba(0, 0, 0, 0.64);

    --color-shadow-ambient: rgba(0, 0, 0, 0.52);
    --color-shadow-key: rgba(0, 0, 0, 0.36);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
