/* BCI Tri-Device Sovereign Shell CSS (PC + Tablet Landscape/Portrait + Mobile Phone)
 * Shared across all 14 Baraxia Commercial Apps (04 // BaraxiaScope Flagship First).
 *
 * Canonical Viewport Breakpoints:
 * - PC Desktop & Ultrawide (>= 1200px; 1440x1024 & 3440x1440):
 *     240px Left 4-Step Rail | minmax(0, 1fr) Center Active Step Surface | 340px Sticky Right Summary (max-width: 1680px; margin: 0 auto)
 * - Tablet Landscape (1024px..1199px; 1194x834):
 *     80px Compact Step Rail | minmax(0, 62fr) Center | minmax(0, 38fr) Sticky Right Summary (zero 100%+80px overflow)
 * - Tablet Portrait (768px..1023px; 834x1194):
 *     Sticky Top Live Bid & Margin Summary Bar | 2-Column Touch Form Grid | Full-Width Summary (zero nested card-in-card clutter)
 * - Mobile Phone (<= 767px; 390x844 & 360x800):
 *     Evidence-first Top Sticky Live Bid & Margin Pill visible at scrollY = 0 |
 *     Fixed Thumb-Zone Bottom 4-Step Nav (min-height: 64px + safe-area) with >= calc(88px + safe-area) main bottom clearance |
 *     16px / >=48px Inputs, Selects & Textareas (zero iOS Safari auto-zoom) | 0px Horizontal Page Overflow
 * - Responsive Table-to-Card Reflow (<= 700px):
 *     .bci-responsive-table rows convert cleanly into labeled stacked cards via data-label attributes.
 */

:root {
  --bci-vv-keyboard-inset: 0px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

@media (max-width: 1023px) {
  html {
    scroll-padding-top: 84px;
    scroll-padding-bottom: calc(116px + var(--bci-vv-keyboard-inset, 0px));
  }
}

.bci-tri-shell {
  max-width: 1680px !important;
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px 56px;
}

.bci-tri-shell > *,
.bci-tri-grid,
.bci-tri-grid > *,
.bci-tri-center,
.bci-tri-center > *,
.bci-sticky-summary,
.bxs-card,
.bxs-card > *,
.bxs-form-grid,
.bxs-form-grid > *,
.bxs-field,
.bxs-btn-row,
.bxs-tier-grid,
.bxs-tier-grid > * {
  min-width: 0;
  max-width: 100%;
}

.bxs-form-grid {
  align-items: end;
}

.bci-hero-pricing-wrap {
  width: 100%;
  flex: 1 1 100%;
  min-width: 0;
}

/* Prevent multi-word status outputs using .bci-unit-badge from overflowing pill boxes due to white-space: nowrap */
.bci-tri-shell output.bci-unit-badge,
.bci-tri-shell .bxs-btn-row > .bci-unit-badge {
  white-space: normal !important;
  height: auto !important;
  line-height: 1.35 !important;
  padding: 6px 11px !important;
  border-radius: 10px !important;
  max-width: 100% !important;
  overflow-wrap: anywhere !important;
}

#bxs-spike-output,
#bxs-po-split-table {
  scroll-margin-top: 118px;
}

/* Customer Tablet Margin-Cloak physically hides wholesale cost & internal margin nodes */
[data-cost-cloak="on"] .bci-internal-cost-sensitive,
[data-cost-cloak="on"] .bxs-cloakable-cost {
  display: none !important;
}

/* High-specificity override beating shared light-world [style*="color:#E2E8F0"] (0,4,1) rules
 * so the dark-navy .bci-3tier-header-badge retains crisp APCA Lc >= 95 light ink across all 5 worlds */
:is(#bci-3tier-contrast-lock, html[data-world]) body .bci-3tier-header-badge {
  background-color: #061024 !important;
  background-image: linear-gradient(135deg, #040814 0%, #0B1936 100%) !important;
  border-color: #D4AF37 !important;
  color: #F8FAFC !important;
}

:is(#bci-3tier-contrast-lock, html[data-world]) body .bci-3tier-header-badge > div:first-child {
  color: #FEF08A !important;
}

:is(#bci-3tier-contrast-lock, html[data-world]) body .bci-3tier-header-badge > div:last-child {
  color: #F8FAFC !important;
}

:is(#bci-3tier-contrast-lock, html[data-world]) body .bci-3tier-header-badge span {
  color: #FDE68A !important;
}

/* Top Sticky Live Bid & Margin Pill (hidden on PC & Tablet Landscape where Right Summary is sticky beside content) */
.bci-mobile-bid-pill {
  display: none;
  position: sticky;
  top: 6px;
  z-index: 55;
  background: var(--bci-surface-solid, #FFFDF9);
  border: 2px solid var(--bci-copper, #B8642B);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 8px 20px rgba(28, 19, 14, 0.14);
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.bci-mobile-bid-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.bci-mobile-bid-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bci-copper, #B8642B);
}

.bci-mobile-bid-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.bci-mobile-bid-value {
  font-size: 1.18rem;
  font-weight: 900;
  color: var(--bci-ink-primary, #1C130E);
  font-variant-numeric: tabular-nums slashed-zero;
}

.bci-mobile-bid-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* PC & Ultrawide 3-Column Grid (>= 1200px; 1440x1024 & 3440x1440):
 * 240px Left Rail | minmax(0, 1fr) Center | 340px Sticky Right Summary */
.bci-tri-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
  width: 100%;
}

.bci-step-rail-left {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 10px;
  background: var(--bci-surface-solid, #FFFDF9);
  border: 1.5px solid var(--bci-border-hairline, #DFCBB5);
  border-radius: 14px;
  padding: 12px;
}

.bci-step-rail-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bci-copper-deep, #5E2B0B);
  padding: 2px 4px;
}

html[data-bci-mode="night"] .bci-step-rail-title,
html[data-world="midnight-gold"] .bci-step-rail-title,
html[data-bci-world="midnight-gold"] .bci-step-rail-title {
  color: #FEF08A;
}

.bci-step-rail-btn {
  min-height: 52px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--bci-border-hairline, #DFCBB5);
  background: var(--bci-surface-recess, #F2E9DC);
  color: var(--bci-ink-primary, #1C130E);
  font-weight: 800;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.25;
}

.bci-step-rail-btn.is-active {
  border-color: var(--bci-copper, #B8642B);
  background: var(--bci-surface-solid, #FFFDF9);
  box-shadow: inset 4px 0 0 var(--bci-copper, #B8642B);
}

.bci-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #7C3216;
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

html[data-bci-mode="night"] .bci-step-num,
html[data-world="midnight-gold"] .bci-step-num,
html[data-bci-world="midnight-gold"] .bci-step-num {
  background: #FEF08A;
  color: #040814;
}

.bci-step-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bci-tri-center {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.bci-sticky-summary {
  position: sticky;
  top: 16px;
  min-width: 0;
}

/* PointerEvent On-Glass Signature Pad (Mouse + Stylus/Apple Pencil + Thumb) */
.bci-sig-wrap {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.bci-sig-canvas {
  width: 100%;
  max-width: 100%;
  height: 148px;
  display: block;
  border-radius: 10px;
  border: 2px dashed var(--bci-copper, #B8642B);
  background: #FFFFFF;
  touch-action: none;
  cursor: crosshair;
}

/* Fixed Mobile Bottom Thumb-Zone 4-Step Navigation Bar (hidden on PC & Tablet) */
.bci-mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: var(--bci-surface-solid, #FFFDF9);
  border-top: 2px solid var(--bci-copper, #B8642B);
  box-shadow: 0 -8px 24px rgba(28, 19, 14, 0.16);
  min-height: 64px;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

html[data-bci-keyboard-open="true"] .bci-mobile-bottom-nav {
  transform: translateY(100%);
  pointer-events: none;
}

.bci-bottom-nav-btn {
  min-height: 48px;
  padding: 6px 4px;
  border-radius: 10px;
  border: 1.5px solid var(--bci-border-hairline, #DFCBB5);
  background: var(--bci-surface-recess, #F2E9DC);
  color: var(--bci-ink-primary, #1C130E);
  font-weight: 800;
  font-size: 11.5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 1.1;
}

.bci-bottom-nav-btn.is-active {
  border-color: var(--bci-copper, #B8642B);
  background: var(--bci-copper, #B8642B);
  color: #FFFDF9;
}

html[data-world="midnight-gold"] .bci-bottom-nav-btn.is-active {
  background: #D4AF37;
  color: #040814;
  border-color: #F5E09B;
}

/* Ensure all interactive buttons respect >= 44px touch target minimum */
.bci-tri-shell button,
.bci-tri-shell [role="button"],
.bci-tri-shell a.bxs-btn {
  min-height: 44px;
}

/* ============================================================================
 * TABLET LANDSCAPE (1024px .. 1199px, e.g. 1194x834 iPad Pro 11" Landscape)
 * 80px compact step rail | 62% fluid master | 38% sticky right summary
 * ============================================================================ */
@media (min-width: 1024px) and (max-width: 1199px) {
  .bci-tri-shell {
    padding: 14px 14px 48px;
  }

  .bci-tri-grid {
    grid-template-columns: 80px minmax(0, 62fr) minmax(0, 38fr);
    gap: 12px;
  }

  .bci-step-rail-left {
    padding: 8px 6px;
  }

  .bci-step-rail-title {
    font-size: 9.5px;
    text-align: center;
    padding: 0;
  }

  .bci-step-rail-btn {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 8px 4px;
    gap: 4px;
    font-size: 10.5px;
  }

  .bci-step-label {
    font-size: 10px;
  }

  #btn-cost-cloak-toggle,
  #btn-step4-cloak-toggle {
    min-height: 48px;
  }
}

/* ============================================================================
 * TABLET PORTRAIT (768px .. 1023px, e.g. 834x1194 iPad Pro 11" Portrait)
 * Sticky Top Live Bid & Margin Bar | 2-Column Touch Grid | >= 48px Cloak Button
 * ============================================================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  header.bci-copper-sticky-header {
    position: relative !important;
  }

  .bci-tri-shell {
    padding: 14px 14px 56px;
  }

  .bci-mobile-bid-pill {
    display: flex;
  }

  .bci-tri-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .bci-step-rail-left {
    position: static;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 8px;
  }

  .bci-step-rail-title {
    display: none;
  }

  .bci-step-rail-btn {
    min-height: 48px;
    justify-content: center;
    padding: 8px;
    font-size: 12px;
  }

  .bci-sticky-summary {
    position: static;
  }

  .bxs-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #btn-cost-cloak-toggle,
  #btn-step4-cloak-toggle,
  #btn-mobile-cloak-toggle {
    min-height: 48px;
  }
}

/* ============================================================================
 * MOBILE PHONE (<= 767px, e.g. 390x844 iPhone 14/15/16 Pro & 360x800 Android)
 * Evidence-First Sticky Top Live Bid & Margin Pill visible at scrollY = 0 |
 * Fixed Thumb-Zone Bottom 4-Step Bar (>= 64px) + >= 88px main bottom clearance |
 * 16px / >= 48px Form Controls (zero iOS auto-zoom) | 0px Horizontal Overflow
 * ============================================================================ */
@media (max-width: 767px) {
  header.bci-copper-sticky-header {
    position: relative !important;
    padding: 8px 12px !important;
  }

  .bci-tri-shell {
    padding: 10px 10px calc(108px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .bci-mobile-bid-pill {
    display: flex;
    top: 4px;
  }

  .bci-mobile-bottom-nav {
    display: grid;
  }

  .bci-tri-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .bci-step-rail-left {
    display: none !important;
  }

  .bci-sticky-summary {
    position: static;
  }

  .bxs-card,
  .bxs-hero-bar {
    padding: 12px !important;
  }

  .bxs-form-grid,
  .bxs-tier-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* Zero iOS Safari auto-zoom on focus: 16px font-size & >= 48px height on mobile form controls */
  .bci-tri-shell input:not([type="checkbox"]):not([type="radio"]),
  .bci-tri-shell select,
  .bci-tri-shell textarea {
    font-size: 16px !important;
    min-height: 48px;
  }

  .bxs-safety-check-label {
    min-height: 44px;
    align-items: center;
  }

  .bxs-safety-check-label input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-height: 22px;
  }

  .bxs-btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
    white-space: normal;
    text-align: center;
  }

  .bci-mobile-bid-actions .bxs-btn {
    width: auto;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 12px;
  }

  .bxs-toolbar {
    width: 100%;
  }

  .bxs-toolbar select {
    width: 100%;
    max-width: 100%;
  }
}

/* ============================================================================
 * AUTOMATIC TABLE-TO-CARD REFLOW (<= 700px)
 * Converts .bci-responsive-table rows into labeled stacked cards (data-label)
 * ============================================================================ */
@media (max-width: 700px) {
  .bci-responsive-table {
    display: block;
    width: 100%;
  }

  .bci-responsive-table thead {
    display: none;
  }

  .bci-responsive-table tbody {
    display: grid;
    gap: 10px;
    width: 100%;
  }

  .bci-responsive-table tr {
    display: grid;
    gap: 6px;
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--bci-border-hairline, #DFCBB5);
    border-radius: 10px;
    background: var(--bci-surface-recess, #F2E9DC);
  }

  .bci-responsive-table td {
    display: block;
    width: 100%;
    padding: 2px 0 !important;
    border-bottom: none !important;
    overflow-wrap: anywhere;
  }

  [data-cost-cloak="on"] .bci-responsive-table td.bci-internal-cost-sensitive,
  [data-cost-cloak="on"] .bci-responsive-table td.bxs-cloakable-cost {
    display: none !important;
  }

  .bci-responsive-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--bci-copper, #B8642B);
    margin-bottom: 2px;
  }
}
