/**
 * Mobile chrome from mobile.zip — bottom nav + rail drawer (≤900px).
 * Loaded after site.css on shell.php. Revert: .mobile-chrome-disabled in site root.
 */

/* ── Bottom nav bar ── */
.mob-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 56px;
  background: rgba(4,12,15,.98);
  border-top: 1px solid var(--border-bright);
  z-index: 500;
  grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
}
.mob-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 8px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 4px 8px;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.mob-nav-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.mob-nav-btn.active { color: var(--amber); }
.mob-nav-btn.active svg { filter: drop-shadow(0 0 4px rgba(232,160,32,.5)); }
.mob-nav-btn:active { color: var(--cyan); }

/* ── Drawer (left/right rail content on mobile) ── */
.mob-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 490;
  backdrop-filter: blur(2px);
}
.mob-drawer-overlay.open { display: block; }
.mob-drawer {
  position: fixed;
  bottom: 56px; left: 0; right: 0;
  max-height: 72dvh;
  background: rgba(4,12,15,.99);
  border-top: 1px solid var(--border-bright);
  border-radius: 0;
  z-index: 495;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32,.72,0,1);
  will-change: transform;
}
.mob-drawer.open { transform: translateY(0); }
.mob-drawer-handle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mob-drawer-pill {
  width: 36px; height: 3px;
  background: var(--border-bright);
  border-radius: 2px;
  margin: 0 auto 0;
}
.mob-drawer-title {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--text-dim);
  text-transform: uppercase;
}
.mob-drawer-close {
  font-size: 16px;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}
.mob-drawer-close:hover { color: var(--red); }
.mob-drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mob-drawer-tab {
  flex: 1;
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 8px 4px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.mob-drawer-tab.active { color: var(--amber); border-bottom-color: var(--amber); }
.mob-drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.mob-drawer-panel { display: none; padding: 10px 12px 16px; }
.mob-drawer-panel.active { display: block; }

.mob-drawer-panel .rail-component-shell,
.mob-drawer-panel .rail-component-shell__inner,
.mob-drawer-panel .map-filter-panel,
.mob-drawer-panel .quick-submit {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.mob-drawer-panel .search-suggest,
.mob-drawer-panel .search-suggest-list {
  position: relative;
  z-index: 20;
}

.mob-drawer-panel #effect-selector,
.mob-drawer-panel .es-list {
  max-height: min(42dvh, 360px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mob-more-menu { padding: 4px 0 8px; }
.mob-more-kicker { margin-bottom: 12px; font-size: 9px; letter-spacing: 0.2em; color: var(--text-dim); }
.mob-more-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.mob-more-link--cta { color: var(--amber); border-color: rgba(232, 160, 32, 0.45); background: rgba(232, 160, 32, 0.06); }
.mob-more-link--danger { color: var(--red); border-color: rgba(232, 32, 80, 0.35); }
.mob-more-logout { margin: 0; padding: 0; }

#mob-map-panel-btn {
  display: none;
  position: absolute;
  right: 12px;
  z-index: 60;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 9px 14px;
  border: 1px solid var(--border-bright);
  background: rgba(4, 12, 15, 0.92);
  color: var(--cyan);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

body.mm-mob-drawer-open { overflow: hidden !important; }

/* Desktop: classic header tabs + 3-column rails (no bottom-nav left rail). */
@media (min-width: 901px) {
  html.mm-mob-chrome .mob-nav,
  html.mm-mob-chrome .mob-drawer,
  html.mm-mob-chrome .mob-drawer-overlay,
  html.mm-mob-chrome #mob-map-panel-btn {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  html.mm-mob-chrome .nav-tabs {
    display: flex !important;
  }

  html.mm-mob-chrome .app {
    display: grid !important;
    grid-template-columns: none !important;
    grid-template-rows: auto minmax(0, 1fr) auto !important;
    padding-bottom: 0 !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
  }

  html.mm-mob-chrome .app > header,
  html.mm-mob-chrome .app > .content,
  html.mm-mob-chrome .app > .app-footer {
    grid-column: auto !important;
    grid-row: auto !important;
  }

  html.mm-mob-chrome .app-footer {
    display: grid !important;
    visibility: visible !important;
  }

  html.mm-mob-chrome,
  html.mm-mob-chrome body {
    overflow: hidden !important;
  }
  html.mm-mob-chrome body.mm-mob-drawer-open {
    overflow: hidden !important;
  }
}

/* ── Detail panel as bottom sheet on mobile ── */
@media (max-width: 900px) {
  #detail-panel {
    position: fixed !important;
    top: auto !important;
    right: 0 !important;
    bottom: 56px !important;
    left: 0 !important;
    width: 100% !important;
    max-height: 72dvh;
    border-left: none !important;
    border-top: 1px solid var(--border-bright) !important;
    box-shadow: 0 -8px 32px rgba(0,0,0,.6) !important;
    z-index: 480 !important;
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.32,.72,0,1) !important;
    display: flex !important;
    flex-direction: column;
  }
  #detail-panel.open {
    transform: translateY(0) !important;
  }
}

@media (max-width: 900px) {

  /* ── Lock body scroll, account for bottom nav ── */
  html, body { overflow: hidden; }
  .app {
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100dvh;
    min-height: 100dvh;
    padding-bottom: 56px; /* room for fixed bottom nav */
  }

  /* ── Header: logo + account only, tabs hidden ── */
  header {
    padding: 0 12px;
    height: 44px;
  }
  .nav-tabs { display: none !important; }
  .live-pill { display: none !important; }
  .header-right > .btn.header-cta.btn-primary,
  .header-right > #header-submit-effect,
  .header-right > #find-timeline-btn { display: none !important; }
  .mm-header-burger,
  .mm-mobile-nav-root { display: none !important; }
  .logo { font-size: 18px; letter-spacing: 2px; margin-right: 0; }
  .logo small { display: none; }
  .header-right { gap: 6px; flex-wrap: nowrap !important; }

  /* ── Bottom nav + drawer (override any desktop hide rules) ── */
  .mob-nav {
    display: grid !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  .mob-drawer {
    display: flex !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  .mob-drawer-overlay.open {
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  /* ── Content: single column, full width (no phantom side-rail columns) ── */
  .content {
    grid-template-columns: minmax(0, 1fr) !important;
    column-gap: 0 !important;
    overflow: visible;
  }

  #registry-view,
  #evidence-view,
  #profile-view,
  #map-view,
  #surveys-view,
  #account-view,
  #admin-view,
  #forgot-password-view,
  #reset-password-view,
  #change-password-view,
  #survey-view,
  #results-view,
  #timelines-view,
  #requests-view {
    grid-column: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  #registry-view .reg-main,
  .effects-shell {
    padding-left: 12px !important;
    padding-right: 12px !important;
    box-sizing: border-box;
  }

  /* ── Hide desktop rails ── */
  .shell-rail,
  #left-map, #right-map,
  #left-registry, #right-registry,
  #left-effects, #right-effects,
  #left-evidence, #right-evidence,
  #left-requests, #right-requests,
  #left-survey, #right-survey,
  #left-register, #right-register,
  #left-profile, #right-profile,
  #left-surveys, #right-surveys,
  #left-account, #right-account,
  #left-admin, #right-admin,
  #left-forgot-password, #right-forgot-password,
  #left-reset-password, #right-reset-password,
  #left-change-password, #right-change-password,
  #left-timelines, #right-timelines {
    display: none !important;
  }

  /* ── All views fill the column ── */
  #map-view,
  #registry-view,
  #evidence-view,
  #profile-view,
  #surveys-view,
  #account-view,
  #admin-view,
  #forgot-password-view,
  #reset-password-view,
  #change-password-view,
  #survey-view,
  #results-view,
  #timelines-view,
  #requests-view {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: 100%;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Map specific ── */
  #map-view { overflow: hidden; }
  #world-svg { width: 100%; height: 100%; }

  /* Map HUD: move to bottom above the nav bar */
  #country-hud {
    bottom: calc(56px + 8px) !important;
    left: 8px !important;
    max-width: calc(100vw - 16px) !important;
  }

  #mob-map-panel-btn {
    bottom: calc(56px + 12px) !important;
  }

  .mm-toast-stack {
    bottom: calc(56px + 12px) !important;
    top: auto !important;
    left: 12px !important;
    right: 12px !important;
  }

  /* Tooltip: cap width on small screens */
  #mtt { width: min(295px, calc(100vw - 24px)) !important; }

  /* Breadcrumb: smaller on mobile */
  .map-breadcrumb { font-size: 8px; letter-spacing: 1px; padding: 4px 8px; }

  /* ── Footer stats: compact row above bottom nav ── */
  .app-footer {
    display: grid !important;
    visibility: visible !important;
    grid-column: 1 / -1;
    height: auto !important;
    min-height: 2.75rem;
    padding: 0.35rem 0 0.45rem !important;
    z-index: 120;
  }
  .app-footer .foot-num { font-size: 1.15rem !important; }
  .app-footer .foot-lbl { font-size: 0.45rem !important; letter-spacing: 0.08em !important; }
  .app-footer .foot-stat { padding: 0.25rem 0.35rem !important; }

  /* ── Registry card grid: single col on narrow ── */
  .effects-grid,
  #cards-container {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .effects-shell { padding: 12px; }
  .effects-head { flex-direction: column; gap: 12px; }
  .effects-title { font-size: 36px; }
  .effects-tools { width: 100%; min-width: 0; }

  /* ── Effect card hero: reduce aspect on phone ── */
  .ec-hero { aspect-ratio: 16/9; }

  /* ── View center: full width ── */
  .view-center { max-width: 100%; padding: 14px; }

  /* ── Modals: full-bleed on small screens ── */
  .modal-overlay { padding: 12px; align-items: flex-end; }
  .modal { max-width: 100% !important; max-height: 88dvh; border-radius: 0; }
  .modal.modal-survey { max-width: 100% !important; width: 100% !important; height: 82dvh !important; }

  /* ── Survey/results inline views ── */
  #survey-view, #results-view { padding: 12px; }

  /* ── Notif: above bottom nav ── */
  #notif { bottom: 66px; right: 12px; left: 12px; text-align: center; }

  /* ── Quick touch target bumps ── */
  .rank-item { padding: 10px 12px; }
  .recent-item { padding: 10px 12px; }
  .btn { padding: 8px 14px; font-size: 10px; }

  /* ── Drawer positioned above bottom nav ── */
  .mob-drawer { bottom: 56px; }
}

/* ── Extra narrow (≤ 480px) ── */
@media (max-width: 480px) {
  .logo { font-size: 16px; }
  .effects-title { font-size: 30px; }
  .mob-nav-btn { font-size: 7px; letter-spacing: 1px; }
  .mob-nav-btn svg { width: 16px; height: 16px; }
  header { height: 42px; }
  .app { padding-bottom: 56px; }
}

@media (max-width: 900px) {
  /* Account/profile rail: expose user navigation as a horizontal strip. */
  html.mm-mob-chrome .content.content--account {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: minmax(0, 1fr) !important;
    overflow: auto !important;
    height: 100% !important;
    min-height: 0 !important;
  }

  html.mm-mob-chrome .content.content--account #left-account.shell-rail,
  html.mm-mob-chrome .content.content--account .shell-rail#left-account {
    display: block !important;
    visibility: visible !important;
    position: relative !important;
    inset: auto !important;
    grid-column: 1 !important;
    grid-row: auto !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-top: 0 !important;
    border-bottom: 1px solid var(--border) !important;
    background: rgba(4, 15, 18, 0.98) !important;
    overflow: visible !important;
    transform: none !important;
    animation: none !important;
    opacity: 1 !important;
    z-index: 1 !important;
  }

  html.mm-mob-chrome .content.content--account #left-account .side-header {
    display: none !important;
  }

  html.mm-mob-chrome .content.content--account #left-account .side-body {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 10px 12px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    box-sizing: border-box;
  }

  html.mm-mob-chrome .content.content--account #left-account .sec-lbl,
  html.mm-mob-chrome .content.content--account #left-account .side-body > div:not(.sec-lbl) {
    display: none !important;
  }

  html.mm-mob-chrome .content.content--account #left-account .fi {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    min-height: 40px !important;
    padding: 9px 12px !important;
    border: 1px solid var(--border) !important;
    background: rgba(3, 12, 15, 0.9) !important;
    color: var(--text) !important;
    white-space: nowrap !important;
    font-size: 10px !important;
    line-height: 1.15 !important;
    letter-spacing: 1.5px !important;
    text-align: center !important;
    box-sizing: border-box !important;
  }

  html.mm-mob-chrome .content.content--account #left-account .fi.active {
    border-color: rgba(232, 160, 32, 0.72) !important;
    color: var(--amber) !important;
    background: rgba(232, 160, 32, 0.12) !important;
  }

  html.mm-mob-chrome .content.content--account .mm-module-account,
  html.mm-mob-chrome .content.content--account .mm-module-profile {
    display: block !important;
    grid-column: 1 !important;
    grid-row: auto !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  html.mm-mob-chrome .content.content--account #account-view,
  html.mm-mob-chrome .content.content--account #profile-view {
    grid-row: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  html.mm-mob-chrome .content.content--account #account-form-shell {
    max-width: 100% !important;
  }

  html.mm-mob-chrome .content.content--account #account-form-shell .account-field {
    width: 100% !important;
    max-width: 100% !important;
  }

  html.mm-mob-chrome .content.content--account #change-password-form-shell {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  html.mm-mob-chrome .content.content--account #change-password-form-shell > div {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 16px !important;
    width: 100% !important;
  }

  html.mm-mob-chrome .content.content--account #change-password-form-shell > div > div {
    width: 100% !important;
    min-width: 0 !important;
  }

  html.mm-mob-chrome .content.content--account #change-password-form-shell .auth-input {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 46px !important;
    padding: 12px 14px !important;
    box-sizing: border-box !important;
    font-size: 16px !important;
    letter-spacing: 1px !important;
  }

  html.mm-mob-chrome .content.content--account #change-password-policy-mount {
    width: 100% !important;
    min-width: 0 !important;
  }

  html.mm-mob-chrome .content.content--account #change-password-policy-mount .policy-box {
    min-height: 0 !important;
  }

  html.mm-mob-chrome .content.content--admin {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: minmax(0, 1fr) !important;
    overflow: auto !important;
    height: 100% !important;
    min-height: 0 !important;
  }

  html.mm-mob-chrome .content.content--admin #left-admin.shell-rail,
  html.mm-mob-chrome .content.content--admin .shell-rail#left-admin {
    display: block !important;
    visibility: visible !important;
    position: relative !important;
    inset: auto !important;
    grid-column: 1 !important;
    grid-row: auto !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-top: 0 !important;
    border-bottom: 1px solid var(--border) !important;
    background: rgba(4, 15, 18, 0.98) !important;
    overflow: visible !important;
    transform: none !important;
    animation: none !important;
    opacity: 1 !important;
    z-index: 1 !important;
  }

  html.mm-mob-chrome .content.content--admin #left-admin .side-header {
    display: none !important;
  }

  html.mm-mob-chrome .content.content--admin #left-admin .side-body {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 10px 12px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    box-sizing: border-box;
  }

  html.mm-mob-chrome .content.content--admin #left-admin .sec-lbl,
  html.mm-mob-chrome .content.content--admin #left-admin .mm-note {
    display: none !important;
  }

  html.mm-mob-chrome .content.content--admin #left-admin .fi {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    min-height: 40px !important;
    padding: 9px 12px !important;
    border: 1px solid var(--border) !important;
    background: rgba(3, 12, 15, 0.9) !important;
    color: var(--text) !important;
    white-space: nowrap !important;
    font-size: 10px !important;
    line-height: 1.15 !important;
    letter-spacing: 1.5px !important;
    text-align: center !important;
    box-sizing: border-box !important;
  }

  html.mm-mob-chrome .content.content--admin #left-admin .fi.active {
    border-color: rgba(232, 32, 80, 0.72) !important;
    color: var(--red) !important;
    background: rgba(232, 32, 80, 0.12) !important;
  }

  html.mm-mob-chrome .content.content--admin .mm-admin-single {
    display: block !important;
    grid-column: 1 !important;
    grid-row: auto !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  html.mm-mob-chrome .content.content--admin #admin-view {
    grid-row: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
}
