/*!
 * house-safe.css: layout countermeasures for the In House system (web and Electron apps).
 * Load it before the app's own styles. It changes no colours; it only prevents shifts, overlaps
 * and text poking out of its space. Spec: Apps project → claude/house-motion.md, "Layout safety".
 */

/* 1. STATE CHANGES NEVER CHANGE SIZE
   Selected / hover / pressed / loading states change colour, fill or opacity only.
   A label may turn bold on selection only if it reserves its bold width first:
   add class "hs-stable" and data-label="<same text>" (house-guard.js stabilize() does this for you). */
.hs-stable { display: inline-grid; justify-items: center; }
.hs-stable { flex-shrink: 0; }   /* in a crowded row, scroll the row (hs-scroll-x) instead of squeezing labels */
.hs-stable::after {
  content: attr(data-label);
  font-weight: var(--hs-bold, 600);
  height: 0; visibility: hidden; pointer-events: none; user-select: none;   /* no overflow:hidden here: it would drop the reserved width when space is tight */
  white-space: nowrap;
}
/* Borders exist in every state so a selected border never adds width. */
.hs-ring { border: 1px solid transparent; }

/* 2. TEXT STAYS INSIDE ITS BOX */
.hs-clip  { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }   /* one line, ellipsis; give it a title attribute */
.hs-wrap  { min-width: 0; overflow-wrap: anywhere; }                                          /* names, titles, user text */
.hs-clamp-2, .hs-clamp-3 { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; }
.hs-clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.hs-clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }
/* Every child of a flex/grid row that holds text can shrink. Opt in per container: */
.hs-row > *, .hs-grid > * { min-width: 0; }
/* Changing numbers keep their width. */
.hs-num { font-variant-numeric: tabular-nums; }

/* 3. CONTROLS THAT CAN RUN OUT OF ROOM SCROLL INSIDE THEMSELVES (never push the page wider)
   Segmented controls and tab bars: when the options don't fit, they scroll sideways inside the capsule.
   The control model says when to switch to a dropdown chip instead (5+ options on phones). */
.hs-scroll-x { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.hs-scroll-x::-webkit-scrollbar { display: none; }
button, .hs-btn { max-width: 100%; }

/* 4. FOCUS RINGS STAY INSIDE CAPSULES (no rings poking out of a segmented control or the dock) */
.hs-inset-focus:focus-visible,
.hs-inset-focus :focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: -3px; }

/* 5. FLOATING THINGS NEVER COVER CONTENT
   Pages under the floating pill dock reserve its space at the bottom. */
:root { --hs-dock-space: calc(64px + 16px + 16px + env(safe-area-inset-bottom, 0px)); }
.hs-under-dock { padding-bottom: var(--hs-dock-space); scroll-padding-bottom: var(--hs-dock-space); }
/* Sticky headers reserve their height for anchor jumps and focus scrolling. */
.hs-under-header { scroll-padding-top: var(--hs-header-space, 64px); }

/* 6. ANIMATION NEVER MOVES LAYOUT
   house-motion.js only animates translate, scale and opacity (plus the width of selection indicators,
   which are absolutely positioned). Those never push neighbours. Keep it that way in hand-written CSS. */

/* 7. MEDIA KEEPS ITS SHAPE */
img, video, canvas, svg { max-width: 100%; }
.hs-media { display: block; width: 100%; height: auto; object-fit: cover; }
