/**
 * 乐安援手义工协会 - 官方设计系统
 * Official Design System for Volunteer Organization
 * Based on WCAG 2.1 AA accessibility standards
 * Inspired by authoritative government and public welfare organizations
 */

/* Import Professional Typography - Chinese-optimized */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;600;700&display=swap');

:root {
  /* === COLOR SYSTEM === */
  /* Primary Colors - Red (Official Chinese Government/Organization Color) */
  --color-primary-50: #FEF2F2;
  --color-primary-100: #FEE2E2;
  --color-primary-200: #FECACA;
  --color-primary-300: #FCA5A5;
  --color-primary-400: #F87171;
  --color-primary-500: #EF4444;
  --color-primary-600: #DC2626;
  --color-primary-700: #B91C1C;
  --color-primary-800: #991B1B;
  --color-primary-900: #7F1D1D;

  /* Secondary Colors - Gold (Traditional Chinese Official Color) */
  --color-secondary-50: #FFFBEB;
  --color-secondary-100: #FEF3C7;
  --color-secondary-200: #FDE68A;
  --color-secondary-300: #FCD34D;
  --color-secondary-400: #FBBF24;
  --color-secondary-500: #F59E0B;
  --color-secondary-600: #D97706;
  --color-secondary-700: #B45309;
  --color-secondary-800: #92400E;
  --color-secondary-900: #78350F;

  /* Success/CTA Colors - Positive Actions */
  --color-success-50: #F0FDF4;
  --color-success-100: #DCFCE7;
  --color-success-200: #BBF7D0;
  --color-success-300: #86EFAC;
  --color-success-400: #4ADE80;
  --color-success-500: #22C55E;
  --color-success-600: #16A34A;
  --color-success-700: #15803D;
  --color-success-800: #166534;
  --color-success-900: #14532D;

  /* Semantic Colors */
  --color-error-50: #FEF2F2;
  --color-error-100: #FEE2E2;
  --color-error-200: #FECACA;
  --color-error-300: #FCA5A5;
  --color-error-400: #F87171;
  --color-error-500: #EF4444;
  --color-error-600: #DC2626;
  --color-error-700: #B91C1C;
  --color-error-800: #991B1B;
  --color-error-900: #7F1D1D;

  --color-warning-50: #FFFBEB;
  --color-warning-100: #FEF3C7;
  --color-warning-200: #FDE68A;
  --color-warning-300: #FCD34D;
  --color-warning-400: #FBBF24;
  --color-warning-500: #F59E0B;
  --color-warning-600: #D97706;
  --color-warning-700: #B45309;
  --color-warning-800: #92400E;
  --color-warning-900: #78350F;

  /* Neutral Colors */
  --color-slate-50: #F8FAFC;
  --color-slate-100: #F1F5F9;
  --color-slate-200: #E2E8F0;
  --color-slate-300: #CBD5E1;
  --color-slate-400: #94A3B8;
  --color-slate-500: #64748B;
  --color-slate-600: #475569;
  --color-slate-700: #334155;
  --color-slate-800: #1E293B;
  --color-slate-900: #0F172A;

  /* === DESIGN TOKEN ASSIGNMENTS === */
  /* Primary Brand Colors - Official Red */
  --ds-color-primary: var(--color-primary-700);
  --ds-color-primary-hover: var(--color-primary-800);
  --ds-color-primary-light: var(--color-primary-50);
  --ds-color-secondary: var(--color-secondary-600);
  --ds-color-secondary-hover: var(--color-secondary-700);

  /* Call-to-Action Colors */
  --ds-color-cta: var(--color-success-600);
  --ds-color-cta-hover: var(--color-success-700);
  --ds-color-cta-light: var(--color-success-100);

  /* Background Colors - Clean and Professional */
  --ds-color-background: #F5F5F5;
  --ds-color-surface: #FFFFFF;
  --ds-color-surface-hover: var(--color-slate-50);
  --ds-color-surface-active: var(--color-slate-100);

  /* Text Colors - Enhanced for better contrast */
  --ds-color-text-primary: var(--color-slate-900);
  --ds-color-text-secondary: var(--color-slate-700);
  --ds-color-text-muted: var(--color-slate-600);
  --ds-color-text-inverse: #FFFFFF;

  /* Border Colors */
  --ds-color-border: var(--color-slate-200);
  --ds-color-border-hover: var(--color-slate-300);
  --ds-color-border-focus: var(--color-primary-600);

  /* Semantic Colors */
  --ds-color-success: var(--color-success-600);
  --ds-color-success-light: var(--color-success-100);
  --ds-color-error: var(--color-error-600);
  --ds-color-error-light: var(--color-error-100);
  --ds-color-warning: var(--color-warning-600);
  --ds-color-warning-light: var(--color-warning-100);

  /* === TYPOGRAPHY SYSTEM === */
  /* Font Families - Chinese-optimized */
  --ds-font-heading: 'Noto Serif SC', 'SimSun', serif;
  --ds-font-body: 'Noto Sans SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Font Sizes - Based on 16px base */
  --ds-text-xs: 0.75rem;    /* 12px */
  --ds-text-sm: 0.875rem;   /* 14px */
  --ds-text-base: 1rem;     /* 16px */
  --ds-text-lg: 1.125rem;   /* 18px */
  --ds-text-xl: 1.25rem;    /* 20px */
  --ds-text-2xl: 1.5rem;    /* 24px */
  --ds-text-3xl: 1.875rem;  /* 30px */
  --ds-text-4xl: 2.25rem;   /* 36px */
  --ds-text-5xl: 3rem;      /* 48px */
  --ds-text-6xl: 3.75rem;   /* 60px */

  /* Font Weights */
  --ds-font-light: 300;
  --ds-font-normal: 400;
  --ds-font-medium: 500;
  --ds-font-semibold: 600;
  --ds-font-bold: 700;

  /* Line Heights */
  --ds-leading-tight: 1.25;
  --ds-leading-snug: 1.375;
  --ds-leading-normal: 1.5;
  --ds-leading-relaxed: 1.625;
  --ds-leading-loose: 2;

  /* === SPACING SYSTEM - 8px Grid === */
  --ds-space-0: 0;
  --ds-space-1: 0.25rem;   /* 4px */
  --ds-space-2: 0.5rem;    /* 8px */
  --ds-space-3: 0.75rem;   /* 12px */
  --ds-space-4: 1rem;      /* 16px */
  --ds-space-5: 1.25rem;   /* 20px */
  --ds-space-6: 1.5rem;    /* 24px */
  --ds-space-8: 2rem;      /* 32px */
  --ds-space-10: 2.5rem;   /* 40px */
  --ds-space-12: 3rem;     /* 48px */
  --ds-space-16: 4rem;     /* 64px */
  --ds-space-20: 5rem;     /* 80px */
  --ds-space-24: 6rem;     /* 96px */

  /* === BORDER RADIUS === */
  --ds-radius-none: 0;
  --ds-radius-sm: 0.25rem;   /* 4px */
  --ds-radius-base: 0.5rem;  /* 8px */
  --ds-radius-md: 0.75rem;   /* 12px */
  --ds-radius-lg: 1rem;      /* 16px */
  --ds-radius-xl: 1.5rem;    /* 24px */
  --ds-radius-full: 9999px;

  /* === SHADOWS === */
  --ds-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --ds-shadow-base: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --ds-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --ds-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --ds-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* === TRANSITIONS === */
  --ds-transition-fast: 150ms ease;
  --ds-transition-base: 200ms ease;
  --ds-transition-slow: 300ms ease;

  /* === Z-INDEX SCALE === */
  --ds-z-dropdown: 1000;
  --ds-z-sticky: 1020;
  --ds-z-fixed: 1030;
  --ds-z-modal-backdrop: 1040;
  --ds-z-modal: 1050;
  --ds-z-popover: 1060;
  --ds-z-tooltip: 1070;

  /* === BREAKPOINTS === */
  --ds-breakpoint-sm: 640px;
  --ds-breakpoint-md: 768px;
  --ds-breakpoint-lg: 1024px;
  --ds-breakpoint-xl: 1280px;
  --ds-breakpoint-2xl: 1536px;
}

/* === BASE STYLES === */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -moz-tab-size: 4;
  tab-size: 4;
}

body {
  font-family: var(--ds-font-body);
  font-size: var(--ds-text-base);
  font-weight: var(--ds-font-normal);
  line-height: var(--ds-leading-normal);
  color: var(--ds-color-text-primary);
  background-color: var(--ds-color-background);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === TYPOGRAPHY STYLES === */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--ds-font-heading);
  font-weight: var(--ds-font-semibold);
  line-height: var(--ds-leading-tight);
  color: var(--ds-color-text-primary);
  margin: 0 0 var(--ds-space-4) 0;
}

h1 {
  font-size: var(--ds-text-4xl);
  font-weight: var(--ds-font-bold);
  line-height: var(--ds-leading-tight);
}

h2 {
  font-size: var(--ds-text-3xl);
  font-weight: var(--ds-font-semibold);
}

h3 {
  font-size: var(--ds-text-2xl);
  font-weight: var(--ds-font-semibold);
}

h4 {
  font-size: var(--ds-text-xl);
  font-weight: var(--ds-font-medium);
}

h5 {
  font-size: var(--ds-text-lg);
  font-weight: var(--ds-font-medium);
}

h6 {
  font-size: var(--ds-text-base);
  font-weight: var(--ds-font-medium);
}

p {
  margin: 0 0 var(--ds-space-4) 0;
  color: var(--ds-color-text-secondary);
}

/* === UTILITY CLASSES === */
.ds-text-primary { color: var(--ds-color-text-primary) !important; }
.ds-text-secondary { color: var(--ds-color-text-secondary) !important; }
.ds-text-muted { color: var(--ds-color-text-muted) !important; }
.ds-text-inverse { color: var(--ds-color-text-inverse) !important; }
.ds-text-success { color: var(--ds-color-success) !important; }
.ds-text-error { color: var(--ds-color-error) !important; }
.ds-text-warning { color: var(--ds-color-warning) !important; }

.ds-bg-primary { background-color: var(--ds-color-primary) !important; }
.ds-bg-secondary { background-color: var(--ds-color-secondary) !important; }
.ds-bg-cta { background-color: var(--ds-color-cta) !important; }
.ds-bg-surface { background-color: var(--ds-color-surface) !important; }
.ds-bg-success { background-color: var(--ds-color-success) !important; }
.ds-bg-error { background-color: var(--ds-color-error) !important; }
.ds-bg-warning { background-color: var(--ds-color-warning) !important; }

/* === ACCESSIBILITY UTILITIES === */
.ds-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ds-focus-visible:focus-visible,
.ds-btn:focus-visible,
.ds-input:focus-visible,
.tabbar-item:focus-visible,
.menu .item:focus-visible,
.cate-menu .item:focus-visible,
.list-item:focus-visible {
  outline: 3px solid var(--ds-color-border-focus);
  outline-offset: 2px;
  border-radius: var(--ds-radius-sm);
}

/* Enhanced focus styles for better visibility */
.pc-header .nav a:focus-visible {
  outline: 3px solid var(--ds-color-border-focus);
  outline-offset: 2px;
  border-radius: var(--ds-radius-sm);
}

.pc-header .login-btn:focus-visible {
  outline: 3px solid var(--ds-color-text-inverse);
  outline-offset: 2px;
}

/* Skip links styling */
.ds-sr-only.ds-focus-visible:focus {
  position: absolute;
  top: var(--ds-space-2);
  left: var(--ds-space-2);
  width: auto;
  height: auto;
  padding: var(--ds-space-2) var(--ds-space-4);
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: nowrap;
  background: var(--ds-color-primary);
  color: var(--ds-color-text-inverse);
  border-radius: var(--ds-radius-base);
  font-size: var(--ds-text-sm);
  font-weight: var(--ds-font-medium);
  text-decoration: none;
  z-index: var(--ds-z-tooltip);
}

/* === REDUCED MOTION SUPPORT === */
@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;
  }
}

/* === RESPONSIVE TYPOGRAPHY === */
@media (max-width: 767px) {
  html {
    font-size: 16px; /* Ensure minimum 16px on mobile */
  }
  
  h1 {
    font-size: var(--ds-text-3xl);
  }
  
  h2 {
    font-size: var(--ds-text-2xl);
  }
  
  h3 {
    font-size: var(--ds-text-xl);
  }
  
  /* Mobile spacing adjustments */
  .ds-card {
    margin-bottom: var(--ds-space-4);
  }
  
  .ds-card__body {
    padding: var(--ds-space-4);
  }
  
  .ds-card__header,
  .ds-card__footer {
    padding: var(--ds-space-4);
  }
  
  .ds-form-group {
    margin-bottom: var(--ds-space-4);
  }
  
  .ds-btn {
    padding: var(--ds-space-3) var(--ds-space-4);
    font-size: var(--ds-text-base);
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  /* Tablet spacing adjustments */
  .ds-card__body {
    padding: var(--ds-space-5);
  }
  
  .ds-card__header,
  .ds-card__footer {
    padding: var(--ds-space-5);
  }
}

@media (min-width: 1024px) {
  /* Desktop spacing adjustments */
  .ds-card__body {
    padding: var(--ds-space-6);
  }
  
  .ds-card__header,
  .ds-card__footer {
    padding: var(--ds-space-6);
  }
  
  .ds-form-group {
    margin-bottom: var(--ds-space-6);
  }
}

/* === CURSOR STYLES === */
.ds-btn,
.menu .item,
.cate-menu .item,
.list-item,
.tabbar-item,
.pc-header .nav a,
.pc-header .login-btn,
.pc-menu-list .item,
.ds-card--interactive,
.ds-breadcrumb__item:not(.ds-breadcrumb__item--current),
button,
[role="button"],
[onclick],
a:not([disabled]) {
  cursor: pointer;
}

/* Disabled elements */
[disabled],
.ds-btn:disabled,
.ds-btn--loading {
  cursor: not-allowed;
}

/* Text selection cursor for text inputs */
.ds-input,
.ds-textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
textarea {
  cursor: text;
}

/* === BRAND LOGO SYSTEM === */

/* Base Logo Styles */
.ds-logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--ds-color-text-primary);
  font-family: var(--ds-font-heading);
  font-weight: var(--ds-font-semibold);
  transition: all var(--ds-transition-fast);
}

.ds-logo:hover {
  color: var(--ds-color-primary);
  text-decoration: none;
}

.ds-logo:focus-visible {
  outline: 2px solid var(--ds-color-border-focus);
  outline-offset: 2px;
  border-radius: var(--ds-radius-sm);
}

/* Logo Image Styles */
.ds-logo__image {
  height: 40px;
  width: auto;
  margin-right: var(--ds-space-3);
  object-fit: contain;
  transition: transform var(--ds-transition-fast);
}

.ds-logo:hover .ds-logo__image {
  transform: scale(1.05);
}

/* Logo Text Styles */
.ds-logo__text {
  font-size: var(--ds-text-lg);
  font-weight: var(--ds-font-semibold);
  line-height: var(--ds-leading-tight);
  white-space: nowrap;
}

/* Logo Size Variants */
.ds-logo--sm .ds-logo__image {
  height: 32px;
}

.ds-logo--sm .ds-logo__text {
  font-size: var(--ds-text-base);
}

.ds-logo--lg .ds-logo__image {
  height: 48px;
}

.ds-logo--lg .ds-logo__text {
  font-size: var(--ds-text-xl);
}

.ds-logo--xl .ds-logo__image {
  height: 64px;
}

.ds-logo--xl .ds-logo__text {
  font-size: var(--ds-text-2xl);
}

/* Logo Layout Variants */
.ds-logo--vertical {
  flex-direction: column;
  text-align: center;
}

.ds-logo--vertical .ds-logo__image {
  margin-right: 0;
  margin-bottom: var(--ds-space-2);
}

.ds-logo--center {
  justify-content: center;
}

/* Logo Color Variants */
.ds-logo--inverse {
  color: var(--ds-color-text-inverse);
}

.ds-logo--inverse:hover {
  color: var(--ds-color-primary-light);
}

/* Responsive Logo Behavior */
@media (max-width: 767px) {
  .ds-logo__text {
    font-size: var(--ds-text-base);
  }
  
  .ds-logo__image {
    height: 36px;
  }
  
  .ds-logo--hide-text-mobile .ds-logo__text {
    display: none;
  }
}

@media (max-width: 480px) {
  .ds-logo__image {
    height: 32px;
  }
}
/* Map old CSS variables to new design system */
:root {
  --projectColor: var(--ds-color-primary);
  --projectColorLight: var(--ds-color-primary-light);
  --projectCompareColor: var(--ds-color-warning-400);
  --bgColor: var(--ds-color-background);
  --textColor: var(--ds-color-text-primary);
  --greyColor: var(--ds-color-text-muted);
}

/* Maintain backward compatibility with existing classes */
.text-project { color: var(--ds-color-primary) !important; }
.bg-project { 
  background-color: var(--ds-color-primary) !important; 
  color: var(--ds-color-text-inverse) !important; 
}
.text-grey { color: var(--ds-color-text-muted) !important; }