/**
 * brief.pk — Mobile native shell layer (≤768px only)
 * ---------------------------------------------------------------
 * Load immediately AFTER /css/main.css on any surface that uses the
 * intel header + global-nav bottom bar. Desktop is unchanged: every rule
 * lives inside this single media query so we do not fork the whole theme.
 *
 * Pair with: /css/app-shell-desktop.css (≥769px polish).
 */

@media (max-width: 768px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  /* ── MOBILE OVERFLOW HARDENING ─────────────────────────────────────────
   * Forces flex/grid children to actually shrink below their min-content,
   * so long words, sparkline SVGs, nowrap labels, etc. cannot expand a
   * `1fr` track past the viewport. Pairs with `minmax(0, 1fr)` tracks on
   * the dashboard shell in main.css. */
  .dashboard-shell,
  .main-lane,
  .left-rail,
  .right-rail,
  .main-lane-dual,
  .ticker-stack {
    min-width: 0;
    max-width: 100%;
  }

  .dashboard-shell > *,
  .main-lane > *,
  .main-lane-dual > *,
  .left-rail > *,
  .right-rail > * {
    min-width: 0;
    max-width: 100%;
  }

  /* brief's Pulse + lane blocks: ensure nothing inside can push past
   * the card's own width (sparkline SVGs, long unbreakable strings,
   * eyebrow labels, evidence panel rows). */
  .lane-block,
  .briefpk-pulse-lane,
  .rail-block,
  .rail-widget {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .briefpk-pulse-quote,
  .briefpk-pulse-title,
  .briefpk-pulse-eyebrow,
  .bpp-ind-signal,
  .bpp-ind-impact,
  .briefing-item,
  .news-card,
  .news-card-title,
  .ai-ind-card {
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
    max-width: 100%;
  }

  /* Indicator cards: containerize so inner sparklines / labels can't
   * stretch the column. */
  .bpp-ind-card,
  .bpp-ind-card * {
    min-width: 0;
    max-width: 100%;
  }

  /* Terminal Hero (May 2026 dashboard refresh) */
  #terminalHeroContainer,
  .terminal-hero,
  .terminal-hero-grid,
  .terminal-hero-narrative,
  .terminal-hero-dashboard,
  .terminal-hero-watch,
  .fx-dashboard,
  .kse-card,
  .narrative-news-list {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .terminal-hero-headline,
  .terminal-hero-body,
  .terminal-hero-eyebrow,
  .watch-chip,
  .narrative-news-item .news-headline,
  .fx-card-label,
  .fx-card-value {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .kse-card-sparkline,
  .kse-card-sparkline svg {
    max-width: 100%;
    height: auto;
  }

  /* Floating sync pill must sit above the bottom tab bar, not under it */
  body.gn-has-bottom-nav .sync-pill {
    bottom: calc(66px + env(safe-area-inset-bottom, 0px) + 8px);
    right: max(12px, env(safe-area-inset-right, 0px));
    max-width: min(280px, calc(100vw - 24px));
  }

  body.gn-has-bottom-nav .scroll-top-btn {
    bottom: calc(66px + env(safe-area-inset-bottom, 0px) + 52px);
  }

  /* Sparklines: SVGs default to their intrinsic size unless constrained. */
  .bpp-sparkline-wrap,
  .bpp-sparkline-wrap svg,
  .ai-sparkline {
    max-width: 100%;
    height: auto;
  }

  @media (prefers-reduced-motion: no-preference) {
    html {
      scroll-behavior: smooth;
    }
  }

  /* Reduce rubber-band overscroll glare on iOS PWAs / in-app browsers */
  body {
    overscroll-behavior-y: contain;
  }

  /* Notch + Dynamic Island: keep header content off the sensor housing */
  .intel-header {
    padding-top: max(6px, env(safe-area-inset-top, 0px));
  }

  /* Tablet / small laptop: keep logo + full-width search when bottom tabs are on */
  @media (min-width: 641px) and (max-width: 768px) {
    body.gn-has-bottom-nav .intel-header .intel-mainbar {
      flex-direction: column;
      align-items: stretch;
      height: auto;
      min-height: 0;
      padding-top: 10px;
      padding-bottom: 10px;
      gap: 8px;
    }

    body.gn-has-bottom-nav .intel-header .header-toolbar-end {
      flex: none;
      width: 100%;
      justify-content: stretch;
    }

    body.gn-has-bottom-nav .intel-header .header-toolbar-end > .header-search-wrap {
      flex: 1 1 auto;
      max-width: none;
      width: 100%;
    }
  }

  body.gn-has-bottom-nav .intel-header .header-toolbar-end--hidden {
    display: none !important;
  }

  /* Tab bar: native iOS-style proportions */
  .app-bottom-nav {
    min-height: calc(58px + env(safe-area-inset-bottom, 0px));
    padding: 7px 4px calc(9px + env(safe-area-inset-bottom, 0px));
  }

  .app-bn-item,
  .app-bn-item--more {
    min-height: 48px;
    border-radius: 0;  /* no box — the icon pill provides the highlight */
    gap: 3px;
    font-size: 10.5px;
    letter-spacing: 0.01em;
    transition: color 0.18s ease;
  }

  /* Tap spring — only fires on the icon element */
  .app-bn-item:active .app-bn-icon,
  .app-bn-item--more:active .app-bn-icon {
    transform: scale(0.88);
    transition: transform 0.08s ease;
  }

  .app-more-link {
    min-height: 48px;
  }

  /* Drawer — comfortable thumb zone */
  .gn-drawer-link {
    min-height: 48px;
    padding-top: 14px;
    padding-bottom: 14px;
    font-size: 16px;
  }

  .gn-drawer-close {
    width: 44px;
    height: 44px;
  }

  .gn-burger {
    width: 44px;
    height: 44px;
  }

  /* Policy + Constitution detail: bottom sheet + above bottom nav (z 150) */
  .pol-detail-backdrop,
  .con-detail-backdrop {
    z-index: 180 !important;
  }

  .pol-detail-panel,
  .con-detail-panel {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 88vh !important;
    height: auto !important;
    border-left: none !important;
    border-top: 1px solid var(--panel-border) !important;
    border-radius: 16px 16px 0 0 !important;
    box-shadow: 0 -16px 48px rgba(15, 23, 42, 0.22) !important;
    transform: translateY(100%) !important;
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.32, 1) !important;
    z-index: 190 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .pol-detail-panel.is-open,
  .pol-detail-panel[aria-hidden="false"],
  .con-detail-panel[aria-hidden="false"] {
    transform: translateY(0) !important;
  }

  .pol-detail-close,
  .con-detail-close {
    top: 14px !important;
  }

  /* Accountability detail — same bottom sheet idiom (sheet z already 210) */
  .acc-detail-panel {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: min(88vh, 100%) !important;
    height: auto !important;
    border-left: none !important;
    border-top: 1px solid var(--panel-border) !important;
    border-radius: 16px 16px 0 0 !important;
    transform: translateY(100%) !important;
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.32, 1) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -16px 48px rgba(15, 23, 42, 0.22) !important;
  }

  .acc-detail-panel.is-open {
    transform: translateY(0) !important;
  }

  .acc-detail-inner {
    padding: 52px 18px calc(24px + env(safe-area-inset-bottom, 0px));
    max-height: min(78vh, 720px);
  }

  .acc-detail-close {
    top: 14px;
    right: 14px;
    width: 44px;
    height: 44px;
  }

  /* Horizontal registry / data tables: momentum scroll */
  .pol-table-wrap,
  .con-table-wrap,
  .acc-table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  /* Admin console (no main.css): larger tap targets when this sheet is linked */
  .admin-shell .btn,
  .admin-head .btn,
  .admin-head button {
    min-height: 44px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .admin-shell {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}
