/* FazeOne UI guard v1 (3 Dec 2026). Load LAST on every page. Source of truth for button, pill, chip and text rules on the platform.
   Why: David (3 Dec 2026) - off-centre labels, wrapped button labels and squeezed text columns must never ship, anywhere.
   Checked before every deploy by scripts/ui-guard/ui_check.py. Opt out only with data-ui-free (rare, listed in the check report).
   Generated customer sites use the same rules from waxlight-api/ui-guard.js (SITE_GUARD_CSS). */
:root{--ui-tap:44px;--ui-gutter:16px;--ui-pad-x:18px;--ui-chip-gap:10px;--ui-primary:#B83A25;--ui-on-primary:#fff}

/* 1. Text: no hyphen splits, balanced headings, pretty body copy (no one-word last lines), long words wrap instead of overflowing */
html{text-wrap:pretty;-webkit-hyphens:none;hyphens:none;-webkit-text-size-adjust:100%;text-size-adjust:100%}
h1,h2,h3,h4,h5,h6,figcaption,legend,summary,[class*="title"],[class*="headline"]{text-wrap:balance}
p,li,dd,dt,td,th,blockquote,small,label,b,strong,[class*="detail"],[class*="muted"],[class*="lead"],[class*="sub"],[class*="blurb"],[class*="copy"],[class*="note"]{text-wrap:pretty;overflow-wrap:break-word}
h1,h2,h3,h4,p,li,td,th{hyphens:none}

/* 2. Buttons, pills, chips: one centred label, never wraps, never underlined, 44pt tap target.
   Tab bars and two-line row buttons (title + subtitle) are not labels, so they are left alone (they are still checked for edges and clipping). */
:is(button,[role="button"],input[type="submit"],input[type="button"],[class*="btn"],[class*="chip"],[class*="pill"],[class*="cta"]):not([data-ui-free],[class*="link"],[class*="chips"],[class*="pills"],[class*="btns"],[class*="ctas"],[class*="text-"],[class*="stage"],[class*="tagline"],[class*="subtitle"],:has(button,a[class],[class*="btn"],[class*="chip"],[class*="pill"]),:has(>:is(b,strong,small,p,div,h1,h2,h3,h4,h5,h6)),:is(.tabs,.tabbar,[class*="tabbar"],[role="tablist"],.nav-item,[class*="seg"]) *){
  white-space:nowrap!important;text-decoration:none!important;box-sizing:border-box;
  min-height:var(--ui-tap)!important;min-width:var(--ui-tap);max-width:100%;flex-shrink:0;text-align:center;line-height:1.15;
}
/* baseline centring (kept non-important so components that deliberately use grid or a column layout keep it) */
:is(button,[role="button"],input[type="submit"],input[type="button"],[class*="btn"],[class*="chip"],[class*="pill"],[class*="cta"]):not([data-ui-free],[class*="link"],[class*="chips"],[class*="pills"],[class*="btns"],[class*="ctas"],[class*="text-"],[class*="stage"],[class*="tagline"],[class*="subtitle"],:has(button,a[class],[class*="btn"],[class*="chip"],[class*="pill"]),:has(>:is(b,strong,small,p,div,h1,h2,h3,h4,h5,h6)),:is(.tabs,.tabbar,[class*="tabbar"],[role="tablist"],.nav-item,[class*="seg"]) *){
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
}
/* FS-66: the centring rule above outranks the browser's [hidden] (and components' own .x[hidden]{display:none}), so hidden
   buttons were showing (e.g. "Send a WhatsApp template" on every conversation). A hidden button stays hidden. */
[hidden]:is(button,[role="button"],input[type="submit"],input[type="button"],[class*="btn"],[class*="chip"],[class*="pill"],[class*="cta"]){display:none!important}
/* labels with an icon keep the icon the same size and never squash it */
:is(button,[class*="btn"],[class*="chip"],[class*="pill"]) svg,:is(button,[class*="btn"],[class*="chip"],[class*="pill"]) img{flex:none}
/* primary Waxlight button: AA contrast for the white label */
.wx-btn:not(.wx-btn--plum,.wx-btn--gold,.wx-btn--ghost,.wx-btn--white,.wx-btn--glass,[disabled]){background:var(--ui-primary);color:var(--ui-on-primary)}
.wx-btn:not(.wx-btn--plum,.wx-btn--gold,.wx-btn--ghost,.wx-btn--white,.wx-btn--glass,[disabled]):hover{background:#9F2F1D}

/* 3. Chip rows: an even grid or a single scroller, never ragged wrapping */
:is([class*="chips"],[class*="pills"],.ui-chips):not(.ui-rail,[data-ui-free]){display:grid!important;grid-template-columns:minmax(0,1fr);gap:var(--ui-chip-gap);align-items:stretch}
:is([class*="chips"],[class*="pills"],.ui-chips):not(.ui-rail)>*{width:100%;min-width:0}
.ui-rail{display:flex!important;flex-wrap:nowrap!important;overflow-x:auto;gap:var(--ui-chip-gap);scroll-snap-type:x proximity;-webkit-overflow-scrolling:touch;scrollbar-width:none}
.ui-rail::-webkit-scrollbar{display:none}.ui-rail>*{flex:none;scroll-snap-align:start}

/* 4. Rows with an icon or avatars and a text block: the text never gets squeezed into a sliver. Wrap the row, give the text a real minimum width. */
.ui-row{display:flex;flex-wrap:wrap;align-items:center;gap:12px}
.ui-row>.ui-text,.ui-text{flex:1 1 14ch;min-width:min(14ch,100%)}

/* 5. Tables and definition lists on phones read as stacked rows, not 100px columns */
@media (max-width:640px){
  table.ui-stack,table.ui-stack tbody,table.ui-stack tr,table.ui-stack td,table.ui-stack th{display:block;width:100%}
  table.ui-stack tr{padding:10px 0;border-bottom:1px solid rgba(0,0,0,.08)}
  table.ui-stack td,table.ui-stack th{border:0;padding:2px 0}
}

/* 6. Page gutters: nothing sits on the screen edge */
.ui-gutter{padding-inline:max(var(--ui-gutter),env(safe-area-inset-left)) max(var(--ui-gutter),env(safe-area-inset-right))}

/* 7. Runtime helpers (ui-guard.js sets these; without JS the safe defaults above apply: chip groups stack as equal full-width rows) */
:is([class*="chips"],[class*="pills"],.ui-chips):not(.ui-rail,[data-ui-free]){grid-template-columns:repeat(var(--ui-cols,1),minmax(0,1fr))}
[data-ui-row]{flex-wrap:wrap!important}
[data-ui-text]{flex:1 1 14ch!important;min-width:min(14ch,100%)!important}

/* 8. Tables never squeeze a column into a sliver: on phones they scroll sideways with readable column widths */
@media (max-width:640px){
  table:not(.ui-stack,[data-ui-free]){display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
  table:not(.ui-stack,[data-ui-free]) :is(td,th){min-width:190px}
}

/* 9. Floating hero chips on the marketing pages keep a 16px gutter on phones and a balanced icon inset */
@media (max-width:480px){
  .chip.c1,.chip.c3{left:16px}.chip.c2,.chip.c4{right:16px}
  .chip{padding:6px 14px 6px 8px}
}

/* Desktop tables (including stacked-on-phone legal tables): never a sliver first column. */
@media (min-width:641px){
  table:not([data-ui-free]) :is(td,th){min-width:16ch}
  .lg-table th:first-child,.lg-table td:first-child{width:32%;min-width:18ch}
}
