/*
 * My Digital Space - design tokens
 * Stable design decisions and compatibility aliases live here.
 * Page layout and page-specific styling continue to live in app.css.
 */

:root {
  color-scheme: light;

  /* Surfaces and text */
  --color-bg-page: #f5f3ed;
  --color-bg-subtle: #edf2ed;
  --color-bg-muted: #efeee9;
  --color-surface: #fffdf9;
  --color-surface-strong: #ffffff;
  --color-surface-inverse: #263b32;
  --color-text-primary: #26332e;
  --color-text-secondary: #68736e;
  --color-text-muted: #929b96;
  --color-text: var(--color-text-primary);
  --color-text-weak: var(--color-text-muted);
  --color-text-inverse: #f9fbf9;
  --color-border: rgba(37, 76, 61, 0.16);
  --color-border-strong: rgba(37, 76, 61, 0.28);
  --color-divider: rgba(37, 76, 61, 0.11);

  /* Brand and semantic colors */
  --accent: #315d4e;
  --color-primary: var(--accent);
  --color-primary-hover: color-mix(in srgb, var(--color-primary), #000 14%);
  --color-primary-active: color-mix(in srgb, var(--color-primary), #000 22%);
  --color-primary-soft: #edf3ee;
  --color-primary-soft-hover: #e3ece5;
  --color-accent-warm: #ad8658;
  --color-success: #4f755f;
  --color-success-soft: #edf4ef;
  --color-warning: #8b6a36;
  --color-warning-soft: #f7f1e5;
  --color-error: #96544c;
  --color-error-soft: #f8ece9;
  --color-danger: var(--color-error);
  --color-focus-ring: rgba(49, 93, 78, 0.24);

  /* Typography */
  --font-display: "Songti SC", "STSong", "SimSun", Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", "Courier New", monospace;
  --font-size-page-title: clamp(2rem, 3vw, 3rem);
  --font-size-section-title: 1.25rem;
  --font-size-card-title: 1rem;
  --font-size-body: 0.9375rem;
  --font-size-supporting: 0.8125rem;
  --font-size-meta: 0.75rem;
  --font-size-micro: 0.6875rem;
  --line-height-tight: 1.3;
  --line-height-compact: 1.5;
  --line-height-body: 1.75;
  --line-height-reading: 1.85;

  /* Spacing - 4px base */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-9: 36px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* Shape */
  --radius-control-sm: 8px;
  --radius-control: 10px;
  --radius-container: 13px;
  --radius-dialog: 16px;
  --radius-pill: 999px;

  /* Elevation */
  --shadow-none: none;
  --shadow-popover: 0 10px 30px rgba(29, 48, 39, 0.09), 0 2px 8px rgba(29, 48, 39, 0.05);
  --shadow-dialog: 0 26px 70px rgba(24, 42, 34, 0.18), 0 8px 24px rgba(24, 42, 34, 0.08);
  --shadow-focus: 0 0 0 3px var(--color-focus-ring);

  /* Managed stacking layers */
  --z-base: 0;
  --z-sticky: 30;
  --z-dropdown: 160;
  --z-overlay: 180;
  --z-modal: 240;

  /* Motion */
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 240ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);

  /* Compatibility aliases used by existing templates and scripts */
  --ink: var(--color-text-primary);
  --paper: var(--color-bg-page);
  --white: var(--color-surface);
  --line: var(--color-border);
  --muted: var(--color-text-secondary);
  --pine: var(--color-primary);
  --pine-deep: var(--color-primary-hover);
  --sage: #dfe8e1;
  --gold: var(--color-accent-warm);
  --danger: var(--color-error);
  --shadow-sm: var(--shadow-popover);
  --shadow-md: var(--shadow-dialog);
  --radius-sm: var(--radius-control);
  --radius-md: var(--radius-dialog);
  --radius-lg: 24px;
}

html[data-tone="warm"] {
  --color-bg-page: #f3f1eb;
  --color-bg-subtle: #efeee8;
  --color-surface: #fffdf9;
  --color-border: rgba(70, 55, 38, 0.13);
  --color-divider: rgba(70, 55, 38, 0.09);
}

html[data-tone="neutral"] {
  --color-bg-page: #f2f3f2;
  --color-bg-subtle: #edf0ee;
  --color-surface: #ffffff;
  --color-border: rgba(40, 50, 45, 0.13);
  --color-divider: rgba(40, 50, 45, 0.09);
}

html[data-tone="cool"] {
  --color-bg-page: #edf2f3;
  --color-bg-subtle: #e8eff0;
  --color-surface: #fbfdfd;
  --color-border: rgba(38, 66, 72, 0.14);
  --color-divider: rgba(38, 66, 72, 0.1);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-normal: 0ms;
    --duration-slow: 0ms;
  }
}
