/* Helix Med click-through prototype: mobile safety layer.
   Rules for this file: it never adds borders, never restyles components, and
   only (a) stops fixed-size design frames from overflowing real phones,
   (b) supports the editable-document and toast behaviour added by helix-nav.js. */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html { max-width: 100%; overflow-x: hidden; overflow-y: auto; height: auto; }
body { max-width: 100%; overflow-x: clip; }
/* Safety net: exported mock-ups sometimes carry a fixed pixel size on <html>, which locks scrolling on a real phone. */
html[style] { width: auto !important; height: auto !important; min-height: 0 !important; overflow-x: hidden !important; overflow-y: auto !important; position: static !important; }
img, svg, video, canvas { max-width: 100%; }
button, a, [role="button"], label, input, select, textarea { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
input, select, textarea { max-width: 100%; }

/* Fixed-size design frames exported from the mock-ups: fill the real viewport instead. */
.h-\[852px\], .h-\[890px\], .h-\[844px\] { height: 100vh !important; height: 100dvh !important; max-height: 100dvh !important; }
.min-h-\[890px\], .min-h-\[920px\], .min-h-\[777px\] { min-height: 100vh !important; min-height: 100dvh !important; }
.max-h-\[960px\] { max-height: none !important; }

/* Logo: keep proportions, never crop, never overflow. */
img[alt="Helix Med"] { object-fit: contain; max-width: 100%; background: transparent; }

/* Elements the prototype layer has made clickable. */
[data-hx-click] { cursor: pointer; }

/* Editable documents / notes (tint only, no borders). */
[data-hx-edit="on"] { background-color: rgba(250, 204, 21, 0.22); border-radius: 4px; outline: none; caret-color: #0a0a0a; -webkit-user-select: text; user-select: text; }
[data-hx-edit="on"]:focus { background-color: rgba(250, 204, 21, 0.34); }

/* Short confirmation message (e.g. "Uploaded"). */
.hx-toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none; z-index: 99999;
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 9999px;
  background: #0a0a0a; color: #fff; font: 600 13px/1.2 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); transition: opacity .2s ease, transform .2s ease; text-align: center;
}
.hx-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Back arrow added to Ask Helix (it had none) so the encounter can be re-entered. */
#hx-ask-back {
  position: absolute; left: 58px; top: 14px; width: 36px; height: 36px; z-index: 5;
  display: flex; align-items: center; justify-content: center; border-radius: 9999px;
  background: transparent; color: #374151; cursor: pointer;
}
#hx-ask-back:active { background: rgba(0, 0, 0, 0.06); }

/* Ask Helix prototype thread. */
#hx-thread { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
#hx-thread .hx-msg { max-width: 88%; padding: 10px 14px; font-size: 13px; line-height: 1.45; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
#hx-thread .hx-user { align-self: flex-end; background: #0a0a0a; color: #fff; border-top-right-radius: 4px; }
#hx-thread .hx-bot { align-self: flex-start; background: #f3f4f6; color: #111827; border-top-left-radius: 4px; }

/* Back arrows keep their declared size instead of being squeezed by neighbours. */
[data-hx-back] { flex: none; }
/* Small controls: invisible hit-area extension only (no visual change, no border). */
[data-hx-hit]::after { content: ""; position: absolute; left: calc(var(--hx-dx, 0px) * -1); right: calc(var(--hx-dx, 0px) * -1); top: calc(var(--hx-dy, 0px) * -1); bottom: calc(var(--hx-dy, 0px) * -1); }

/* Narrow phones (320px): let the header title give way so the Medical Record pill and avatar stay on screen. */
@media (max-width: 359px) {
  header .truncate { max-width: 96px !important; }
  header a[data-path="medical-record"] { padding-left: 10px; padding-right: 10px; }
}

/* Header: the supplied wide logo gives way a little rather than squeezing the step badge or buttons. */
[data-hx-nowrap] { white-space: nowrap; flex: none; }
header img[alt="Helix Med"], div img[alt="Helix Med"] { min-width: 0; flex-shrink: 1; }

/* Supplied logo is a wide icon + wordmark lock-up: give it enough height for the wordmark to read. */
img[alt="Helix Med"].h-4, img[alt="Helix Med"].h-6 { height: 34px !important; width: auto; }
img[alt="Helix Med"].h-12 { height: 60px !important; width: auto; }
@media (min-width: 640px) { img[alt="Helix Med"].sm\:h-14 { height: 60px !important; } }

/* ---------- Uniform screen size (requested): no phone mock-up frame, no rounded frame corners, no frame shadow. ---------- */
body[data-hx-framed] { padding: 0 !important; }
body[data-hx-framed="wrapper"] { display: block !important; }
[data-hx-frame] {
  width: 100% !important; max-width: 430px !important; margin: 0 auto !important;
  border-radius: 0 !important; box-shadow: none !important; border-width: 0 !important;
  min-height: 100dvh;
}
body[data-hx-framed="body"] { max-width: 430px; margin-left: auto !important; margin-right: auto !important; }
body[data-hx-framed="body"] > header, body[data-hx-framed="body"] > main, body[data-hx-framed="body"] > footer, body[data-hx-framed="body"] > nav { max-width: none !important; }
@media (max-width: 639px) {
  [data-hx-frame], body[data-hx-framed="body"] { max-width: 100% !important; }
  html, body { background: inherit; }
}
@media (min-width: 640px) {
  /* bottom bars and sheets that are fixed to the viewport stay inside the 430px column */
  [data-purpose="bottom-menu-bar"], body > nav.fixed, body > header.fixed, body > footer.fixed, body > div.fixed { max-width: 430px; margin-left: auto; margin-right: auto; left: 0; right: 0; }
}
