/* NHPQ Mobile UX V38.12
   Mobile-only layout consolidation. Desktop layout remains unchanged. */
.nhpq-mobile-menu-toggle,
.nhpq-mobile-menu,
.nhpq-mobile-menu-backdrop,
.nhpq-mobile-dock,
.nhpq-mobile-support-sheet,
.nhpq-mobile-sheet-head,
.nhpq-gps-card-toggle,
.nhpq-mobile-layer-info { display:none; }

@media (max-width:760px) {
  :root { --nhpq-mobile-header:60px; --nhpq-mobile-dock-h:64px; --nhpq-mobile-edge:8px; }
  html,body { width:100%; max-width:100%; overflow:hidden; }
  body { min-height:100dvh; }

  .topbar {
    height:var(--nhpq-mobile-header);
    min-width:0;
    padding:0 max(12px,env(safe-area-inset-left)) 0 max(12px,env(safe-area-inset-left));
    gap:10px;
    justify-content:space-between;
    box-shadow:0 2px 12px rgba(14,45,60,.08);
  }
  .topbar .brand { min-width:0; max-width:calc(100% - 58px); gap:9px; }
  .topbar .brand-mark { width:36px; height:36px; flex:0 0 36px; border-radius:11px; font-size:10px; }
  .topbar .brand > span:last-child { min-width:0; }
  .topbar .brand strong { overflow:hidden; font-size:12px; line-height:1.18; text-overflow:ellipsis; white-space:nowrap; }
  .topbar .brand small { margin-top:1px; font-size:10.5px; }
  .topbar .support-header,
  .topbar .top-actions,
  .topbar > .nhpq-intro-header-btn { display:none !important; }

  .nhpq-mobile-menu-toggle {
    width:44px;
    height:44px;
    flex:0 0 44px;
    display:grid;
    place-items:center;
    padding:0;
    border:1px solid #c9dcdf;
    border-radius:13px;
    color:#155062;
    background:#fff;
    box-shadow:0 5px 15px rgba(20,63,78,.1);
  }
  .nhpq-mobile-menu-toggle svg { width:22px; height:22px; }
  .nhpq-mobile-menu-toggle[aria-expanded="true"] { color:#fff; background:var(--teal); border-color:var(--teal); }

  .map-shell { height:calc(100dvh - var(--nhpq-mobile-header)); min-height:0; }

  /* One clear bottom dock replaces the two competing toolbar rows. */
  .mobile-map-toolbar { display:none !important; }
  .nhpq-mobile-dock {
    position:absolute;
    z-index:40;
    right:var(--nhpq-mobile-edge);
    bottom:max(var(--nhpq-mobile-edge),env(safe-area-inset-bottom));
    left:var(--nhpq-mobile-edge);
    height:var(--nhpq-mobile-dock-h);
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:4px;
    padding:5px;
    border:1px solid rgba(194,216,221,.95);
    border-radius:19px;
    background:rgba(255,255,255,.96);
    box-shadow:0 10px 30px rgba(12,44,58,.22);
    backdrop-filter:blur(14px);
    -webkit-backdrop-filter:blur(14px);
  }
  .nhpq-mobile-dock button {
    min-width:0;
    min-height:52px;
    display:grid;
    place-items:center;
    align-content:center;
    gap:2px;
    padding:4px 2px;
    border:0;
    border-radius:14px;
    color:#486778;
    background:transparent;
    font-size:10px;
    font-weight:850;
    line-height:1.05;
  }
  .nhpq-mobile-dock button svg { width:21px; height:21px; stroke-width:2; }
  .nhpq-mobile-dock button.active,
  .nhpq-mobile-dock button[aria-pressed="true"] { color:#fff; background:var(--teal); }
  .nhpq-mobile-dock button:focus-visible,
  .nhpq-mobile-menu-toggle:focus-visible,
  .nhpq-mobile-sheet-close:focus-visible { outline:3px solid rgba(6,119,129,.28); outline-offset:2px; }

  /* Search and all auxiliary content now use the same bottom-sheet pattern. */
  .search-card,
  .data-browser-card,
  .left-map-stack .documents-card,
  .left-map-stack .legend-card,
  .nhpq-mobile-support-sheet {
    position:absolute !important;
    z-index:32 !important;
    top:auto !important;
    right:var(--nhpq-mobile-edge) !important;
    bottom:calc(var(--nhpq-mobile-dock-h) + max(16px,env(safe-area-inset-bottom))) !important;
    left:var(--nhpq-mobile-edge) !important;
    width:auto !important;
    max-height:min(72dvh,660px) !important;
    margin:0 !important;
    border:1px solid rgba(207,224,228,.98) !important;
    border-radius:22px !important;
    overflow:auto !important;
    overscroll-behavior:contain;
    background:rgba(255,255,255,.99) !important;
    box-shadow:0 18px 48px rgba(13,43,57,.26) !important;
    -webkit-overflow-scrolling:touch;
  }
  .search-card { display:none; padding:0 !important; }
  .search-card.search-open { display:block; }
  .search-card .mobile-search-toggle { position:sticky; z-index:2; top:0; min-height:54px; padding:14px 16px; background:rgba(255,255,255,.99); }
  .search-card .search-card-body { max-height:none; padding:0 16px 18px; overflow:visible; }
  .search-card .search-mode-tab,
  .search-card input,
  .search-card button { min-height:44px; }

  .data-browser-card,
  .left-map-stack .documents-card,
  .left-map-stack .legend-card { display:none; }
  .data-browser-card.mobile-open,
  .left-map-stack .documents-card.mobile-open,
  .left-map-stack .legend-card.mobile-open { display:block; }
  .left-map-stack { position:static !important; display:block !important; width:auto !important; }

  .nhpq-mobile-sheet-head {
    position:sticky;
    z-index:5;
    top:0;
    min-height:55px;
    display:grid;
    grid-template-columns:1fr 44px;
    align-items:center;
    gap:10px;
    padding:8px 10px 8px 16px;
    border-bottom:1px solid #e0eaed;
    background:rgba(255,255,255,.985);
  }
  .nhpq-mobile-sheet-head::before {
    content:"";
    position:absolute;
    top:6px;
    left:50%;
    width:38px;
    height:4px;
    border-radius:999px;
    background:#cfdee1;
    transform:translateX(-50%);
  }
  .nhpq-mobile-sheet-head strong { padding-top:5px; color:#17394d; font-size:15px; }
  .nhpq-mobile-sheet-close {
    width:40px;
    height:40px;
    display:grid;
    place-items:center;
    padding:0;
    border:0;
    border-radius:12px;
    color:#557383;
    background:#edf4f5;
    font-size:24px;
    line-height:1;
  }

  .data-browser-card > .controls-card {
    position:static !important;
    display:grid !important;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:7px;
    max-width:none !important;
    padding:12px 14px !important;
    border:0;
    border-bottom:1px solid #e0eaed;
    border-radius:0;
    box-shadow:none;
    background:#f7fbfb;
  }
  .data-browser-card > .controls-card .control-button { min-height:44px; padding:8px 6px; font-size:11px; }
  .data-browser-card > .controls-card .gps-control-button { display:none !important; }
  .data-browser-card > .controls-card .pdf-control-button { grid-column:1/-1; }
  .data-browser-card > .opacity-card {
    position:static !important;
    display:grid !important;
    width:auto !important;
    margin:0 !important;
    padding:12px 15px !important;
    border:0;
    border-bottom:1px solid #e0eaed;
    border-radius:0;
    box-shadow:none;
    background:#fff;
  }
  .data-browser-card .data-browser-section { padding:14px 15px; }
  .data-browser-card .layer-row { min-height:43px; }
  .data-browser-card .sheet-filter { min-height:44px; }
  .data-browser-card .sheet-row { min-height:42px; }

  .left-map-stack .documents-card .legend-heading,
  .left-map-stack .legend-card .legend-heading { min-height:48px; }
  .left-map-stack .documents-card .document-body,
  .left-map-stack .legend-card .legend-list { max-height:none !important; overflow:visible !important; }

  /* GPS is a readable, collapsible sheet rather than a floating card over the parcel. */
  .gps-status-card {
    z-index:34;
    right:var(--nhpq-mobile-edge);
    bottom:calc(var(--nhpq-mobile-dock-h) + max(16px,env(safe-area-inset-bottom)));
    left:var(--nhpq-mobile-edge);
    width:auto;
    max-height:min(46dvh,430px);
    padding:15px 48px 15px 15px;
    overflow:auto;
    border-radius:20px;
    box-shadow:0 16px 42px rgba(13,42,55,.25);
  }
  .gps-status-card > strong { font-size:14px; }
  .gps-status-card > span { font-size:12px; line-height:1.4; }
  .gps-parcel-actions button { min-height:44px; flex:1 1 145px; font-size:12px; }
  .nhpq-gps-card-toggle {
    position:absolute;
    top:9px;
    right:9px;
    width:38px;
    height:38px;
    display:grid;
    place-items:center;
    padding:0;
    border:0;
    border-radius:12px;
    color:#4b6b79;
    background:#edf5f5;
    font-size:18px;
  }
  .gps-status-card.nhpq-collapsed { max-height:92px; overflow:hidden; }
  .gps-status-card.nhpq-collapsed .gps-parcel-result,
  .gps-status-card.nhpq-collapsed .gps-parcel-actions,
  .gps-status-card.nhpq-collapsed > small { display:none !important; }

  .info-panel {
    z-index:35;
    top:auto;
    right:var(--nhpq-mobile-edge);
    bottom:calc(var(--nhpq-mobile-dock-h) + max(16px,env(safe-area-inset-bottom)));
    left:var(--nhpq-mobile-edge);
    width:auto;
    max-height:min(68dvh,620px);
    padding:20px 18px;
    overflow:auto;
    border-radius:22px;
    transform:translateY(calc(100% + 100px));
  }
  .info-panel.open { transform:translateY(0); }
  .info-details { grid-template-columns:112px minmax(0,1fr); gap:8px 10px; }

  .maplibregl-ctrl-bottom-right { bottom:calc(var(--nhpq-mobile-dock-h) + 18px + env(safe-area-inset-bottom)); }
  .maplibregl-ctrl-bottom-left { bottom:calc(var(--nhpq-mobile-dock-h) + 18px + env(safe-area-inset-bottom)); }
  .disclaimer { display:none; }

  /* The advisor remains available from the dock, without its own competing bubble. */
  .advisor-contact { right:0; bottom:0; }
  .advisor-contact-toggle { display:none !important; }
  .advisor-contact-panel {
    z-index:5205;
    right:var(--nhpq-mobile-edge) !important;
    bottom:calc(var(--nhpq-mobile-dock-h) + max(16px,env(safe-area-inset-bottom))) !important;
    left:var(--nhpq-mobile-edge) !important;
    width:auto !important;
    max-height:min(72dvh,660px) !important;
    border:1px solid rgba(199,221,215,.96) !important;
    border-radius:22px !important;
    padding-bottom:18px !important;
  }
  .advisor-contact-backdrop { z-index:5204; }
  body.advisor-contact-open .nhpq-mobile-dock {
    opacity:.55;
    pointer-events:none;
  }

  /* Compact site menu. */
  .nhpq-mobile-menu-backdrop {
    position:fixed;
    z-index:5298;
    inset:0;
    display:block;
    background:rgba(10,31,42,.44);
    backdrop-filter:blur(3px);
    -webkit-backdrop-filter:blur(3px);
  }
  .nhpq-mobile-menu-backdrop[hidden],
  .nhpq-mobile-menu[hidden],
  .nhpq-mobile-support-sheet[hidden] { display:none !important; }
  .nhpq-mobile-menu {
    position:fixed;
    z-index:5299;
    top:calc(var(--nhpq-mobile-header) + 8px);
    right:max(10px,env(safe-area-inset-right));
    width:min(310px,calc(100% - 20px));
    display:grid;
    gap:7px;
    padding:12px;
    border:1px solid #d6e4e7;
    border-radius:18px;
    background:#fff;
    box-shadow:0 20px 55px rgba(12,40,54,.28);
  }
  .nhpq-mobile-menu button {
    min-height:48px;
    display:flex;
    align-items:center;
    gap:12px;
    width:100%;
    padding:10px 12px;
    border:0;
    border-radius:13px;
    color:#193d50;
    background:#f4f8f9;
    font-size:14px;
    font-weight:800;
    text-align:left;
  }
  .nhpq-mobile-menu button svg { width:21px; height:21px; color:var(--teal); }
  .nhpq-mobile-menu small { padding:2px 8px 5px; color:#6b808d; font-size:11px; line-height:1.45; }

  .nhpq-mobile-support-sheet { display:block; padding:0 15px 18px; }
  .nhpq-mobile-support-sheet .nhpq-mobile-sheet-head { margin:0 -15px 14px; }
  .nhpq-mobile-support-list { display:grid; gap:9px; }
  .nhpq-mobile-support-list .support-contact { min-height:58px; padding:11px 13px; }
  .nhpq-mobile-support-list .support-contact a { min-height:30px; display:flex; align-items:center; }

  .nhpq-intro-floating-btn { display:none !important; }
}

@media (max-width:360px) {
  .topbar .brand strong { font-size:11px; }
  .topbar .brand small { font-size:10px; }
  .nhpq-mobile-dock button { font-size:9.5px; }
  .nhpq-mobile-dock button svg { width:20px; height:20px; }
  .info-details { grid-template-columns:1fr; gap:3px; }
  .info-details dt { margin-top:7px; }
}

@media (prefers-reduced-motion:reduce) {
  .nhpq-mobile-menu,
  .search-card,
  .data-browser-card,
  .gps-status-card,
  .info-panel { scroll-behavior:auto; transition:none !important; animation:none !important; }
}


/* V38.15: keep legal documents and the active legend reachable inside the mobile layer sheet. */
@media (max-width:760px) {
  .nhpq-mobile-layer-info {
    display:grid;
    gap:8px;
    padding:12px 14px 14px;
    border-bottom:1px solid #dfeaec;
    background:#f5fafb;
  }
  .nhpq-mobile-layer-info-heading {
    display:grid;
    gap:2px;
    padding:0 2px 3px;
  }
  .nhpq-mobile-layer-info-heading strong {
    color:#17394d;
    font-size:13px;
    font-weight:900;
  }
  .nhpq-mobile-layer-info-heading small {
    color:#6b8290;
    font-size:10.5px;
    line-height:1.35;
  }
  .nhpq-mobile-layer-info-item {
    border:1px solid #d6e5e8;
    border-radius:14px;
    overflow:hidden;
    background:#fff;
  }
  .nhpq-mobile-layer-info-item > summary {
    min-height:54px;
    display:grid;
    grid-template-columns:minmax(0,1fr) 28px;
    align-items:center;
    gap:8px;
    padding:9px 10px 9px 13px;
    color:#1b4053;
    cursor:pointer;
    list-style:none;
    -webkit-tap-highlight-color:transparent;
  }
  .nhpq-mobile-layer-info-item > summary::-webkit-details-marker { display:none; }
  .nhpq-mobile-layer-info-item > summary > span:first-child {
    min-width:0;
    display:grid;
    gap:2px;
  }
  .nhpq-mobile-layer-info-item > summary strong {
    overflow:hidden;
    font-size:12.5px;
    font-weight:900;
    line-height:1.3;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .nhpq-mobile-layer-info-item > summary small {
    color:#718894;
    font-size:10px;
    line-height:1.3;
  }
  .nhpq-mobile-layer-info-chevron {
    width:28px;
    height:28px;
    display:grid;
    place-items:center;
    border-radius:9px;
    color:#4d7180;
    background:#edf5f6;
    font-size:0;
  }
  .nhpq-mobile-layer-info-chevron::before {
    content:"";
    width:7px;
    height:7px;
    border-right:2px solid currentColor;
    border-bottom:2px solid currentColor;
    transform:translateY(-2px) rotate(45deg);
    transition:transform .18s ease;
  }
  .nhpq-mobile-layer-info-item[open] .nhpq-mobile-layer-info-chevron::before {
    transform:translateY(2px) rotate(225deg);
  }
  .nhpq-mobile-layer-info-content {
    border-top:1px solid #e2ecee;
    background:#fff;
  }
  .nhpq-mobile-layer-info-content .document-body,
  .nhpq-mobile-layer-info-content .legend-list {
    max-height:min(42dvh,380px) !important;
    margin:0;
    overflow:auto !important;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
  }
  .nhpq-mobile-layer-info-content .document-body {
    padding:13px 13px 15px !important;
  }
  .nhpq-mobile-layer-info-content .legend-list {
    padding:12px 13px 15px !important;
  }
  .nhpq-mobile-layer-info-content .document-entry:first-child,
  .nhpq-mobile-layer-info-content .legend-dataset-title:first-child { margin-top:0; }
}
