/* CPQ core shell, shared by every screen: Halo on top, Stream in the middle, Omnibar at the bottom.
   Every colour, size and font comes from hba-tokens.css. Designed at 360 x 800. See DESIGN-NOTES.md. */

:root {
  --shell-gutter: var(--hba-space-4);      /* 16 px side margin */
  --halo-h: var(--hba-size-touch);         /* compact Halo strip, 44 px */
  --omni-h: 72px;                          /* Omnibar: 56 px main action + 8 px each side */
  --omni-main-h: var(--hba-size-touch-worker); /* 56 px */
  --omni-round: 48px;                      /* Back and Search */
  /* Motion, as proposed in docs/workstreams/cpq/MOTION.md section 2. Held here until the brand package carries them. */
  --motion-press: 100ms; --motion-fast: var(--hba-duration-fast); --motion-base: 200ms; --motion-slow: 280ms; --motion-draw: 420ms;
  --motion-fade-reduced: 120ms;
  --ease-enter: cubic-bezier(0, 0, 0.2, 1); --ease-exit: cubic-bezier(0.4, 0, 1, 1); --ease-move: cubic-bezier(0.4, 0, 0.2, 1);
  --foot-h: 125px;                         /* 1 line + 8 + summary 24 + 8 + Omnibar 72 + 12 */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--hba-surface-alt); color: var(--hba-text-primary);
  font-family: var(--hba-font-family-sans); font-size: var(--hba-type-size-body); line-height: var(--hba-type-leading-body);
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
input, textarea, select, [contenteditable] { -webkit-user-select: text; user-select: text; touch-action: manipulation; }
:focus-visible { outline: var(--hba-focus-width) solid var(--hba-focus-ring); outline-offset: var(--hba-focus-offset); }
.icon { width: var(--hba-icon-medium); height: var(--hba-icon-medium); flex: none; }
.icon-s { width: var(--hba-icon-small); height: var(--hba-icon-small); flex: none; }
.icon-l { width: var(--hba-icon-large); height: var(--hba-icon-large); flex: none; }

/* The frame. Halo and footer float over one scrolling layer, so content passes beneath them. Their solid look is here; glass.css upgrades it. */
.app {
  position: relative; overflow: hidden; height: 100vh; height: 100dvh; max-width: 600px; margin: 0 auto;
  background: var(--hba-surface-page);
}
.scroll {
  position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  padding-top: calc(var(--halo-h) + var(--hba-border-thin) + env(safe-area-inset-top, 0px));
  padding-bottom: calc(var(--foot-h) + env(safe-area-inset-bottom, 0px) + var(--kb-pad, 0px));
  scroll-padding-top: calc(var(--halo-h) + 20px);
  scroll-padding-bottom: calc(var(--foot-h) + 32px + var(--kb-pad, 0px));
}

/* ---------- Halo (compact strip) ---------- */
.halo {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  height: calc(var(--halo-h) + env(safe-area-inset-top, 0px) + var(--hba-border-thin));
  padding: env(safe-area-inset-top, 0px) var(--hba-space-2) 0;
  display: flex; align-items: center;
  background: var(--hba-surface-page); border-bottom: var(--hba-border-thin) solid var(--hba-line-decorative);
}
/* Every Halo control is a 44 x 44 tap area; what you see inside it is smaller */
.halo-hit {
  height: var(--hba-size-touch); min-width: var(--hba-size-touch); flex: none; padding: 0;
  display: grid; place-items: center; background: none; border: 0; border-radius: 22px;
}
.halo-me {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--hba-brand-surface); color: var(--hba-brand-on-surface);
  font-size: var(--hba-type-size-small); font-weight: var(--hba-font-weight-bold);
}
.halo-rule { width: var(--hba-border-thin); height: 24px; background: var(--hba-line-decorative); flex: none; margin: 0 var(--hba-space-1); }
/* Clients scroll sideways; You and Home stay put */
.halo-clients { flex: 1; min-width: 0; display: flex; align-items: center; overflow-x: auto; scrollbar-width: none; }
.halo-clients::-webkit-scrollbar { display: none; }
.halo-home { color: var(--hba-action-link); }

/* The client this screen is about: a pill with the name */
.halo-chip {
  height: 36px; padding: 0 var(--hba-space-3) 0 var(--hba-space-1); border-radius: 18px;
  display: flex; align-items: center; gap: var(--hba-space-2); white-space: nowrap;
  background: var(--hba-surface-selected); border: var(--hba-border-thick) solid var(--hba-action-primary);
  font-size: var(--hba-type-size-small); font-weight: var(--hba-font-weight-bold);
}
.halo-chip .av {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--hba-surface-page); border: var(--hba-border-thin) solid var(--hba-line-decorative);
}
/* Other clients: a ring. "Due" is a thick ring plus a badge, never colour alone */
.halo-ring {
  position: relative; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--hba-surface-page); border: var(--hba-border-thick) solid var(--hba-line-control);
  font-size: var(--hba-type-size-small); font-weight: var(--hba-font-weight-bold);
}
.halo-ring.due { border: 3px solid var(--hba-status-warning); }
.halo-ring .badge {
  position: absolute; top: -5px; right: -6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--hba-status-warning); color: var(--hba-surface-page);
  box-shadow: 0 0 0 2px var(--hba-surface-page);
}

/* ---------- Screen header ---------- */
.head { padding: var(--hba-space-3) var(--shell-gutter) var(--hba-space-2); }
.head .meta { font-size: var(--hba-type-size-small); line-height: 1.35; color: var(--hba-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head h1 { margin: 0; font-size: var(--hba-type-size-h2); line-height: var(--hba-type-leading-heading); font-weight: var(--hba-font-weight-bold); }

/* ---------- Stream ---------- */
.stream { padding: 0 var(--shell-gutter); }

/* ---------- Footer: running summary, then the Omnibar ---------- */
.foot {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: var(--hba-space-2) var(--hba-space-3) calc(var(--hba-space-3) + env(safe-area-inset-bottom, 0px));
  display: grid; gap: var(--hba-space-2);
  background: var(--hba-surface-page); border-top: var(--hba-border-thin) solid var(--hba-line-decorative);
}
.summary {
  height: 24px; display: flex; justify-content: center; align-items: center; column-gap: var(--hba-space-2);
  font-size: var(--hba-type-size-small); white-space: nowrap; overflow: hidden;
}
.summary b { font-weight: var(--hba-font-weight-bold); }
.summary .muted { color: var(--hba-text-muted); }

/* Progress ring (owner, 2026-11-13; it replaced a row of dots the same day): a 32 px solid disc sitting on the top
   edge of the bar at its start. Drawn by js/steps.js. It is its own piece on top of the bar, never inside it and
   never glass. Touches pass through to the button beneath. A screen with a ring carries .has-ring, which opens the
   gap above the bar a little so the ring clears the summary line. */
.omni-row { position: relative; }
.ring-step {
  position: absolute; z-index: 1; top: -16px; inset-inline-start: calc(var(--omni-main-h) + var(--hba-space-3) + 18px);
  width: 32px; height: 32px; border-radius: 50%; pointer-events: none; box-shadow: var(--hba-elevation-card);
}
.ring-step svg { display: block; }
.ring-disc { fill: var(--hba-surface-page); stroke: var(--hba-line-decorative); stroke-width: 1; }
/* Stage by colour and thickness together. To come: grey, thinnest. Done: brand, medium. This page: near black, thickest.
   Square ends, so the gaps between pieces stay open at this size. Each colour is 3 to 1 or better against the disc. */
.ring-piece { fill: none; stroke: var(--hba-line-control); stroke-width: 2; stroke-linecap: butt; }
.ring-piece.done { stroke: var(--hba-action-primary); stroke-width: 3; }
.ring-piece.now { stroke: var(--hba-text-primary); stroke-width: 4.5; }
.ring-num { fill: var(--hba-text-primary); font-family: var(--hba-font-family-sans); font-size: var(--hba-type-size-small); font-weight: var(--hba-font-weight-bold); }
.ring-full { fill: var(--hba-action-primary); }
.ring-tick { fill: none; stroke: var(--hba-action-on-primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.has-ring { --foot-h: 133px; }
.has-ring .foot { gap: var(--hba-space-4); }
/* Arriving on a page: the new piece is drawn in once. Not when the phone asks for less motion. */
@media (prefers-reduced-motion: no-preference) {
  .ring-step.arrive .ring-piece.now { animation: ring-sweep 420ms ease-out both; }
}
@keyframes ring-sweep { from { stroke-dasharray: 0 100; } }

.omnibar {
  height: var(--omni-h); padding: var(--hba-space-2); border-radius: calc(var(--omni-h) / 2);
  display: flex; align-items: center; gap: var(--hba-space-2);
  background: var(--hba-surface-raised); border: var(--hba-border-thin) solid var(--hba-line-decorative);
  box-shadow: var(--hba-elevation-card);
}
/* Three parts in a row (owner, 2026-11-13): a round button at the far left (Back; on Home, Add), the bar with the
   one main action, and a round button at the far right (.omni-side: Search, or whatever that screen needs).
   Both round buttons are apart from the bar, so each is real glass with its own blur. */
.omni-row { display: flex; align-items: center; gap: var(--hba-space-3); }
.omni-row .omnibar { flex: 1; min-width: 0; }
.omni-back, .omni-side {
  width: var(--omni-main-h); height: var(--omni-main-h); flex: none; border-radius: 50%; padding: 0;
  display: grid; place-items: center; background: var(--hba-surface-raised);
  border: var(--hba-border-thin) solid var(--hba-line-control); box-shadow: var(--hba-elevation-card);
  transition: transform var(--hba-duration-fast);
}
.omni-back:active, .omni-side:active { background: var(--hba-action-secondary-pressed-surface); transform: scale(0.96); }
/* Search, and Add on Home: round buttons inside the bar */
.omni-round {
  width: var(--omni-round); height: var(--omni-round); flex: none; border-radius: 50%; padding: 0;
  display: grid; place-items: center; background: var(--hba-surface-page);
  border: var(--hba-border-thin) solid var(--hba-line-control);
}
.omni-round:active { background: var(--hba-action-secondary-pressed-surface); }
/* Pressing gives a little, like a real key. Off when the phone asks for less motion. */
.omni-round, .omni-main { transition: transform var(--hba-duration-fast); }
.omni-round:active, .omni-main:active { transform: scale(0.96); }
/* The one main action */
.omni-main {
  flex: 1; min-width: 0; height: var(--omni-main-h); border-radius: calc(var(--omni-main-h) / 2); border: 0;
  padding: 0 var(--hba-space-3); background: var(--hba-action-primary); color: var(--hba-action-on-primary);
  box-shadow: none;
  font-size: var(--hba-type-size-large); font-weight: var(--hba-font-weight-bold);
  /* A label that does not fit runs to two centred lines; it is never cut with "..." */
  line-height: 1.15; text-align: center; text-wrap: balance; overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; align-content: center;
}
.omni-main:active { background: var(--hba-action-primary-pressed); }
/* Search opens in place: the main action steps aside, the bar becomes a field, and Search becomes Close */
.omni-field {
  display: none; flex: 1; min-width: 0; height: var(--omni-main-h); padding: 0 var(--hba-space-4); border-radius: calc(var(--omni-main-h) / 2);
  border: var(--hba-border-thin) solid var(--hba-line-control); background: var(--hba-surface-page); color: var(--hba-text-primary);
  font-family: inherit; font-size: var(--hba-type-size-input);
}
.omnibar.searching .omni-main { display: none; }
.omnibar.searching .omni-field { display: block; }
.omni-main[aria-disabled="true"] {
  background: var(--hba-control-disabled-surface); color: var(--hba-control-disabled-text);
  font-size: var(--hba-type-size-body);
}

/* ---------- Toast: says what happened and offers Undo. Never used for errors ---------- */
.toast {
  position: fixed; left: 50%; transform: translate(-50%, 8px); z-index: 10;
  bottom: calc(var(--omni-h) + 60px + env(safe-area-inset-bottom, 0px));
  width: min(calc(100% - 24px), 456px); min-height: 52px;
  padding: var(--hba-space-1) var(--hba-space-2) var(--hba-space-1) var(--hba-space-4); border-radius: var(--hba-radius-card);
  background: var(--hba-text-primary); color: var(--hba-surface-page); box-shadow: var(--hba-elevation-dialog);
  display: flex; align-items: center; justify-content: space-between; gap: var(--hba-space-3);
  font-size: var(--hba-type-size-small); opacity: 0; pointer-events: none;
  transition: opacity var(--hba-duration-base), transform var(--hba-duration-base);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button {
  flex: none; min-height: var(--hba-size-touch); min-width: var(--hba-size-touch); padding: 0 var(--hba-space-3);
  background: none; border: 0; color: inherit; font-size: var(--hba-type-size-body); font-weight: var(--hba-font-weight-bold); text-decoration: underline;
}

/* ---------- Small phones, and normal phones with larger text ----------
   Under 340 px of width the two round buttons shrink to 48 px and the main label drops to 16 px, so a page name
   such as "Check the scope" still fits, on two lines if it must. From the scope wireframes' small-screen rules. */
@media (max-width: 339px) {
  .omni-back, .omni-side { width: 48px; height: 48px; }
  .omni-main { font-size: var(--hba-type-size-body); }
  .ring-step { inset-inline-start: calc(48px + var(--hba-space-3) + 14px); }
}

/* ---------- Larger screens: the layout is reorganised by the room it has, not just scaled ----------
   Owner, 2026-11-13: "when pixel density is more some screens are larger so we need to resizes and redo the layoiut
   and organisation". The steps follow the Android and Material window sizes (600 and 840 px), proposed by the
   scope engine session; the shell's part of each step is here, each screen adds its own.
     under 340   small-phone rules (above)
     340 to 599  as designed: the page fills the width
     600 to 839  one centred column 640 px wide; the bottom row stays thumb-sized in the middle, not stretched
     840 and up  the same column for now; a second pane is each screen's own design, not built yet
   The bar stays at the bottom at every size. */
@media (min-width: 600px) {
  .app { max-width: 640px; }
  .omni-row { width: 100%; max-width: 456px; margin-inline: auto; }
  .head, .stream { padding-inline: var(--hba-space-5); }
}

/* ---------- Condensed view (owner, 2026-11-14: switched on in Me) ----------
   Labels/values 14 px, secondary hints/units 12 px, tighter spacing, targets still >= 44 px. */
:root[data-density="condensed"] body { font-size: var(--hba-type-size-small); }
:root[data-density="condensed"] .head { padding-block: var(--hba-space-2) var(--hba-space-1); }
:root[data-density="condensed"] .head h1 { font-size: var(--hba-type-size-h3); }
:root[data-density="condensed"] .head .meta,
:root[data-density="condensed"] .summary { font-size: 12px; }
