/* ===== 朴果英语 · 移动端适配补丁 ===== */
/* 将此文件引入所有页面：<link rel="stylesheet" href="/english/assets/mobile-patch.css"> */

/* Base responsive settings */
@media (max-width: 480px) {
  /* Font size scaling */
  body { font-size: 15px; }

  /* Prevent horizontal scroll */
  html, body { overflow-x: hidden; max-width: 100vw; }

  /* Card padding reduction */
  .grammar-card, .word-card, .quiz-section, .sentence-card, .listen-card, .book-card {
    margin: 12px !important;
    padding: 16px !important;
    border-radius: 16px !important;
  }

  /* Question area - prevent excessive scrolling */
  .question-area, .quiz-question, .listen-question, .example-en {
    font-size: 16px !important;
    line-height: 1.7 !important;
    max-height: 60vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Larger touch targets - prevent mis-taps */
  button, .quiz-option, .listen-opt, .action-btn, .nav-btn, .review-btn,
  .level-chip, .grammar-tab, .date-chip, .cat-tab, .tier-tab {
    min-height: 44px !important;
    min-width: 44px !important;
  }

  /* Option spacing */
  .quiz-options, .listen-options, .options-grid {
    gap: 12px !important;
  }

  .quiz-option, .listen-opt, .option-item {
    padding: 14px 16px !important;
    font-size: 15px !important;
  }

  /* Image responsive */
  img, .word-image, .word-image-placeholder, .diagram-canvas canvas {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Word image sizing */
  .word-image, .word-image-placeholder {
    width: 160px !important;
    height: 160px !important;
  }

  /* Score big text */
  .hero-score, .score-big {
    font-size: 48px !important;
  }

  /* Header compact */
  .header { padding: 10px 12px !important; }
  .header-title { font-size: 16px !important; }

  /* Bottom safe area */
  .safe-bottom { padding-bottom: 80px !important; }

  /* Grid to single column on very small screens */
  .book-grid, .badges-grid, .tips-grid, .variants {
    grid-template-columns: 1fr !important;
  }

  /* Tier list horizontal scroll */
  .tier-list { gap: 6px !important; }
  .tier-item { min-width: 64px !important; padding: 8px 6px !important; }

  /* Leaderboard compact */
  .lb-row { padding: 8px 0 !important; }
  .lb-avatar { width: 32px !important; height: 32px !important; font-size: 14px !important; }

  /* Modal sizing */
  .level-card, .coach-tooltip {
    max-width: 90vw !important;
    padding: 20px 16px !important;
  }

  /* Report page */
  .hero-card { padding: 24px 16px !important; }
  .focus-card, .summary-card { padding: 16px !important; }

  /* Input fields - keyboard friendly */
  input, textarea, select {
    font-size: 16px !important; /* Prevent iOS zoom */
  }

  /* Focus visible */
  button:focus, .quiz-option:focus, .listen-opt:focus {
    outline: 2px solid #4CAF50 !important;
    outline-offset: 2px !important;
  }

  /* Reduce animations for performance */
  .streak-flame, .hero-emoji, .rank-emoji {
    animation-duration: 1.5s !important;
  }
}

/* Very small screens */
@media (max-width: 360px) {
  body { font-size: 14px; }

  .word-english { font-size: 28px !important; }
  .word-chinese { font-size: 16px !important; }

  .grammar-name { font-size: 20px !important; }
  .sentence-en { font-size: 17px !important; }

  .tier-icon { font-size: 24px !important; }
  .tier-label { font-size: 10px !important; }
}

/* Landscape mode */
@media (max-height: 500px) and (orientation: landscape) {
  .header { position: relative !important; }
  .bottom-tab { position: relative !important; }
  .safe-bottom { padding-bottom: 20px !important; }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2) {
  .word-image, .word-image-placeholder, .node-circle {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  body { background: #121212; }
  .grammar-card, .word-card, .quiz-section, .book-card,
  .sentence-card, .listen-card, .lb-card, .stat-card {
    background: #1e1e1e !important;
    color: #e0e0e0 !important;
  }
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .book-card:hover, .node-info:hover, .level-chip:hover {
    transform: none !important;
  }

  /* Larger touch targets */
  .tab-item { padding: 8px 0 !important; }
  .back-btn { width: 40px !important; height: 40px !important; }
}
