/* ========================================
   流光之境 - 字體系統
   Typography System v2.0
   ======================================== */

/* ===== 字體載入優化 ===== */
/* Google Fonts 預連線 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;600;700&family=Playfair+Display:wght@400;600;700&family=Amatic+SC:wght@400;700&display=swap');

/* 本地字體回退 */
@font-face {
  font-family: 'System Sans';
  src: local('system-ui'), local('-apple-system'), local('BlinkMacSystemFont'), 
       local('Segoe UI'), local('Roboto'), local('Helvetica Neue'), local('Arial');
  font-display: swap;
}

/* ===== 基礎字體設定 ===== */
html {
  font-size: 16px; /* 基準字體大小 */
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-family-primary);
  font-weight: var(--font-weight-normal);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  letter-spacing: var(--letter-spacing-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ===== 標題系統 (Heading System) ===== */
.heading-1,
.h1,
h1 {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-5xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--secondary-700);
  margin-bottom: var(--space-6);
}

.heading-2,
.h2,
h2 {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--secondary-700);
  margin-bottom: var(--space-5);
}

.heading-3,
.h3,
h3 {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
  letter-spacing: var(--letter-spacing-normal);
  color: var(--secondary-600);
  margin-bottom: var(--space-4);
}

.heading-4,
.h4,
h4 {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
  letter-spacing: var(--letter-spacing-normal);
  color: var(--secondary-600);
  margin-bottom: var(--space-3);
}

.heading-5,
.h5,
h5 {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-snug);
  letter-spacing: var(--letter-spacing-normal);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.heading-6,
.h6,
h6 {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  letter-spacing: var(--letter-spacing-wide);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
}

/* ===== 段落系統 (Paragraph System) ===== */
.text-body,
.body,
p {
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

.text-body-large {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-relaxed);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

.text-body-small {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

/* ===== 文字樣式變體 (Text Style Variants) ===== */
.text-lead {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-light);
  line-height: var(--line-height-relaxed);
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
}

.text-quote {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-lg);
  font-style: italic;
  line-height: var(--line-height-relaxed);
  color: var(--text-secondary);
  border-left: 4px solid var(--primary-300);
  padding-left: var(--space-4);
  margin: var(--space-6) 0;
}

.text-caption {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--text-tertiary);
  letter-spacing: var(--letter-spacing-wide);
}

.text-overline {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--text-tertiary);
  letter-spacing: var(--letter-spacing-widest);
  text-transform: uppercase;
}

/* ===== 連結系統 (Link System) ===== */
.link,
a {
  color: var(--primary-600);
  text-decoration: none;
  transition: var(--transition-colors);
  position: relative;
}

.link:hover,
a:hover {
  color: var(--primary-700);
}

.link:focus-visible,
a:focus-visible {
  color: var(--primary-700);
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* 連結下劃線效果 */
.link-underline {
  position: relative;
}

.link-underline::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--primary-500);
  transition: width var(--duration-normal) var(--ease-out);
}

.link-underline:hover::after {
  width: 100%;
}

/* ===== 清單系統 (List System) ===== */
.list,
ul,
ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

.list-item,
li {
  margin-bottom: var(--space-2);
  line-height: var(--line-height-relaxed);
}

/* 無樣式清單 */
.list-none {
  list-style: none;
  padding-left: 0;
}

/* 自訂項目符號 */
.list-custom {
  list-style: none;
  padding-left: 0;
}

.list-custom .list-item {
  position: relative;
  padding-left: var(--space-6);
}

.list-custom .list-item::before {
  content: '✦';
  position: absolute;
  left: 0;
  color: var(--primary-500);
  font-weight: var(--font-weight-bold);
}

/* ===== 特殊文字效果 (Special Text Effects) ===== */
.text-gradient {
  background: linear-gradient(135deg, var(--primary-500), var(--secondary-500));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.text-shadow {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.text-shadow-strong {
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ===== 文字對齊 (Text Alignment) ===== */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

/* ===== 文字轉換 (Text Transform) ===== */
.text-uppercase { text-transform: uppercase; }
.text-lowercase { text-transform: lowercase; }
.text-capitalize { text-transform: capitalize; }
.text-normal-case { text-transform: none; }

/* ===== 文字權重 (Font Weight) ===== */
.font-light { font-weight: var(--font-weight-light); }
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

/* ===== 行高公用類別 (Line Height Utilities) ===== */
.leading-tight { line-height: var(--line-height-tight); }
.leading-snug { line-height: var(--line-height-snug); }
.leading-normal { line-height: var(--line-height-normal); }
.leading-relaxed { line-height: var(--line-height-relaxed); }
.leading-loose { line-height: var(--line-height-loose); }

/* ===== 字母間距公用類別 (Letter Spacing Utilities) ===== */
.tracking-tighter { letter-spacing: var(--letter-spacing-tighter); }
.tracking-tight { letter-spacing: var(--letter-spacing-tight); }
.tracking-normal { letter-spacing: var(--letter-spacing-normal); }
.tracking-wide { letter-spacing: var(--letter-spacing-wide); }
.tracking-wider { letter-spacing: var(--letter-spacing-wider); }
.tracking-widest { letter-spacing: var(--letter-spacing-widest); }

/* ===== 響應式字體 (Responsive Typography) ===== */
@media (max-width: 768px) {
  .heading-1, .h1, h1 {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--space-4);
  }
  
  .heading-2, .h2, h2 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-4);
  }
  
  .text-lead {
    font-size: var(--font-size-lg);
  }
}

/* ===== 印刷優化 (Print Optimization) ===== */
@media print {
  body {
    font-size: 12pt;
    line-height: 1.4;
    color: #000;
  }
  
  .heading-1, .h1, h1,
  .heading-2, .h2, h2,
  .heading-3, .h3, h3 {
    color: #000;
    page-break-after: avoid;
  }
  
  p {
    orphans: 3;
    widows: 3;
  }
  
  .text-gradient {
    background: none;
    color: #000;
  }
}
