/* PianoPlayer Common Styles & Design System Tokens */

:root {
  /* System Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font-display: "Cabinet Grotesk", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;

  /* Default Transition */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-theme: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, fill 0.3s ease;

  /* Spacing Scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 36px;
  --space-2xl: 64px;

  /* Base Radii */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-muted: #e2e8f0;

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #0284c7;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-on-accent: #ffffff;

  --accent-primary: #0284c7;
  --accent-primary-hover: #0369a1;
  --accent-subtle: #e0f2fe;

  --accent-secondary: #0d9488;
  --accent-warm: #d97706;

  --card-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --card-shadow-hover: 0 12px 32px -4px rgba(15, 23, 42, 0.1), 0 4px 12px -2px rgba(15, 23, 42, 0.05);

  --baidu-color: #2932e1;
  --quark-color: #ff5722;
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --bg-page: #0a0e17;
  --bg-surface: #111827;
  --bg-surface-elevated: #162032;
  --bg-subtle: #1a2436;
  --bg-muted: #243248;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-focus: #38bdf8;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-on-accent: #0a0e17;

  --accent-primary: #38bdf8;
  --accent-primary-hover: #7dd3fc;
  --accent-subtle: rgba(56, 189, 248, 0.12);

  --accent-secondary: #2dd4bf;
  --accent-warm: #fbbf24;

  --card-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --card-shadow-hover: 0 14px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(56, 189, 248, 0.2);

  --baidu-color: #3e4aff;
  --quark-color: #ff6e40;
}

/* Base Reset & Global Rules */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  transition: var(--transition-theme);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

img, svg {
  display: block;
}

/* Demo Switcher Top Toolbar */
.demo-switcher-bar {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 16px;
  color: #f1f5f9;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.demo-switcher-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.demo-switcher-tag {
  background: #38bdf8;
  color: #0f172a;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.demo-switcher-options {
  display: flex;
  align-items: center;
  gap: 6px;
}

.demo-pill {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: #94a3b8;
  transition: all var(--transition-fast);
  background: transparent;
  border: 1px solid transparent;
}

.demo-pill:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
}

.demo-pill.active {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.3);
  font-weight: 600;
}

.demo-switcher-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.demo-docs-link {
  color: #cbd5e1;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 12px;
  transition: color var(--transition-fast);
}

.demo-docs-link:hover {
  color: #38bdf8;
}

/* Toast Component */
.ui-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transform: translateY(60px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

[data-theme="light"] .ui-toast {
  background: #1e293b;
  color: #ffffff;
  border-color: #38bdf8;
}

.ui-toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Micro-interaction & Focus Visibility */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .demo-switcher-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
