/* ScrollTracker test page only. Shared rules: /lab.css. */

:root {
  --panel-w: 340px;
  --st-engaged: var(--green);
  --st-scanned: var(--warning);
  --st-skipped: var(--ink-3);
  --st-confused: var(--primary-light);
}

body {
  margin-right: var(--panel-w);
}

/* Page */

.scroll-intro {
  padding: 48px 0 32px;
}

.scroll-intro h1 span {
  color: var(--ink-3);
  font-weight: 400;
}

.main-content {
  margin-right: -1px;
  border-top: 1px solid var(--line);
}

.section {
  padding: 32px 24px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.section > * {
  max-width: 65ch;
}

.section h2 {
  margin-bottom: 16px;
  font-size: 1.125rem;
  line-height: 1.3;
  letter-spacing: 0;
}

.section p {
  margin-bottom: 12px;
  color: var(--ink-2);
  line-height: 1.7;
}

.section p:last-child {
  margin-bottom: 0;
}

.marker {
  display: block;
  padding: 12px 24px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--low);
  color: var(--ink-3);
  line-height: 1.2;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.lazy-btn {
  display: flex;
  margin: 32px 24px;
}

.lazy-content {
  display: none;
}

.lazy-content.visible {
  display: block;
}

/* Debug panel */

#debug-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  width: var(--panel-w);
  height: 100vh;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.panel-toggle {
  display: none;
}

.panel-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

#debug-panel h2 {
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
}

#debug-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

/* Metrics */

#metrics {
  display: grid;
  flex-shrink: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.metric-label,
.viz-label,
.cfg-label,
.event-row-label {
  color: var(--ink-3);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.metric-value {
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.metric-value.accent {
  color: var(--primary-light);
}

/* Scroll progress */

#scroll-viz {
  flex-shrink: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.viz-label {
  margin-bottom: 8px;
}

.viz-track {
  height: 6px;
  overflow: hidden;
  background: var(--high);
}

.viz-fill {
  width: 0%;
  height: 100%;
  background: var(--primary);
}

.viz-zones {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.viz-zone {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 2px;
  border-bottom: 2px solid transparent;
  background: var(--low);
  color: var(--ink-3);
  font-size: 0.6875rem;
  line-height: 1.3;
}

.viz-zone.active {
  border-bottom-color: var(--primary);
  color: var(--ink);
}

.viz-zone[class*="fired-"] {
  color: var(--page);
  font-weight: 600;
}

.viz-zone[class*="fired-"]::after {
  font-size: 0.625rem;
  font-weight: 600;
}

.viz-zone.fired-engaged {
  background: var(--st-engaged);
}

.viz-zone.fired-engaged::after {
  content: "engaged";
}

.viz-zone.fired-scanned {
  background: var(--st-scanned);
}

.viz-zone.fired-scanned::after {
  content: "scanned";
}

.viz-zone.fired-skipped {
  background: var(--st-skipped);
}

.viz-zone.fired-skipped::after {
  content: "skipped";
}

.viz-zone.fired-confused {
  background: var(--st-confused);
}

.viz-zone.fired-confused::after {
  content: "confused";
}

/* Event log */

#event-log {
  flex: 1;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
}

#event-log::-webkit-scrollbar {
  width: 4px;
}

#event-log::-webkit-scrollbar-track {
  background: transparent;
}

#event-log::-webkit-scrollbar-thumb {
  background: var(--line-muted);
}

.empty-state {
  padding: 20px 8px;
  color: var(--ink-3);
  font-size: 0.75rem;
}

.event-card {
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--ink-3);
  background: var(--card);
}

.event-card.engaged {
  border-left-color: var(--st-engaged);
}

.event-card.scanned {
  border-left-color: var(--st-scanned);
}

.event-card.skipped {
  border-left-color: var(--st-skipped);
}

.event-card.confused {
  border-left-color: var(--st-confused);
}

.event-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.event-pct {
  font-size: 1.375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.event-pct.engaged,
.event-type.engaged {
  color: var(--st-engaged);
}

.event-pct.scanned,
.event-type.scanned {
  color: var(--st-scanned);
}

.event-pct.skipped,
.event-type.skipped {
  color: var(--st-skipped);
}

.event-pct.confused,
.event-type.confused {
  color: var(--st-confused);
}

.event-type {
  flex: none;
  padding: 2px 8px;
  border: 1px solid currentColor;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.event-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.event-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.event-row-label {
  font-size: 0.625rem;
}

.event-row-value {
  color: var(--ink);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.event-time {
  margin-top: 8px;
  color: var(--ink-3);
  font-size: 0.6875rem;
  text-align: right;
}

/* Signals */

#signals-panel {
  flex-shrink: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
}

.signal-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}

.signal-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
}

.signal-label {
  color: var(--ink-3);
  font-size: 0.6875rem;
}

.signal-value {
  color: var(--primary-light);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Config */

#config-section {
  flex-shrink: 0;
  padding: 4px 20px;
  border-top: 1px solid var(--line);
}

#config-toggle {
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

#config-toggle:hover {
  color: var(--ink);
}

#config-fields {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 14px;
}

#config-fields.open {
  display: flex;
}

.cfg-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cfg-row .lab-input {
  font-family: var(--mono);
  font-size: 0.8125rem;
}

#apply-btn {
  width: 100%;
  margin-top: 4px;
}

#height-info {
  display: flex;
  flex-shrink: 0;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 0.75rem;
}

#height-info span:last-child {
  color: var(--ink);
}

/* Phones: the panel becomes a bottom sheet, collapsed by default */

@media (max-width: 767px) {
  body {
    margin-right: 0;
    padding-bottom: 48px;
  }

  .section {
    padding: 24px;
  }

  #debug-panel {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 75vh;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .panel-toggle {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 48px;
    padding: 0 var(--gutter);
    border: 0;
    border-bottom: 2px solid var(--primary);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
  }

  .panel-toggle-state {
    color: var(--ink-3);
  }

  #debug-panel:not(.is-open) .panel-body {
    display: none;
  }

  #debug-panel.is-open .panel-body {
    overflow-y: auto;
  }

  #event-log {
    flex: none;
    max-height: 30vh;
  }
}
