/* Official JBF rail-panel shell (franzen-app-standards: skills/official-sidebars,
   references/RED_CROSS_SIDEBARS.md). Light-theme tokens from the standard's
   brand-system.css. Structure is the h120v2 exemplar: a CSS-grid .map-shell with
   data-left-open / data-right-open, each side an aside.surface holding both a
   collapsed .rail and an open .rail-panel; center stage holds the map and a
   collapsible bottom tray. All state is CSS driven; tabs/rails.js only flips
   the data attributes and persists them. */

.map-shell {
  --rail: 52px;
  --left-open: clamp(320px, 23vw, 420px);
  --right-open: clamp(340px, 27vw, 480px);
  --tray-open: clamp(260px, 36vh, 440px);
  --surface: #ffffff;
  --surface-strong: #f9fafb;
  --border: #dfe3e8;
  --border-hover: #b9c1cb;
  --text: #20242b;
  --text-bright: #111318;
  --muted: #69717d;
  --accent: #ED1B2E;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--left, var(--rail)) minmax(0, 1fr) var(--right, var(--rail));
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text);
}
.map-shell[data-left-open="true"] { --left: var(--left-open); }
.map-shell[data-right-open="true"] { --right: var(--right-open); }

.map-shell .surface {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--surface-strong);
}
.map-shell .surface--left { border-right: 1px solid var(--border); }
.map-shell .surface--right { border-left: 1px solid var(--border); }

.map-shell .rail {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.map-shell .rail button,
.map-shell .panel-head button,
.map-shell .tray-rail button,
.map-shell .tray-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.map-shell .panel-head button, .map-shell .tray-rail button, .map-shell .tray-close { width: 30px; height: 30px; font-size: 14px; }
.map-shell .rail button:hover, .map-shell .panel-head button:hover,
.map-shell .tray-rail button:hover, .map-shell .tray-close:hover { border-color: var(--border-hover); color: var(--text-bright); background: var(--surface); }
.map-shell button:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
.map-shell .rail-label {
  writing-mode: vertical-rl;
  color: var(--muted);
  font: 650 11px/1 var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
  letter-spacing: .14em;
  text-transform: uppercase;
}
.map-shell[data-left-open="true"] .surface--left .rail,
.map-shell[data-right-open="true"] .surface--right .rail { display: none; }
.map-shell[data-left-open="false"] .surface--left .rail-panel,
.map-shell[data-right-open="false"] .surface--right .rail-panel { display: none; }

.map-shell .rail-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  resize: horizontal;
  background: var(--surface-strong);
  color: var(--text);
}
.map-shell .surface--right .rail-panel { resize: none; }
.map-shell .panel-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.map-shell .panel-head h2 { margin: 0; color: var(--text-bright); font-size: 14px; font-weight: 700; letter-spacing: .01em; }
.map-shell .panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px;
}
.map-shell .panel-section { padding: 0 0 14px; margin: 0 0 14px; border-bottom: 1px solid var(--border); }
.map-shell .panel-section:last-child { border-bottom: 0; margin-bottom: 0; }
.map-shell .panel-section > h3 { margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.map-shell .center-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}
/* isolation: Leaflet panes (z-index 400+) and Plotly stay inside their cell, so the
   sticky tab nav and the gateway bar always paint above a map that scrolls under them. */
.map-shell .map-area,
.map-shell .tray-content,
.map-shell .rail-panel { position: relative; min-width: 0; min-height: 0; overflow: hidden; isolation: isolate; }
.map-shell .rail-panel { overflow: hidden; }

/* Bottom tray: open working surface, or a 44px rail with chevron + label. */
.map-shell .tray { border-top: 1px solid var(--border); background: var(--surface-strong); min-height: 0; display: flex; flex-direction: column; }
.map-shell .tray-rail {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 44px;
  color: var(--muted);
  font: 650 11px/1 var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
  letter-spacing: .14em;
  text-transform: uppercase;
}
.map-shell .tray-body { display: flex; flex-direction: column; height: var(--tray-open); min-height: 0; position: relative; }
.map-shell .tray-head { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.map-shell .tray-title { color: var(--muted); font: 650 11px/1 var(--font-mono, "IBM Plex Mono", ui-monospace, monospace); letter-spacing: .14em; text-transform: uppercase; }
.map-shell .tray-content { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; background: var(--surface); }
.map-shell .tray-grip { position: absolute; top: -4px; left: 0; right: 0; height: 8px; cursor: row-resize; touch-action: none; z-index: 3; }
.map-shell .center-stage[data-tray-open="false"] .tray-rail { display: flex; }
.map-shell .center-stage[data-tray-open="false"] .tray-body { display: none; }

@media (max-width: 820px) {
  .map-shell { --rail: 44px; position: relative; }
  .map-shell[data-left-open="true"] { --left: var(--rail); }
  .map-shell[data-right-open="true"] { --right: var(--rail); }
  .map-shell .surface { overflow: visible; position: static; }
  .map-shell .surface .rail-panel { position: absolute; z-index: 2000; top: 0; bottom: 0; width: min(86vw, 360px); background: var(--surface-strong); resize: none; box-shadow: 0 10px 30px rgba(31,41,55,.18); }
  .map-shell .surface--left .rail-panel { left: 0; border-right: 1px solid var(--border); }
  .map-shell .surface--right .rail-panel { right: 0; border-left: 1px solid var(--border); }
  .map-shell[data-left-open="true"] .surface--left .rail,
  .map-shell[data-right-open="true"] .surface--right .rail { display: flex; }
  .map-shell .rail button, .map-shell .panel-head button, .map-shell .tray-rail button, .map-shell .tray-close { min-width: 44px; min-height: 44px; }
  .map-shell .rail-label { font-size: 10px; }
  .map-shell { --tray-open: clamp(200px, 32vh, 320px); }
}
