/* =========================================================
   BLACK HOLE — RESPONSIVE FOUNDATION
   Loaded after page-specific stylesheets so overrides win.
   Breakpoints: 1024 (tablet), 768 (mobile landscape), 480 (mobile)
   ========================================================= */

@media (max-width: 1024px) {
  .bh-container { padding: 0 24px; }
  .bh-section { padding: 90px 0; }

  .bh-split { grid-template-columns: 1fr; gap: 40px; }
  .bh-grid { grid-template-columns: repeat(2, 1fr); }
  .bh-steps { grid-template-columns: repeat(3, 1fr); row-gap: 32px; }
}

@media (max-width: 768px) {
  .bh-nav__links,
  .bh-nav__login { display: none; }
  .bh-nav__toggle { display: block; }

  .bh-hero__sub { font-size: 0.95rem; }
  .bh-hero__cta { flex-direction: column; width: 100%; }
  .bh-hero__cta .bh-btn { width: 100%; }

  .bh-grid { grid-template-columns: 1fr; }
  .bh-steps { grid-template-columns: repeat(2, 1fr); }

  .bh-demo-panel { padding: 32px; flex-direction: column; }

  .bh-footer { flex-direction: column; align-items: flex-start; }

  /* app shell (used on later phases) */
  .bh-app-sidebar { transform: translateX(-100%); }
  .bh-app-sidebar.is-open { transform: translateX(0); }
  .bh-app-main { margin-left: 0; }
}

@media (max-width: 480px) {
  .bh-container { padding: 0 18px; }
  .bh-section { padding: 64px 0; }
  .bh-hero__title { letter-spacing: -0.01em; }
  .bh-steps { grid-template-columns: 1fr; }
}

/* Reduce/disable the heaviest visual effects on low-power or
   explicitly reduced-motion contexts. animations.js also reads
   this to decide whether to run the full particle field. */
@media (max-width: 640px), (prefers-reduced-motion: reduce) {
  .bh-hero__scroll-line { animation: none; }
}


/* =========================================================
   MOBILE APP HARDENING — iOS/Safari layout + fixed drawer
   ========================================================= */
@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* A transform animation on <body> makes position:fixed descendants
     scroll with the document in mobile Safari. Main content already has
     its own entrance animation, so keep body untransformed on mobile. */
  body {
    animation: none !important;
    transform: none !important;
  }

  .bh-app-sidebar {
    position: fixed !important;
    top: 0 !important;
    right: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    z-index: 1000;
    contain: layout paint;
  }

  .bh-app-sidebar__brand,
  .bh-app-sidebar__footer {
    flex: 0 0 auto;
  }

  .bh-app-sidebar__scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  html.bh-sidebar-open,
  body.bh-sidebar-open {
    overflow: hidden !important;
    overscroll-behavior: none !important;
  }

  /* iOS date controls have a large intrinsic minimum width. Without
     these constraints the date field can force the one-column trade
     grid wider than the phone viewport. */
  .bh-trade-form,
  .bh-trade-section,
  .bh-trade-grid,
  .bh-trade-grid > *,
  .bh-trade-form .bh-field {
    min-width: 0 !important;
    max-width: 100%;
  }

  .bh-trade-form .bh-field input,
  .bh-trade-form .bh-field select,
  .bh-trade-form .bh-field textarea,
  .bh-trade-form input[type="date"] {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}


/* =========================================================
   CROSS-BROWSER MOBILE NORMALIZATION
   Keep iOS Safari and Android Chrome visually aligned.
   ========================================================= */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button,
a,
input,
select,
textarea,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bh-mobile-viewport: 100vh;
}
@supports (height: 100dvh) {
  :root { --bh-mobile-viewport: 100dvh; }
}

@media (max-width: 768px) {
  html,
  body {
    width: 100%;
    min-width: 0;
    min-height: 100%;
  }

  .bh-app {
    width: 100%;
    min-width: 0;
    height: var(--bh-mobile-viewport) !important;
    min-height: var(--bh-mobile-viewport) !important;
  }

  .bh-app-main {
    width: 100%;
    min-width: 0;
    height: var(--bh-mobile-viewport) !important;
    min-height: var(--bh-mobile-viewport) !important;
    scrollbar-gutter: auto !important;
  }

  .bh-app-sidebar {
    height: var(--bh-mobile-viewport) !important;
    max-height: var(--bh-mobile-viewport) !important;
  }

  /* Safari otherwise enlarges controls/text differently from Chrome. */
  input,
  select,
  textarea {
    font-size: 16px !important;
    line-height: 1.35;
  }

  button,
  .bh-btn,
  a.bh-btn {
    -webkit-appearance: none;
    appearance: none;
  }

  .bh-auth,
  .bh-auth__card,
  .bh-card,
  .bh-panel,
  .bh-trade-section,
  .bh-ai-journal-modal__panel {
    box-sizing: border-box;
    max-width: 100%;
  }

  .bh-auth {
    width: 100%;
  }

  /* Width-based backdrop sizing is more consistent between tall iPhones
     and shorter Android browser viewports than vh-based sizing. */
  .bh-app-scrim {
    background:
      linear-gradient(180deg,rgba(0,1,5,.10),rgba(0,1,5,.56) 46%,#010207 100%),
      url('../assets/images/black-hole-command-center.png') 64% 0% / auto clamp(360px, 108vw, 455px) no-repeat,
      #010207 !important;
  }

  .bh-app-scrim::before {
    left: 64% !important;
    top: 132px !important;
    width: min(66vw,270px) !important;
  }

  .bh-app-scrim::after {
    left: 64% !important;
    top: 132px !important;
    width: min(22vw,96px) !important;
  }
}

/* =========================================================
   BLACK HOLE — APP LAYOUT REFINEMENT 2026-09-10
   Sidebar brand position, readable Journal filters,
   full Performance empty states, and full-width Add Trade.
   Scoped to authenticated app classes only; landing is untouched.
   ========================================================= */

/* 1) Sidebar brand: lower it slightly and give the mark breathing room. */
.bh-app-sidebar__brand {
  padding-top: 36px !important;
  padding-bottom: 27px !important;
  min-height: 88px;
  align-items: center !important;
}
.bh-app-sidebar .bh-nav__mark { transform: translateY(2px); }

/* 2) Journal filters: readable, comfortable controls instead of a compressed strip. */
.bh-journal-filters {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  align-items: end !important;
  gap: 12px !important;
  padding: 15px 16px !important;
  overflow: visible !important;
}
.bh-journal-filter {
  width: 100% !important;
  min-width: 0 !important;
  gap: 8px !important;
}
.bh-journal-filter--search {
  grid-column: span 2;
}
.bh-journal-filter__label {
  padding-left: 2px !important;
  font-size: 11px !important;
  line-height: 1.25 !important;
  letter-spacing: .11em !important;
  color: #9198aa !important;
}
.bh-journal-filter input[type="search"],
.bh-journal-filter select,
.bh-journal-date-shell {
  height: 48px !important;
  min-height: 48px !important;
  padding-left: 14px !important;
  padding-right: 14px !important;
  border-radius: 10px !important;
  font-size: 14px !important;
  line-height: 1.35 !important;
  background: rgba(5,7,14,.88) !important;
  border-color: rgba(143,123,210,.17) !important;
  color: #e8e9f0 !important;
}
.bh-journal-filter select { padding-right: 34px !important; }
.bh-journal-date-value {
  font-size: 14px !important;
  line-height: 1.35 !important;
  color: #dde0e9 !important;
}
.bh-journal-filter input[type="search"]::placeholder { color: #7d8495 !important; }
.bh-journal-filter--select::after { right: 15px !important; bottom: 20px !important; }

/* 3) Performance: empty chart state fills the chart surface cleanly. */
.bh-performance-grid { align-items: stretch; }
.bh-performance-panel { height: 100%; }
.bh-performance-chart {
  width: 100%;
  min-width: 0;
}
.bh-performance-chart > .bh-playbook-empty {
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  margin: 0 !important;
  padding: 28px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.bh-performance-chart > .bh-playbook-empty h3 {
  font-size: 18px !important;
  margin-bottom: 7px !important;
}
.bh-performance-chart > .bh-playbook-empty p {
  max-width: 560px;
  margin: 0 !important;
  color: #9198a8 !important;
  font-size: 14px !important;
  line-height: 1.65 !important;
}

/* 4) Add Trade: use the available workspace and stop looking like a centered sheet. */
.bh-trade-form {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
  display: grid;
  gap: 16px;
}
.bh-trade-section,
.bh-trade-advanced {
  border: 1px solid rgba(139,108,224,.16) !important;
  border-radius: 16px !important;
  background: linear-gradient(150deg, rgba(8,10,22,.90), rgba(4,5,13,.86)) !important;
  box-shadow: 0 18px 48px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.025);
  overflow: hidden;
}
.bh-trade-section {
  padding: 27px 28px !important;
}
.bh-trade-section__head {
  margin-bottom: 22px !important;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,.045);
}
.bh-trade-section__head h2 { font-size: 20px !important; }
.bh-trade-section__head p { font-size: 13.5px !important; line-height: 1.55; }
.bh-trade-section__step {
  width: 34px !important;
  height: 34px !important;
  border-radius: 10px !important;
  font-size: 11px !important;
}
.bh-trade-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 16px !important;
}
.bh-trade-grid .bh-field { min-width: 0; }
.bh-trade-grid .bh-field > label,
.bh-trade-form .bh-field > label {
  font-size: 11px !important;
  line-height: 1.35 !important;
  letter-spacing: .09em;
}
.bh-trade-form .bh-field input,
.bh-trade-form .bh-field select,
.bh-trade-form .bh-field textarea {
  min-height: 48px !important;
  padding: 12px 14px !important;
  border-radius: 10px !important;
  font-size: 14.5px !important;
  background: rgba(3,5,12,.82) !important;
}
.bh-trade-form .bh-field textarea { min-height: 110px !important; }
.bh-trade-grid .bh-field:has(#notes),
.bh-trade-grid .bh-field:has(#setup) { grid-column: 1 / -1 !important; }
.bh-trade-advanced__grid .bh-field:has(#entryReason),
.bh-trade-advanced__grid .bh-field:has(#confluences) { grid-column: span 3 !important; }
.bh-trade-summary {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 12px !important;
}
.bh-trade-summary .bh-computed {
  min-height: 88px;
  padding: 16px 17px !important;
}
.bh-plan-checklist { gap: 10px !important; }
.bh-plan-checklist label {
  min-height: 64px !important;
  padding: 12px !important;
  font-size: 12.5px !important;
  line-height: 1.5 !important;
}
.bh-rule-detector { padding: 14px 16px !important; }
.bh-rule-detector strong { font-size: 13.5px !important; }
.bh-rule-detector p,
.bh-rule-detector ul { font-size: 12.5px !important; line-height: 1.55 !important; }
.bh-trade-uploads { gap: 16px !important; }
.bh-trade-actions {
  margin-top: 0 !important;
  padding: 2px 0 8px !important;
}

/* Comfortable laptop widths. */
@media (max-width: 1380px) {
  .bh-journal-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .bh-journal-filter--search { grid-column: span 2; }
  .bh-trade-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .bh-trade-grid .bh-field:has(#notes),
  .bh-trade-grid .bh-field:has(#setup),
  .bh-trade-advanced__grid .bh-field:has(#entryReason),
  .bh-trade-advanced__grid .bh-field:has(#confluences) { grid-column: 1 / -1 !important; }
}

/* Tablet/mobile: lower logo safely and make every control genuinely readable. */
@media (max-width: 768px) {
  .bh-app-sidebar__brand {
    padding-top: max(30px, calc(env(safe-area-inset-top) + 18px)) !important;
    padding-bottom: 23px !important;
    min-height: 82px;
  }
  .bh-app-sidebar .bh-nav__mark { transform: translateY(1px); }

  .bh-journal-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 11px !important;
    padding: 13px !important;
  }
  .bh-journal-filter--search { grid-column: 1 / -1; }
  .bh-journal-filter input[type="search"],
  .bh-journal-filter select,
  .bh-journal-date-shell {
    min-height: 50px !important;
    height: 50px !important;
    font-size: 16px !important;
  }
  .bh-journal-date-value { font-size: 16px !important; }

  .bh-trade-form { gap: 12px; }
  .bh-trade-section { padding: 21px 18px !important; border-radius: 14px !important; }
  .bh-trade-section__head { align-items: flex-start !important; gap: 12px !important; }
  .bh-trade-section__head h2 { font-size: 19px !important; }
  .bh-trade-section__head p { font-size: 13px !important; }
  .bh-trade-grid { grid-template-columns: 1fr !important; gap: 13px !important; }
  .bh-trade-grid .bh-field,
  .bh-trade-grid .bh-field:has(#notes),
  .bh-trade-grid .bh-field:has(#setup),
  .bh-trade-advanced__grid .bh-field:has(#entryReason),
  .bh-trade-advanced__grid .bh-field:has(#confluences) { grid-column: 1 / -1 !important; }
  .bh-trade-summary { grid-template-columns: 1fr !important; }
  .bh-plan-checklist { grid-template-columns: 1fr !important; }
  .bh-plan-checklist label { min-height: 58px !important; font-size: 14px !important; }
  .bh-trade-section__head > p { max-width: 100%; }
}

@media (max-width: 480px) {
  .bh-journal-filters { grid-template-columns: 1fr !important; }
  .bh-journal-filter--search { grid-column: auto; }
  .bh-performance-chart { min-height: 220px !important; height: 220px !important; }
  .bh-performance-chart > .bh-playbook-empty { padding: 18px !important; }
  .bh-performance-chart > .bh-playbook-empty h3 { font-size: 17px !important; }
  .bh-performance-chart > .bh-playbook-empty p { font-size: 13.5px !important; }
}

/* =========================================================
   FINAL MOBILE CLEANUP
   Fix topbar action overlap and keep the floating mobile nav
   from covering content, buttons and form rows.
   ========================================================= */
@media (max-width: 900px) {
  :root {
    --bh-mobile-nav-safe-space: calc(112px + env(safe-area-inset-bottom));
  }

  .bh-app-main {
    padding-bottom: calc(var(--bh-mobile-nav-safe-space) + 34px) !important;
    scroll-padding-bottom: calc(var(--bh-mobile-nav-safe-space) + 24px);
  }

  .bh-app-main > *:last-child,
  .bh-app-main > form:last-child,
  .bh-app-main > section:last-child,
  .bh-app-main > article:last-child,
  .bh-app-main > div:last-child {
    margin-bottom: calc(var(--bh-mobile-nav-safe-space) + 12px) !important;
  }

  .bh-mobile-nav {
    left: 14px !important;
    right: 14px !important;
    bottom: max(12px, calc(env(safe-area-inset-bottom) + 8px)) !important;
    padding: 7px !important;
    border-radius: 18px !important;
    background: rgba(6, 7, 14, 0.94) !important;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42) !important;
  }

  .bh-mobile-nav a {
    min-height: 54px !important;
    gap: 4px !important;
    font-size: 9px !important;
    letter-spacing: 0.04em !important;
  }

  .bh-mobile-nav a b {
    font-size: 11px !important;
    line-height: 1 !important;
  }
}

@media (max-width: 768px) {
  .bh-app-topbar {
    position: relative !important;
    min-height: auto !important;
    align-items: flex-start !important;
    gap: 14px !important;
    margin-bottom: 20px !important;
  }

  .bh-app-topbar > .bh-sidebar-toggle {
    order: 0;
    flex: 0 0 auto;
  }

  .bh-app-topbar > div {
    order: 1;
    flex: 1 1 calc(100% - 52px);
    min-width: 0;
  }

  .bh-app-topbar > .bh-btn,
  .bh-app-topbar > .bh-topbar-actions,
  .bh-app-topbar > .bh-app-topbar__tools {
    order: 2;
    width: 100%;
    margin-left: 0 !important;
  }

  .bh-app-topbar > .bh-btn,
  .bh-app-topbar > .bh-btn--primary,
  .bh-app-topbar > .bh-btn--ghost {
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  .bh-topbar-actions,
  .bh-app-topbar__tools {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px !important;
  }

  .bh-topbar-actions .bh-btn,
  .bh-app-topbar__tools .bh-btn,
  .bh-app-topbar__tools > * {
    width: 100% !important;
    min-width: 0 !important;
  }

  .bh-app-topbar__title {
    margin-top: 0 !important;
    line-height: 1.08 !important;
  }

  .bh-app-topbar__sub {
    margin-top: 8px !important;
    max-width: 100% !important;
  }

  .bh-trade-actions,
  .bh-indicator-access-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px !important;
  }

  .bh-trade-actions .bh-btn,
  .bh-indicator-access-actions .bh-btn,
  .bh-indicator-access-actions a,
  .bh-indicator-access-actions button {
    width: 100% !important;
    min-width: 0 !important;
  }
}

@media (max-width: 520px) {
  .bh-topbar-actions,
  .bh-app-topbar__tools,
  .bh-trade-actions,
  .bh-indicator-access-actions {
    grid-template-columns: 1fr !important;
  }

  .bh-app-main {
    padding-bottom: calc(124px + env(safe-area-inset-bottom)) !important;
  }
}

/* Hide Netlify preview badge/overlay when present so it does not sit over the mobile nav. */
iframe[src*="netlify"],
iframe[title*="Netlify"],
#netlify-devtools,
.netlify-identity-widget,
.netlify-visual-editor,
[data-netlify-badge],
[class*="netlify-badge"] {
  display: none !important;
}

/* =========================================================
   2026-09-10 — TRUE MOBILE APP DOCK
   The primary navigation occupies its own layout row instead
   of floating over page content. This guarantees that buttons,
   cards and form controls remain visible and clickable.
   ========================================================= */
@media (max-width: 900px) {
  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden !important;
  }

  .bh-app {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) auto !important;
    width: 100% !important;
    height: var(--bh-mobile-viewport) !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .bh-app-main {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin-left: 0 !important;
    padding-bottom: 34px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scroll-padding-bottom: 32px !important;
  }

  .bh-app-main > *:last-child,
  .bh-app-main > form:last-child,
  .bh-app-main > section:last-child,
  .bh-app-main > article:last-child,
  .bh-app-main > div:last-child {
    margin-bottom: 18px !important;
  }

  .bh-mobile-nav {
    position: relative !important;
    grid-column: 1 !important;
    grid-row: 2 !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: auto !important;
    margin: 0 14px max(10px, env(safe-area-inset-bottom)) !important;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    padding: 6px !important;
    z-index: 45 !important;
    border: 1px solid rgba(255,255,255,.075) !important;
    border-radius: 17px !important;
    background: rgba(7, 8, 15, .97) !important;
    backdrop-filter: blur(20px) saturate(125%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(125%) !important;
    box-shadow: 0 12px 34px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.025) !important;
  }

  .bh-mobile-nav a {
    min-width: 0 !important;
    min-height: 52px !important;
    padding: 6px 3px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    border-radius: 11px !important;
    color: #827c8a !important;
    font-size: 9px !important;
    line-height: 1.1 !important;
    letter-spacing: .02em !important;
    white-space: nowrap;
    touch-action: manipulation;
  }

  .bh-mobile-nav a b {
    font: 700 10px/1 var(--bh-font-mono) !important;
    color: #8f8897 !important;
  }

  .bh-mobile-nav a.is-active {
    color: #e6e0ee !important;
    background: linear-gradient(180deg, rgba(119,87,204,.11), rgba(119,87,204,.055)) !important;
    box-shadow: inset 0 0 0 1px rgba(146,116,232,.06) !important;
  }

  .bh-mobile-nav a.is-active b {
    color: #b39dff !important;
  }

  /* Keep the slide-out sidebar above the dock while open. */
  .bh-app-sidebar {
    z-index: 90 !important;
  }

  .bh-app-scrim {
    z-index: 0 !important;
  }
}

@media (max-width: 420px) {
  .bh-mobile-nav {
    margin-left: 9px !important;
    margin-right: 9px !important;
    padding: 5px !important;
  }

  .bh-mobile-nav a {
    min-height: 50px !important;
    font-size: 8.5px !important;
  }
}
/* =========================================================
   V1.62 — PUBLIC LEGAL PAGE MOBILE SCROLL FIX
   The mobile app shell intentionally locks html/body scrolling and
   scrolls .bh-app-main instead. Public legal/contact pages do not
   use .bh-app, so restore native document scrolling for them.
   ========================================================= */
@media (max-width: 900px) {
  html.bh-legal-document,
  html.bh-legal-document body.bh-legal-page {
    height: auto !important;
    min-height: 100% !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: auto !important;
    scroll-snap-type: none !important;
    scroll-behavior: auto !important;
    touch-action: pan-y pinch-zoom !important;
    -webkit-overflow-scrolling: touch;
  }

  html.bh-legal-document body.bh-legal-page {
    min-height: 100dvh !important;
  }
}

