/* BSP 3-Tier Zoom Magnifier and mobile reflow, BUILD_ADDON_243 run B.
   Standard 100% (16px) / Medium 130% (20.8px) / Large 165% (26.4px).
   Sizes come from the root rem only. Never scale transforms or body zoom. */

html[data-bsp-zoom="standard"] { font-size: 16px !important; }
html[data-bsp-zoom="medium"] { font-size: 20.8px !important; }
html[data-bsp-zoom="large"] { font-size: 26.4px !important; }

html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) body { font-size: 1rem; }
html, body { max-width: 100%; }
html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) body { overflow-x: clip; }

/* Standard tier keeps 44px touch targets on primary controls. */
html[data-bsp-zoom="standard"] :is(main, .page-section, [role="dialog"]) :is(button, .btn-modern, a.btn-modern, select) { min-height: 44px; }

/* Medium tier */
html[data-bsp-zoom="medium"] :is(main, .page, .page-section, [role="dialog"], #bsp-portal-topbar) :is(button, input, select, textarea, .btn-modern) {
  font-size: max(19px, 0.95rem) !important;
  min-height: 50px;
}
html[data-bsp-zoom="medium"] :is(main, .page-section, [role="dialog"]) :is(p, li, td, label, dd, summary) { font-size: max(19px, 0.95rem); line-height: 1.55; }

/* Large tier: noticeably bigger and bolder */
html[data-bsp-zoom="large"] :is(main, .page, .page-section, [role="dialog"]) :is(button, input, select, textarea, .btn-modern) {
  font-size: 23px !important;
  font-weight: 700;
  min-height: 58px;
  max-width: 100%;
}
html[data-bsp-zoom="large"] :is(main, .page-section, [role="dialog"]) :is(p, li, td, label, dd, summary, blockquote) {
  font-size: max(25px, 0.95rem) !important;
  line-height: 1.55;
}
html[data-bsp-zoom="large"] :is(main, .page-section, [role="dialog"]) :is(h1) { font-size: clamp(32px, 1.45rem, 38px) !important; line-height: 1.2; }
html[data-bsp-zoom="large"] :is(main, .page-section, [role="dialog"]) :is(h2) { font-size: clamp(30px, 1.3rem, 36px) !important; line-height: 1.22; }
html[data-bsp-zoom="large"] :is(main, .page-section, [role="dialog"]) :is(h3, h4) { font-size: clamp(28px, 1.15rem, 32px) !important; line-height: 1.25; }

html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(main, .page, .page-section, [role="dialog"]) :is(input[type="checkbox"], input[type="radio"], input[type="range"]) {
  min-height: 0;
  width: auto;
}
html[data-bsp-zoom="large"] :is(input[type="checkbox"], input[type="radio"]) { transform: none; width: 26px; height: 26px; }

/* Phones and small tablets at Medium or Large: reflow everything into one clean column. */
@media (max-width: 768px) {
  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(main, .page, .page-section, [role="dialog"]) {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(main, .page, .page-section, [role="dialog"], footer) :is(
    .bsp-zoom-stack, [style*="grid-template-columns"], [style*="display: grid"], [style*="display:grid"],
    [style*="display: flex"], [style*="display:flex"], .bsp-bento-grid, .bento-grid, .grid, .card-grid,
    .bsp-onepush-actions, .bsp-onepush-select-bar, .hero-actions, .hero-buttons, .cta-row, .button-row,
    .pricing-grid, .pricing-cards, .quiz-options, .bsp-quiz-options, .bsp-quiz-grid, .registry-toolbar,
    .bsp-registry-toolbar, .input-row, .form-row, .footer-grid, .footer-columns) {
    grid-template-columns: minmax(0, 1fr) !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    box-sizing: border-box;
  }

  /* Checkbox and radio rows keep the box beside its words. */
  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(main, .page-section, [role="dialog"]) label:is([style*="display: flex"], [style*="display:flex"]) {
    flex-direction: row !important;
    align-items: flex-start !important;
  }

  /* Small inline groups (chips, badges, toggle pairs) may stay in a row but must wrap. */
  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(.bsp-zoom-selector-buttons, .bsp-portal-topbar-tools, .bsp-portal-topbar-links, .bsp-onepush-row) {
    flex-direction: row !important;
    flex-wrap: wrap !important;
  }

  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(main, .page, .page-section, [role="dialog"], footer) > *,
  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(main, .page-section, [role="dialog"]) :is([style*="width:"], [style*="width :"], [style*="min-width"], [style*="flex:"], [style*="flex :"]) {
    max-width: 100% !important;
    min-width: 0 !important;
    flex-basis: auto !important;
  }

  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(main, .page, .page-section, [role="dialog"]) :is(button, a, input, select, textarea, .btn-modern, h1, h2, h3, h4, p, li, span, label, td, th) {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    text-overflow: clip !important;
  }

  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(main, .page-section, [role="dialog"]) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(main, .page-section, [role="dialog"]) :is(img, video, iframe, canvas, svg) { max-width: 100% !important; height: auto; }
  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(main, .page-section, [role="dialog"]) iframe { aspect-ratio: 16 / 9; }

  /* Wide tables scroll inside their own card, never the whole page. */
  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(main, .page-section, [role="dialog"]) table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Sticky bars stay proportionate: chips scroll sideways inside the bar instead of growing it. */
  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) :is(#bsp-master-top-bar, .top-bar) {
    max-height: 32dvh;
    overflow-y: auto;
    overflow-x: hidden;
  }
  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) #bsp-floating-dock {
    max-height: 24dvh;
    max-width: 100vw;
    overflow-x: auto;
    overflow-y: hidden;
  }
  html:is([data-bsp-zoom="medium"], [data-bsp-zoom="large"]) #bsp-portal-topbar .bsp-portal-topbar-tools {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  html[data-bsp-zoom="medium"] body { padding-bottom: calc(220px + env(safe-area-inset-bottom, 0px)) !important; }
  html[data-bsp-zoom="medium"] { scroll-padding-bottom: 220px; }
  html[data-bsp-zoom="large"] body { padding-bottom: calc(330px + env(safe-area-inset-bottom, 0px)) !important; }
  html[data-bsp-zoom="large"] { scroll-padding-bottom: 330px; }
}

/* Every modal and drawer scrolls inside itself. */
:is(#bsp-admin-onepush-modal .bsp-onepush-card, #loginModal > *, #auth-modal > *, #bsp-universal-search-modal > *, #bsp-site-search-modal > *, #bsp-settings-hub-modal > *, #bsp-install-guide-modal .bsp-install-guide-card) {
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
:is(#side-nav, #tim-drawer-window) { max-height: 100dvh; max-width: 100vw; }
#side-nav { overflow-y: auto; overscroll-behavior: contain; }

/* Tim drawer header: close button pinned top right, never on top of the clock strip. */
#tim-drawer-window #bsp-tim-close-btn { flex: 0 0 auto; margin-left: auto; position: relative; z-index: 2; }
#tim-drawer-window #tim-live-clock-bar { flex-wrap: wrap; gap: 4px 10px; }

/* Language pill and menu */
.bsp-lang-pill { cursor: pointer; white-space: nowrap; }
#bsp-lang-menu {
  position: fixed;
  z-index: 100600;
  background: #111317;
  border: 1px solid #4B5563;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 16px;
}
#bsp-lang-menu[hidden] { display: none; }
#bsp-lang-menu button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #262A33;
  color: #F3F4F6;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
#bsp-lang-menu button:hover, #bsp-lang-menu button:focus-visible { border-color: #9CA3AF; outline: none; }
#bsp-lang-menu button[aria-checked="true"] { border-color: #CBD5E1; background: #2F3540; }
#bsp-lang-menu button[aria-checked="true"]::after { content: "✓"; margin-left: 10px; }
#bsp-lang-menu .bsp-lang-code { color: #9CA3AF; font-size: 0.85em; margin-left: auto; padding-left: 12px; }
html[data-amber-trim="on"] #bsp-lang-menu { border-color: #D99B26; }
html[data-bsp-zoom="medium"] #bsp-lang-menu { font-size: 19px; }
html[data-bsp-zoom="large"] #bsp-lang-menu { font-size: 22px; }
html[data-bsp-zoom="large"] #bsp-lang-menu button { min-height: 56px; }

/* Text size confirmation pill */
#bsp-zoom-toast {
  position: fixed;
  left: 50%;
  top: calc(12px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  z-index: 100650;
  background: #262A33;
  color: #F3F4F6;
  border: 1px solid #6B7280;
  border-radius: 999px;
  padding: 10px 18px;
  font: 700 16px/1.2 Inter, system-ui, sans-serif;
  max-width: calc(100vw - 24px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
#bsp-zoom-toast.is-visible { opacity: 1; }

/* Settings Hub selector */
.bsp-zoom-selector { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
.bsp-zoom-selector-buttons { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 220px; }
.bsp-zoom-selector-buttons button { flex: 1 1 90px; min-height: 44px; }
.bsp-zoom-selector-buttons button[aria-pressed="true"] { border-color: #CBD5E1 !important; background: #2F3540 !important; color: #F9FAFB !important; }
html[data-amber-trim="on"] .bsp-zoom-selector-buttons button[aria-pressed="true"] { border-color: #D99B26 !important; }

/* Standalone page top bar */
#bsp-portal-topbar {
  position: sticky;
  top: 0;
  z-index: 100200;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding: 6px 10px;
  padding-top: calc(6px + env(safe-area-inset-top, 0px));
  background: #111317;
  border-bottom: 1px solid #374151;
  font: 600 14px/1.2 Inter, system-ui, -apple-system, sans-serif;
  max-width: 100vw;
  max-height: 34dvh;
  box-sizing: border-box;
  overflow-y: auto;
}
html[data-amber-trim="on"] #bsp-portal-topbar { border-bottom-color: #D99B26; }
.bsp-portal-topbar-links, .bsp-portal-topbar-tools { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
#bsp-portal-topbar .bsp-portal-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #4B5563;
  background: #262A33;
  color: #F3F4F6;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
  margin: 0;
}
#bsp-portal-topbar .bsp-portal-chip:hover, #bsp-portal-topbar .bsp-portal-chip:focus-visible { border-color: #9CA3AF; outline: none; }
#bsp-portal-topbar .bsp-portal-chip[aria-pressed="true"] { border-color: #CBD5E1; background: #2F3540; }
html[data-bsp-zoom="medium"] #bsp-portal-topbar { font-size: 16px; }
html[data-bsp-zoom="large"] #bsp-portal-topbar { font-size: 18px; }
html[data-bsp-zoom="large"] #bsp-portal-topbar .bsp-portal-chip { min-height: 48px; }
@media (max-width: 420px) {
  .bsp-portal-topbar-tools { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
}

/* Daytime Sunrise high-contrast mode for the new controls */
html[data-theme="light"] #bsp-portal-topbar { background: #F1F5F9; border-bottom-color: #92400E; }
html[data-theme="light"] #bsp-portal-topbar .bsp-portal-chip,
html[data-theme="light"] #bsp-lang-menu button { background: #FFFFFF; color: #111827; border-color: #94A3B8; }
html[data-theme="light"] #bsp-portal-topbar .bsp-portal-chip[aria-pressed="true"],
html[data-theme="light"] #bsp-lang-menu button[aria-checked="true"] { border-color: #92400E; background: #FEF3C7; color: #111827; }
html[data-theme="light"] #bsp-lang-menu { background: #F1F5F9; border-color: #92400E; }
html[data-theme="light"] #bsp-lang-menu .bsp-lang-code { color: #475569; }
html[data-theme="light"] #bsp-zoom-toast { background: #FFFFFF; color: #111827; border-color: #92400E; }

/* Install guide */
#bsp-install-guide-modal {
  position: fixed;
  inset: 0;
  z-index: 100560;
  background: rgba(11, 14, 19, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  box-sizing: border-box;
}
.bsp-install-guide-card {
  width: 100%;
  max-width: 440px;
  background: #181C24;
  color: #F3F4F6;
  border: 1px solid #4B5563;
  border-radius: 14px;
  padding: 20px;
  box-sizing: border-box;
  font: 16px/1.5 Inter, system-ui, sans-serif;
}
.bsp-install-guide-card h2 { margin: 0 0 10px; font-size: 1.2em; }
.bsp-install-guide-card ol { padding-left: 1.2em; margin: 0 0 16px; }
.bsp-install-guide-card li { margin-bottom: 8px; }
html[data-theme="light"] .bsp-install-guide-card { background: #F1F5F9; color: #111827; border-color: #92400E; }

/* Arabic: right-to-left content cards, left-to-right control bars and numbers. */
html[lang="ar"] [data-bsp-rtl] { text-align: right; }
html[lang="ar"] :is(#bsp-master-top-bar, #bsp-portal-topbar, #bsp-floating-dock, a[href^="tel:"], input[type="tel"], input[type="number"]) { direction: ltr; }

.bsp-zoom-control {
  min-height: 44px;
  padding: 0.3rem 0.6rem;
  border: 1px solid currentColor;
  border-radius: 0.45rem;
  color: inherit;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  #bsp-zoom-toast { transition: none; }
}

/* Golden Thread quiz hand-off note */
.bsp-golden-thread-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 1rem;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #6B7280;
  background: #262A33;
  color: #F3F4F6;
  font: 600 15px/1.45 Inter, system-ui, sans-serif;
}
.bsp-golden-thread-note span { flex: 1 1 220px; }
.bsp-golden-thread-note a, .bsp-golden-thread-note button {
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #9CA3AF;
  background: #111317;
  color: #F3F4F6;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
html[data-theme="light"] .bsp-golden-thread-note { background: #FFFFFF; color: #111827; border-color: #92400E; }
html[data-theme="light"] .bsp-golden-thread-note :is(a, button) { background: #F1F5F9; color: #111827; border-color: #92400E; }
