/* evidence-vault mobile.css — iPhone-first optimization
   Shared across all pages via <link> tag
   ---------------------------------------------------- */

/* Reset --fs-adj for mobile — the 1920px media query was
   incorrectly reducing font sizes on narrow screens too */
@media (max-width: 1024px) {
  :root { --fs-adj: 0px !important; }
}

/* =====================================================
   TABLET + PHONE  (≤768px)
   ===================================================== */
@media (max-width: 768px) {

  /* --- Layout --- */
  .container {
    padding: 24px 16px;
  }

  /* --- Top bar & Navigation --- */
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .nav-links {
    width: 100%;
    gap: 18px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    flex-wrap: nowrap;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* --- Typography --- */
  h1 { font-size: 22px !important; }
  h2 { font-size: 16px !important; margin-top: 36px; }
  h3 { font-size: 15px !important; }
  .subtitle { font-size: 13px; margin-bottom: 24px; }

  /* --- Tables: horizontal scroll --- */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    margin: 16px -16px;
    padding: 0 16px;
    width: calc(100% + 32px);
  }
  thead, tbody, tr { display: table; width: 100%; table-layout: auto; }
  thead { display: table-header-group; }
  tbody { display: table-row-group; }
  th, td {
    padding: 8px 10px;
    font-size: 13px !important;
    white-space: normal;
    min-width: 80px;
  }
  th {
    font-size: 11px !important;
    position: sticky;
    top: 0;
    z-index: 1;
  }

  /* --- Stats grid (index pages) --- */
  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat { padding: 14px 10px; }
  .stat-value { font-size: 20px !important; }
  .stat-label { font-size: 11px !important; }

  /* --- Evidence items --- */
  .evidence-item { padding-left: 14px; margin: 12px 0; }
  blockquote { padding-left: 12px; font-size: 14px; }
  .source { font-size: 12px; }

  /* --- Callouts --- */
  .callout, .callout-red, .callout-blue { padding: 12px 14px; margin: 16px 0; font-size: 14px; }

  /* --- Touch targets (44px minimum per Apple HIG) --- */
  .btn-access, .btn-sweep, .btn-seeds, .btn-confirm, .btn-dismiss {
    min-height: 44px;
    padding: 12px 20px;
    font-size: 13px;
  }

  .theme-toggle, .ctrl-btn {
    width: 44px;
    height: 44px;
    font-size: 18px;
    line-height: 44px;
  }

  /* --- Changelog (index pages) --- */
  .changelog { padding: 14px 16px; }
  .changelog-entry { flex-direction: column; gap: 2px; font-size: 13px; }
  .changelog-date { min-width: auto; font-size: 12px; }

  /* --- Meta row (index pages) --- */
  .meta-row { flex-direction: column; gap: 4px; align-items: flex-start; }

  /* --- Comparable grid (valuation pages) --- */
  .comparable-grid { grid-template-columns: 1fr; gap: 12px; }
  .comparable-card { padding: 14px; }

  /* --- Baseline box (valuation pages) --- */
  .baseline-box { padding: 16px; }
  .baseline-box h3 { font-size: 16px !important; }

  /* --- Layer headers (valuation pages) --- */
  .layer-header { padding: 10px 14px; font-size: 12px; }

  /* --- Investigate page --- */
  .investigate-lock .pin-input {
    width: 160px;
    padding: 14px 16px;
    font-size: 20px;
  }
  .investigate-lock .lock-label { font-size: 12px; }

  .url-input {
    font-size: 14px !important;
    padding: 12px !important;
  }

  .progress-wrap { margin-top: 16px; }
  .progress-track { height: 8px; }
  .progress-meta { font-size: 12px; margin-top: 8px; }

  /* --- Fixed controls --- */
  .fixed-controls { bottom: 16px; right: 16px; }
  .back-to-top { bottom: 16px; padding: 10px 18px; }

  /* --- Timeline (index pages) --- */
  .timeline { padding-left: 16px; margin-left: 4px; }
  .timeline-item::before { left: -21px; width: 6px; height: 6px; }

  /* --- File list (index pages) --- */
  .file-list { columns: 1; }

  /* --- Published items --- */
  .published-item { padding-left: 14px; }

  /* --- Tags --- */
  .tag { font-size: 10px; padding: 2px 6px; }

  /* --- Notification badge --- */
  .notification-badge { width: 20px; height: 20px; font-size: 11px; }

  /* --- Collapsible sections (investigate) --- */
  .collapsible { padding: 8px 0; }
}

/* =====================================================
   PHONE ONLY  (≤480px)
   ===================================================== */
@media (max-width: 480px) {
  .container { padding: 20px 14px; }

  /* Nav tighter */
  .nav-links { gap: 14px; }
  .nav-links a { font-size: 11px !important; letter-spacing: 0.5px; }

  /* Title */
  h1 { font-size: 20px !important; }

  /* Stats may need single column on very small screens */
  .stats { gap: 8px; }
  .stat { padding: 12px 8px; }

  /* Tables — force minimum width so they scroll nicely */
  table { font-size: 12px !important; }
  th, td { padding: 6px 8px; min-width: 70px; }

  /* Evidence items tighter */
  .evidence-item { padding-left: 12px; }

  /* Smaller callouts */
  .callout, .callout-red, .callout-blue { padding: 10px 12px; font-size: 13px; }
}

/* =====================================================
   iOS-SPECIFIC FIXES
   ===================================================== */

/* Prevent iOS zoom on input focus (requires 16px+ font) */
input, textarea, select {
  font-size: 16px;
}

/* Smooth momentum scrolling for overflow containers */
* {
  -webkit-overflow-scrolling: touch;
}

/* Remove iOS tap highlight */
a, button, input {
  -webkit-tap-highlight-color: transparent;
}

/* Safe area insets for notched iPhones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .fixed-controls, .theme-toggle {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .back-to-top {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* Prevent text size adjust on orientation change */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
