/* relink.css [WP14] — the relink split view (CONTRACT.md §11).
 * Self-contained: does not depend on edit.css or plugin-host's injected
 * styles being loaded — every class here is its own (`vp-relink-*`). Colors
 * restyled to the "All Subjects" editorial brand (brand.css tokens), with a
 * literal fallback on every var() so this still renders correctly if ever
 * reached before brand.css loads. Genuine state colors (amber "unsaved",
 * green "free slot"/"success", the map's occupied/error red) stay their own
 * hue — those are functional signals, not brand chrome, and diluting them
 * into a single crimson would blur the meaning. */

#relink-root {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(22, 22, 22, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#relink-root[hidden] { display: none; }

.vp-relink-shell {
  width: min(1180px, 100%);
  height: min(88vh, 820px);
  background: var(--g-white, #fff);
  color: var(--g-100, #161616);
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(22, 22, 22, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font: 14px var(--font-sans, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif);
}

/* ---------- header ---------- */
.vp-relink-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--g-100, #161616);
  color: var(--paper, #f3efe8);
}
.vp-relink-head h2 { margin: 0; font-family: var(--font-serif, Georgia, serif); font-weight: 400; font-size: 19px; letter-spacing: 0; }
.vp-relink-head .vp-relink-btn {
  background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.2); color: var(--paper, #f3efe8);
}
.vp-relink-head .vp-relink-btn:hover { background: var(--crimson, #a62122); border-color: var(--crimson, #a62122); color: var(--g-white, #fff); }

/* ---------- body: split layout ---------- */
.vp-relink-body { flex: 1; display: flex; min-height: 0; }

.vp-relink-left {
  flex: 0 0 300px;
  padding: 24px;
  border-right: 1px solid var(--g-20, #e0e0e0);
  background: var(--paper, #f3efe8);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.vp-relink-cover {
  border-radius: 4px; overflow: hidden; box-shadow: 0 8px 22px rgba(22, 22, 22, 0.18);
  aspect-ratio: 1 / 1; background: var(--g-20, #e0e0e0); flex: none;
}
.vp-relink-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.vp-relink-left-text { display: flex; flex-direction: column; gap: 8px; }
.vp-relink-left h3 { margin: 0; font-family: var(--font-serif, Georgia, serif); font-weight: 400; font-size: 19px; line-height: 1.3; color: var(--g-100, #161616); }
.vp-relink-note { margin: 0; font-size: 13px; line-height: 1.55; color: var(--g-70, #525252); }
.vp-relink-coords { font-family: var(--font-mono, "SF Mono", Menlo, Consolas, monospace); font-size: 11.5px; color: var(--g-50, #8d8d8d); font-variant-numeric: tabular-nums; }

.vp-relink-right {
  flex: 1; min-width: 0; padding: 20px 24px; display: flex; flex-direction: column; gap: 12px;
}

/* ---------- destination controls ---------- */
.vp-relink-dest-controls { display: flex; gap: 16px; flex-wrap: wrap; flex: none; }
.vp-relink-field { flex: 1 1 240px; display: flex; flex-direction: column; gap: 5px; }
.vp-relink-field label {
  font-family: var(--font-mono, "SF Mono", Menlo, Consolas, monospace);
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--g-60, #6f6f6f);
}
.vp-relink-field select, .vp-relink-field input {
  font: 14px var(--font-sans, sans-serif); padding: 9px 10px;
  border: none; border-bottom: 1px solid var(--g-50, #8d8d8d); border-radius: 0;
  background: var(--g-10, #f4f4f4); color: var(--g-100, #161616);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.vp-relink-field select:focus, .vp-relink-field input:focus {
  outline: none; border-bottom-color: var(--crimson, #a62122); box-shadow: 0 1px 0 0 var(--crimson, #a62122);
}

/* ---------- destination map ---------- */
.vp-relink-map-wrap {
  position: relative; flex: 1; min-height: 220px; border-radius: 6px;
  overflow: hidden; border: 1px solid var(--g-20, #e0e0e0); background: var(--paper, #f3efe8);
}
#relink-map { position: absolute; inset: 0; }
#relink-map .leaflet-container { background: var(--paper, #f3efe8); cursor: crosshair; }
.vp-relink-map-status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center; color: var(--g-50, #8d8d8d); font-size: 13px; line-height: 1.5;
}
.vp-relink-map-error { color: var(--crimson-hover, #8e1c1d); }

.vp-relink-hint { margin: 0; flex: none; font-size: 11.5px; color: var(--g-50, #8d8d8d); line-height: 1.4; }

/* hover box on the destination map — color signals what a click will do */
.vp-relink-hover {
  position: absolute; top: 0; left: 0; z-index: 50; pointer-events: none;
  border: 2px solid var(--crimson, #a62122); border-radius: 4px;
  box-shadow: 0 6px 18px rgba(22, 22, 22, 0.14);
  transition: transform 0.1s ease-out, width 0.1s ease-out, height 0.1s ease-out;
}
.vp-relink-hover[hidden] { display: none; }
.vp-relink-hover.depth { border-color: var(--crimson, #a62122); background: rgba(166, 33, 34, 0.08); }
.vp-relink-hover.occupied { border-color: var(--crimson-hover, #8e1c1d); background: rgba(142, 28, 29, 0.12); }
.vp-relink-hover.free { border-color: #2f6b4f; background: rgba(47, 107, 79, 0.14); }

/* ---------- confirm / success / spec bars ---------- */
.vp-relink-confirm, .vp-relink-success, .vp-relink-spec {
  flex: none; border-radius: 6px; padding: 14px 16px;
}
.vp-relink-confirm[hidden], .vp-relink-success[hidden], .vp-relink-spec[hidden] { display: none; }

.vp-relink-confirm {
  background: #fff7ec; border: 1px solid #f0dcb0;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.vp-relink-confirm-text { flex: 1 1 auto; font-size: 13.5px; font-weight: 700; color: #6b4a12; }
.vp-relink-confirm-actions { display: flex; gap: 10px; flex: none; }

.vp-relink-success {
  background: #eef6f0; border: 1px solid #cfe7d6;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.vp-relink-success-text { font-weight: 700; color: #1f4d3a; }
.vp-relink-success-link { color: var(--crimson, #a62122); font-weight: 700; text-decoration: none; margin-right: auto; }
.vp-relink-success-link:hover { text-decoration: underline; color: var(--crimson-hover, #8e1c1d); }

.vp-relink-spec {
  background: var(--g-10, #f4f4f4); border: 1px solid var(--g-20, #e0e0e0); display: flex; flex-direction: column; align-items: flex-start;
}
.vp-relink-spec-copy { margin: 0 0 10px; font-size: 13px; line-height: 1.55; color: var(--g-100, #161616); }
.vp-relink-spec-block {
  width: 100%; margin: 0 0 12px; padding: 12px 14px; box-sizing: border-box;
  background: var(--g-100, #161616); color: var(--paper, #f3efe8); border-radius: 4px;
  font: 12.5px var(--font-mono, ui-monospace, Menlo, Consolas, monospace); white-space: pre-wrap; word-break: break-all;
}

/* ---------- buttons (self-contained — not shared with edit.css) ---------- */
.vp-relink-btn {
  font: 500 13px var(--font-sans, sans-serif); border-radius: 3px; padding: 10px 16px; cursor: pointer;
  border: 1px solid var(--g-30, #c6c6c6); background: var(--g-white, #fff); color: var(--g-70, #525252);
  transition: background 0.15s, border-color 0.15s;
}
.vp-relink-btn:hover { background: var(--g-10, #f4f4f4); }
.vp-relink-btn-primary { background: var(--crimson, #a62122); color: var(--g-white, #fff); border: 0; font-weight: 600; }
.vp-relink-btn-primary:hover { background: var(--crimson-hover, #8e1c1d); }
.vp-relink-btn-ghost { background: var(--g-white, #fff); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  #relink-root { padding: 0; }
  .vp-relink-shell { width: 100vw; height: 100vh; border-radius: 0; }
  .vp-relink-body { flex-direction: column; overflow-y: auto; }
  .vp-relink-left {
    flex: none; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--g-20, #e0e0e0);
  }
  .vp-relink-cover { width: 76px; height: 76px; flex: none; aspect-ratio: auto; }
  .vp-relink-right { flex: 1 1 auto; }
  .vp-relink-map-wrap { min-height: 260px; }
}
@media (max-width: 520px) {
  .vp-relink-dest-controls { flex-direction: column; }
}
