/* ============================================================================
   Meijin neighborhood picker — shared component styles
   Single source of truth, loaded by picker-test.html AND onboarding/index.html.
   All rules scoped under .mjp so they can't collide with host page styles.
   Palette vars live on .mjp (not :root) to avoid clobbering --ink etc. globally.
   ============================================================================ */

.mjp {
  /* Surveyor's palette — paper, ink, plot lines */
  --paper:        #F4EFE6;
  --paper-warm:   #EDE5D3;
  --paper-cool:   #E8E1D1;
  --ink:          #1A1814;
  --ink-soft:     #4A463E;
  --ink-faint:    #8A8478;
  --rule:         #C9C0AD;
  --rule-faint:   #DDD4BF;

  /* Plot colors — drafting ink + survey markers */
  --plot:         #C1440E;   /* survey-stake red */
  --plot-soft:    #D86A3C;
  --plot-fill:    rgba(193, 68, 14, 0.12);
  --plot-fill-h:  rgba(193, 68, 14, 0.22);

  --primary:      #2D4A3E;   /* forest ink */
  --primary-soft: #5A7060;
  --primary-fill: rgba(45, 74, 62, 0.08);
  --primary-fill-h: rgba(45, 74, 62, 0.18);

  --selected-fill: rgba(193, 68, 14, 0.78);
  --selected-stroke: #7A2A08;

  --adjacent-fill: rgba(74, 70, 62, 0.04);
  --adjacent-stroke: #8A8478;

  --display:  'Fraunces', Georgia, serif;
  --mono:     'JetBrains Mono', ui-monospace, monospace;

  --shadow-soft: 0 1px 0 rgba(26,24,20,0.04), 0 4px 12px rgba(26,24,20,0.04);
  --shadow-lifted: 0 1px 0 rgba(26,24,20,0.06), 0 12px 32px rgba(26,24,20,0.08);

  color: var(--ink);
  font-family: var(--display);
}

.mjp * { box-sizing: border-box; }

/* ───────────────── Layout ───────────────── */
.mjp .layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr);
  gap: 32px;
  align-items: start;
}

/* ───────────────── Map panel ───────────────── */
.mjp .map-panel {
  background: var(--paper-warm);
  border: 0.5px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  position: relative;
}

.mjp .map-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 0.5px solid var(--rule);
  background: rgba(244, 239, 230, 0.5);
  backdrop-filter: blur(8px);
}

.mjp .zip-input-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mjp .zip-input-group label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.mjp .zip-input {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.08em;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink);
  width: 90px;
  padding: 4px 0;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s;
}
.mjp .zip-input:focus { border-bottom-color: var(--plot); }

.mjp .zip-meta {
  font-family: var(--display);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-soft);
}
.mjp .zip-meta::before {
  content: '·';
  margin-right: 10px;
  color: var(--ink-faint);
}

.mjp .adjacent-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  transition: color 0.2s;
}
.mjp .adjacent-toggle:hover { color: var(--ink); }

.mjp .adjacent-toggle .switch {
  width: 26px;
  height: 14px;
  background: var(--rule);
  border-radius: 7px;
  position: relative;
  transition: background 0.2s;
}
.mjp .adjacent-toggle .switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  background: var(--paper);
  border-radius: 50%;
  transition: transform 0.2s;
}
.mjp .adjacent-toggle.on .switch { background: var(--ink); }
.mjp .adjacent-toggle.on .switch::after { transform: translateX(12px); }

/* ───────────────── SVG map ───────────────── */
.mjp .map-stage {
  position: relative;
  height: 540px;
  background:
    linear-gradient(to bottom, rgba(244, 239, 230, 0) 0%, rgba(232, 225, 209, 0.6) 100%),
    var(--paper-warm);
}

.mjp .map-stage svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  user-select: none;
}
.mjp .map-stage svg.panning {
  cursor: grabbing;
}
.mjp .zoom-hint {
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}
.mjp .map-stage:hover .zoom-hint {
  opacity: 1;
}

.mjp .compass {
  position: absolute;
  top: 18px;
  right: 22px;
  font-family: var(--display);
  font-size: 11px;
  color: var(--ink-faint);
  text-align: center;
  letter-spacing: 0.1em;
  pointer-events: none;
}
.mjp .compass .arrow {
  display: block;
  font-size: 20px;
  line-height: 1;
  margin-bottom: 2px;
  color: var(--ink-soft);
}

.mjp .map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: rgba(244, 239, 230, 0.7);
  border-top: 0.5px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

.mjp .map-footer .selection-count {
  color: var(--ink);
  font-weight: 500;
}

/* Polygon interactions */
.mjp .neighborhood-poly {
  cursor: pointer;
  transition: fill 0.18s ease, stroke-width 0.18s ease, transform 0.2s;
  transform-origin: center;
  transform-box: fill-box;
}
.mjp .neighborhood-poly:hover { transform: translateY(-1px); }

.mjp .neighborhood-label {
  pointer-events: none;
  font-family: var(--display);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: -0.01em;
}

.mjp .source-flag {
  pointer-events: none;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
  fill: var(--plot);
  letter-spacing: 0.1em;
}

.mjp .zip-boundary {
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 1.2;
  stroke-dasharray: 8 4 2 4;
  pointer-events: none;
}

/* ───────────────── Side panel ───────────────── */
.mjp .side-panel {
  position: sticky;
  top: 24px;
}

.mjp .selection-card {
  background: var(--paper);
  border: 0.5px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.mjp .selection-card .head {
  padding: 22px 22px 16px;
  border-bottom: 0.5px solid var(--rule);
}

.mjp .selection-card .head h2 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.mjp .selection-card .head .sub {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

.mjp .selection-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 380px;
  overflow-y: auto;
}

.mjp .selection-list:empty::after {
  content: 'No selections yet.\A Click a parcel on the map to begin.';
  white-space: pre-line;
  display: block;
  padding: 48px 22px;
  text-align: center;
  font-family: var(--display);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-faint);
  line-height: 1.6;
}

.mjp .selection-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 0.5px solid var(--rule-faint);
  transition: background 0.15s;
}
.mjp .selection-item:last-child { border-bottom: none; }
.mjp .selection-item:hover { background: var(--paper-warm); }

.mjp .selection-item .index {
  font-family: var(--display);
  font-style: italic;
  font-size: 18px;
  color: var(--plot);
  font-weight: 500;
  width: 22px;
  text-align: right;
}

.mjp .selection-item .body { min-width: 0; }
.mjp .selection-item .name {
  font-family: var(--display);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.005em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mjp .selection-item .meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  margin-top: 3px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mjp .selection-item .meta .tag {
  color: var(--plot);
  font-weight: 500;
}
.mjp .selection-item .meta .tag.adjacent { color: var(--ink-soft); }

.mjp .selection-item .remove {
  background: none;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
  font-size: 18px;
  line-height: 1;
}
.mjp .selection-item .remove:hover { color: var(--plot); }

.mjp .footer-cta {
  padding: 20px 22px;
  border-top: 0.5px solid var(--rule);
  background: var(--paper-cool);
}

.mjp .counter {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.mjp .counter .n {
  font-family: var(--display);
  font-style: italic;
  font-size: 28px;
  color: var(--ink);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.mjp .counter .of { color: var(--ink-faint); }

.mjp .continue-btn {
  width: 100%;
  padding: 16px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  font-family: var(--display);
  font-size: 16px;
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.mjp .continue-btn:hover:not(:disabled) {
  background: var(--plot);
  letter-spacing: 0.005em;
}
.mjp .continue-btn:disabled {
  background: var(--rule);
  color: var(--ink-faint);
  cursor: not-allowed;
}
.mjp .continue-btn .arrow { font-style: normal; }

/* ───────────────── Legend (below map) ───────────────── */
.mjp .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 20px;
  padding: 16px 22px;
  background: var(--paper-warm);
  border: 0.5px solid var(--rule-faint);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.mjp .legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mjp .legend-swatch {
  width: 16px;
  height: 12px;
  border-radius: 1px;
}
.mjp .legend-swatch.primary { background: var(--plot-fill); border: 1px solid var(--plot-soft); }
.mjp .legend-swatch.partial {
  background: var(--plot-fill);
  border: 1px solid var(--plot-soft);
  background-image: repeating-linear-gradient(45deg, transparent, transparent 3px, var(--plot-soft) 3px, var(--plot-soft) 4px);
}
.mjp .legend-swatch.adjacent {
  background: var(--adjacent-fill);
  border: 1px dashed var(--adjacent-stroke);
}
.mjp .legend-swatch.selected { background: var(--selected-fill); border: 1px solid var(--selected-stroke); }

/* ───────────────── States: loading, error, empty ───────────────── */
.mjp .state-overlay {
  position: absolute;
  inset: 0;
  background: rgba(244, 239, 230, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.mjp .state-overlay.hidden { display: none; }

.mjp .state-overlay .label {
  font-family: var(--display);
  font-style: italic;
  font-size: 18px;
  color: var(--ink-soft);
}

.mjp .state-overlay .detail {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.mjp .spinner {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--rule);
  border-top-color: var(--plot);
  border-radius: 50%;
  animation: mjp-spin 0.8s linear infinite;
}
@keyframes mjp-spin { to { transform: rotate(360deg); } }

.mjp .state-overlay.error .label { color: var(--plot); }

/* ───────────────── Responsive ───────────────── */
@media (max-width: 980px) {
  .mjp .layout { grid-template-columns: 1fr; }
  .mjp .side-panel { position: static; }
  .mjp .map-stage { height: 420px; }
}

@media (max-width: 600px) {
  .mjp .map-controls { flex-wrap: wrap; gap: 12px; }
}
