/* ============================================================
   ConnexionTrack Design System v9 — Core Foundation
   设计令牌 + Reset + 工具类 + 动画 + 明暗主题
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────── */
:root {
  /* Primary: 深海蓝绿 — 传递信任与专业（保持不变） */
  --ct-teal-50:  #ecfeff;
  --ct-teal-100: #cffafe;
  --ct-teal-200: #a5f3fc;
  --ct-teal-300: #67e8f9;
  --ct-teal-400: #22d3ee;
  --ct-teal-500: #06b6d4;
  --ct-teal-600: #0891b2;
  --ct-teal-700: #0e7490;
  --ct-teal-800: #155e75;
  --ct-teal-900: #164e63;
  --ct-teal-950: #083344;

  /* Accent: 暖金 — 行动号召 */
  --ct-gold-400: #facc15;
  --ct-gold-500: #eab308;
  --ct-gold-600: #ca8a04;

  /* Neutral: 暖灰 */
  --ct-gray-50:  #fafaf9;
  --ct-gray-100: #f5f5f4;
  --ct-gray-200: #e7e5e4;
  --ct-gray-300: #d6d3d1;
  --ct-gray-400: #a8a29e;
  --ct-gray-500: #78716c;
  --ct-gray-600: #57534e;
  --ct-gray-700: #44403c;
  --ct-gray-800: #292524;
  --ct-gray-900: #1c1917;

  /* Semantic */
  --ct-success:     #059669;
  --ct-success-bg:  #ecfdf5;
  --ct-warning:     #d97706;
  --ct-warning-bg:  #fffbeb;
  --ct-danger:      #dc2626;
  --ct-danger-bg:   #fef2f2;
  --ct-info:        #2563eb;
  --ct-info-bg:     #eff6ff;

  /* Typography */
  --ct-font: -apple-system, BlinkMacSystemFont, 'SF Pro', 'Segoe UI', Roboto, 'Helvetica Neue', system-ui, sans-serif;
  --ct-font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* Fluid type scale */
  --ct-text-xs:   clamp(0.69rem, 0.65rem + 0.1vw, 0.75rem);
  --ct-text-sm:   clamp(0.83rem, 0.8rem + 0.1vw, 0.875rem);
  --ct-text-base: clamp(0.94rem, 0.92rem + 0.1vw, 1rem);
  --ct-text-lg:   clamp(1.06rem, 1.0rem + 0.15vw, 1.125rem);
  --ct-text-xl:   clamp(1.19rem, 1.1rem + 0.2vw, 1.25rem);
  --ct-text-2xl:  clamp(1.38rem, 1.25rem + 0.3vw, 1.5rem);
  --ct-text-3xl:  clamp(1.75rem, 1.5rem + 0.5vw, 2rem);

  /* Spacing */
  --ct-space-xs:  4px;
  --ct-space-sm:  8px;
  --ct-space-md:  16px;
  --ct-space-lg:  24px;
  --ct-space-xl:  32px;
  --ct-space-2xl: 48px;
  --ct-space-3xl: 64px;

  /* Borders & Shadows */
  --ct-radius-sm: 6px;
  --ct-radius:    10px;
  --ct-radius-lg: 16px;
  --ct-radius-xl: 24px;

  --ct-shadow-xs:  0 1px 2px rgba(0,0,0,.04);
  --ct-shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 2px 6px rgba(0,0,0,.04);
  --ct-shadow:     0 4px 12px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --ct-shadow-md:  0 6px 20px rgba(0,0,0,.07), 0 2px 6px rgba(0,0,0,.04);
  --ct-shadow-lg:  0 10px 40px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --ct-shadow-xl:  0 20px 60px rgba(0,0,0,.1);

  --ct-border:     1px solid var(--ct-gray-200);
  --ct-border-lg:  1.5px solid var(--ct-gray-200);

  /* Transitions */
  --ct-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --ct-bounce:     400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --ct-container: min(1120px, 100% - 48px);
  --ct-container-sm: min(720px, 100% - 32px);

  /* Focus & Selection */
  --ct-focus-ring: 0 0 0 3px rgba(6, 182, 212, 0.2);
  --ct-selection-bg: var(--ct-teal-200);

  /* Scrollbar */
  --ct-scrollbar-thumb: var(--ct-gray-300);
  --ct-scrollbar-track: transparent;

  /* ── 亮色模式背景层（由浅到深） ─────────────────── */
  --ct-bg-page:     #f2f1ef;    /* 最底层 - 页面外围 */
  --ct-bg:          #fafaf9;    /* 主内容区 */
  --ct-bg-subtle:   #edebe9;    /* 交替 section / tab bar */
  --ct-bg-card:     #ffffff;    /* 卡片表面 */
  --ct-bg-raised:   #ffffff;    /* 弹出层 / 对话框 */
  --ct-bg-hover:    #f0efee;    /* hover / active 态 */

  --ct-text:       #292524;
  --ct-text-muted: #78716c;
  --ct-border-subtle: #e7e5e4;
  --ct-overlay:    rgba(0,0,0,.3);
}

/* ── 暗色模式（系统跟随） ───────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ct-bg-page:     #0d0c0a;
    --ct-bg:          #1c1917;
    --ct-bg-subtle:   #151312;
    --ct-bg-card:     #292524;
    --ct-bg-raised:   #3a3632;
    --ct-bg-hover:    #221f1d;

    --ct-text:       #e7e5e4;
    --ct-text-muted: #a8a29e;
    --ct-border-subtle: #44403c;
    --ct-overlay:    rgba(0,0,0,.6);

    /* Neutral palette dark shift */
    --ct-gray-50:  #1c1917;
    --ct-gray-100: #292524;
    --ct-gray-200: #44403c;
    --ct-gray-300: #57534e;
    --ct-gray-400: #78716c;
    --ct-gray-500: #a8a29e;
    --ct-gray-600: #d6d3d1;
    --ct-gray-700: #e7e5e4;
    --ct-gray-800: #f5f5f4;
    --ct-gray-900: #fafaf9;

    --ct-shadow-xs: 0 1px 2px rgba(0,0,0,.2);
    --ct-shadow-sm: 0 1px 3px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.2);
    --ct-shadow:    0 4px 12px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.2);
    --ct-shadow-md: 0 6px 20px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.2);
    --ct-shadow-lg: 0 10px 40px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.2);
    --ct-shadow-xl: 0 20px 60px rgba(0,0,0,.45);

    --ct-border:     1px solid var(--ct-gray-200);
    --ct-border-lg:  1.5px solid var(--ct-gray-200);

    --ct-success-bg: #064e3b;
    --ct-warning-bg: #78350f;
    --ct-danger-bg:  #7f1d1d;
    --ct-info-bg:    #1e3a5f;

    --ct-teal-50:  #0c1929;
    --ct-teal-100: #0f2a3a;
  }
}

/* ── 手动暗色模式（html[data-theme="dark"]，优先级高于系统） ─── */
html[data-theme="dark"] {
  --ct-bg-page:     #0d0c0a;
  --ct-bg:          #1c1917;
  --ct-bg-subtle:   #151312;
  --ct-bg-card:     #292524;
  --ct-bg-raised:   #3a3632;
  --ct-bg-hover:    #221f1d;

  --ct-text:       #e7e5e4;
  --ct-text-muted: #a8a29e;
  --ct-border-subtle: #44403c;
  --ct-overlay:    rgba(0,0,0,.6);

  --ct-gray-50:  #1c1917;
  --ct-gray-100: #292524;
  --ct-gray-200: #44403c;
  --ct-gray-300: #57534e;
  --ct-gray-400: #78716c;
  --ct-gray-500: #a8a29e;
  --ct-gray-600: #d6d3d1;
  --ct-gray-700: #e7e5e4;
  --ct-gray-800: #f5f5f4;
  --ct-gray-900: #fafaf9;

  --ct-shadow-xs: 0 1px 2px rgba(0,0,0,.2);
  --ct-shadow-sm: 0 1px 3px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.2);
  --ct-shadow:    0 4px 12px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.2);
  --ct-shadow-md: 0 6px 20px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.2);
  --ct-shadow-lg: 0 10px 40px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.2);
  --ct-shadow-xl: 0 20px 60px rgba(0,0,0,.45);

  --ct-border:     1px solid var(--ct-gray-200);
  --ct-border-lg:  1.5px solid var(--ct-gray-200);

  --ct-success-bg: #064e3b;
  --ct-warning-bg: #78350f;
  --ct-danger-bg:  #7f1d1d;
  --ct-info-bg:    #1e3a5f;

  --ct-teal-50:  #0c1929;
  --ct-teal-100: #0f2a3a;
}

/* ── 亮色模式手动锁定 ───────────────────────────────── */
html[data-theme="light"] {
  --ct-bg-page:     #f2f1ef;
  --ct-bg:          #fafaf9;
  --ct-bg-subtle:   #edebe9;
  --ct-bg-card:     #ffffff;
  --ct-bg-raised:   #ffffff;
  --ct-bg-hover:    #f0efee;
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--ct-font);
  font-size: var(--ct-text-base);
  line-height: 1.6;
  color: var(--ct-text);
  background: var(--ct-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
a { color: var(--ct-teal-700); text-decoration: none; transition: color var(--ct-transition); }
a:hover { color: var(--ct-teal-600); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
svg { display: block; }

/* ── Focus, Selection & Scrollbar ─────────────────────── */
:focus-visible {
  outline: 2px solid var(--ct-teal-500);
  outline-offset: 2px;
}
::selection {
  background: var(--ct-teal-200);
  color: var(--ct-teal-950);
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ct-gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ct-gray-400); }

/* ── 触控目标规范（铁律：移动端 ≥34px） ──────────────── */
.ct-lang-bar button { min-height: 34px; }
.ct-nav-link { min-height: 34px; }

/* ── 动画尊重（无障碍） ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ══════════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════════ */
@keyframes ct-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ct-fade-in-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ct-scale-in {
  from { opacity: 0; transform: scale(.95); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes ct-slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ct-spin {
  to { transform: rotate(360deg); }
}
@keyframes ct-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes ct-fade-in-down {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ct-slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ct-bounce-in {
  0%   { opacity: 0; transform: scale(.9); }
  50%  { transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes ct-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .5; }
}
@keyframes ct-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

.ct-fade-in      { animation: ct-fade-in .4s ease; }
.ct-fade-in-up   { animation: ct-fade-in-up .5s ease; }
.ct-fade-in-down { animation: ct-fade-in-down .4s ease; }
.ct-scale-in     { animation: ct-scale-in .3s ease; }
.ct-bounce-in    { animation: ct-bounce-in .4s ease; }
.ct-shake        { animation: ct-shake .3s ease; }
.ct-pulse        { animation: ct-pulse 2s ease infinite; }

/* ══════════════════════════════════════════════════════════
   UTILITY CLASSES
   ══════════════════════════════════════════════════════════ */
.ct-flex          { display: flex; align-items: center; }
.ct-flex-center   { display: flex; align-items: center; justify-content: center; }
.ct-flex-between  { display: flex; align-items: center; justify-content: space-between; }
.ct-flex-wrap     { flex-wrap: wrap; }
.ct-flex-col      { flex-direction: column; }
.ct-gap-xs        { gap: 4px; }
.ct-gap-sm        { gap: 8px; }
.ct-gap-md        { gap: 16px; }
.ct-gap-lg        { gap: 24px; }
.ct-flex-1        { flex: 1; min-width: 0; }
.ct-flex-shrink0  { flex-shrink: 0; }
.ct-text-center   { text-align: center; }
.ct-text-left     { text-align: left; }
.ct-text-sm       { font-size: var(--ct-text-sm); }
.ct-text-xs       { font-size: var(--ct-text-xs); }
.ct-text-muted    { color: var(--ct-text-muted); }
.ct-mt-xs         { margin-top: 4px; }
.ct-mt-sm         { margin-top: 8px; }
.ct-mt-md         { margin-top: 16px; }
.ct-mt-lg         { margin-top: 24px; }
.ct-mt-xl         { margin-top: 32px; }
.ct-mb-sm         { margin-bottom: 8px; }
.ct-mb-md         { margin-bottom: 16px; }
.ct-mb-lg         { margin-bottom: 24px; }
.ct-my-sm         { margin-top: 8px; margin-bottom: 8px; }
.ct-my-md         { margin-top: 16px; margin-bottom: 16px; }
.ct-my-lg         { margin-top: 24px; margin-bottom: 24px; }
.ct-p-sm          { padding: 8px; }
.ct-p-md          { padding: 16px; }
.ct-p-lg          { padding: 24px; }
.ct-hidden        { display: none; }
.ct-visible       { display: block; }
.ct-mono          { font-family: var(--ct-font-mono); }
.ct-w-full        { width: 100%; }
.ct-relative      { position: relative; }
.ct-grid-2        { display: grid; grid-template-columns: 1fr 1fr; gap: var(--ct-space-md); }
.ct-grid-3        { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--ct-space-md); }
.ct-grid-4        { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--ct-space-md); }

/* Expanded utilities */
.ct-max-w-xs  { max-width: 320px; margin-left: auto; margin-right: auto; }
.ct-max-w-sm  { max-width: 480px; margin-left: auto; margin-right: auto; }
.ct-max-w-md  { max-width: 640px; margin-left: auto; margin-right: auto; }
.ct-mx-auto   { margin-left: auto; margin-right: auto; }
.ct-my-auto   { margin-top: auto; margin-bottom: auto; }
.ct-pt-sm     { padding-top: var(--ct-space-sm); }
.ct-pb-sm     { padding-bottom: var(--ct-space-sm); }
.ct-pt-md     { padding-top: var(--ct-space-md); }
.ct-pb-md     { padding-bottom: var(--ct-space-md); }
.ct-pl-lg     { padding-left: var(--ct-space-lg); }
.ct-pr-lg     { padding-right: var(--ct-space-lg); }
.ct-col-span-full { grid-column: 1 / -1; }
.ct-border-top    { border-top: 1px solid var(--ct-gray-200); }
.ct-border-bottom { border-bottom: 1px solid var(--ct-gray-200); }
.ct-border-none   { border: none !important; }
.ct-font-bold      { font-weight: 700; }
.ct-font-semibold  { font-weight: 600; }
.ct-text-primary   { color: var(--ct-teal-700); }
.ct-text-white     { color: #fff; }
.ct-bg-primary     { background: var(--ct-teal-700); color: #fff; }
.ct-pointer        { cursor: pointer; }
.ct-select-all     { user-select: all; }
.ct-overflow-auto  { overflow: auto; }
.ct-truncate       { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-block          { display: block; }
.ct-inline-block   { display: inline-block; }
.ct-inline-flex    { display: inline-flex; align-items: center; }
.ct-min-w-0        { min-width: 0; }
.ct-min-w-200      { min-width: 200px; }
.ct-slide-down     { animation: ct-slide-down .3s ease; }
.ct-stagger        { animation: ct-fade-in .4s ease; }
.ct-whitespace-nowrap { white-space: nowrap; }
.ct-leading-snug   { line-height: 1.4; }
.ct-rounded-full   { border-radius: 999px; }
.ct-shadow-none    { box-shadow: none !important; }
.ct-gap-10         { gap: 10px; }
.ct-self-stretch   { align-self: stretch; }
.ct-items-start    { align-items: flex-start; }
.ct-justify-center { justify-content: center; }
.ct-flex-wrap-gap  { display: flex; flex-wrap: wrap; gap: var(--ct-space-sm); align-items: center; }
.ct-overflow-hidden { overflow: hidden; }
.ct-absolute       { position: absolute; }
.ct-top-0          { top: 0; }
.ct-left-0         { left: 0; }
.ct-right-0        { right: 0; }
.ct-bottom-0       { bottom: 0; }
.ct-inset-0        { top: 0; right: 0; bottom: 0; left: 0; }
.ct-z-10           { z-index: 10; }
.ct-z-20           { z-index: 20; }
.ct-z-30           { z-index: 30; }
.ct-opacity-0      { opacity: 0; }
.ct-opacity-100    { opacity: 1; }
.ct-transition     { transition: all var(--ct-transition); }
.ct-truncate-2     { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ct-truncate-3     { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ct-border-0       { border: none !important; }
.ct-rounded        { border-radius: var(--ct-radius); }
.ct-rounded-lg     { border-radius: var(--ct-radius-lg); }
.ct-rounded-sm     { border-radius: var(--ct-radius-sm); }
.ct-py-xs          { padding-top: 4px; padding-bottom: 4px; }
.ct-py-sm          { padding-top: 8px; padding-bottom: 8px; }
.ct-px-sm          { padding-left: 8px; padding-right: 8px; }
.ct-px-md          { padding-left: 16px; padding-right: 16px; }
.ct-ml-auto        { margin-left: auto; }
.ct-mr-sm          { margin-right: 8px; }
.ct-mx-auto        { margin-left: auto; margin-right: auto; }
.ct-text-subtle    { color: var(--ct-gray-400); }
.ct-text-danger    { color: var(--ct-danger); }
.ct-bg-danger-subtle { background: var(--ct-danger-bg); }
.ct-border-danger  { border-color: var(--ct-danger); }
.ct-flex-row       { display: flex; flex-direction: row; align-items: center; }
.ct-flex-col       { display: flex; flex-direction: column; }
.ct-flex-wrap      { flex-wrap: wrap; }
.ct-justify-end    { justify-content: flex-end; }
.ct-items-start    { align-items: flex-start; }
.ct-self-start     { align-self: flex-start; }
.ct-gap-0          { gap: 0; }
.ct-inline         { display: inline; }
.ct-w-auto         { width: auto; }
.ct-h-full         { height: 100%; }
.ct-border         { border: 1px solid var(--ct-gray-200); }
.ct-border-radius  { border-radius: var(--ct-radius); }
.ct-overflow-y     { overflow-y: auto; }
.ct-nowrap         { white-space: nowrap; }
.ct-break-word     { word-break: break-word; }

/* ── Empty state（通用空状态） ─────────────────── */
.ct-empty-state {
  padding: 24px; text-align: center; color: var(--ct-gray-400); font-size: var(--ct-text-sm);
}

/* ── Two-column form grid ─────────────────────── */
.ct-form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0;
}

/* ══════════════════════════════════════════════════════════
   PRINT
   ══════════════════════════════════════════════════════════ */
@media print {
  body { background: #fff !important; }
  .ct-lang-bar, .ct-float-wa, .ct-nav, .ct-hero,
  .ct-section, .ct-footer, .ct-toast,
  .ct-btn, form, .ct-state, [onclick] { display: none !important; }
  .ct-card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
  .ct-timeline-step { break-inside: avoid; }
}
