/* @ekm-tags: style, misc */
/* Phone fit (owner 2026-11-09, "this still needs a lot of work"; audit 2026-11-06): on a phone (html.ekm-mobile, a touch
   screen at phone width) — desktop with a mouse never matches these rules.
   1. Text boxes use 16px text: smaller text makes iPhone Safari zoom the whole page in when the box is tapped.
   2. Buttons and pickers are at least 44px tall (WCAG 2.5.5 / Apple HIG); links inside a sentence are exempt (WCAG 2.5.8).
   3. Wide tables scroll sideways inside their own box (js/ekm-mobile-shell.js marks them) instead of being cut off.
   4. The Day Sheet's tab row is a sideways strip: its tabs were squeezed into equal thirds and overlapped.
   5. The Day Sheet's count tiles and section headers scroll with the page instead of pinning under the top bar.
   6. The schedule's date box fits between its arrows.
   7. Tapping a button never selects its text (no Copy / Look Up / Translate bubble over a control).
   8. A double tap never zooms the page; pinch-to-zoom still works. */

html.ekm-mobile input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]),
html.ekm-mobile select,
html.ekm-mobile textarea {
  font-size: 16px !important;
}

html.ekm-mobile.ekm-mobile-authed :is(#main-content, #modal, #pch-root, #pws-drawer, .eui-drawer, .whats-new-drawer)
  :is(button, [role="button"]:not(a), select, input[type="button"], input[type="submit"], input[type="reset"]):not(.ekm-fit-exempt) {
  min-height: 44px;
}
/* icon-only buttons get a 44px width too; buttons with words keep the browser's own floor (never narrower than their
   label), which a fixed min-width would replace and let a squeezed row cut the label (Spruce tabs at 390px). The floor
   has no weight (:where), so a screen's own min-width still wins. */
:where(html.ekm-mobile.ekm-mobile-authed) :where(#main-content, #modal, #pch-root, #pws-drawer, .eui-drawer, .whats-new-drawer)
  :where(button, [role="button"]:not(a)):where(:has(> svg:only-child), :has(> i:only-child)) {
  min-width: 44px;
}

html.ekm-mobile table.ekm-table-scroll {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* any segmented control (e.g. the Billing Communication drawer's tabs) stays one compact control, and scrolls inside
   itself if it is wider than the screen */
html.ekm-mobile .bcv-seg {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
html.ekm-mobile .bcv-seg::-webkit-scrollbar { display: none; }
/* the Day Sheet's Pearl tab row (underlined words, css/ekm-2030-day-sheet.css) is one swipeable row of whole labels; the
   Pearl rule gave each tab an equal third (flex 1 1 0, min-width 0), so long labels ran into each other */
html.ekm-mobile:is([data-theme="pearl"], [data-theme="pearl_night"]) #workflow-content .dwx-page .dwx-toolbar .bcv-seg {
  flex-wrap: nowrap;
  gap: 0 20px;
}
html.ekm-mobile:is([data-theme="pearl"], [data-theme="pearl_night"]) #workflow-content .dwx-page .dwx-toolbar .bcv-seg > .bcv-seg-btn {
  flex: 0 0 auto;
  width: auto;
  min-width: max-content;
  max-width: none;
}

/* A soft fade on the side of a swipeable row / table that has more to see (js/ekm-mobile-shell.js sets data-more). */
html.ekm-mobile :is(table.ekm-table-scroll, .bcv-seg)[data-more="right"] {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
}
html.ekm-mobile :is(table.ekm-table-scroll, .bcv-seg)[data-more="left"] {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent);
          mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent);
}
html.ekm-mobile :is(table.ekm-table-scroll, .bcv-seg)[data-more="both"] {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
          mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
}

/* The last thing on a page scrolls clear of the tab bar, with a small gap. (It used to leave 76px more for the floating chat
   bubble; the bubble is gone on a phone (js/ekm-mobile-shell.css), so that strip was empty space: Bugbot on #1963.) */
html.ekm-mobile.ekm-mobile-authed main#main-content,
html.ekm-mobile.ekm-mobile-authed body.hp-active main#main-content {
  padding-bottom: calc(var(--ekm-mobile-nav-height, 56px) + 16px);
}

/* The Day Sheet's count tiles (All items, Action required, …) pin to the top while the list scrolls (#dwx-statebar,
   js/ekm-daily-workspace.js). On a phone they pinned at the very top of the page, half under the fixed top bar, and the
   frosted glass let the cards scroll visibly behind and through them: buttons looked stacked on buttons (owner
   2026-11-10, "There's still buttons overlapping things on day sheet"). Even condensed, six tiles are three rows, a
   fifth of a phone screen. On a phone they scroll away with the page instead; the top bar's Day Sheet title stays. */
/* The section headers (Action required, Pending patient, …) pinned 46px down, just under where the tiles sat: on a phone
   that is half under the top bar too, with the same glass showing the cards through them (Bugbot on #1917). They scroll
   with their section as well. Nothing on the Day Sheet pins on a phone; the top bar is the only thing that stays. */
html.ekm-mobile #workflow-content :is(#dwx-statebar, .dwx-sec-head, .dwx-cats) {
  position: static;
}

/* The schedule's date row (← [date] → Today; Day Sheet Schedule, Patient Routing, EHR & Billing): iPhone Safari draws a
   date box at its own width, wider than its column once the text is 16px (rule 1), so the → button sat on top of the date
   (owner 2026-11-11). The date's column takes the room the arrows and Today leave, and the box fills that column and never
   more: appearance none is what lets Safari size a date box at all. */
/* ...and the arrows, the date box and Today line up: the "Day" caption sits above the box, so the row aligns on the
   bottom edge and the box is the arrows' height (44px). */
html.ekm-mobile .today-sched-date-nav { flex-wrap: nowrap; align-items: flex-end; }
html.ekm-mobile .today-sched-date-nav > .today-sched-date-label { flex: 1 1 0; min-width: 0; max-width: none; }
html.ekm-mobile .today-sched-date-nav > .wf-date-nav-btn,
html.ekm-mobile .today-sched-date-nav > .wf-date-nav-today { flex: none; }
html.ekm-mobile .today-sched-date-nav input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 44px;
  min-height: 44px;
  margin: 0;
  box-sizing: border-box;
}

/* A quick double tap on a button (the Intake Readiness week arrows ‹ ›) selected its character and opened iPhone's
   Copy / Look Up / Translate bubble over the page (owner 2026-11-11). Controls are not text: no selection, no long-press
   callout, and no double-tap zoom delay on them. Text people read or type (inputs, notes, messages) keeps selection. */
html.ekm-mobile :is(button, [role="button"], [role="tab"], [role="switch"], summary, select, .ir-board-date-nav, .wf-date-nav, .ekm-mobile-bottom-nav, .ekm-mobile-appbar) {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* A double tap anywhere zoomed the whole app in (owner 2026-11-11: "When I double click something it's changing the size
   of the app"). touch-action applies to everything inside the element it is set on, so on the page root it turns off
   double-tap zoom everywhere, while pinch-to-zoom and scrolling keep working (WCAG 1.4.4: people can still zoom). */
html.ekm-mobile,
html.ekm-mobile body {
  touch-action: manipulation;
}
