/* ===== MOBILE-FIRST TERRAIN UX ===== */

/* All touch targets >= 44px */
@media (max-width: 768px) {
  .sp-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  .sg {
    padding: 6px 8px;
    min-height: 44px;
  }
}

@media (max-width: 600px) {
  /* Topbar */
  .logo { font-size: .9em; }
  .month-ctrl { min-width: 0; }
  .month-ctrl input[type=range] { min-width: 40px; }
  .alt-badge { font-size: .7em; padding: 2px 4px; }
  .scan-badge { font-size: .6em; max-width: 100px; }

  /* Search */
  .search-bar input { font-size: .85em; padding: 5px 10px; }
  .loc-name { max-width: 80px; font-size: .65em; }
  .sr-item { padding: 12px; font-size: .95em; min-height: 48px; }

  /* Score bar */
  .score-go-badge { font-size: .85em; padding: 4px 10px; }
  .best-chip { font-size: .8em; }

  /* Species grid */
  .sp-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 4px; }
  .sg { font-size: .78em; padding: 5px 8px; }

  /* Species cards */
  .sp-photo { width: 55px; height: 44px; }
  .sp-card { padding: 5px; }

  /* Bottom panel */
  .panel-scroll { padding: 0 8px 12px; }
  .panel-title { font-size: .9em; }

  /* Bottom nav */
  .bottom-nav .tab-btn { min-height: 56px; }
  .bottom-nav .tab-btn .tab-icon { font-size: 1.2em; }
  .bottom-nav .tab-btn .tab-label { font-size: .6em; }

  /* FAB */
  .fab-find { width: 52px; height: 52px; font-size: 1.3em; bottom: 66px; right: 14px; }

  /* Float score */
  .float-score { font-size: 1em; padding: 6px 12px; top: 8px; right: 8px; }

  /* Weather */
  .wx-day { min-width: 40px; }
  .wx-score { font-size: .85em; padding: 4px 8px; }

  /* Popups full-width on mobile */
  .leaflet-popup-content-wrapper { max-width: calc(100vw - 40px) !important; }
  .leaflet-popup-content { font-size: .85em; min-width: 200px; }
  .myco-popup .leaflet-popup-content-wrapper { max-width: calc(100vw - 24px) !important; }

  /* Find modal */
  .find-modal { padding: 12px; border-radius: 10px; }
  .find-form select, .find-form input, .find-form textarea { font-size: .95em; padding: 8px 10px; }

  /* Layer controls in panel */
  .layer-controls { gap: 6px 10px; }
  .layer-controls label { font-size: .8em; }

  /* Calendar compact */
  .cal-row .cn { width: 55px; font-size: .65em; }
  .cal-cell { width: 12px; height: 8px; }
}

/* Very small screens (iPhone SE, 320px) */
@media (max-width: 360px) {
  .topbar { padding: 0 4px; gap: 4px; }
  .logo { font-size: .8em; }
  .month-name { font-size: .85em; min-width: 28px; }
  .alt-badge { display: none; }
  .search-bar { padding: 0 4px; gap: 3px; }
  .search-bar input { padding: 4px 8px; }
  .score-bar { padding: 0 6px; gap: 4px; }
  .score-go-badge { font-size: .8em; padding: 3px 8px; }
  .best-chip { font-size: .75em; }
  .sp-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* Landscape phone */
@media (max-height: 500px) {
  .topbar { height: 36px; }
  .search-bar { height: 36px; }
  .score-bar { height: 32px; }
  body { padding-bottom: 48px; }
  .bottom-nav .tab-btn { min-height: 48px; }
  .bottom-nav { height: 48px; }
  .bottom-panel { bottom: 48px; }
  .fab-find { width: 44px; height: 44px; font-size: 1.1em; bottom: 58px; }
}

/* High contrast for outdoor use */
@media (prefers-contrast: high) {
  :root {
    --text: #fff;
    --dim: #aab;
    --accent: #ffb830;
  }
  .score-go-badge.go { background: #0a4a0a; border-width: 2px; }
  .score-go-badge.wait { background: #4a3a00; border-width: 2px; }
  .score-go-badge.no { background: #4a0a0a; border-width: 2px; }
}
