/* ==========================================================================
   BASE STYLES
   ========================================================================== */

/* Reset & Normalize */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 
              "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", 
              "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Remove list styles */
ul, ol {
  list-style: none;
}

/* Remove default button styles */
button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

/* Remove default link styles */
a {
  text-decoration: none;
  color: inherit;
}

/* Image defaults */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Form elements */
input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* Focus outline */
:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ==========================================================================
   CSS VARIABLES & COLOR SYSTEM
   ========================================================================== */

:root {
  /* Light theme colors */
  --bg: #fefefe;
  --bg-elevated: #f9f9f9;
  --text: #1a1a1a;
  --text-secondary: #525252;
  --text-muted: #00000080;
  --primary: #1a1a1a;
  --primary-hover: #000000;
  --primary-contrast: #fefefe;
  --border: #f0f0f0;
  --border-light: #f7f7f7;
  --card: rgba(255, 255, 255, 0.90);
  --card-hover: rgba(0, 0, 0, 0.06);
  --shadow: rgba(0, 0, 0, 0.04);
  --shadow-lg: rgba(0, 0, 0, 0.08);
  
  /* 蓝色点缀色 - 极少使用 */
  --accent-blue: #2563eb;
  
  /* Spacing scale - 更大的间距 */
  --space-xs: 0.375rem;   /* 6px */
  --space-sm: 0.75rem;    /* 12px */
  --space-md: 1.25rem;    /* 20px */
  --space-lg: 2rem;       /* 32px */
  --space-xl: 3rem;       /* 48px */
  --space-2xl: 4.5rem;    /* 72px */
  --space-3xl: 6rem;      /* 96px */
  --space-4xl: 8rem;      /* 128px */
  
  /* Font sizes */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */
  --text-5xl: 3rem;      /* 48px */
  --text-6xl: 3.75rem;   /* 60px */
  
  /* Font weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  
  /* Line heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  
  /* Border radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  
  /* Transitions */
  --transition-fast: 0.15s ease-out;
  --transition-base: 0.2s ease-out;
  --transition-slow: 0.3s ease-out;
  
  /* Container max widths */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1200px;
  --container-2xl: 1400px;
}

/* Dark theme colors */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-elevated: #141414;
  --text: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-muted: #737373;
  --primary: #f5f5f5;
  --primary-hover: #ffffff;
  --primary-contrast: #0a0a0a;
  --border: #262626;
  --border-light: #1a1a1a;
  --card: rgba(20, 20, 20, 0.95);
  --card-hover: #1f1f1f;
  --shadow: rgba(0, 0, 0, 0.2);
  --shadow-lg: rgba(0, 0, 0, 0.2);
  
  /* 蓝色点缀色 - 极少使用 */
  --accent-blue: #3b82f6;
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */

body {
  background-color: var(--bg);
  color: var(--text);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  transition: background-color var(--transition-base), color var(--transition-base);
  position: relative;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--leading-tight);
  font-weight: var(--font-bold);
  letter-spacing: -0.025em;
  margin-bottom: var(--space-md);
}

h1 {
  font-size: var(--text-5xl);
  margin-bottom: var(--space-lg);
}

h2 {
  font-size: var(--text-4xl);
}

h3 {
  font-size: var(--text-3xl);
}

h4 {
  font-size: var(--text-2xl);
}

h5 {
  font-size: var(--text-xl);
}

h6 {
  font-size: var(--text-lg);
}

/* Paragraphs */
p {
  margin-bottom: var(--space-md);
}

p:last-child {
  margin-bottom: 0;
}

/* Link styles */
a {
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary);
}

/* Strong emphasis */
strong, b {
  font-weight: var(--font-semibold);
}

/* ==========================================================================
   MOTION & ACCESSIBILITY
   ========================================================================== */

/* 向下滚动指示器 */
.scroll-indicator {
  position: absolute;
  bottom: var(--space-2xl);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  margin-bottom: 64px;
}

.scroll-arrow {
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
  animation: scroll-pulse 2s ease-in-out infinite;
  cursor: pointer;
  transition: color var(--transition-base);
}

.scroll-arrow:hover {
  color: var(--primary);
}

@keyframes scroll-pulse {
  0%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(4px);
  }
}

/* Respect user's motion preferences */
@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;
  }
  
  html {
    scroll-behavior: auto;
  }
  
  /* 禁用滚动指示器动画 */
  .scroll-arrow {
    animation: none !important;
    opacity: 0.6 !important;
    transform: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #000000;
    --text-secondary: var(--text);
  }
  
  [data-theme="dark"] {
    --border: #ffffff;
    --text-secondary: var(--text);
  }
}

/* ==========================================================================
   UTILITIES
   ========================================================================== */

/* Screen reader only */
.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;
}

/* Skip to main content */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary);
  color: var(--primary-contrast);
  padding: 8px;
  border-radius: var(--radius-md);
  text-decoration: none;
  z-index: 100;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 6px;
}

/* Focus styles for better accessibility */
.focus-ring:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

@media (min-width: 640px) {
  h1 {
    font-size: var(--text-6xl);
  }
}

@media (min-width: 768px) {
  :root {
    --space-xs: 0.375rem;   /* 6px */
    --space-sm: 0.75rem;    /* 12px */
    --space-md: 1.25rem;    /* 20px */
    --space-lg: 2rem;       /* 32px */
    --space-xl: 2.5rem;     /* 40px */
    --space-2xl: 3.5rem;    /* 56px */
    --space-3xl: 5rem;      /* 80px */
    --space-4xl: 7rem;      /* 112px */
  }
}

/* 深色模式图片切换 */
.project-image img[data-dark-src] {
  transition: transform var(--transition-slow), opacity var(--transition-fast);
}

[data-theme="dark"] .project-image img[data-dark-src] {
  content: attr(data-dark-src);
}