/* Grantee · map layout: the full-bleed map, its controls, the selection tag, the legend and the floating record panel. */

.maplibregl-canvas:focus-visible { outline: none; }
.maplibregl-ctrl-group { background: var(--surface) !important; border: 1px solid var(--rule); border-radius: 10px !important; box-shadow: var(--shadow-sm) !important; overflow: hidden; }
.maplibregl-ctrl-group button { width: 34px !important; height: 34px !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--rule) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { background-image: none !important; position: relative; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon::before, .maplibregl-ctrl-group button .maplibregl-ctrl-icon::after { content: ""; position: absolute; left: 50%; top: 50%; background: var(--ink); width: 12px; height: 1.5px; transform: translate(-50%, -50%); }
.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::after { width: 1.5px !important; height: 12px !important; }
.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::after { display: none; }
.maplibregl-ctrl-group button:hover { background: var(--hover) !important; }
.maplibregl-ctrl-top-right { top: calc(var(--top) + 12px); right: 4px; }
.maplibregl-ctrl.maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--surface) 82%, transparent) !important; color: var(--quiet); font: 400 10.5px/1.4 var(--sans); }
.maplibregl-ctrl.maplibregl-ctrl-attrib a { color: var(--graphite); }
.maplibregl-ctrl-attrib.maplibregl-compact { border-radius: 8px; }
.maplibregl-ctrl-attrib-button { filter: grayscale(1); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1); }

/* the selected parcel's tag */
.sel-tag { display: inline-flex; width: max-content; align-items: center; gap: 6px; height: 24px; padding: 0 8px 0 7px; background: var(--ink); color: var(--on-ink); font: 600 11px/1 var(--sans); border-radius: 3px; white-space: nowrap; box-shadow: var(--shadow-sm); pointer-events: none; }
.sel-tag::after { content: ""; position: absolute; left: -9px; top: 50%; width: 9px; height: 1.5px; background: var(--ink); transform: translateY(-50%); }
.sel-tag i { width: 7px; height: 7px; border-radius: 50%; background: var(--needs); box-shadow: 0 0 0 1.5px var(--ink), 0 0 0 2.5px color-mix(in srgb, var(--needs) 50%, transparent); }
.sel-tag[data-state="review"] i { background: var(--amber); border-radius: 1.5px; box-shadow: 0 0 0 1.5px var(--ink); }
.sel-tag[data-state="released"] i { background: var(--green); border-radius: 1px; box-shadow: 0 0 0 1.5px var(--ink); }
.sel-tag[data-state="queued"] i, .sel-tag[data-state="unresearched"] i { background: var(--on-ink); border-radius: 1.5px; box-shadow: 0 0 0 1.5px var(--ink); opacity: .7; }

/* hover card for parcels on the map (desktop pointer only) */
.hovercard { position: fixed; z-index: 15; pointer-events: none; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow-sm); padding: 7px 10px; font-size: 12.5px; display: none; max-width: 260px; }
.hovercard b { display: block; font-weight: 600; font-size: 13.5px; }
.hovercard span { color: var(--graphite); }
.hovercard .st { font-weight: 500; font-size: 12.5px; margin-top: 3px; color: var(--graphite); }

/* ───────── legend ───────── */
.legend {
  position: fixed; z-index: 9; left: calc(var(--panel-w) + 32px); bottom: 16px; height: 48px; display: flex; align-items: center; gap: 2px; padding: 0 6px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow-sm);
  transition: left 260ms var(--ease);
}
body.rec-closed .legend { left: 16px; }
.lg-toggle { display: none; }
.legend .t { font-size: 12.5px; color: var(--graphite); padding: 0 8px; margin-right: 2px; border-right: 1px solid var(--rule); height: 24px; display: flex; align-items: center; white-space: nowrap; }
.lg { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: 8px; font-size: 13.5px; white-space: nowrap; transition: background-color 160ms var(--ease), opacity 160ms var(--ease); }
.lg:hover { background: var(--hover); }
.lg[aria-pressed="false"] { opacity: .45; }
.lg[aria-pressed="false"] .lg-sw { filter: grayscale(1); }
.lg .n { font: 500 11px/1 var(--mono); color: var(--graphite); display: inline-block; overflow: hidden; height: 13px; line-height: 13px; }
/* the legend count rolls when an approval or a send-back moves one parcel */
.lg .n .nr { display: inline-block; animation: nroll 160ms var(--ease) both; }
@keyframes nroll { from { transform: translateY(100%); opacity: 0; } to { transform: none; opacity: 1; } }
/* dark: "Not researched" is a filled rule swatch, not a white square */
:root[data-theme="dark"] .lg-sw.is-unresearched { background: var(--rule-strong); box-shadow: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lg-sw.is-unresearched { background: var(--rule-strong); box-shadow: none; } }
@media (max-width: 1240px) and (min-width: 721px) { .legend .t { display: none; } .lg { padding: 0 8px; } }
@media (max-width: 1100px) and (min-width: 721px) { .lg .w { display: none; } }

/* ───────── floating record panel ───────── */
.panel {
  position: fixed; z-index: 10; left: 16px; top: calc(var(--top) + 16px); bottom: 16px; width: var(--panel-w);
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
  transition: transform 260ms var(--ease), opacity 200ms var(--ease);
}
body.is-viewas .panel { top: calc(var(--top) + 28px + 12px); }
.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel.is-empty { bottom: auto; }
.panel .scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }

/* empty record state */
.rec-empty { padding: 18px 20px 18px; }
.rec-empty h2 { margin: 0; font-size: 15px; font-weight: 600; }
.rec-empty p { margin: 4px 0 12px; color: var(--graphite); font-size: 13.5px; }
.rec-empty .try { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 10px; text-align: left; transition: border-color 160ms var(--ease), background-color 160ms var(--ease); }
.rec-empty .try:hover { border-color: var(--ink); background: var(--hover); }
.rec-empty .try b { display: block; font-weight: 600; font-size: 13.5px; }
.rec-empty .try span { font-size: 12.5px; color: var(--graphite); }
.rec-empty .try .go { margin-left: auto; font: 500 11px/1 var(--mono); color: var(--graphite); }

/* ───────── phone: the record becomes a bottom sheet ───────── */
@media (max-width: 720px) {
  :root { --panel-w: 0px; }
  .panel {
    left: 0; right: 0; top: auto !important; bottom: var(--tab-h, 0px); width: auto; height: var(--sheet-h, 52vh);
    border-radius: 14px 14px 0 0; border-bottom: 0;
    transition: height 300ms var(--ease);
  }
  .panel.is-empty { height: auto; }
  .panel.dragging { transition: none; }
  .panel .grip { display: grid; place-items: center; flex: none; height: 26px; width: 100%; touch-action: none; cursor: grab; }
  .panel .grip::before { content: ""; width: 40px; height: 4px; border-radius: 2px; background: var(--rule-strong); }
  .panel .grip:focus-visible { outline-offset: -4px; }
  .panel.is-empty .grip { display: none; }
  .panel .scroll { overflow-y: hidden; }
  .panel[data-snap="full"] .scroll { overflow-y: auto; }

  .legend { left: 8px !important; top: calc(var(--top) + 8px); bottom: auto; height: auto; padding: 3px; flex-direction: column; align-items: stretch; gap: 0; border-radius: 10px; }
  body.is-viewas .legend { top: calc(var(--top) + 36px); }
  .legend .t { display: none; }
  .lg-toggle { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 8px; font-size: 12.5px; font-weight: 600; border-radius: 8px; }
  .lg-toggle .sw4 { display: grid; grid-template-columns: 7px 7px; gap: 2px; }
  .lg-toggle .sw4 .lg-sw { width: 7px; height: 7px; border-radius: 1.5px; --c: 1.5px; }
  .lg-toggle .sw4 .lg-sw::after { display: none; }
  .lg-toggle .sw4 .lg-sw.is-needs { background: var(--needs); box-shadow: none; border-radius: 50%; }
  .legend:not(.open) .lg { display: none; }
  .legend.open .lg-toggle { border-bottom: 1px solid var(--rule); border-radius: 8px 8px 0 0; margin-bottom: 3px; }
  .lg { height: 40px; padding: 0 10px 0 8px; font-size: 13.5px; }
  .lg .w { display: inline !important; }
  .lg .n { margin-left: auto; padding-left: 12px; }
  .maplibregl-ctrl-bottom-right { bottom: calc(var(--sheet-h, 52vh) + var(--tab-h, 0px)); }
  .maplibregl-ctrl-top-right { top: calc(var(--top) + 8px); }
  .hovercard { display: none !important; }
}
