/* Development view (#/development) — the Sussex Pipeline map + list.
   Scoped under .pipeline-view / .pl-dialog so nothing bleeds into other pages.
   Uses the dashboard tokens (styles.css); stage hues come from pipeline.js
   TONE_HEX, which is the same status ramp. */

.pipeline-view {
  --pl-top: 85px;
  --pl-bottom: 0px;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--pl-top) - var(--pl-bottom));
  min-height: 480px;
  background: var(--surface);
  color: var(--ink);
}
.pipeline-view[hidden] { display: none; }
.pl-icon { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- header ---------- */
.pl-head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-5); border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.pl-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.pl-logo { width: 32px; height: 32px; }
.pl-brand h1 { font-family: var(--font-display); font-size: 19px; font-weight: 600; line-height: 1; margin: 0; }
.pl-brand p { margin: 3px 0 0; font-size: var(--fs-1); font-weight: 500; color: var(--ink-mute); }
.pl-modes { display: flex; background: var(--neutral-soft); border-radius: 999px; padding: 2px; flex-shrink: 0; }
.pl-modes a {
  padding: 6px 14px; border-radius: 999px; font-size: var(--fs-4); font-weight: 600;
  color: var(--ink-mute); text-decoration: none;
}
.pl-modes a.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.pl-search { position: relative; display: flex; align-items: center; flex: 1 1 auto; max-width: 560px; min-width: 0; margin: 0 auto; }
.pl-search > .pl-icon { position: absolute; left: 13px; color: var(--ink-mute); pointer-events: none; }
.pl-search input {
  width: 100%; height: 40px; border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 0 36px 0 38px; font: inherit; font-size: var(--fs-4); background: var(--surface); color: var(--ink);
}
.pl-search input::-webkit-search-cancel-button { display: none; }
.pl-search-clear { position: absolute; right: 8px; border: 0; background: none; color: var(--ink-mute); padding: 4px; cursor: pointer; display: flex; }
.pl-synced { flex-shrink: 0; text-align: right; font-size: var(--fs-2); color: var(--ink-mute); line-height: 1.35; }
.pl-linkbtn { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); font-weight: 600; cursor: pointer; }
.pl-linkbtn:hover { text-decoration: underline; }

/* ---------- filter bar ---------- */
.pl-filters {
  display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0;
  padding: 10px var(--space-5); border-bottom: 1px solid var(--line);
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
}
.pl-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; flex-shrink: 0;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  font: inherit; font-size: var(--fs-3); font-weight: 500; color: var(--ink); white-space: nowrap; cursor: pointer;
}
.pl-chip:hover { border-color: var(--ink-mute); }
.pl-chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.pl-chip .pl-icon { width: 14px; height: 14px; }
.pl-chip i, .pl-legend i, .pl-badge i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.pl-seg { display: inline-flex; flex-shrink: 0; height: 32px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); }
.pl-seg button {
  border: 0; background: none; border-radius: 999px; padding: 0 12px; white-space: nowrap;
  font: inherit; font-size: var(--fs-3); font-weight: 500; color: var(--ink-mute); cursor: pointer;
}
.pl-seg button.is-active { background: var(--accent); color: #fff; }
.pl-seg.is-small { height: auto; }
.pl-seg.is-small button { padding: 4px 12px; font-size: var(--fs-2); font-weight: 600; }
.pl-sep { width: 1px; height: 20px; background: var(--line-strong); flex-shrink: 0; margin: 0 4px; }
.pl-select {
  height: 32px; flex-shrink: 0; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  padding: 0 28px 0 12px; font: inherit; font-size: var(--fs-3); color: var(--ink); max-width: 190px;
}

/* ---------- body: map + list ---------- */
.pl-body { position: relative; display: flex; flex: 1 1 auto; min-height: 0; }
.pl-map-pane { position: relative; flex: 1.15 1 0; min-width: 0; background: #eef0eb; }
/* More specific than maplibre-gl.css, which sets .maplibregl-map { position: relative }. */
.pipeline-view .pl-map { position: absolute; inset: 0; }
.pl-map-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 32px; text-align: center; color: var(--ink-soft); font-size: var(--fs-4); }
.pl-map-msg[hidden] { display: none; }
.pl-follow {
  position: absolute; left: 12px; top: 12px; display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.95);
  box-shadow: var(--shadow-sm); font-size: var(--fs-2); font-weight: 600; cursor: pointer;
}
.pl-follow input { accent-color: var(--accent); margin: 0; }
.pl-legend {
  position: absolute; left: 12px; bottom: 24px; max-width: 340px; display: flex; flex-wrap: wrap; gap: 4px 12px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: rgba(255,255,255,.95);
  box-shadow: var(--shadow-sm); font-size: var(--fs-1); font-weight: 500;
}
.pl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.pl-legend i { width: 10px; height: 10px; }

.pl-list-pane { display: flex; flex-direction: column; width: min(52%, 760px); flex-shrink: 0; min-height: 0; border-left: 1px solid var(--line); background: var(--bg); }
.pl-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-4); padding: 12px var(--space-5); border-bottom: 1px solid var(--line); background: var(--surface); flex-shrink: 0; }
.pl-kpi { min-width: 0; }
.pl-kpi-label, .pl-kpi-sub { font-size: var(--fs-2); color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-kpi-label { font-weight: 500; }
.pl-kpi-value { font-size: 18px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.pl-list-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 12px var(--space-5) 8px; flex-shrink: 0; font-size: var(--fs-4); }
.pl-list-head strong { font-variant-numeric: tabular-nums; }
.pl-list-head span { color: var(--ink-mute); }
.pl-sort { display: flex; align-items: center; gap: 4px; color: var(--ink-mute); }
.pl-sort .pl-icon { width: 14px; height: 14px; }
.pl-sort .pl-select { border: 0; background: transparent; font-weight: 600; color: var(--ink); padding-left: 2px; }
.pl-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--space-5) var(--space-6); }
.pl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.pl-more { display: flex; justify-content: center; margin-top: var(--space-5); }
.pl-empty { display: flex; flex-direction: column; align-items: center; padding: 64px 16px; text-align: center; }
.pl-empty .pl-icon { width: 32px; height: 32px; color: var(--line-strong); }
.pl-empty strong { margin-top: 12px; font-size: var(--fs-4); }
.pl-empty p { margin: 4px 0 0; max-width: 320px; font-size: var(--fs-4); color: var(--ink-mute); }
.pl-source { display: flex; gap: 8px; margin: 32px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: var(--fs-2); line-height: 1.6; color: var(--ink-mute); }
.pl-source .pl-icon { width: 14px; height: 14px; margin-top: 2px; }
.pl-source a { color: inherit; }

/* ---------- cards ---------- */
.pl-card {
  overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  cursor: pointer; transition: box-shadow .15s, border-color .15s; content-visibility: auto; contain-intrinsic-size: auto 300px;
}
.pl-card:hover, .pl-card.is-active { box-shadow: var(--shadow-md); }
.pl-card.is-active { border-color: var(--accent); }
.pl-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.pl-card-media, .pl-detail-media { position: relative; }
.pl-thumb { position: relative; height: 128px; overflow: hidden; }
.pl-thumb.is-large { height: 220px; }
.pl-thumb svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.pl-thumb-icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: .45; }
.pl-thumb-icon .pl-icon { width: 36px; height: 36px; stroke-width: 1.5; }
.pl-card-badge { position: absolute; left: 10px; top: 10px; }
.pl-detail-media .pl-card-badge { left: 16px; top: 16px; }
.pl-card-hearing {
  position: absolute; right: 10px; top: 10px; display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.95); box-shadow: var(--shadow-sm);
  font-size: var(--fs-1); font-weight: 700;
}
.pl-card-hearing .pl-icon { width: 12px; height: 12px; }
.pl-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: var(--fs-2); font-weight: 700; white-space: nowrap;
}
.pl-badge.is-solid { color: #fff; box-shadow: var(--shadow-sm); }
.pl-badge i { width: 6px; height: 6px; }
.pl-card-body { padding: 12px; }
.pl-card-facts { font-size: var(--fs-5); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-card h3 { margin: 4px 0 0; font-size: var(--fs-4); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-card-meta { display: flex; align-items: center; gap: 4px; margin-top: 2px; font-size: var(--fs-2); color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-card-meta span { overflow: hidden; text-overflow: ellipsis; }
.pl-card-meta .pl-icon { width: 12px; height: 12px; }
.pl-card .pl-stepper { margin-top: 10px; }
.pl-card-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: var(--fs-1); color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.pl-card-foot strong { color: var(--ink); }
.pl-card-permit { padding: 12px; }
.pl-permit-top { display: flex; align-items: flex-start; gap: 12px; }
.pl-permit-icon { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--r-md); flex-shrink: 0; }
.pl-permit-icon .pl-icon { width: 20px; height: 20px; }
.pl-permit-title { min-width: 0; flex: 1; }
.pl-permit-title > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pl-permit-title h3 { margin: 0; }
.pl-permit-desc {
  margin: 8px 0 0; min-height: 2.6em; font-size: var(--fs-2); line-height: 1.3; color: var(--ink-mute);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pl-card-skel { padding: 0 0 12px; cursor: default; }
.pl-skel { height: 44px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--neutral-soft), #f8f8f6, var(--neutral-soft)); background-size: 200% 100%; animation: pl-shimmer 1.4s linear infinite; }
.pl-card-skel .pl-skel { height: 14px; margin: 10px 12px 0; }
.pl-card-skel .pl-skel.is-short { width: 50%; }
.pl-card-skel .pl-skel-thumb { height: 128px; margin: 0; border-radius: 0; }
@keyframes pl-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .pl-skel { animation: none; } }

/* ---------- stepper ---------- */
.pl-stepper-bars { display: flex; gap: 4px; }
.pl-stepper-bars span { flex: 1; height: 6px; border-radius: 999px; background: rgba(102,110,107,.18); }
.pl-stepper-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: var(--fs-1); font-weight: 500; color: var(--ink-mute); }
.pl-stepper-labels .is-current { color: var(--ink); font-weight: 700; }

/* ---------- mobile map/list toggle ---------- */
.pl-toggle-view { display: none; }

/* ---------- detail dialog ---------- */
.pl-dialog {
  width: min(768px, calc(100vw - 32px)); max-height: 92dvh; padding: 0; border: 0;
  border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); overflow: hidden;
}
.pl-dialog[open] { display: flex; flex-direction: column; }
.pl-dialog::backdrop { background: rgba(15,26,20,.45); }
.pl-dialog > div { overflow-y: auto; overscroll-behavior: contain; }
.pl-dialog-close {
  position: absolute; right: 12px; top: 12px; z-index: 2; display: flex; padding: 6px;
  border: 0; border-radius: 999px; background: rgba(255,255,255,.92); box-shadow: var(--shadow-sm); color: var(--ink); cursor: pointer;
}
.pl-dialog.is-viewer { height: 88dvh; }
.pl-dialog.is-viewer > div { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.pl-detail { display: flex; flex-direction: column; gap: var(--space-6); padding: var(--space-6); }
.pl-detail h4 { margin: 0 0 8px; font-size: var(--fs-4); font-weight: 700; }
.pl-eyebrow { margin-top: 12px; font-size: var(--fs-2); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-mute); }
.pl-detail-media + .pl-detail .pl-eyebrow { margin-top: 0; }
.pl-detail-title { margin: 4px 0 0; font-family: var(--font-display); font-size: 22px; font-weight: 600; line-height: 1.25; }
.pl-detail-sub { display: flex; align-items: center; gap: 4px; margin: 4px 0 0; font-size: var(--fs-4); color: var(--ink-mute); }
.pl-detail-sub .pl-icon { width: 14px; height: 14px; }
.pl-box { padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--r-lg); }
.pl-box .pl-muted { margin: 12px 0 0; font-size: var(--fs-2); }
.pl-muted { color: var(--ink-mute); }
.pl-muted strong { color: var(--ink); }
.pl-desc { margin: 0; font-size: var(--fs-4); line-height: 1.6; }
.pl-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.pl-fact { min-width: 0; }
.pl-fact div { font-size: var(--fs-2); font-weight: 500; color: var(--ink-mute); }
.pl-fact strong { display: block; font-size: var(--fs-4); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-hearings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pl-hearings li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-md); font-size: var(--fs-4); }
.pl-hearings li > span { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; color: var(--ink-mute); }
.pl-hearings li > span:first-child { color: var(--ink); }
.pl-hearings .is-upcoming { color: var(--ink); font-weight: 700; }
.pl-hearings small { font-weight: 500; color: var(--ink-mute); }
.pl-hearings a { display: flex; color: var(--accent); }
.pl-parcels { display: flex; flex-wrap: wrap; gap: 8px; }
.pl-parcel {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border: 1px solid var(--line-strong); border-radius: 999px;
  font-size: var(--fs-3); font-weight: 500; color: var(--ink); text-decoration: none; font-variant-numeric: tabular-nums;
}
.pl-parcel:hover { border-color: var(--accent); color: var(--accent); }
.pl-parcel .pl-icon { width: 12px; height: 12px; }
.pl-docs-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pl-docs-head h4 { margin: 0; }
.pl-docs { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.pl-docs li + li { border-top: 1px solid var(--line); }
.pl-docs button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; background: none;
  font: inherit; text-align: left; color: var(--ink); cursor: pointer;
}
.pl-docs button:hover { background: var(--surface-alt); }
.pl-docs button:hover strong { color: var(--accent); }
.pl-docs button:disabled { opacity: .6; cursor: default; }
.pl-docs .pl-icon { color: var(--ink-mute); }
.pl-docs .pl-icon.is-plan { color: var(--accent); }
.pl-docs span { flex: 1; min-width: 0; }
.pl-docs strong, .pl-docs small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-docs strong { font-size: var(--fs-4); font-weight: 500; }
.pl-docs small { font-size: var(--fs-2); color: var(--ink-mute); }
.pl-docs time { flex-shrink: 0; font-size: var(--fs-2); color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.pl-docs-empty { margin: 0; padding: 16px 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); text-align: center; font-size: var(--fs-4); color: var(--ink-mute); }
.pl-docs-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: var(--fs-2); }
.pl-docs-foot a { color: var(--ink-mute); font-weight: 600; }
.pl-docs-foot a:hover { color: var(--accent); }
.pl-notice {
  display: flex; gap: 10px; margin-bottom: 8px; padding: 10px 12px; border: 1px solid var(--warn-bd); border-radius: var(--r-md);
  background: var(--warn-soft); color: var(--warn); font-size: var(--fs-2); line-height: 1.55; text-align: left;
}
.pl-notice a { color: inherit; font-weight: 700; }
.pl-notice .pl-icon { margin-top: 1px; }
.pl-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: var(--space-4); border-top: 1px solid var(--line); }
.pl-detail-actions .btn, .pl-viewer-head .btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.pl-detail-actions .pl-icon, .pl-viewer-head .pl-icon { width: 14px; height: 14px; }
.pl-viewer-head { display: flex; align-items: center; gap: 12px; padding: 12px 56px 12px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.pl-viewer-title { flex: 1; min-width: 0; }
.pl-viewer-title strong, .pl-viewer-title small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-viewer-title strong { font-size: var(--fs-4); }
.pl-viewer-title small { font-size: var(--fs-2); color: var(--ink-mute); }
.pl-viewer-frame { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }
.pl-viewer-down { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; }
.pl-viewer-down > .pl-icon { width: 40px; height: 40px; color: var(--ink-mute); }
.pl-viewer-down .pl-notice { max-width: 460px; }
.pl-viewer-down .pl-detail-actions { border: 0; justify-content: center; }

/* MapLibre's attribution sits under our legend otherwise. */
.pipeline-view .maplibregl-ctrl-bottom-right { z-index: 1; }

/* ---------- narrower screens ---------- */
@media (max-width: 1180px) {
  .pl-synced { display: none; }
  .pl-brand div { display: none; }
  .pl-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pl-kpi:nth-child(n+4) { display: none; }
  .pl-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  /* Phones and tablets: one pane at a time, swapped by a floating button, and
     the fixed tab bar takes the bottom 56px. */
  .pipeline-view { --pl-bottom: calc(56px + env(safe-area-inset-bottom)); }
  .pl-head { flex-wrap: wrap; padding: 10px var(--space-4); }
  .pl-search { order: 3; flex-basis: 100%; max-width: none; }
  .pl-filters { padding: 8px var(--space-4); }
  .pl-list-pane { width: 100%; border-left: 0; }
  .pl-map-pane { display: none; }
  .pipeline-view.show-map .pl-map-pane { display: block; }
  .pipeline-view.show-map .pl-list-pane { display: none; }
  .pl-kpis, .pl-list-head { padding-left: var(--space-4); padding-right: var(--space-4); }
  .pl-list { padding: 0 var(--space-4) 88px; }
  .pl-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .pl-toggle-view {
    position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 5;
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border: 0; border-radius: 999px;
    background: var(--ink); color: #fff; font: inherit; font-size: var(--fs-4); font-weight: 700; box-shadow: var(--shadow-lg); cursor: pointer;
  }
  .pl-legend { bottom: 72px; right: 12px; }
  .pl-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pl-dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .pl-detail { padding: var(--space-5); }
}
