/* Mobile M2: the shared touch frame. One place for every page (Login and Emergency login link it directly,
   shared.js adds it on every other page, on touch devices only).
   Binding rule G0: every rule sits inside (hover:none) and (pointer:coarse). A desktop browser, at any window
   size, never matches it, so nothing here changes the desktop. Width conditions only decide the layout class:
   phone and tablet portrait up to 1024 px get the collapsed header; iPad landscape (above 1024 px) keeps today's header. */
@media (hover:none) and (pointer:coarse){
  /* Inputs: 16 px at least, otherwise iOS zooms the page on focus. */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=hidden]),select,textarea{font-size:16px!important}

  /* Full-screen heights follow the visible area (dvh) instead of the largest one (vh). Each override sits in
     exactly the width range in which the original 100vh rule is the one that applies, so no narrow-width rule
     of the pages is overridden (tests/test_mobile_nav_frontend.py checks the ranges). */
  .development-page{min-height:100dvh}
  .development-workspace{min-height:calc(100dvh - 58px)}
  .strategy-coalitions-page{min-height:100dvh}
  .strategy-global-page{height:100dvh}
  .strategy-tabs-enabled .development-workspace{min-height:calc(100dvh - 104px)}
  .home-page{min-height:100dvh}
  .preview-grid{min-height:calc(100dvh - 58px)}
}
@media (hover:none) and (pointer:coarse) and (min-width:901px){
  .history-page{height:calc(100dvh - 58px)}
  .analysis-layout{height:calc(100dvh - 58px)}
}
@media (hover:none) and (pointer:coarse) and (min-width:1051px){
  body.dashboard{min-height:100dvh}
  .page-grid{min-height:calc(100dvh - 58px)}
  .map-shell{height:calc(100dvh - 190px)}
}
@media (hover:none) and (pointer:coarse) and (min-width:621px){
  .strategy-shell{height:calc(100dvh - 64px)}
  .strategy-tabs-enabled .strategy-shell{height:calc(100dvh - 110px)}
}
@media (hover:none) and (pointer:coarse) and (max-width:620px){
  .strategy-shell{min-height:calc(100dvh - 64px)}
}
@media (hover:none) and (pointer:coarse) and (min-width:701px){
  .cm-map,.cm-panel{height:calc(100dvh - 310px)}
}
@media (hover:none) and (pointer:coarse) and (min-width:721px){
  .map-view-preview{height:calc(100dvh - 165px)}
}

/* Home: key hints need a keyboard, the command bar stacks instead of running off the side, targets are 44 px. */
@media (hover:none) and (pointer:coarse){
  .home-keys{display:none}
  .home-page .tile-chips a{display:inline-flex;align-items:center;min-height:44px;box-sizing:border-box}
  .home-page .command-item{min-height:44px;box-sizing:border-box}
  .home-page .tile-metrics>a{min-height:44px;box-sizing:border-box}
  .home-page .header-user-placeholder{min-height:44px;box-sizing:border-box}
  .home-page .header-user-panel a{display:flex;align-items:center;min-height:44px;box-sizing:border-box}
}
@media (hover:none) and (pointer:coarse) and (max-width:899px){
  .home-header{flex-wrap:wrap}
  .clearance-badges{flex-wrap:wrap;gap:8px}
  .command-bar{flex:0 0 auto}
  .command-items,.command-title{min-width:0}
  .home-page .command-open{align-self:flex-start;margin:14px 18px}
  .command-fill{display:none}
}

/* Profile, Settings and the shared page controls: 44 px targets. */
@media (hover:none) and (pointer:coarse){
  .profile-shell button,.profile-shell select,.profile-shell input:not([type=checkbox]):not([type=radio]):not([type=hidden]),.profile-actions a,.admin-subnav a,.settings-tabs button,.settings-workspace button,.settings-workspace select,.settings-statusbar button{min-height:44px;box-sizing:border-box}
  .settings-workspace .expand-button{min-width:44px}
  .profile-shell a[href^="/auth"]{display:inline-flex;align-items:center;min-height:44px}
  .home-page .home-brand{min-height:44px}
  .profile-shell .toggle-row{min-height:44px;box-sizing:border-box}
  .profile-shell .btn-link{display:inline-flex;align-items:center;min-height:44px}
}

/* Header: logo, region and menu button on one row; the navigation, user menu and EVE time move into the drawer. */
@media (hover:none) and (pointer:coarse){
  .mnav-button,.mnav-scrim,.mnav-drawer{display:none}
}
@media (hover:none) and (pointer:coarse) and (max-width:1024px){
  header.mnav-header{display:flex!important;flex-direction:row!important;flex-wrap:nowrap!important;justify-content:flex-start!important;align-items:center!important;gap:8px!important;box-sizing:border-box!important;height:auto!important;min-height:58px;margin:0;padding:7px 10px!important;padding-top:calc(7px + env(safe-area-inset-top,0px))!important}
  header.mnav-header>.topnav,header.mnav-header>.global-header-meta,header.mnav-header>.header-system-selector,header.mnav-header>.bi-delay,
  header.mnav-header .brand small,header.mnav-header .brand-scope,header.mnav-header .active-region,header.mnav-header>div:first-child p{display:none!important}
  header.mnav-header>div:first-child,header.mnav-header>.brand{flex:0 1 auto;min-width:0;margin:0;white-space:nowrap}
  header.mnav-header>div:first-child h1{margin:0;min-width:0;font-size:inherit}
  header.mnav-header .brand-home{min-width:0;max-width:100%;min-height:44px}
  header.mnav-header .brand-home>span{overflow:hidden;font-size:14px;text-overflow:ellipsis;white-space:nowrap}
  header.mnav-header .header-region-selector{order:0!important;flex:1 1 0;min-width:0;margin:0 0 0 auto!important}
  header.mnav-header .header-region-label{display:none}
  header.mnav-header .header-region-trigger{width:100%;min-width:0;height:44px;box-sizing:border-box}
  header.mnav-header .header-region-trigger>span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  header.mnav-header .header-region-menu{position:fixed;top:calc(env(safe-area-inset-top,0px) + 62px);right:10px;left:10px;width:auto}
  header.mnav-header .header-region-search{height:44px;box-sizing:border-box}
  header.mnav-header .header-region-options{max-height:min(320px,55dvh)}
  header.mnav-header .header-region-option{min-height:44px;box-sizing:border-box}

  .mnav-button{position:relative;display:grid;flex:0 0 44px;place-items:center;box-sizing:border-box;width:44px;height:44px;margin:0 0 0 auto;padding:0;border:1px solid #2b465e;border-radius:6px;background:#0b1925;color:#eef7ff;cursor:pointer;touch-action:manipulation}
  .mnav-header .header-region-selector+.mnav-button{margin-left:0}
  .mnav-button:focus:not(:focus-visible){outline:none}
  .mnav-button:focus-visible{outline:2px solid var(--cyan,#36bffa);outline-offset:1px}
  .mnav-dot{position:absolute;top:5px;right:5px;width:11px;height:11px;border:2px solid #0b1925;border-radius:50%;background:#ef4444}
  .mnav-dot[data-state="stale"]{background:var(--ops,#ffb02e)}
  .mnav-dot[hidden]{display:none}

  .mnav-scrim{position:fixed;z-index:2090;inset:0;display:block;background:#000b;opacity:0;visibility:hidden;touch-action:none;transition:opacity .2s,visibility 0s .2s}
  .mnav-drawer{position:fixed;z-index:2100;top:0;right:0;bottom:0;display:flex;flex-direction:column;box-sizing:border-box;width:min(86vw,360px);padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) 0;border-left:1px solid var(--line,#263746);background:#09131c;box-shadow:-18px 0 45px #000a;color:#b8cad8;font-family:inherit;transform:translateX(100%);visibility:hidden;transition:transform .22s ease,visibility 0s .22s}
  .mnav-open .mnav-scrim{opacity:1;visibility:visible;transition:opacity .2s}
  .mnav-open .mnav-drawer{transform:none;visibility:visible;transition:transform .22s ease}
  html.mnav-lock,html.mnav-lock body{overflow:hidden!important}
  .mnav-top{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 8px 8px 16px;border-bottom:1px solid var(--line,#263746)}
  .mnav-user{display:flex;align-items:center;gap:10px;min-width:0}
  .mnav-avatar{display:grid;flex:0 0 auto;place-items:center;width:32px;height:32px;overflow:hidden;border-radius:50%}
  .mnav-avatar:empty{display:none}
  .mnav-avatar>*{width:32px;height:32px}
  .mnav-user-copy{display:grid;min-width:0}
  .mnav-user-copy b{overflow:hidden;color:#edf5fa;font-size:14px;font-weight:600;text-overflow:ellipsis;white-space:nowrap}
  .mnav-user-copy small{margin-top:2px;color:var(--muted,#8596a8);font-size:11px}
  .mnav-close{display:grid;flex:0 0 44px;place-items:center;box-sizing:border-box;width:44px;height:44px;padding:0;border:1px solid #2b465e;border-radius:6px;background:#0b1925;color:#eef7ff;cursor:pointer;touch-action:manipulation}
  .mnav-close:focus:not(:focus-visible){outline:none}
  .mnav-close:focus-visible{outline:2px solid var(--cyan,#36bffa);outline-offset:1px}
  .mnav-status{display:flex;align-items:center;gap:10px;min-height:44px;padding:0 16px;border-bottom:1px solid var(--line,#263746);background:#0b1925;color:var(--muted,#8596a8);font-size:12px;font-weight:700;letter-spacing:.08em}
  .mnav-status[data-state="error"]{background:#2a0a0d;color:#fecaca}
  .mnav-status[data-state="stale"]{background:#2a1d06;color:var(--ops,#ffb02e)}
  .mnav-status[hidden]{display:none}
  .mnav-status-dot{flex:0 0 auto;width:10px;height:10px;border-radius:50%;background:var(--strategy,#36bffa)}
  .mnav-status[data-state="error"] .mnav-status-dot{background:#ef4444}
  .mnav-status[data-state="stale"] .mnav-status-dot{background:var(--ops,#ffb02e)}
  .mnav-status[data-state="waiting"] .mnav-status-dot{background:transparent;border:1px solid currentColor;box-sizing:border-box}
  .mnav-time{display:flex;align-items:baseline;justify-content:space-between;gap:10px;padding:10px 16px;border-bottom:1px solid var(--line,#263746)}
  .mnav-time-clock{color:#e9f4fb;font-size:13px;font-weight:700;letter-spacing:.025em}
  .mnav-time-date{color:var(--muted,#8596a8);font-size:11px}
  .mnav-list{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding-bottom:16px}
  .mnav-group-title{margin:0;padding:16px 16px 6px;color:var(--muted,#8596a8);font-size:10px;font-weight:700;letter-spacing:.12em;text-transform:uppercase}
  .mnav-item{display:flex;align-items:center;box-sizing:border-box;min-height:44px;padding:0 16px;color:#b8cad8;font-size:15px;text-decoration:none;touch-action:manipulation}
  .mnav-item:active,.mnav-item:focus-visible{background:#0d2a3d;color:#51c9ff;outline:none}
  .mnav-item.active{background:#0c2030;box-shadow:inset 3px 0 0 var(--cyan,#36bffa);color:var(--cyan,#36bffa)}
}
/* Phone: with a region selector in the row, the logo stands without the wordmark so the region name has room. */
@media (hover:none) and (pointer:coarse) and (max-width:600px){
  header.mnav-header:has(.header-region-selector) .brand-home>span{display:none}
}
