/* ═══════════════════════════════════════════════════════════════════════
   SmartNOTAM — mobile tune
   Loads after style.css + notam.css. Targets phones (≤640px) with a
   secondary tablet pass (≤900px). Reference: Notamify's mobile layout —
   tight padding, single column, touch-friendly tap targets, minimal
   chrome around the NOTAM cards.
   ═══════════════════════════════════════════════════════════════════════ */


/* ── Tablet (≤900px) — small tweaks before phones ─────────────────── */
@media (max-width: 900px) {
  .container { padding: var(--space-4) var(--space-4); }

  /* Severity bar can take a full row; toggle below it instead of cramped */
  .sev-bar { width: 100%; }
}


/* ── Phone (≤640px) — main mobile layout ──────────────────────────── */
@media (max-width: 640px) {

  /* iOS zooms the page when an input < 16px gets focus. Force 16px on
     interactive inputs to prevent the jump. */
  input, select, textarea, button { font-size: 16px; }

  /* ── Layout & rhythm ── */
  .container { padding: 14px 12px 24px; }
  .container-md, .container-wide { padding: 14px 12px; }

  /* ── Top nav ── */
  .nav { padding: 10px 12px; gap: 8px; }
  .nav-logo { font-size: 14px; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
  .brand-mark svg { width: 15px; height: 15px; }
  .nav-links { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .nav-links a, .nav-links .btn { font-size: 13px; }
  .nav-links .btn { padding: 8px 14px; }
  /* The ICAO label + cache badge in the nav can crowd; let them shrink */
  #notamIcaoLabel { font-size: 12px !important; }

  /* ── Tabs (segmented pill) ── */
  .tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 10px 14px; font-size: 13px; flex-shrink: 0; }

  /* ── Search hero ── */
  #notamInputSection { padding: 24px 16px !important; }
  #notamInputSection .h-3 { font-size: 18px; }
  #notamInputSection .text-sm { font-size: 13px; max-width: 100%; }
  #notamInputSection .icao-input { font-size: 22px; padding: 12px 14px; }
  #notamInputSection .btn.lg { padding: 14px 22px; min-height: 48px; font-size: 15px; }

  /* Time filter — keep 2-col layout but tighter */
  #notamTimeFilter { padding-top: 14px !important; }
  #notamTimeFilter .grid-2 { gap: 10px !important; }
  #notamTimeFilter input[type=date],
  #notamTimeFilter input[type=time] {
    font-size: 14px !important;
    padding: 9px 8px !important;
    min-height: 42px;
  }
  #notamTimeFilter .btn.sm { padding: 8px 12px; font-size: 12px; min-height: 40px; }

  /* ── Airport header ── */
  .airport-header {
    grid-template-columns: 1fr !important;
    padding: 14px 14px !important;
    gap: 12px !important;
  }
  .airport-header-plate {
    grid-column: 1 / -1;
    border-right: none !important;
    border-bottom: 1px solid var(--line);
    padding: 0 0 10px !important;
    min-width: 0 !important;
    flex-direction: row;
    gap: 10px;
    align-items: baseline;
  }
  .airport-header-plate .plate-icao { font-size: 28px !important; }
  .airport-header-plate .plate-iata { font-size: 14px; }
  .airport-header-main { padding: 0 !important; }
  .airport-header-right {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }
  .airport-header-btn, .airport-header-link {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
    min-height: 40px;
    font-size: 12px;
    padding: 8px 10px;
  }
  .airport-title { font-size: 18px !important; line-height: 1.3 !important; }
  .airport-subtitle { font-size: 12px !important; }
  .airport-brief-strip { font-size: 11px; flex-wrap: wrap; gap: 4px 8px; }

  /* ── Map preview ── */
  #notamMap { height: 300px !important; }
  .notam-map-hint { font-size: 11px; padding: 6px 10px; }
  /* Leaflet popup readability */
  .map-popup .leaflet-popup-content { min-width: 200px !important; max-width: 86vw !important; padding: 12px 14px !important; }

  /* ── Severity bar + view toggle row ── */
  .sev-bar { gap: 6px; }
  .sev-bar > * { font-size: 11px !important; }
  .view-toggle { width: 100%; }
  .view-toggle .view-btn { flex: 1; min-height: 38px; }

  /* ── NOTAM overview ── */
  .notam-overview { padding: 12px 14px !important; }
  .notam-overview-label { font-size: 10px !important; }

  /* ── NOTAM cards ── */
  .notam-cards-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
  .notam-card-head { padding: 10px 12px 0 !important; gap: 5px !important; }
  .notam-cat, .notam-effect { font-size: 9px !important; padding: 3px 6px !important; }
  .notam-card-body { padding: 6px 12px 10px !important; }
  .notam-card-title { font-size: 13px !important; line-height: 1.4; margin-bottom: 8px !important; }
  .notam-card-meta { font-size: 11px !important; gap: 8px !important; flex-wrap: wrap; }
  .notam-card-toggle { padding: 8px 12px !important; font-size: 12px !important; min-height: 40px; }
  .notam-card-expanded { padding: 12px !important; }

  /* ── Briefing view (long markdown) ── */
  .ai-summary { padding: 16px 14px !important; font-size: 14px; line-height: 1.6; }
  .ai-summary h1, .ai-summary h2, .ai-summary h3 { font-size: 16px !important; margin-top: 18px !important; }
  .ai-summary code { font-size: 12px; word-break: break-word; }

  /* ── Buttons & touch targets ── */
  .btn { min-height: 42px; padding: 10px 16px; }
  .btn.sm { min-height: 36px; padding: 7px 12px; font-size: 12px; }
  .btn.lg { min-height: 48px; }

  /* ── My Flights tab ── */
  #addFlightForm { padding: 14px !important; }
  #addFlightForm .grid-2 { gap: 10px; }
  #addFlightForm .form-group label { font-size: 12px; }

  /* ── Settings tab ── */
  [data-panel="settings"] .card { padding: 16px !important; }

  /* ── Footer ── */
  .footer { padding: 18px 12px !important; }

  /* Hide non-essential subtitle text (saves vertical space) */
  .airport-subtitle { display: none; }
}


/* ── Tiny phones (≤380px) — last-mile shrink ──────────────────────── */
@media (max-width: 380px) {
  .nav-links a:not(.btn) { display: none; }   /* drop "Login" text-link if user not logged in; user pill stays via inline display:flex */
  .airport-header-plate .plate-icao { font-size: 24px !important; }
  .airport-header-btn, .airport-header-link { flex-basis: 100%; }
  #notamMap { height: 260px !important; }
  .icao-input { font-size: 20px !important; }
}
