/* HALO on phones and as an installed app. Loaded after styles.css so it only adds to it.
   Owned by the mobile/PWA work: keep phone-only rules here, scoped to small screens or touch. */

/* ── Install prompt and offline notice (pwa.js) ── */
.pwa-install { position: fixed; z-index: 60; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; padding: 12px 10px 12px 12px; border-radius: 20px;
  background: rgba(16, 30, 54, .94); border: 1px solid var(--edge); box-shadow: var(--shadow); animation: pwa-up .35s ease both; }
.pwa-install img { border-radius: 11px; flex: none; }
.pwa-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; line-height: 1.35; }
.pwa-txt > b { font-size: 15px; }
.pwa-txt span { color: var(--muted); }
.pwa-txt svg { vertical-align: -3px; color: #5cbdf5; }
.pwa-go { min-height: 44px; flex: none; }
.pwa-x { flex: none; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; border-radius: 50%; }
@keyframes pwa-up { from { transform: translateY(20px); opacity: 0; } }
.pwa-offline { position: fixed; z-index: 70; left: 50%; transform: translateX(-50%); top: calc(8px + env(safe-area-inset-top));
  max-width: calc(100% - 24px); padding: 8px 16px; border-radius: 999px; font-size: 13px; text-align: center;
  background: rgba(245, 168, 69, .95); color: #1b1203; font-weight: 600; box-shadow: var(--shadow); }
@media (prefers-reduced-motion: reduce) { .pwa-install { animation: none; } }

/* ── Safe areas: the installed iPhone app draws under the status bar and home indicator ── */
.shell { padding-top: max(18px, env(safe-area-inset-top)); padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.signin { padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.dock { bottom: calc(14px + env(safe-area-inset-bottom)); right: calc(18px + env(safe-area-inset-right)); }
@media (max-width: 860px) {
  .shell { padding-top: max(12px, env(safe-area-inset-top)); padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right)); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .nav { top: max(12px, env(safe-area-inset-top)); bottom: max(12px, env(safe-area-inset-bottom)); left: max(12px, env(safe-area-inset-left)); }
  .dock { right: calc(8px + env(safe-area-inset-right)); bottom: calc(8px + env(safe-area-inset-bottom)); }
}

/* ════ Phone layout pass (mobile thread) ════
   Safe areas, 16px fields (no iOS zoom), 44px taps, sticky top bar, tidy tab grids,
   smaller H-AI-LEY dock that steps aside, bottom sheets, App directory as cards. */
@media (max-width: 860px) {
  /* safe areas (viewport-fit=cover + black-translucent status bar) */
  .shell { padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .nav { top: calc(12px + env(safe-area-inset-top)); bottom: calc(12px + env(safe-area-inset-bottom)); }
  .top { position: sticky; top: 0; z-index: 15; margin-top: calc(-8px - env(safe-area-inset-top)); padding: calc(8px + env(safe-area-inset-top)) 0 8px; }
  .top::before { content: ""; position: absolute; inset: 0 -12px -10px; z-index: -1; pointer-events: none; background: linear-gradient(180deg, rgba(7,13,26,.94) 75%, rgba(7,13,26,0)); }
  .icon-btn { min-width: 44px; min-height: 44px; justify-content: center; }
  .ask { min-width: 0; } /* needed once inputs go to 16px, else the Ask bar overflows at 320 */
  /* iOS zoom-on-focus */
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; }
  /* tabs: a tidy grid, never a giant pill, never a hidden tab */
  .segs, .view .pj .segs { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); width: 100%; min-width: 0; border-radius: 18px; overflow: visible; }
  .seg, .view .pj .seg { min-height: 44px; justify-content: center; text-align: center; white-space: normal; line-height: 1.15; border-radius: 14px; padding: 6px 10px; }
  .seg.big { font-size: 14px; }
  /* touch targets */
  .btn.small, .chip, .or-dots, .or-more > summary, .mi, .linkish, .rec-opt span, .wo-link, .pj .mini button, .pj .tl-row, .needs-list a, .subs a, .cat-row a, .app-acts .btn { min-height: 44px; }
  .linkish, .pp-dl .linkish { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; }
  .cat-tog { width: 44px; height: 44px; }
  .si { width: 44px; height: 44px; }
  .si::after { display: none; } .si.tip-open::after, .si:focus-visible::after { display: block; } /* invisible max-content tooltips widen the row */
  .chk, .pj .check { min-height: 44px; }
  .chk input, input[data-all], .pj .check input { width: 22px; height: 22px; }
  .pj-drawer .x, .ap-x { min-width: 44px; min-height: 44px; }
  .dock-hide { width: 32px; height: 32px; }
  .dock-hide::before { content: ""; position: absolute; inset: -6px; }
  /* H-AI-LEY dock: smaller, safe-area aware, out of the way of iframes and sheets */
  .dock { right: max(6px, env(safe-area-inset-right)); bottom: calc(6px + env(safe-area-inset-bottom)); }
  .dock-pet { --hs: 60px !important; }
  .dock-hide { bottom: 46px; right: -4px; }
  body:has(.view.framed) .dock, body:has(.or-menu .or-pop:not([hidden])) .dock, body:has(#pwa-install) .dock { display: none; }
  /* row bottom sheet: .glass backdrop-filter traps position:fixed inside the row */
  .or-row:has(.or-pop:not([hidden])) { backdrop-filter: none; -webkit-backdrop-filter: none; z-index: 41; }
  .or-menu .or-pop { bottom: calc(8px + env(safe-area-inset-bottom)); }
  .or-row { gap: 10px; } .or-row .or-main { flex: 1 1 calc(100% - 110px); min-width: 0; }
  /* home: compact hero so "Needs you now" is on the first screen */
  .hero { flex-direction: row; align-items: flex-start; text-align: left; padding: 12px 14px; gap: 10px; border-radius: 22px; margin-bottom: 12px; }
  .hero-stage { width: 72px; height: 72px; } .hero-stage .hailey { --hs: 72px !important; }
  .hero .pill { display: none; }
  .hero-copy { gap: 8px; } .hero-copy h1 { font-size: 20px !important; }
  .hero .bubble { align-self: stretch; font-size: 14px; padding: 9px 12px; }
  .hero .bubble::after { left: -6px; top: 14px; margin-left: 0; }
  .hero-acts { justify-content: flex-start; }
  .view .sub { font-size: 14px; margin-bottom: 12px; }
  /* sheets and panels: dynamic viewport + safe areas */
  .modal { max-height: calc(100dvh - 24px); }
  .modal.ss, .ap { padding-top: env(safe-area-inset-top); }
  .modal.ss { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal.ss .ss-foot { background: transparent; }
  .ap-body { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .ask-panel { height: min(86dvh, 720px); bottom: calc(8px + env(safe-area-inset-bottom)); }
  .ask-stage { width: 72px; height: 72px; } .ask-stage .hailey { --hs: 72px !important; }
  .ask-id { padding-bottom: 10px; } .ask-head .btn { margin-bottom: 10px; }
  .ask-hint { display: none; }
  .ask-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .ask-chips .chip { flex: none; white-space: nowrap; }
  .pj-drawer .sec { padding: 0; border-radius: 0; }
  .frame-wrap { height: calc(100dvh - 72px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-height: 0; }
  .frame-bar { flex-wrap: nowrap; padding: 6px; gap: 6px; } .frame-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* nested scroll traps */
  .pp-list, .fu-list { max-height: none; overflow: visible; min-height: 0; }
  /* follow-up report summary: status pill gets its own line */
  .fu-rep-h > .grow { flex: 1 1 calc(100% - 80px); }
  .fu-rep-h > .ans { margin-left: 58px; }
  .pj .board { grid-template-columns: repeat(5, 86%); scroll-snap-type: x mandatory; } .pj .col { scroll-snap-align: start; }
}
@media (max-width: 560px) {
  .dir-wrap { overflow: visible; }
  table.dir, .dir tbody, .dir tr, .dir td { display: block; }
  .dir thead { display: none; }
  .dir tr { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
  .dir td { padding: 0; border: 0; font-size: 13px; }
  .dir td:nth-child(1) { grid-column: 1 / -1; font-size: 14px; } .dir td small { max-width: none; }
  .dir td:nth-child(2) { grid-column: 1 / -1; }
  .dir td:nth-child(3), .dir td:nth-child(4), .dir td:nth-child(5) { grid-column: 1 / -1; color: var(--muted); }
  .dir td:nth-child(3):not(:empty)::before { content: "In HALO: "; } .dir td:nth-child(4):not(:empty)::before { content: "Sign-in: "; } .dir td:nth-child(5):not(:empty)::before { content: "Move-in: "; }
  .dir td:nth-child(6) { grid-column: 1 / -1; }
  .pp-dl { grid-template-columns: 1fr; } .pp-dl dd { margin-bottom: 6px; word-break: normal; overflow-wrap: anywhere; }
  .modal-wrap { place-items: end stretch; padding: 0; }
  .modal { width: 100%; border-radius: 24px 24px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal.ss { border-radius: 0; }
  .kpi { padding: 10px 12px; } .kpi b { font-size: 20px; }
  .seg.big { font-size: 13px; padding: 6px 8px; }
}
@media (max-width: 860px) {
  .btn { min-height: 44px; }
  .crumbs a { display: inline-flex; align-items: center; min-height: 32px; }
  .fu-filters input, .fu-filters select, .pj select, .pj input[type=search], .ob-search { min-height: 44px; }
  .dir td:nth-child(6) a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* The install banner steps aside while the menu drawer or H-AI-LEY's Ask panel is open (QA SHELL-1). */
body:has(.nav.open) .pwa-install, body.asking .pwa-install { display: none; }

/* "HALO was updated" refresh notice (pwa.js), all screen sizes. */
.pwa-update { position: fixed; z-index: 70; left: 50%; transform: translateX(-50%); top: calc(10px + env(safe-area-inset-top));
  max-width: calc(100% - 24px); min-height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25);
  font: inherit; font-weight: 600; font-size: 14px; white-space: nowrap; color: #fff; cursor: pointer; box-shadow: var(--shadow);
  background: linear-gradient(180deg, #5cbdf5 0%, #1686CB 55%, #1173b0 100%); }

/* Phone polish from QA TR-7 (mobile thread).
   1. H-AI-LEY's dock tucks to the right edge while you scroll down, so it never sits on a card
      you are reading; she slides back when you scroll up, stop near the top, or reach the end.
   2. Guest Inbox filters stay on one swipeable row instead of wrapping to three lines.
   3. List links (Home morning items, App directory, Team directory and friends) get 44px taps. */
@media (max-width: 860px) {
  .dock { transition: opacity .2s ease, transform .28s cubic-bezier(.2,.8,.2,1); }
  html.dock-peek .dock { transform: translateX(calc(100% - 16px)); opacity: .45; pointer-events: none; }
  html.dock-peek .dock > * { pointer-events: none; }
  html.dock-peek .dock-say { visibility: hidden; }
  .segs.gi-filters { display: flex; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; gap: 4px; }
  .segs.gi-filters .seg { flex: 0 0 auto; white-space: nowrap; scroll-snap-align: start; }
  .td-card li a, .ex-card li a, .ex-card-h a.link, .tm-item a, .fc-item .meta a, .frame-help a, .view td a:not(.btn) { display: inline-flex; align-items: center; min-height: 44px; }
  .tm-contact a { display: flex; align-items: center; min-height: 44px; }
  .rva-rowbtn { min-height: 44px; }
  .td-foot a, .ex-src a { display: inline-flex; align-items: center; min-height: 44px; }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) { .dock { transition: opacity .2s ease; } }

/* == issues (QA Relay): Operations > Issues scrolled sideways 104px on a 390px phone; the page grid sized to its widest child. == */
.fi-page { grid-template-columns: minmax(0, 1fr); }
.fi-page > * { min-width: 0; }
@media (max-width: 860px) { .fi-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
