/* =============================================================================
   mobile.css — ARES Mobile Optimization
   All rules are scoped to max-width: 720px unless noted.
   Desktop layout is completely unaffected.

   Phases:
     1 · Hamburger button + slide-in sidebar drawer
     2 · Sovereign strip → hide; mobile-nav takes over
     3 · Overview page
     4 · Classification feed → card layout
     5 · Data tables → horizontal scroll
     6 · ADI Console
     7 · Modals → bottom sheet
     8 · Touch targets + typography
   ============================================================================= */

/* ── Phase 1: Hamburger button (base styles, shown via media query) ─────────── */

.mobile-nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 6px;
  flex-shrink: 0;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-hamburger:active { background: var(--surface2); }

.hamburger-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

/* Animate bars → X when drawer is open */
.shell.sidebar-open .hamburger-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.shell.sidebar-open .hamburger-bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
.shell.sidebar-open .hamburger-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Right-side cluster in mobile-nav (notif + hamburger) */
.mobile-nav-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Mobile notification icon */
.mobile-nav-icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  min-width: 36px;
  min-height: 36px;
  color: var(--text-dim);
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}

/* Sidebar overlay backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 199;
  -webkit-tap-highlight-color: transparent;
}

/* Logout button inside sidebar footer — mobile only */
.sidebar-logout-mobile {
  display: none;
  width: calc(100% - 24px);
  margin: 8px 12px 12px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--ease), color var(--ease);
}
.sidebar-logout-mobile:hover { border-color: var(--magenta); color: var(--magenta); }

/* ── Mobile breakpoint ───────────────────────────────────────────────────────── */
@media (max-width: 720px) {

  /* ── Phase 1: Drawer ──────────────────────────────────────────────────── */

  .mobile-nav-hamburger { display: flex; }
  .mobile-nav-icon-btn  { display: flex; }
  .sidebar-logout-mobile { display: block; }

  /* Sidebar becomes a fixed slide-in drawer */
  .sidebar {
    display: flex !important;       /* override display:none at this breakpoint */
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    height: 100dvh;
    width: min(280px, 85vw);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Open state */
  .shell.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
  }
  .shell.sidebar-open .sidebar-overlay { display: block; }

  /* Collapse btn not useful in drawer mode */
  .sidebar-foot .sidebar-collapse-btn { display: none; }

  /* ── Phase 2: Strip → hidden on mobile; mobile-nav takes over ──────────── */

  .sovereign-strip { display: none; }

  /* Mobile nav bar refinements */
  .mobile-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    height: 52px;
    padding: 0 8px 0 16px;
    gap: 10px;
  }
  /* Sep not needed — right cluster provides enough visual separation */
  .mobile-nav-sep { display: none; }
  .mobile-nav-page {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-dim);
  }

  /* State bar — 4-column grid, no scrollbar */
  .state-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
  }
  .state-item  { padding: 10px 10px; min-width: 0; }
  .state-value { font-size: 18px; }
  .state-label { font-size: 9px; }

  /* ── Phase 3: Overview ────────────────────────────────────────────────── */

  .overview-grid          { grid-template-columns: 1fr; gap: 12px; }
  .ov-panel               { padding: 16px; }
  .ov-panel-title         { font-size: 11px; }
  .ov-prog-stat-grid      { grid-template-columns: repeat(2, 1fr); }
  .ov-rail-card           { padding: 12px 14px; }
  .ov-action-card         { padding: 14px; }
  .page-identity          { padding: 16px; }
  .page-identity-title    { font-size: 16px; }
  .xp-bar-track           { max-width: 100%; }

  /* ── Phase 4: Classification feed → card-per-row ─────────────────────── */

  /* Hide thead — cards are self-labelled */
  .cls-feed-thead { display: none; }

  /* Each row becomes a card */
  .cls-feed-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
  }
  /* Reset grid overrides from 720px breakpoint already in owner.css */
  .cls-feed-row > * { overflow: visible; white-space: normal; }

  /* Title — largest, top of card */
  .cls-feed-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    order: 1;
    white-space: normal;
    text-overflow: unset;
  }
  /* State badge row */
  .cls-feed-state {
    order: 2;
    flex-wrap: wrap;
    gap: 6px;
  }
  /* Deploy ID + date — small, below the badge */
  .cls-feed-id {
    font-size: 10px;
    color: var(--text-dim);
    order: 3;
  }
  .cls-feed-ts {
    font-size: 10px;
    order: 4;
    display: block;
  }
  /* Confidence and By columns are redundant at card width */
  .cls-feed-conf,
  .cls-feed-by { display: none; }

  /* Work queue */
  .cls-queue-item { padding: 10px 12px; }

  /* Di tabs wrap on narrow screens */
  .di-tabs         { flex-wrap: wrap; gap: 4px; }
  .di-tab          { font-size: 10px; padding: 5px 10px; }

  /* ── Phase 5: Data tables → horizontal scroll ────────────────────────── */

  .data-table-wrapper,
  .audit-table-wrapper,
  .ledger-table-wrapper,
  .pipeline-table-wrapper,
  .thresh-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Ensure inner tables don't collapse below their content */
  .data-table,
  .audit-table,
  .ledger-table,
  .thresh-table {
    min-width: 560px;
  }

  /* Stack master-detail layouts */
  .master-detail-layout { grid-template-columns: 1fr !important; }

  /* ── Phase 6: ADI Console ─────────────────────────────────────────────── */

  .adi-header {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
  }
  .adi-header-left  { font-size: 10px; }
  .adi-mode-btn     { padding: 3px 8px; font-size: 10px; }

  /* 16px minimum — prevents iOS from zooming in on focus */
  .adi-input        { font-size: 16px !important; }

  .adi-submit-btn {
    min-width: 52px;
    min-height: 40px;
    font-size: 11px;
    padding: 0 12px;
  }
  .adi-input-row {
    padding: 8px 10px;
    gap: 8px;
  }
  .adi-output {
    font-size: 12px;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Phase 7: Modals → bottom sheet ──────────────────────────────────── */

  .cls-modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .cls-modal {
    width: 100%     !important;
    max-width: 100% !important;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0 !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: mobileSlideUp 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  /* Drag handle pill */
  .cls-modal::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border-mid);
    border-radius: 2px;
    margin: 10px auto 0;
  }
  @keyframes mobileSlideUp {
    from { transform: translateY(60px); opacity: 0.6; }
    to   { transform: translateY(0);    opacity: 1;   }
  }

  /* 16px minimum on all inputs — prevents iOS zoom-on-focus */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  select,
  textarea {
    font-size: max(16px, 1em) !important;
  }

  /* Notification panel — full width on mobile */
  .notif-panel {
    width: 100%  !important;
    right: 0     !important;
    left: 0      !important;
    border-radius: 0 !important;
  }

  /* ── Phase 8: Touch targets + typography ─────────────────────────────── */

  /* 44×44px minimum tap targets */
  .btn, .btn-primary, .btn-secondary,
  .ov-panel-link,
  .cls-tag-btn, .cls-suggest-btn, .cls-confirm-quick-btn,
  .cls-map-prefix-btn, .cls-edit-confirmed-btn,
  .di-tab,
  .bf-run-btn, .bf-ctrl-btn,
  .ms-panel-action,
  .alert-banner-view,
  #adi-submit, #adi-clear, #adi-toggle,
  #btn-theme, #btn-logout {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Sidebar links — generous tap targets */
  .sidebar-link { padding: 10px 16px !important; }

  /* Momentum scrolling */
  .owner-content,
  .adi-output,
  .notif-panel-body {
    -webkit-overflow-scrolling: touch;
  }

  /* Breathing room at bottom so ADI bar doesn't obscure content */
  .owner-content { padding-bottom: 108px; }

  /* Alert banner wraps on narrow screens */
  .alert-banner      { flex-wrap: wrap; padding: 10px 14px; gap: 6px; }
  .alert-banner-view { margin-left: 0; }

  /* Sidebar nav label size */
  .sidebar-group-label { font-size: 9px; letter-spacing: 0.12em; }

  /* Milestone layout */
  .ms-page-layout { grid-template-columns: 1fr; gap: 16px; }
  .ms-panel       { padding: 14px; }
}
