/* ============================================
   LF Groups — Design Tokens & Base Reset
   ============================================ */

/* --- CSS Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

/* --- Color Tokens --- */
:root {
  /* Primary palette */
  --color-primary-dark: #0a1628;
  --color-accent: #c9a84c;
  --color-accent-hover: #d4b85e;
  --color-accent-muted: rgba(201, 168, 76, 0.15);
  
  /* Surfaces */
  --color-surface-light: #f8f7f4;
  --color-surface-card: #ffffff;
  --color-surface-dark: #0a1628;
  --color-surface-dark-alt: #0f1d33;
  
  /* Text */
  --color-text-primary: #1a1a2e;
  --color-text-muted: #6b7280;
  --color-text-on-dark: #ffffff;
  --color-text-on-dark-muted: rgba(255, 255, 255, 0.7);
  
  /* Borders & shadows */
  --color-border: #e5e7eb;
  --color-border-hover: #c9a84c;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(10, 22, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(10, 22, 40, 0.08);
  --shadow-lg: 0 8px 24px rgba(10, 22, 40, 0.12);
  --shadow-xl: 0 16px 48px rgba(10, 22, 40, 0.16);
  
  /* Typography scale (fluid) */
  --text-xs: clamp(0.75rem, 0.7rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.8125rem, 0.78rem + 0.18vw, 0.875rem);
  --text-base: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  --text-lg: clamp(1.0625rem, 1rem + 0.3vw, 1.125rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.2rem + 0.8vw, 2rem);
  --text-3xl: clamp(1.875rem, 1.5rem + 1.2vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 1.8rem + 1.5vw, 3.25rem);
  --text-5xl: clamp(2.75rem, 2rem + 2vw, 4rem);
  
  /* Spacing (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;
  --space-32: 128px;
  
  /* Layout */
  --max-width: 1200px;
  --max-width-wide: 1400px;
  --gutter: clamp(20px, 4vw, 80px);
  --section-padding: clamp(60px, 8vw, 120px);
  
  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 300ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 500ms cubic-bezier(0.16, 1, 0.3, 1);
  
  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

/* --- Typography base --- */
body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--text-base);
  color: var(--color-text-primary);
  background-color: var(--color-surface-light);
}

/* Chinese page override */
html[lang="zh-Hant"] body {
  font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
}

html[lang="zh-Hans"] body {
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

h1, h2, h3, h4 {
  font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-text-primary);
}

html[lang="zh-Hant"] h1,
html[lang="zh-Hant"] h2,
html[lang="zh-Hant"] h3,
html[lang="zh-Hant"] h4 {
  font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  font-weight: 700;
}

html[lang="zh-Hans"] h1,
html[lang="zh-Hans"] h2,
html[lang="zh-Hans"] h3,
html[lang="zh-Hans"] h4 {
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-weight: 700;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-interactive);
}

ul, ol { list-style: none; }

/* --- Utility --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.container-wide {
  width: 100%;
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Skip link — hidden until focused */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  padding: 8px 16px;
  background: #c9a84c;
  color: #0a1628;
  font-weight: 600;
  font-size: 0.875rem;
  z-index: 10000;
  border-radius: 0 0 4px 4px;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* --- Scroll animation (CSS-only with JS fallback) --- */
.fade-in {
  opacity: 0;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-in.is-visible {
  opacity: 1;
}

/* prefers-reduced-motion */
@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; }
  .fade-in { opacity: 1; }
}
