/* @ekm-tags: style, misc */
/* EKM Overlay (js/ekm-overlay.js): pop-ups you can always get out of on a phone or tablet. Everything here is scoped to
   html.ekm-ov-active, which the module sets only on touch screens / the phone layout, so desktop with a mouse is unchanged. */

/* Scroll lock while a full-screen pop-up is open; the module removes the class when the last one closes. */
html.ekm-ov-active.ekm-ov-lock,
html.ekm-ov-active.ekm-ov-lock body { overflow: hidden; overscroll-behavior: none; }

/* The shared modal keeps clear of the notch / status bar and the home indicator. */
html.ekm-ov-active .modal-bg {
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
}
html.ekm-ov-active .modal-bg .modal { max-height: 100%; overscroll-behavior: contain; }

/* Close (X) pinned to the top of the shared modal when its content has none up there. */
html.ekm-ov-active .modal .ekm-ov-x {
  position: sticky;
  top: 0;
  z-index: 3;
  float: right;
  width: 44px;
  height: 44px;
  margin: -8px -8px 4px 8px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0.5px solid var(--stroke-subtle, var(--c-box-border, rgba(0, 0, 0, .12)));
  border-radius: 10px;
  background: var(--surface-card, var(--c-box, #fff));
  color: var(--c-ink, #1f1d1a);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
html:not(.ekm-ov-active) .modal .ekm-ov-x { display: none; }
html.ekm-ov-active .modal .ekm-ov-x:focus-visible { outline: 2px solid var(--c-accent, #6b5a45); outline-offset: 2px; }

/* Full-screen pop-ups keep their top row (title and close) below the notch / status bar. In the installed app the page is
   drawn under the status bar and an iPhone never passes a tap in that strip to the page, so a close (X) placed there can
   be seen through the clock but never pressed (owner 2026-11-20: "impossible to click out of things ... billing
   communication, you click a case, you have to completely close out"). The patient chart and the patient quick view
   already do this (js/ekm-mobile-shell.css, which also defines --ekm-safe-top so a notch can be simulated in tests).
   The inset is 0 on a desktop, so nothing moves there. */
html.ekm-ov-active .eui-drawer,
html.ekm-ov-active .bc2 .bc2-panel {
  box-sizing: border-box;
  padding-top: var(--ekm-safe-top, env(safe-area-inset-top, 0px));
}
html.ekm-ov-active .whats-new-drawer {
  box-sizing: border-box;
  padding-top: calc(1.1rem + var(--ekm-safe-top, env(safe-area-inset-top, 0px)));
}
/* Search is a full-screen sheet only at phone width (css/ekm-command-palette.css); wider, it already starts lower. */
@media (max-width: 560px) {
  html.ekm-ov-active .ekmk-sheet { padding-top: var(--ekm-safe-top, env(safe-area-inset-top, 0px)); }
}

/* ...and clear of a status area at the SIDE of the screen. On the owner's phone (2026-11-20 screenshot) the camera, clock
   and battery sit in a column in the top right corner: the top inset is 0 and the right inset is about 83px. Every close
   (X) is at the top right, so every one of them was under that column, the patient quick view's included ("impossible
   to click out of things"). The phone's top bar already kept clear of it (.ekm-mobile-appbar-row); these pop-ups now do
   too. --ekm-safe-left / --ekm-safe-right (js/ekm-mobile-shell.css) are 0 on every phone without such a column. */
html.ekm-ov-active :is(.eui-drawer, .bc2 .bc2-panel, #pws-drawer) {
  box-sizing: border-box;
  padding-left: var(--ekm-safe-left, env(safe-area-inset-left, 0px));
  padding-right: var(--ekm-safe-right, env(safe-area-inset-right, 0px));
}
html.ekm-ov-active .whats-new-drawer {
  padding-left: calc(1.25rem + var(--ekm-safe-left, env(safe-area-inset-left, 0px)));
  padding-right: calc(1.25rem + var(--ekm-safe-right, env(safe-area-inset-right, 0px)));
}
html.ekm-ov-active .ekm-mobile-more-sheet {
  padding-left: calc(var(--ekm-mobile-gutter) + var(--ekm-safe-left, env(safe-area-inset-left, 0px)));
  padding-right: calc(var(--ekm-mobile-gutter) + var(--ekm-safe-right, env(safe-area-inset-right, 0px)));
}
@media (max-width: 560px) {
  html.ekm-ov-active .ekmk-sheet {
    padding-left: var(--ekm-safe-left, env(safe-area-inset-left, 0px));
    padding-right: var(--ekm-safe-right, env(safe-area-inset-right, 0px));
  }
}
/* Billing Communication's account panel is the whole screen at phone width: its close stays pinned at the top right, and
   the name / balance / "Open full case" row wraps beside it instead of pushing it off the screen (a 320px phone). Kept
   here, not in css/ekm-bc2.css: it is about the way out on a touch screen, and the billing files are not touched. */
@media (max-width: 640px) {
  html.ekm-ov-active .bc2 .bc2-panel__head { position: relative; }
  html.ekm-ov-active .bc2 .bc2-panel__top { flex-wrap: wrap; padding-right: 56px; }
  html.ekm-ov-active .bc2 .bc2-panel__top > div:last-child { flex-wrap: wrap; }
  html.ekm-ov-active .bc2 .bc2-panel .bc2-close { position: absolute; top: 18px; right: 22px; }
}
/* The patient chart is a whole page, so only its top bar moves in (like the phone's own top bar). Its buttons stay on
   one line and on the screen: when Back, Sections, Quick view and Portal access do not all fit, Back gives up the room
   (its arrow stays, its words end in an ellipsis). Before, the last button ran off the right edge instead: Portal
   access was off the screen on a 390px phone, and under the status column on the owner's. */
html.ekm-ov-active .pch-root.is-phone .pch-topbar {
  padding-left: max(8px, var(--ekm-safe-left, env(safe-area-inset-left, 0px)));
  padding-right: max(8px, var(--ekm-safe-right, env(safe-area-inset-right, 0px)));
}
html.ekm-ov-active .pch-root.is-phone .pch-topbar > :not(.pch-back) { flex: none; }
html.ekm-ov-active .pch-root.is-phone .pch-topbar > .pch-back {
  flex: 0 1 auto;
  min-width: 44px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Close controls that were smaller than a fingertip. */
html.ekm-ov-active .pws-close,
html.ekm-ov-active .eui-drawer__close,
html.ekm-ov-active .bc2 .bc2-close,
html.ekm-ov-active .whats-new-drawer button[aria-label="Close"] {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Search: "Esc" means nothing on a phone; show Cancel there instead. */
.ekmk-close .ekmk-close-touch { display: none; }
html.ekm-ov-active .ekmk-close .ekmk-close-key { display: none; }
html.ekm-ov-active .ekmk-close .ekmk-close-touch { display: inline; }
