/* navfix3b: theme source of truth = html[data-theme], never prefers-color-scheme.
   Loaded AFTER styles-tw-prod.css so token surfaces beat Tailwind light utilities. */

html[data-theme="dark"],
html.dark {
  color-scheme: dark;
}
html[data-theme="light"],
html.light {
  color-scheme: light;
}

/* Mirror token blocks onto data-theme (class kept for Tailwind :is(.dark *)) */
html[data-theme="dark"] {
  /* inherits from :root, html.dark block already in styles-fixes */
}

/* Kill any prefers-color-scheme leakage if a stylesheet reintroduces it */
html[data-theme="dark"],
html.dark,
html[data-theme="dark"] body,
html.dark body {
  background-color: var(--bg) !important;
  color: var(--text) !important;
}
html[data-theme="light"],
html.light,
html[data-theme="light"] body,
html.light body {
  background-color: var(--bg) !important;
  color: var(--text) !important;
}

/* Tailwind light utilities must not paint over the app theme */
html[data-theme="dark"] .bg-white,
html.dark .bg-white,
html[data-theme="dark"] .bg-white\/60,
html.dark .bg-white\/60,
html[data-theme="dark"] .bg-slate-50,
html.dark .bg-slate-50,
html[data-theme="dark"] .bg-slate-100,
html.dark .bg-slate-100 {
  background-color: var(--surface-2) !important;
}
html[data-theme="dark"] .text-slate-700,
html.dark .text-slate-700,
html[data-theme="dark"] .text-gray-700,
html.dark .text-gray-700,
html[data-theme="dark"] .text-gray-800,
html.dark .text-gray-800,
html[data-theme="dark"] .text-gray-900,
html.dark .text-gray-900 {
  color: var(--text) !important;
}

/* Board section titles + actions follow tokens */
html[data-theme="dark"] .btn-alt,
html.dark .btn-alt {
  background: var(--surface-3) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
html[data-theme="light"] .btn-alt,
html.light .btn-alt {
  background: var(--surface-3) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Unselected bottom-nav labels: muted, AA on surface-1/2 */
.app-v2-mobile-nav-btn,
.app-v2-mobile-nav-btn--inactive {
  color: var(--text-muted) !important;
}
.app-v2-mobile-nav-btn--active {
  color: var(--accent) !important;
}
.app-v2-mobile-nav-btn .text-xs {
  color: inherit !important;
}

/* Sticky/clipped section titles: scrollport padding + anchor offset */
.app-v2-scroll {
  scroll-padding-top: 12px;
}
.app-v2-scroll h2,
.app-v2-scroll h3,
.app-v2-content h2,
.app-v2-content h3 {
  scroll-margin-top: 12px;
}
.app-v2-header {
  position: relative !important;
  top: auto !important;
  flex: 0 0 auto;
  z-index: 20;
}

/* TrendChart lives inside .card — keep one surface; legend is transparent */
.bb-trend-chart,
[data-bb-trend-chart] {
  background: transparent;
  color: var(--text);
}

/* ---- navfix3c (Bill 7:12): themed dock + menu sheet above nav ---- */

/* Safe-area top lives on the shell (same painted bg), not a separate body band */
.app-v2-shell {
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
}
@media (min-width: 640px) {
  .app-v2-shell {
    padding-top: calc(1.25rem + env(safe-area-inset-top, 0px));
  }
}

/* Dock surface, border, icons, labels → theme tokens (light surface in light, dark in dark) */
html[data-theme="light"] .app-v2-mobile-nav.app-v2-mobile-nav--dock,
html.light .app-v2-mobile-nav.app-v2-mobile-nav--dock,
html[data-theme="light"] .app-v2-mobile-nav[data-bb-bottom-nav],
html.light .app-v2-mobile-nav[data-bb-bottom-nav] {
  background: var(--surface-1) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  box-shadow: 0 -8px 24px -20px rgba(10, 16, 24, 0.18);
}
html[data-theme="dark"] .app-v2-mobile-nav.app-v2-mobile-nav--dock,
html.dark .app-v2-mobile-nav.app-v2-mobile-nav--dock,
html[data-theme="dark"] .app-v2-mobile-nav[data-bb-bottom-nav],
html.dark .app-v2-mobile-nav[data-bb-bottom-nav] {
  background: var(--surface-1) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  box-shadow: 0 -10px 28px -22px rgba(0, 0, 0, 0.45);
}

/* Frost pseudo matches the themed surface (no hard-coded charcoal) */
.app-v2-mobile-nav.app-v2-mobile-nav--dock::before,
.app-v2-mobile-nav[data-bb-bottom-nav]::before {
  background: var(--surface-1) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/* Inactive labels/icons: AA-readable muted on the nav surface in BOTH themes */
.app-v2-mobile-nav-btn--inactive,
.app-v2-mobile-nav-btn:not(.app-v2-mobile-nav-btn--active) {
  color: var(--text-muted) !important;
}
.app-v2-mobile-nav-btn--inactive .app-v2-mobile-nav-icon,
.app-v2-mobile-nav-btn:not(.app-v2-mobile-nav-btn--active) .app-v2-mobile-nav-icon {
  background: var(--surface-3) !important;
  color: var(--text-muted) !important;
}
.app-v2-mobile-nav-btn .text-xs {
  color: inherit !important;
}

/* Active: brand green icon + label + subtle underline pill (not a mint block) */
.app-v2-mobile-nav-btn--active {
  color: var(--brand) !important;
  background: transparent !important;
}
.app-v2-mobile-nav-btn--active .app-v2-mobile-nav-icon {
  background: color-mix(in srgb, var(--brand) 16%, var(--surface-2)) !important;
  color: var(--brand) !important;
  box-shadow: none !important;
}
.app-v2-mobile-nav-btn--active::after {
  background: var(--brand) !important;
}

/* Nav row sits flush; safe-area is padding INSIDE the same painted nav */
.app-v2-mobile-nav.app-v2-mobile-nav--dock,
.app-v2-mobile-nav[data-bb-bottom-nav] {
  padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  margin-bottom: 0 !important;
}

/* Menu sheet: in-flow flex row between header and dock — ends above nav, scrolls internally */
.app-v2-mobile-menu.app-v2-mobile-menu--sheet {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  border-radius: 0;
  border-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 14px 24px;
  background: var(--surface-1) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  box-shadow: none;
}
.app-v2-mobile-menu--sheet .app-v2-mobile-menu-item,
.app-v2-mobile-menu--sheet .btn-alt,
.app-v2-mobile-menu--sheet .btn {
  min-height: 44px;
  display: flex;
  align-items: center;
}
/* Last actions (Sign out) get clear padding + tap target above the dock */
.app-v2-mobile-menu--sheet > .flex.flex-col:last-child {
  padding-bottom: 16px;
  margin-top: auto;
}
.app-v2-mobile-menu--sheet > .flex.flex-col:last-child .btn-alt:last-child,
.app-v2-mobile-menu--sheet > .flex.flex-col:last-child .btn:last-child {
  min-height: 48px;
  margin-bottom: 4px;
}
/* When the sheet is open, free the middle flex slot (don't leave an invisible scroll ghost) */
.app-v2-shell--menu-open > .app-v2-scroll {
  display: none !important;
}
.app-v2-shell {
  position: relative;
}

/* ---- install card (Blackbook → Brag Wire) ---- */
.bb-install-card {
  flex: 0 0 auto;
  margin: 0 0 12px;
  padding: 14px 14px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text);
  box-shadow: 0 10px 28px -22px var(--v2-glow);
}
.bb-install-card-brand {
  margin-bottom: 8px;
}
.bb-install-card-logo {
  max-width: 160px;
}
.bb-install-card-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.bb-install-card-lead {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.4;
}
.bb-install-card-steps {
  margin: 0 0 12px;
  padding-left: 1.15rem;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}
.bb-install-card-steps li { margin-bottom: 6px; }
.bb-install-card-step-label {
  display: inline-block;
  font-weight: 700;
  color: var(--brand);
  margin-right: 4px;
}
.bb-install-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.bb-install-card-btn {
  min-height: 44px;
  padding-left: 14px;
  padding-right: 14px;
}

/* ---- Safari iOS 26: frame fills dynamic viewport; shell flex-fills; nav last row flush ---- */
html, body, #root, .app-v2-frame {
  height: 100%;
  height: 100dvh;
  max-height: 100%;
  max-height: 100dvh;
}
.app-v2-shell {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  height: 100%;
}
