/* mobile-optimizations.css - 移動端優化 */

/* 觸控友好的按鈕尺寸 */
@media (max-width: 768px) {
  .btn,
  button:not(.cookie-close):not(.policy-close),
  input[type="submit"],
  input[type="button"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
    font-size: 16px; /* 防止 iOS 自動縮放 */
  }

  /* 表單輸入框 */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="tel"],
  select,
  textarea {
    min-height: 44px;
    font-size: 16px; /* 防止 iOS 自動縮放 */
    padding: 12px;
  }

  /* 優化 Hero 區域 */
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 20px;
  }

  .hero-card {
    padding: 20px;
  }

  .hero-metrics {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .metric-card {
    padding: 16px;
  }

  /* 績效圖表 */
  .perf-chart-card {
    padding: 16px;
    margin: 0 -16px;
  }

  .perf-canvas-wrap {
    min-height: 300px;
  }

  .perf-kpis {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .perf-kpi {
    padding: 12px;
  }

  /* 導航優化 */
  .site-header {
    padding: 12px 16px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    text-align: center;
  }

  .footer-nav {
    flex-direction: column;
    gap: 12px;
  }

  /* 卡片堆疊 */
  .strategy-cards,
  .about-cards,
  .team-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* 表格滾動 */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 模態框優化 */
  .policy-dialog {
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    margin: 16px;
  }

  /* Cookie Banner */
  .cookie-banner {
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 16px 16px 0 0;
    padding: 20px;
  }

  .cookie-actions {
    flex-direction: column;
    gap: 12px;
  }

  .cookie-actions .btn {
    width: 100%;
  }

  /* 通知容器 */
  #notification-container {
    left: 16px !important;
    right: 16px !important;
    top: 16px !important;
    max-width: calc(100vw - 32px) !important;
  }

  .notification {
    font-size: 14px;
    padding: 14px 16px !important;
  }

  /* 儀表板卡片 */
  .dashboard-card {
    padding: 16px;
  }

  .portfolio-dashboard {
    gap: 16px;
  }

  /* 區域標題 */
  .section-heading {
    text-align: center;
  }

  .section-title {
    font-size: 28px;
  }

  .section-eyebrow {
    font-size: 12px;
  }

  /* 提升觸控區域 */
  a {
    padding: 4px 0;
  }

  /* 優化間距 */
  .container {
    padding-left: 20px;
    padding-right: 20px;
  }

  .section {
    padding: 40px 0;
  }

  /* 隱藏桌面元素 */
  .desktop-only {
    display: none !important;
  }

  /* 顯示移動元素 */
  .mobile-only {
    display: block !important;
  }

  /* 圖表工具提示優化 */
  .chartjs-tooltip {
    font-size: 14px !important;
  }

  /* 表單佈局 */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .form-row-group.two-col {
    grid-template-columns: 1fr;
  }

  /* 改進滾動性能 */
  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* 平滑滾動 */
  html {
    scroll-behavior: smooth;
  }

  /* 優化圖片 */
  img {
    max-width: 100%;
    height: auto;
  }
}

/* 小屏幕額外優化 */
@media (max-width: 480px) {
  .section-title {
    font-size: 24px;
  }

  .perf-kpis {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    flex-direction: column;
    gap: 12px;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .compliance-list {
    font-size: 13px;
  }

  /* 進一步減小內邊距 */
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .section {
    padding: 32px 0;
  }
}

/* 橫屏優化 */
@media (max-width: 768px) and (orientation: landscape) {
  .hero {
    min-height: auto;
  }

  .perf-canvas-wrap {
    min-height: 250px;
  }
}

/* 高 DPI 屏幕優化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .hero-background,
  .gradient-overlay {
    image-rendering: crisp-edges;
  }
}

/* 可訪問性 - 大字體模式 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 深色模式適配（如果用戶偏好） */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0b1a2a;
    --text-primary: #eaf3fb;
  }
}

/* 返回頂部按鈕移動端優化 */
@media (max-width: 768px) {
  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    font-size: 24px;
  }
}

/* 加載狀態 */
.loading {
  pointer-events: none;
  opacity: 0.6;
}

/* 骨架屏 */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* 改進焦點可見性 */
*:focus-visible {
  outline: 2px solid #c8a96a;
  outline-offset: 2px;
}

/* 優化選擇框 */
::selection {
  background-color: rgba(200, 169, 106, 0.3);
  color: #eaf3fb;
}
