/* ============================================================================
   Manas AI + LENS — mobile polish.

   The last stylesheet in <head> on /manas and /first-connect, so it sees the
   pages' own phone rules and can correct them. It adds no colours, no type
   and no new components. It does three jobs:

     1 · KEEP THE PAGE TIDY. LENS also links the public site's mobile layer
         (mobile-ux.css), which was written for marketing pages. Some of its
         `!important` rules hit LENS too. `.block` gave every assessment
         section card 32px of top and bottom padding, so a closed section was
         108px tall. `section, header, footer, main` re-padded the records
         panels at 360px and narrower, so the Android width the team uses most
         had panels inset that are flush at 361px. And the rule that turns
         every button into `inline-flex` left the text of full-width buttons
         sitting on the left. Each fix below is scoped to a LENS id, so no
         public page changes.

     2 · SMOOTH SCROLLING. Swipe rails (module tabs, section chips,
         record-view pills, filters, the hospital rail, the activity plot)
         snap gently, keep the swipe inside the rail instead of passing it to
         the page, hide the desktop scrollbar, and fade at the edge only while
         there is more to see.

     3 · SOFT TOUCH ON CARDS. manas-touch.css answers a press on buttons.
         Cards are bigger, and the same 2.2% scale makes a 360px card look like
         it flinches. Cards settle about 1.2% instead, on the same spring
         curve, and the hover lift only happens with a real pointer.

   Everything that moves stops under prefers-reduced-motion.
   ========================================================================== */

/* ── Page floor (both apps) ───────────────────────────────────────────────
   `clip`, not `hidden`. A stray wide child is cut off without making the body
   a scroll container, so sticky headers keep working. */
html{ -webkit-text-size-adjust:100%; text-size-adjust:100% }
body{ overflow-x:clip }
@media (prefers-reduced-motion:no-preference){
  html{ scroll-behavior:smooth }
}
/* Photos and video never overflow their card. */
img, video{ max-width:100% }
/* Installed (standalone) apps have no browser chrome to pull to refresh, so
   the rubber-band bounce at the ends of the page is all that is left. */
@media (display-mode:standalone){
  html, body{ overscroll-behavior-y:none }
}

/* ── 2 · Swipe rails ───────────────────────────────────────────────────── */
@media (max-width:899px){
.modtabs,
.secrail,
.mr-seg-pills,
.mr-filters,
.mr-pend-rail,
#mrView .gk-attn-row,
.rom-wrap,
.pl-wrap,
.cons-plot,
.cons-table-wrap{
  overscroll-behavior-x:contain;
  -webkit-overflow-scrolling:touch;
  scroll-padding-inline:12px;
}
.modtabs,
.secrail,
.mr-seg-pills,
.mr-filters{
  scroll-snap-type:x proximity;
  scrollbar-width:none;
}
.modtabs::-webkit-scrollbar,
.secrail::-webkit-scrollbar,
.mr-seg-pills::-webkit-scrollbar,
.mr-filters::-webkit-scrollbar{ display:none }
.modtabs > *,
.secrail > *,
.mr-seg-pills > *,
.mr-filters > *{ scroll-snap-align:start; flex-shrink:0 }

}
/* An edge fade that follows the scroll: the right edge fades while there is
   more to the right, the left edge fades once the rail has moved. A rail that
   fits has no scroll range, so it gets no fade. Browsers without scroll-driven
   animations see a plain rail. The sticky section rail is left out because a
   mask would also fade its bottom border. */
@supports (animation-timeline: scroll(self inline)){
  @media (prefers-reduced-motion:no-preference){
    .modtabs,
    .mr-seg-pills,
    .mr-filters{
      --mp-l:0px; --mp-r:0px;
      -webkit-mask-image:linear-gradient(90deg,transparent 0,#000 var(--mp-l),#000 calc(100% - var(--mp-r)),transparent 100%);
              mask-image:linear-gradient(90deg,transparent 0,#000 var(--mp-l),#000 calc(100% - var(--mp-r)),transparent 100%);
      animation:mp-rail-fade linear both;
      animation-timeline:scroll(self inline);
    }
  }
}
@property --mp-l{ syntax:'<length>'; inherits:false; initial-value:0px }
@property --mp-r{ syntax:'<length>'; inherits:false; initial-value:0px }
@keyframes mp-rail-fade{
  0%  { --mp-l:0px;  --mp-r:22px }
  8%  { --mp-l:22px; --mp-r:22px }
  92% { --mp-l:22px; --mp-r:22px }
  100%{ --mp-l:22px; --mp-r:0px }
}

/* ── 3 · Soft touch on cards ───────────────────────────────────────────── */
a.tool,
a.zio,
.hid-pt,
.hid-pulse-next,
.pp-lockup,
.mr-pcard,
.mr-dash-card,
#mrView .gk-card,
.tl-report{
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
  transition-property:transform, box-shadow, border-color, background-color, filter;
  transition-duration:.36s, .24s, .2s, .2s, .2s;
  transition-timing-function:var(--mt-press, cubic-bezier(.34,1.56,.64,1)), ease, ease, ease, ease;
}
a.tool:not(.locked):active,
a.zio:active,
.hid-pt:active,
.hid-pulse-next:active,
.pp-lockup:active,
.mr-pcard:active,
.mr-dash-card:active,
.tl-report:active{
  transform:scale(.988);
  transition-duration:.08s;
}
/* A card that is not available still answers the tap, with a dim instead of
   a press, so it never looks like it is about to open. */
a.tool.locked:active{ filter:brightness(.97) }
@media (hover:none){
  /* Touch screens keep :hover after a tap, so a card would stay lifted. */
  a.tool:hover, .hid-pt:hover, .mr-pcard:hover, .mr-dash-card:hover{ transform:none }
}

/* ── 1 · LENS: undo the public-site layer ─────────────────────────────── */

/* Every button with its label centred. The public layer makes buttons
   inline-flex without centring them, which left "Got it" against the left
   edge of the install sheet. */
.pwa-sheet-act button{ display:flex; align-items:center; justify-content:center; text-align:center }

/* Breaking long words only when they would overflow, not anywhere. The public
   layer's `anywhere` also shrinks the min-content width, which split short
   labels mid-word in narrow cards. */
#assessView :is(a,p,li,span,h1,h2,h3,h4),
#mrView :is(a,p,li,span,h1,h2,h3,h4){
  overflow-wrap:break-word;
  word-break:normal;
}

@media (max-width:700px){
  /* Section cards: the padding LENS asks for, not the marketing band
     padding. A closed section is a tidy row of about 76px instead of 108px. */
  #assessView section.block{ padding-top:16px !important; padding-bottom:16px !important }
  #assessView section.block:not(.open){ padding-top:14px !important; padding-bottom:14px !important }
}

@media (max-width:360px){
  /* The insets LENS uses at 361px, kept at 360px and narrower. */
  html:has(#assessView) #main{ padding-left:14px !important; padding-right:14px !important }
  html:has(#assessView) body[data-view="mr"] #main{ padding-left:12px !important; padding-right:12px !important }
  html:has(#assessView) body > footer, html:has(#assessView) footer{ padding-left:16px !important; padding-right:16px !important }
  #assessView section.block{ padding-left:14px !important; padding-right:14px !important }
  #axHero{ padding-left:16px !important; padding-right:16px !important }
  #mrBento, #mrDue, #mrPend{ padding-left:0 !important; padding-right:0 !important }
  #mrAttn{ padding-left:10px !important; padding-right:10px !important }
}

/* ZIO voice row. The wave, the name and three controls did not fit a 320px
   card, and the Speak button stuck out past the card edge. Below 360px the
   name goes and the wave alone marks the row as ZIO; every control has its
   own label. */
#zioVoice{ min-width:0 }
#zioVoice .ziov-acts{ min-width:0 }
@media (max-width:359px){
  #zioVoice .ziov-txt{ display:none }
  #zioVoice{ gap:8px }
}

/* ── Manas AI: clinical activity figures ───────────────────────────────
   Two across on a phone, the four tiles came out in two shapes: "Filing
   consistency" was too wide to sit beside its icon, so that one tile wrapped
   and stood taller than the rest. Now every tile is the same grid (icon,
   then figure and label) and the label can take a second line. */
@media (max-width:479px){
  .cons-kpis{ grid-auto-rows:1fr }
  .cons-kpi{
    display:grid; grid-template-columns:28px minmax(0,1fr);
    column-gap:10px; row-gap:6px; align-items:center; align-content:start;
    padding:11px 12px;
  }
  .cons-kpi-i{ width:28px; height:28px; border-radius:8px }
  .cons-kpi-l{ white-space:normal; line-height:1.25; overflow:visible }
  .cons-kpi-d{ grid-column:1 / -1 }
  .cons-kpi-d:empty{ display:none }
}

/* ── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion:reduce){
  a.tool, a.zio, .hid-pt, .hid-pulse-next, .pp-lockup,
  .mr-pcard, .mr-dash-card, #mrView .gk-card, .tl-report{
    transition-duration:.01ms !important;
  }
  a.tool:active, a.zio:active, .hid-pt:active, .hid-pulse-next:active,
  .pp-lockup:active, .mr-pcard:active, .mr-dash-card:active, .tl-report:active{
    transform:none !important;
    filter:brightness(.95);
  }
}
