/* ══════════════════════════════════════════════
   responsive.css — 跨裝置適配
   - 全域 horizontal overflow 防護
   - 報單表格手機優化（欄位摺疊 / 隱藏）
   - 各區塊在小螢幕的微調
   ══════════════════════════════════════════════ */

/* ── 1. 全域防護:任何情況下都不會橫向滾動 ─────────────── */
html, body {
  overflow-x: hidden !important;
  max-width: 100vw;
}
* { max-width: 100%; }
img, svg, canvas, video, iframe { max-width: 100%; height: auto; }

/* ── 2. SVG pipeline 在窄螢幕縮小 ──────────────────── */
@media (max-width: 768px) {
  #sc-pipeline-svg {
    margin-top: 30px;
    padding: 12px 8px;
  }
  /* SVG 文字在小螢幕縮小 */
  .sc-pl-label { font-size: 16px !important; }
  .sc-pl-sub   { font-size: 12px !important; }
}

/* ── 3. 報單明細表格 - 手機版優化 ────────────────── */

/* < 900px:隱藏「機率」「CLV」兩欄(modal 看就好) */
@media (max-width: 900px) {
  .rec-table th:nth-child(7),
  .rec-table td:nth-child(7),
  .rec-table th:nth-child(8),
  .rec-table td:nth-child(8) { display: none; }
}

/* < 700px:隱藏「等級」(用顏色差別表示就好) */
@media (max-width: 700px) {
  .rec-table th:nth-child(5),
  .rec-table td:nth-child(5) { display: none; }
  .rec-table th, .rec-table td {
    padding: 10px 10px;
    font-size: 12px;
  }
  .rec-table th { font-size: 10px; }
}

/* < 560px:卡片化表格(整列堆疊,不再用 table grid) */
@media (max-width: 560px) {
  .rec-table thead { display: none; }
  .rec-table, .rec-table tbody { display: block; width: 100%; }
  .rec-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "player  status"
      "market  outcome"
      "lineDir date";
    gap: 4px 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .rec-table tr:last-child { border-bottom: none; }
  .rec-table td {
    border: none !important;
    padding: 0 !important;
  }
  /* 用 nth-child 安排到 grid area */
  .rec-table td:nth-child(1) { grid-area: date; font-size: 11px !important; }
  .rec-table td:nth-child(2) { grid-area: player; font-size: 14px !important; font-weight: 500; }
  .rec-table td:nth-child(3) { grid-area: market; font-size: 12px !important; opacity: 0.65; }
  .rec-table td:nth-child(4) { grid-area: lineDir; font-family: var(--mono); font-size: 13px !important; }
  .rec-table td:nth-child(6) { grid-area: outcome; justify-self: end; align-self: start; }
  .rec-table td:nth-child(7),
  .rec-table td:nth-child(8) { display: none; }
  /* 等級標籤獨立放在 status 角落 */
  .rec-table td:nth-child(5) {
    grid-area: status;
    justify-self: end;
    align-self: end;
    display: block !important;
  }
  /* hover 動畫關掉,改成觸碰反饋 */
  #rec-tbody tr:hover { transform: none !important; }
  #rec-tbody tr:active {
    background: rgba(124, 140, 255, 0.1) !important;
  }
}

/* ── 4. Track Record 卡片在手機 ────────────────── */
@media (max-width: 600px) {
  .record-summary {
    grid-template-columns: 1fr 1fr;
  }
  .rec-big { font-size: 32px !important; }
  .rec-card { padding: 18px 18px 16px; }
  .rec-updated { font-size: 11px !important; }
}

@media (max-width: 380px) {
  .record-summary { grid-template-columns: 1fr; }
}

/* ── 5. 圖表區手機適配 ──────────────────────── */
@media (max-width: 1024px) {
  .record-charts { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 600px) {
  .rec-chart-box { padding: 18px 16px; }
  .rec-chart-title { font-size: 10px; }
}

/* ── 6. Hero 區手機文字縮小 ─────────────────── */
@media (max-width: 600px) {
  .hero-title { font-size: clamp(36px, 8vw, 56px) !important; }
  .hero-sub { font-size: 14px !important; }
}

/* ── 7. Feature strip 手機 2x2 ──────────────── */
@media (max-width: 600px) {
  .feat-num { font-size: clamp(40px, 10vw, 60px) !important; }
  .feat-label { font-size: 10px !important; }
  .feat-desc { font-size: 11px !important; line-height: 1.5; }
}

/* ── 8. Modal 在小螢幕滿版 ─────────────────── */
@media (max-width: 480px) {
  .sc-modal { padding: 0; align-items: flex-end; }
  .sc-modal-card {
    border-radius: 18px 18px 0 0;
    max-height: 88vh;
    width: 100%;
    padding: 24px 20px 20px;
    animation: sc-md-slide-up 0.35s cubic-bezier(.2,.7,.3,1.1);
  }
  @keyframes sc-md-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: none; opacity: 1; }
  }
  .sc-md-grid { grid-template-columns: 1fr 1fr; }
  .sc-md-title { font-size: 22px; }
  .sc-md-line  { font-size: 18px; }
}

/* ── 9. Ticker / Tape 在手機字小一點 ──────── */
@media (max-width: 600px) {
  .sc-ticker { padding: 14px 0; }
  .sc-ticker-item .vl { font-size: 18px; }
  .sc-ticker-item .lb { font-size: 9px; }
  .sc-ticker-track { gap: 32px; }
}

/* ── 10. Pipeline / Interface / Pricing 卡片 ── */
@media (max-width: 700px) {
  .stage, .iface-cmd, .plan {
    padding: 22px 18px !important;
  }
  .stage-title { font-size: 22px !important; }
}

/* ── 11. Nav 手機簡化 ─────────────────────── */
@media (max-width: 720px) {
  nav .nav-links { gap: 14px; font-size: 13px; }
}
@media (max-width: 540px) {
  nav .nav-links a:nth-child(n+5) { display: none; }
}

/* ── 12. 表格滾動容器在手機關掉(已改卡片) ── */
@media (max-width: 560px) {
  .rec-table-scroll { overflow-x: visible; }
}
