/*
 * reading-overlay.css — styles for js/reading-overlay.js and js/reading-deeplink.js.
 * Lane cc-impl-1, 2026-10-10. Flag: reading_overlay_enabled (the modules add no
 * element while it is off, so nothing here matches).
 *
 * Everything is prefixed .rdg- and nothing here restyles a .pmv- element.
 * The viewer chrome is dark by default and light under html.light, like
 * css/plan-markup-viewer.css; the chrome colours below follow it through the
 * --rdg-* variables. The layer colours sit on a white drawing sheet in BOTH themes,
 * so they are chosen for white paper and do not change with the theme.
 */

.pmv-container,
.rdg-note,
.rdg-qlink {
  --rdg-surface: #1e1e1e;
  --rdg-surface-2: #262626;
  --rdg-border: #3a3a3a;
  --rdg-text: #e0e0e0;
  --rdg-text-2: #9a9a9a;
  --rdg-shadow: 0 10px 32px rgba(0, 0, 0, .5);
  --rdg-accent: var(--primary, #14b8a6);
}
.light .pmv-container,
.light .rdg-note,
.light .rdg-qlink {
  --rdg-surface: #ffffff;
  --rdg-surface-2: #f4f4f4;
  --rdg-border: #dddddd;
  --rdg-text: #333333;
  --rdg-text-2: #777777;
  --rdg-shadow: 0 10px 32px rgba(0, 0, 0, .15);
}

/* ── layer colours (one per layer key; used by the boxes and by the swatches) ── */
.rdg-l-refs          { --rdg-c: #2563eb; }
.rdg-l-dims          { --rdg-c: #0d9488; }
.rdg-l-tags          { --rdg-c: #7c3aed; }
.rdg-l-schedules     { --rdg-c: #b45309; }
.rdg-l-rooms         { --rdg-c: #059669; }
.rdg-l-views         { --rdg-c: #475569; }
.rdg-l-titleblock    { --rdg-c: #0369a1; }
.rdg-l-gaps          { --rdg-c: #dc2626; }
.rdg-l-issues        { --rdg-c: #c026d3; }
.rdg-l-lines_bound   { --rdg-c: #16a34a; }
.rdg-l-lines_form    { --rdg-c: #ca8a04; }
.rdg-l-lines_untyped { --rdg-c: #e11d48; }

/* ── the layer: a sibling of .pmv-overlay, laid out exactly like it ── */
.rdg-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* --rdg-z is the viewer zoom, written by reading-overlay.js on pmv:transform.
     vector-effect undoes the viewBox stretch but not the CSS scale on the wrapper, so
     stroke widths are divided by it to stay hairline at any zoom. */
  --rdg-z: 1;
}
.rdg-box {
  fill: var(--rdg-c);
  fill-opacity: .10;
  stroke: var(--rdg-c);
  stroke-width: calc(1.25px / var(--rdg-z));
  vector-effect: non-scaling-stroke;
  pointer-events: auto;
  cursor: pointer;
}
.rdg-box:hover { fill-opacity: .28; stroke-width: calc(2px / var(--rdg-z)); }
/* A view or table frame encloses other boxes: outline only, and only its edge takes the pointer. */
.rdg-box.rdg-frame {
  fill: none;
  stroke-dasharray: calc(6px / var(--rdg-z)) calc(4px / var(--rdg-z));
  pointer-events: stroke;
}
.rdg-box.rdg-frame:hover { stroke-width: calc(2.5px / var(--rdg-z)); }
.rdg-l-gaps.rdg-box { stroke-dasharray: calc(3px / var(--rdg-z)) calc(2px / var(--rdg-z)); }

.rdg-pulse {
  fill: none;
  stroke: #f59e0b;
  stroke-width: calc(3px / var(--rdg-z));
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  animation: rdg-pulse 1s ease-in-out 5;
}
@keyframes rdg-pulse {
  0%, 100% { stroke-opacity: 1; stroke-width: calc(3px / var(--rdg-z)); }
  50%      { stroke-opacity: .25; stroke-width: calc(7px / var(--rdg-z)); }
}

/* ── toolbar button (a .pmv-btn; only the on-state is ours) ── */
.rdg-toggle.rdg-active {
  border-color: var(--rdg-accent);
  color: var(--rdg-accent);
}

/* ── layers panel ── */
.rdg-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 90;
  width: 232px;
  max-height: calc(100% - 20px);
  overflow-y: auto;
  padding: 10px 12px;
  background: var(--rdg-surface);
  color: var(--rdg-text);
  border: 1px solid var(--rdg-border);
  border-radius: var(--radius-sm, 8px);
  box-shadow: var(--rdg-shadow);
  font-size: 12px;
  cursor: default;
}
.rdg-panel-head { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.rdg-panel-status { color: var(--rdg-text-2); margin-bottom: 6px; line-height: 1.35; }
.rdg-panel-group {
  margin: 8px 0 2px;
  color: var(--rdg-text-2);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.rdg-row { display: flex; align-items: center; gap: 7px; padding: 3px 0; cursor: pointer; }
.rdg-row input { margin: 0; accent-color: var(--rdg-accent); }
.rdg-row-label { flex: 1; }
.rdg-row-count { color: var(--rdg-text-2); font-family: var(--font-mono, 'JetBrains Mono', Consolas, monospace); font-size: 11px; }
.rdg-swatch {
  flex: none;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--rdg-c);
}

/* ── hover tooltip ── */
.rdg-tip {
  display: none;
  position: absolute;
  z-index: 95;
  max-width: 300px;
  padding: 5px 8px;
  background: var(--rdg-surface);
  color: var(--rdg-text);
  border: 1px solid var(--rdg-border);
  border-radius: 6px;
  box-shadow: var(--rdg-shadow);
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  overflow-wrap: anywhere;
}

/* ── click popover ── */
.rdg-pop {
  position: absolute;
  z-index: 96;
  width: 340px;
  max-height: 70%;
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--rdg-surface);
  color: var(--rdg-text);
  border: 1px solid var(--rdg-border);
  border-radius: var(--radius, 10px);
  box-shadow: var(--rdg-shadow);
  font-size: 12px;
  line-height: 1.4;
  cursor: default;
}
.rdg-pop-head { display: flex; align-items: flex-start; gap: 8px; }
.rdg-pop-head .rdg-swatch { margin-top: 4px; }
.rdg-pop-title { flex: 1; font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.rdg-pop-close {
  flex: none;
  background: none;
  border: none;
  color: var(--rdg-text-2);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
}
.rdg-pop-close:hover { color: var(--rdg-text); }
.rdg-pop-meta { margin-top: 4px; color: var(--rdg-text-2); font-size: 11px; text-transform: lowercase; }
.rdg-pop-detail { margin-top: 8px; overflow-wrap: anywhere; }
.rdg-pop-sub {
  margin-top: 10px;
  color: var(--rdg-text-2);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.rdg-fields { width: 100%; margin-top: 8px; border-collapse: collapse; }
.rdg-fields th,
.rdg-fields td { padding: 2px 0; vertical-align: top; text-align: left; border-top: 1px solid var(--rdg-border); }
.rdg-fields th { width: 38%; padding-right: 8px; color: var(--rdg-text-2); font-weight: 500; }
.rdg-fields td { overflow-wrap: anywhere; }
.rdg-cites { margin: 4px 0 0; padding-left: 16px; }
.rdg-cites li { margin: 2px 0; }
.rdg-cite { color: var(--rdg-accent); text-decoration: none; font-weight: 600; }
.rdg-cite:hover { text-decoration: underline; }
.rdg-cite-text { color: var(--rdg-text); }
.rdg-cite-nobox { color: var(--rdg-text-2); }
.rdg-pop-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.rdg-act {
  background: var(--rdg-surface-2);
  color: var(--rdg-text);
  border: 1px solid var(--rdg-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.rdg-act:hover { border-color: var(--rdg-accent); }
.rdg-act.rdg-goto { border-color: var(--rdg-accent); color: var(--rdg-accent); }
.rdg-act-msg { color: var(--rdg-text-2); font-size: 11px; }

/* ── a message of our own, above the viewer (z-index 10000) ── */
.rdg-note {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 10050;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 14px;
  background: var(--rdg-surface);
  color: var(--rdg-text);
  border: 1px solid var(--rdg-border);
  border-radius: var(--radius-sm, 8px);
  box-shadow: var(--rdg-shadow);
  font-family: var(--font, 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  font-size: 13px;
  line-height: 1.4;
}

/* ── "view on sheet" quick link on a report row: inline, no layout of its own ── */
.rdg-qlink {
  display: inline;
  margin-left: .35em;
  color: var(--primary, #14b8a6);
  font-size: .75rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.rdg-qlink:hover { color: var(--primary-hover, #0d9488); text-decoration: underline; }
