/* ScrollTracker Heatmap. Shared type, palette and chrome: /lab.css. */

.heatmap-page [hidden] {
  display: none !important;
}

.heatmap-intro {
  padding-block: 48px 0;
}

.heatmap-intro h1 {
  margin-block: 16px;
}

.heatmap-intro p:not(.lab-label) {
  max-width: 65ch;
  margin-bottom: 16px;
  color: var(--ink-2);
}

.heatmap-intro .lab-actions {
  margin-top: 24px;
}

.heatmap-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.sidebar,
.preview {
  min-width: 0;
  background: var(--card);
}

.sidebar-section {
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.sidebar-section:last-child {
  border-bottom: 0;
}

.section-label,
.field-label,
.stat-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ink-3);
}

.section-label {
  margin-bottom: 16px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.field-label {
  display: block;
  margin-block: 16px 8px;
}

.field-hint {
  margin-top: 8px;
  color: var(--ink-3);
  font-size: 0.875rem;
  line-height: 1.5;
}

.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 96px;
  padding: 16px;
  border: 1px dashed var(--ink-3);
  background: var(--page);
  cursor: pointer;
  text-align: center;
}

.drop-zone:hover,
.drop-zone.drag-over {
  background: var(--high);
}

.drop-zone:focus-within {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

.drop-zone.has-file {
  border-color: var(--green);
  border-style: solid;
}

.drop-zone-text {
  color: var(--ink-2);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.drop-zone input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

.data-input-tabs button {
  flex: 1;
}

.data-textarea {
  width: 100%;
  min-height: 160px;
  padding: 12px;
  resize: vertical;
  border: 1px solid var(--ink-3);
  background: var(--page);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.data-textarea::placeholder {
  color: var(--ink-3);
}

.data-file-upload,
.data-paste {
  display: none;
  margin-top: 16px;
}

.data-file-upload.active,
.data-paste.active {
  display: block;
}

.fold-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.fold-input-group .lab-input {
  min-width: 0;
  flex: 1;
}

.fold-input-group .field-label {
  flex: 0 0 92px;
  margin: 0;
}

.fold-unit {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 0.75rem;
}

#opacityInput {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  accent-color: var(--primary-light);
}

.command-button {
  padding-inline: 8px;
}

.heatmap-actions {
  display: grid;
  gap: 8px;
}

.heatmap-actions button:disabled {
  border-color: var(--line-muted);
  background: var(--low);
  color: var(--ink-3);
  cursor: not-allowed;
}

.preview {
  border-top: 1px solid var(--line);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 24px;
  background: var(--low);
  border-bottom: 1px solid var(--line);
}

.preview-header .section-label {
  margin: 0;
}

.heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0;
  list-style: none;
  color: var(--ink-2);
  font-size: 0.8125rem;
}

.heatmap-legend li::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  background: var(--green);
}

.heatmap-legend .legend-scanned::before { background: var(--warning); }
.heatmap-legend .legend-skipped::before { background: var(--danger); }

.canvas-area {
  position: relative;
  min-height: 360px;
  max-height: 75vh;
  padding: 24px;
  overflow: auto;
  background: var(--page);
}

.empty-state {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 16px;
  min-height: 312px;
  text-align: center;
  color: var(--ink-3);
}

.empty-state p {
  max-width: 36ch;
  font-size: 1rem;
}

.heatmap-container {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  border: 1px solid var(--line);
}

.heatmap-screenshot {
  display: block;
  max-width: 100%;
  height: auto;
}

.overlay-zone {
  position: absolute;
  inset-inline: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px dashed var(--ink-3);
  cursor: pointer;
}

.overlay-zone:hover,
.overlay-zone:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: -2px;
  z-index: 2;
}

.overlay-zone-label {
  position: absolute;
  top: 50%;
  right: 8px;
  padding: 2px 8px;
  background: var(--page);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.75rem;
  pointer-events: none;
}

.edge-bar {
  position: absolute;
  inset: 0 0 0 auto;
  width: 4px;
  pointer-events: none;
}

.edge-bar-segment {
  position: absolute;
  width: 100%;
}

.fold-line {
  position: absolute;
  inset-inline: 0;
  border-top: 2px dashed var(--primary-light);
  z-index: 3;
  pointer-events: none;
}

.fold-line-label {
  position: absolute;
  top: -28px;
  left: 8px;
  padding: 2px 8px;
  background: var(--page);
  color: var(--primary-light);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.stat-card {
  padding: 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.zone-card {
  display: block;
  width: 100%;
  padding: 16px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
}

.zone-card:hover { background: var(--high); }
.zone-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.zone-label { font-family: var(--mono); font-size: 0.875rem; }
.zone-events { color: var(--ink-3); font-size: 0.8125rem; }
.zone-bar, .tooltip-bar { display: flex; height: 8px; margin-bottom: 8px; background: var(--low); }
.zone-bar-engaged { background: var(--green); }
.zone-bar-scanned { background: var(--warning); }
.zone-bar-skipped { background: var(--danger); }
.zone-metrics { display: flex; flex-wrap: wrap; gap: 16px; font-family: var(--mono); font-size: 0.75rem; }
.zone-metric-dot { display: inline-block; width: 8px; height: 8px; margin-right: 4px; }

.tooltip {
  display: none;
  position: fixed;
  z-index: 30;
  width: min(280px, calc(100vw - 16px));
  padding: 16px;
  border: 1px solid var(--ink-3);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.8125rem;
  pointer-events: none;
}

.tooltip.visible { display: block; }
.tooltip-title { margin-bottom: 12px; font-family: var(--mono); font-weight: 600; }
.tooltip-row, .tooltip-metric-row { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.tooltip-row-left { display: flex; align-items: center; gap: 8px; }
.tooltip-dot { width: 8px; height: 8px; }
.tooltip-divider { margin-block: 8px; border-top: 1px solid var(--line); }
.tooltip-metric-row { color: var(--ink-2); font-size: 0.75rem; }

.sql-dialog {
  width: min(760px, calc(100% - 32px));
  max-height: 85vh;
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--ink-3);
  background: var(--page);
  color: var(--ink);
}

.sql-dialog::backdrop { background: color-mix(in srgb, var(--page) 85%, transparent); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-size: 1.125rem; }
.modal-body { padding: 24px; }
.modal-body .section-label { margin-top: 24px; }
.modal-note { margin-block: 16px; color: var(--ink-2); }
.sql-block { position: relative; padding: 64px 16px 16px; overflow: auto; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-family: var(--mono); font-size: 0.8125rem; line-height: 1.6; white-space: pre; }
.sql-block:not(:has(.copy-btn)) { padding-top: 16px; }
.sql-keyword { color: var(--primary-light); }
.sql-string { color: var(--green); }
.sql-function { color: var(--warning); }
.sql-comment { color: var(--ink-3); }
.capture-command { margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.copy-btn { position: absolute; top: 8px; right: 8px; min-height: 44px; padding: 8px 16px; border: 1px solid var(--ink-3); background: var(--low); color: var(--ink); font-family: var(--mono); cursor: pointer; }
.copy-btn:hover { background: var(--high); }

.notification {
  display: none;
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 40;
  max-width: calc(100% - 32px);
  padding: 16px 24px;
  border: 1px solid var(--line-muted);
  border-left: 2px solid var(--green);
  background: var(--surface);
  color: var(--ink);
}

.notification.visible { display: block; }
.notification.error { border-left-color: var(--danger); }

@media (min-width: 1024px) {
  .heatmap-workspace { grid-template-columns: 320px minmax(0, 1fr); }
  .sidebar { border-right: 1px solid var(--line); }
  .preview { align-self: start; position: sticky; top: 72px; border-top: 0; }
  .canvas-area { min-height: 580px; }
  .empty-state { min-height: 532px; }
}
