/* ==========================================================================
   Customer app layer — on top of BFA UI v2 (b/ui/bfa-ui.css)
   --------------------------------------------------------------------------
   Signed-in pages use the kit's canvas app shell (.app.app--canvas: sidebar,
   top bar, grey canvas, white cards). This file is the glue the kit leaves to
   a real page — window scrolling, the tab bar and pinned action bar on
   phones, the page-level sheet backdrop — plus the few customer pieces the
   kit has no opinion on. Tokens and logical properties only, so it stays
   correct in RTL and in the opt-in dark theme.
   ========================================================================== */

body.cx { min-block-size: 100dvh; background: var(--bg-canvas); }

/* The kit's shell scrolls inside .page; the customer app scrolls the window
   (wizards jump back to the top, phone browsers can hide their bars), so the
   sidebar and the top bar stick instead. */
body.cx .app { block-size: auto; min-block-size: 100dvh; overflow: visible; align-items: start; }
body.cx .app__main { grid-column: 2; min-block-size: 100dvh; }
body.cx .page { overflow: visible; }
body.cx .topbar { position: sticky; inset-block-start: 0; z-index: var(--z-header); }
.cx-inner { padding-block-start: 8px; }
.cx--flow .cx-inner { padding-block-start: 24px; }
/* Kit gap: the canvas layer resets input padding and re-adds room for a
   leading icon, but not for a "$" prefix — the amount ran under it. */
.app--canvas .input-wrap__prefix { inset-inline-start: 14px; }
.app--canvas .input-wrap__prefix ~ .input { padding-inline-start: 30px; }
/* KPI rows: on phones a compact row of numbers instead of the kit's stacked list. */
@media (max-width: 767.98px) {
  .cx-kpis.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); gap: 12px; }
  .cx-kpis.kpi-row > .divider-v, .cx-kpis .kpi > .tile { display: none; }
}
@media (max-width: 1023.98px) { .cx-desk-only { display: none !important; } }
.cx-head { padding-inline: 0; }
/* The sidebar brand is a link home (a button in the kit). */
a.workspace { color: var(--text); text-decoration: none; }
@media (min-width: 1024px) {
  body.cx .app > .sidebar { position: sticky; inset-block-start: 0; block-size: 100dvh; }
  .cx-menu-btn, body > .tabbar { display: none; }
}
@media (max-width: 1023.98px) {
  .cx--tab .cx-inner { padding-block-end: calc(112px + env(safe-area-inset-bottom, 0px)); }
  .cx--flow .cx-inner { padding-block-end: calc(180px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 767.98px) {
  body.cx .app--canvas .topbar { padding-inline: 12px; gap: 8px; }
  body.cx .app--canvas .topbar__title { font-size: var(--text-lg); }
  .cx-head { flex-wrap: wrap; }
}

/* Floating tab bar on phones — fixed to the viewport instead of the preview frame. */
body > .tabbar { position: fixed; z-index: var(--z-header); inset-block-end: calc(16px + env(safe-area-inset-bottom, 0px));
  inset-inline-start: 50%; transform: translateX(-50%); }
[dir="rtl"] body > .tabbar { transform: translateX(50%); }

/* Pinned call to action — one ink primary per view. On phones it is fixed to
   the bottom of the screen; on desktop it is a sticky card at the foot of the
   content column, so it never covers the sidebar. */
.phone__cta.cx-ctabar { position: fixed; z-index: var(--z-header); inset-inline: 0; inset-block-end: 0;
  padding-block-end: calc(16px + env(safe-area-inset-bottom, 0px)); border-block-start: 1px solid var(--line); }
.cx-cta { display: flex; flex-direction: column; align-items: stretch; gap: 10px; inline-size: 100%; max-inline-size: 560px; margin-inline: auto; }
.cx-cta > .btn--link { align-self: center; }
.cx-cta__row { display: flex; align-items: center; gap: 12px; }
.cx-cta__row > .btn--block { flex: 1; }
.cx-cta__sum { min-inline-size: 88px; }
@media (min-width: 1024px) {
  .phone__cta.cx-ctabar { position: sticky; inset-inline: auto; margin-block-start: 24px; padding: 16px 20px;
    border: 0; border-radius: var(--radius-2xl); background: var(--bg); box-shadow: var(--shadow-card); }
  .cx-cta { max-inline-size: none; }
}

/* Bottom sheet on a real page: the backdrop the frame used to provide. */
body > .backdrop { position: fixed; inset: 0; z-index: calc(var(--z-modal) - 1); background: var(--backdrop); opacity: 0;
  pointer-events: none; transition: opacity var(--dur-3) var(--ease-out); }
body > .backdrop.is-open { opacity: 1; pointer-events: auto; }
body > .sheet { inset-inline: 0; margin-inline: auto; max-inline-size: 560px; max-block-size: 88dvh;
  padding-block-end: calc(24px + env(safe-area-inset-bottom, 0px)); }
/* A closed sheet waits below the screen; its shadow would show along the
   bottom edge and its links would still take focus. */
body > .sheet:not(.is-open) { visibility: hidden; box-shadow: none;
  transition: transform var(--dur-4) var(--ease-out), visibility 0s linear var(--dur-4); }

/* Signed-out pages — the kit's sign-in recipe: a centred 360 column on white, no card. */
body.cx--auth { background: var(--bg); }
.cx-auth { min-block-size: 100dvh; display: grid; place-items: center; padding: 56px 16px 32px; }
.cx-auth__col { inline-size: min(360px, 100%); }
.cx-auth__mark { inline-size: 36px; block-size: 36px; border-radius: 10px; font-weight: var(--weight-bold); font-size: var(--text-md); }
.cx-auth__theme { position: fixed; z-index: var(--z-header); inset-block-start: max(12px, env(safe-area-inset-top, 0px)); inset-inline-end: 12px; }

/* Notifications menu */
.cx-notif { inline-size: min(320px, calc(100vw - 32px)); }
.cx-notif .menu__item .badge { margin-inline-start: auto; }

/* Wizard — the kit's onboarding pattern (progress steps, one question per
   screen) at every width; on desktop the summary sits beside it. */
.cx-steps-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-block-end: 20px; }
.cx-steps-head .progress-steps { flex: 1; max-inline-size: 280px; }
.cx-step[hidden] { display: none; }
.cx-step__title { margin-block-end: 4px; }
.cx-step__desc { margin-block-end: 20px; }
.cx-hint { margin-block-end: 2px; }
.layout-2 > * { min-inline-size: 0; }
@media (min-width: 1024px) {
  .cx-aside { position: sticky; inset-block-start: 88px; } /* under the 64px canvas top bar */
}
@media (max-width: 1023px) {
  .cx-aside { display: none; }
}

/* Card lists inside the screen */
.cx-stack { display: flex; flex-direction: column; gap: 12px; }
.cx-tap { display: block; color: inherit; text-decoration: none; transition: border-color var(--dur-1) var(--ease-out); }
.cx-tap:hover { text-decoration: none; border-color: var(--line-strong); }
.cx-tap:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Thumbnails of ad creatives (posters are 9:16) */
.cx-poster { inline-size: 40px; block-size: 56px; border-radius: var(--radius-md); object-fit: cover; background: var(--bg-fill) center / cover no-repeat; flex: none; }
.cx-poster--sm { inline-size: 24px; block-size: 34px; border-radius: var(--radius-sm); }

/* Truncate one line */
.cx-trunc { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Kit gap: muted text on ink surfaces is hard-coded white, but --bg-inverse
   turns light in the dark theme. Derive it from --text-inverse instead (the
   .app--canvas copy outranks the canvas layer's own .t-caption.t-3 colour). */
.card--ink :is(.t-2, .t-3, .t-4, .t-micro),
.app--canvas .card--ink :is(.t-2, .t-3, .t-4, .t-micro),
.chip--fill[aria-pressed="true"] .chip__sub,
.choice:is([aria-pressed="true"], .is-selected, :has(> input:checked)) .choice__sub {
  color: color-mix(in srgb, var(--text-inverse) 62%, transparent); }
