/* ═══════════════════════════════════════════════════════════════════════════
 * DRIVER APP LAYOUT B — "Next step first" (Direction B, spec v3.1 §1/§10)
 * B3 + B4 (60, 2026-10-25; 3b #313/#314). g12's 258bda44e was the raw material.
 *
 * Rules:
 *  - Every rule is scoped to html[data-drv-layout="b"] (layout.js sets it), so
 *    Classic gets none of this file.
 *  - Only classes that layoutB.js actually emits are styled.
 *    test-driver-app-layout-b3.js goes RED on any .drv-b-* selector here that
 *    no emitter has.
 *  - Colours come from the driver-app tokens (driver.css / skin-b-driver.css),
 *    so light and dark both work. No inline colours, no emoji.
 *  - Tap targets of 44px or more apply inside B-owned containers only. Classic
 *    screens opened from a B tab keep their own sizes.
 *  - The B tab bar clears the home indicator (env(safe-area-inset-*)), and
 *    #drv-main gets matching bottom padding so nothing hides under it.
 * ═══════════════════════════════════════════════════════════════════════════ */

/* ── Classic's own bar steps aside in B; B's bar takes its place ─────────── */
html[data-drv-layout="b"] nav.drv-tabbar { display: none !important; }
/* WP-B (60): the B header replaces Classic's logo header while B is on (layoutB.js builds #drv-b-header). */
html[data-drv-layout="b"] header.drv-header { display: none !important; }
html[data-drv-layout="b"] body {
  display: flex;
  flex-direction: column;
}
html[data-drv-layout="b"] #drv-main {
  flex: 1 1 0%;
  min-height: 0;
  height: auto;
  padding-top: 16px;
  padding-bottom: calc(var(--tabbar-h, 62px) + env(safe-area-inset-bottom, 0px) + 24px);
  scroll-padding-bottom: calc(var(--tabbar-h, 62px) + env(safe-area-inset-bottom, 0px) + 24px);
}
/* Money codes live under Pay in B (spec D8): Messages shows the conversation only. */
html[data-drv-layout="b"] #view-messages .drv-msg-top-tab[data-top="moneycodes"] { display: none; }

/* ── B tab bar: Load · Docs · Pay · Messages · More ───────────────────────── */
html[data-drv-layout="b"] .drv-b-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; align-items: stretch;
  height: calc(var(--tabbar-h, 62px) + env(safe-area-inset-bottom, 0px));
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  box-sizing: border-box;
  background: var(--emr-bar-bg);
  border-top: 1px solid var(--emr-border);
  box-shadow: inset 0 2px 0 var(--skin-rule, transparent);
}
html[data-drv-layout="b"] .drv-b-tabbar[hidden] { display: none; }
html[data-drv-layout="b"] .drv-b-tab {
  flex: 1; min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  background: transparent; color: var(--emr-text-muted);
  border: 0; border-radius: 0;
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
html[data-drv-layout="b"] .drv-b-tab.is-active {
  background: var(--emr-gold, #FFB70A); color: #111111;
}
html[data-drv-layout="b"] .drv-b-tab-label { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; } /* GO #1341: "Messages" + badge in a 72px slot at 360px */
html[data-drv-layout="b"] .drv-b-badge {
  display: inline-block; min-width: 18px; padding: 1px 5px; box-sizing: border-box;
  border-radius: 999px; background: var(--emr-status-red, #DC2626); color: #FFFFFF;
  font-size: 13px; font-weight: 600; line-height: 16px; text-align: center;
}
html[data-drv-layout="b"] .drv-b-badge--dot { min-width: 0; width: 9px; height: 9px; padding: 0; }

/* ── Sub-tabs (Docs: My documents · Receipts · This load's papers; Pay: Pay · Money codes) ── */
html[data-drv-layout="b"] .drv-b-subnav {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px;
}
html[data-drv-layout="b"] .drv-b-subnav[hidden] { display: none; }
html[data-drv-layout="b"] .drv-b-subtab {
  min-height: 44px; padding: 0 14px;
  background: var(--emr-btn-bg); color: var(--emr-text);
  border: 1px solid var(--emr-border); border-radius: 0;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
html[data-drv-layout="b"] .drv-b-subtab.is-active { border-color: var(--emr-gold, #FFB70A); box-shadow: inset 0 -3px 0 var(--emr-gold, #FFB70A); }

/* ── Home (B2): the next-step card and what sits under it ─────────────────── */
html[data-drv-layout="b"] .drv-b-home,
html[data-drv-layout="b"] #view-b-home {
  display: block;
  padding-bottom: calc(var(--tabbar-h, 62px) + env(safe-area-inset-bottom, 0px) + 24px);
}
html[data-drv-layout="b"] .drv-b-home.hidden,
html[data-drv-layout="b"] #view-b-home.hidden { display: none; }
html[data-drv-layout="b"] .drv-b-stale {
  margin: 0 0 10px; padding: 8px 12px;
  background: var(--emr-surface-sunk); color: var(--emr-text-muted); font-size: 14px;
}
html[data-drv-layout="b"] .drv-b-card {
  margin: 0 0 14px; padding: 18px 16px;
  background: var(--emr-card-bg); color: var(--emr-text);
  border: 1px solid var(--emr-border); border-top: 3px solid var(--emr-gold, #FFB70A);
}
html[data-drv-layout="b"] .drv-b-title { margin: 0 0 8px; font-size: 22px; line-height: 1.25; font-weight: 600; }
html[data-drv-layout="b"] .drv-b-line { margin: 0 0 6px; font-size: 16px; line-height: 1.4; color: var(--emr-text); }
html[data-drv-layout="b"] .drv-b-line.drv-b-addr { font-size: 20px; font-weight: 600; line-height: 1.3; }
html[data-drv-layout="b"] .drv-b-step { margin: 14px 0 0; }
html[data-drv-layout="b"] .drv-b-step-label { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--emr-text-muted); }
html[data-drv-layout="b"] .drv-b-home .drv-b-action {
  display: block; width: 100%; min-height: 56px; margin: 10px 0 0;
  font-size: 17px; font-weight: 600; border-radius: 0;
}
html[data-drv-layout="b"] .drv-b-hint { margin: 10px 0 0; font-size: 14px; color: var(--emr-text-muted); }
html[data-drv-layout="b"] .drv-b-simon {
  margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--emr-hairline);
  font-size: 15px; color: var(--emr-text);
}
html[data-drv-layout="b"] .drv-b-secondary {
  margin: 0 0 12px; padding: 14px 16px;
  background: var(--emr-card-bg); color: var(--emr-text);
  border: 1px solid var(--emr-border);
}
html[data-drv-layout="b"] .drv-b-secondary-title { margin: 0 0 6px; font-size: 17px; font-weight: 600; }

/* ── Intro card (B1): takes over its inline look; 44px stays ─────────────── */
html[data-drv-layout="b"] .drv-b-intro { border-radius: 0; }
html[data-drv-layout="b"] .drv-b-intro-close { min-height: 44px; min-width: 44px; font-size: 15px; font-weight: 600; }

/* ── More (DirB-7 list) ───────────────────────────────────────────────────── */
html[data-drv-layout="b"] .drv-b-more { display: block; }
html[data-drv-layout="b"] .drv-b-more.hidden { display: none; }
html[data-drv-layout="b"] .drv-b-more-title { margin: 0 0 12px; font-size: 22px; font-weight: 600; }
html[data-drv-layout="b"] .drv-b-more-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; min-height: 56px; margin: 0 0 8px; padding: 10px 14px; box-sizing: border-box;
  background: var(--emr-card-bg); color: var(--emr-text);
  border: 1px solid var(--emr-border); border-radius: 0;
  font: inherit; text-align: left; cursor: pointer;
}
html[data-drv-layout="b"] .drv-b-more-main { font-size: 17px; font-weight: 600; }
html[data-drv-layout="b"] .drv-b-more-sub { font-size: 14px; color: var(--emr-text-muted); }

/* ── Pay ▸ Money codes sheet (the only place a code shows in B) ───────────── */
html[data-drv-layout="b"] .drv-b-sheet {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: var(--emr-bg); color: var(--emr-text);
}
html[data-drv-layout="b"] .drv-b-sheet-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--emr-border);
}
html[data-drv-layout="b"] .drv-b-sheet-title { flex: 1; margin: 0; font-size: 20px; font-weight: 600; }
html[data-drv-layout="b"] .drv-b-sheet-close {
  min-height: 44px; min-width: 44px; padding: 0 16px;
  background: var(--emr-btn-bg); color: var(--emr-text);
  border: 1px solid var(--emr-border); border-radius: 0;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
html[data-drv-layout="b"] .drv-b-sheet-body { flex: 1; overflow-y: auto; padding: 16px; }

@media (prefers-reduced-motion: reduce) {
  html[data-drv-layout="b"] .drv-b-tab, html[data-drv-layout="b"] .drv-b-subtab { transition: none; }
}
