/* views.css — UI overhaul (analytics views). Loaded after replay.css.
   Plain-language pass helpers: compact hub header, skeleton loading, ⓘ
   tooltips, ⋯ menus, one-line stats, verdict + "How we calculated this",
   and phone rules (no page-level horizontal scroll at 390px). */

/* ---------- Shared tokens & classes (styling-fix round) ---------- */
/* One control height for inputs, selects and filter-row buttons. */
:root {
  --ctl-h: 38px;
}
@media (max-width: 780px) {
  :root {
    --ctl-h: 44px;
  }
}
/* Numeric table cell: right-aligned, tabular figures. */
.num {
  font-variant-numeric: tabular-nums;
}
th.num,
td.num {
  text-align: right;
}
/* The single treatment for an error count ("5" or "5 errors"). */
.count-bad {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid rgba(176, 58, 42, 0.45);
  color: #b03a2a;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* Secondary info line/value. Use instead of .mono for numbers and prose. */
.vx-meta {
  font-size: 12px;
  color: #7a7a7a;
  font-variant-numeric: tabular-nums;
}
/* Compact in-row variant of .btn (32px desktop, 44px on phones).
   .btn.btn-sm outranks the plain .btn min-height below. */
.btn.btn-sm {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 12.5px;
}
@media (max-width: 780px) {
  .btn.btn-sm {
    min-height: 44px;
  }
}

/* ---------- Numbers & button case ---------- */
.tbl td,
.tbl th,
.kpi-value,
.kpis,
.vx-stat-value,
.ci-note,
.pill {
  font-variant-numeric: tabular-nums;
}
.btn {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 13px;
  /* Anchors inherit the body line-height and rendered ~4px taller than
     <button> twins; one line-height + min-height keeps a.btn == button.btn. */
  line-height: 1.25;
  min-height: var(--ctl-h);
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
}
/* In-row small buttons share the .btn-sm height. */
.vx-pad-btn,
.vx-menu-btn {
  min-height: 32px;
}
/* Standalone .btn-sm (without .btn) gets the same compact box. */
.btn-sm {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 12.5px;
}
/* Table links: inherit ink, quiet underline (never browser blue). */
.tbl td a:not(.btn) {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid #e2e2e2;
}
.tbl td a:not(.btn):hover {
  border-bottom-color: #0a0a0a;
}
/* Chips read as words, not spaced capitals, at the in-row height. */
.chip {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  box-sizing: border-box;
}

/* ---------- Compact (in-hub) page head ---------- */
.page-head.is-compact {
  align-items: center;
  padding: 14px 0 16px;
  gap: 14px;
}
.vx-compact-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0;
  min-width: 0;
  /* Fixed height (one control tall) so the head never shifts when it
     gains or loses action buttons. Block + align-content (not flex) so
     the spaces around inline <em> accents survive. */
  min-height: var(--ctl-h);
  align-content: center;
}
.vx-compact-title em {
  font-style: italic;
  font-weight: 500;
}

/* ---------- Skeleton loading ---------- */
.vx-loading {
  padding: 10px 0;
}
.vx-skeleton {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 2px;
}
.vx-skeleton-row {
  display: flex;
  gap: 24px;
  justify-content: space-between;
}
.vx-skeleton-row .skltn {
  max-width: 100%;
}

/* ---------- ⓘ term tooltip ---------- */
.vx-info {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.vx-info-btn {
  border: 0;
  background: none;
  padding: 2px;
  margin: -2px;
  font: inherit;
  font-size: 12px;
  color: #7a7a7a;
  cursor: pointer;
  line-height: 1;
}
.vx-info-btn:hover,
.vx-info-btn:focus-visible {
  color: #0a0a0a;
}
.vx-info-pop {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 60;
  display: none;
  width: max-content;
  max-width: min(280px, 80vw);
  padding: 8px 10px;
  background: #0a0a0a;
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
}
.vx-info.is-open .vx-info-pop,
.vx-info:hover .vx-info-pop,
.vx-info:focus-within .vx-info-pop {
  display: block;
}

/* ---------- ⋯ overflow menu ---------- */
.vx-menu {
  position: relative;
  display: inline-flex;
}
.vx-menu-btn {
  padding: 6px 12px;
  font-size: 16px;
  line-height: 1;
}
.vx-menu-panel {
  position: fixed;
  z-index: 200;
  min-width: 190px;
  max-width: calc(100vw - 16px);
  background: #fff;
  border: 1px solid #d8d8d8;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.vx-menu-panel[hidden] {
  display: none;
}
.vx-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  color: #0a0a0a;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}
.vx-menu-item:hover,
.vx-menu-item:focus-visible {
  background: #f4f4f4;
}
.vx-menu-item.is-danger {
  color: #b03a2a;
}

/* ---------- Empty-state action ---------- */
.lux-empty-action {
  margin-top: 16px;
}
/* One empty state everywhere: bare in a view it keeps its dashed frame;
   inside a card the card is the frame, so the dashed box drops away and
   the padding shrinks by the card's padding — both read identically. */
.card > .lux-empty {
  border: 0;
  background: transparent;
  padding: 20px 6px;
}

/* ---------- One-line stats strip ---------- */
.vx-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  padding: 12px 0 4px;
}
.vx-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.vx-stat-value {
  font-size: 20px;
  font-weight: 600;
  color: #0a0a0a;
}
.vx-stat-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7a7a7a;
}

/* ---------- Plain verdict + calculation details ---------- */
.vx-verdict {
  border: 1px solid #d8d8d8;
  padding: 14px 16px;
  margin-top: 14px;
  background: #fff;
}
.vx-verdict-title {
  font-weight: 600;
  font-size: 15px;
  color: #0a0a0a;
}
.vx-verdict.is-ok .vx-verdict-title {
  color: #2a6a3a;
}
.vx-verdict.is-warn .vx-verdict-title {
  color: #b07a2a;
}
.vx-verdict.is-bad .vx-verdict-title {
  color: #b03a2a;
}
.vx-verdict-body {
  margin-top: 4px;
}
.vx-calc {
  margin-top: 14px;
  border: 1px solid #ececec;
  background: #fff;
}
.vx-calc > summary {
  cursor: pointer;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #4a4a4a;
}
.vx-calc > summary:hover {
  color: #0a0a0a;
}
.vx-calc-body {
  padding: 0 16px 14px;
  overflow-x: auto;
}

/* ---------- Spacing / layout helpers (replace inline styles) ---------- */
.vx-mt {
  margin-top: 14px;
}
.vx-mt-sm {
  margin-top: 8px;
}
.vx-mt-xs {
  margin-top: 4px;
}
.vx-mt-lg {
  margin-top: 18px;
}
.vx-mb {
  margin-bottom: 14px;
}
.vx-ml {
  margin-left: 8px;
}
.vx-strong {
  font-weight: 500;
}
.vx-sub {
  margin-top: 2px;
}
.vx-amber {
  color: #b07a2a;
}
.vx-source {
  color: #9a9a9a;
  margin-top: 2px;
}
.vx-indent {
  padding-left: 24px;
}
.vx-hidden {
  display: none;
}
.vx-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.vx-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.vx-row-tight {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.vx-grow {
  flex: 1;
  min-width: 200px;
}
.vx-grow-sm {
  flex: 1;
  min-width: 150px;
}
.vx-min0 {
  min-width: 0;
}
.vx-pad-btn {
  padding: 6px 12px;
}
.vx-check {
  width: auto;
}
.vx-full {
  width: 100%;
}
.vx-mono-input {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  width: 100%;
}
.vx-input {
  border: 1px solid #e2e2e2;
  padding: 8px 12px;
  min-height: var(--ctl-h);
  font: inherit;
  font-size: 13px;
  background: #fff;
  box-sizing: border-box;
}
.vx-one-col {
  grid-template-columns: 1fr;
}
.vx-clickable {
  cursor: pointer;
}
.vx-num {
  width: 90px;
}
.vx-num-sm {
  width: 64px;
}
.vx-currency {
  width: 80px;
}
.vx-head-note {
  margin: -8px 0 16px;
}
.vx-list-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #f5f5f5;
  flex-wrap: wrap;
}
.vx-list-row-sm {
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}
.vx-inline-badges {
  display: inline-flex;
  gap: 6px;
  margin-left: 10px;
  flex-wrap: wrap;
}
.vx-legend {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  font-size: 11px;
  flex-wrap: wrap;
}
.vx-swatch {
  display: inline-block;
  width: 16px;
  vertical-align: middle;
  margin-right: 5px;
}
.vx-swatch-line {
  border-top: 2px solid #0a0a0a;
}
.vx-swatch-band {
  height: 10px;
  background: rgba(10, 10, 10, 0.08);
  border: 1px solid #ececec;
}
.vx-swatch-dash {
  border-top: 2px dashed #7a7a7a;
}
.vx-swatch-amber {
  border-top: 2px solid #b07a2a;
}
.vx-swatch-change {
  border-top: 2px dashed #b07a2a;
}
.vx-marker {
  cursor: pointer;
}
.vx-marker:focus {
  outline: 1px dashed #b07a2a;
  outline-offset: 2px;
}
.vx-code-label {
  margin-bottom: 8px;
  font-size: 11px;
}
.vx-mb-sm {
  margin-bottom: 12px;
}
.heat-stage,
.heat-canvas,
canvas {
  max-width: 100%;
}
.vx-small-note {
  font-size: 11px;
}
.vx-note {
  font-size: 12.5px;
}
.vx-divider-row {
  padding: 10px 0;
  border-top: 1px solid #ececec;
}
.vx-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: -1px;
}
.vx-nowrap {
  white-space: nowrap;
}
.vx-shrink0 {
  flex-shrink: 0;
}
.vx-svg {
  width: 100%;
  height: auto;
  display: block;
  max-width: 100%;
}

/* Focused (deep-linked) error row */
tr.is-focused > td {
  background: #fdf3e3;
}
tr.is-focused {
  outline: 2px solid #b07a2a;
  outline-offset: -2px;
}

/* Wide tables scroll inside their own container, never the page */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.card,
.page-head,
.kpis {
  min-width: 0;
  max-width: 100%;
}

/* ---------- Short URLs, routes, repeat errors ---------- */
.vx-route {
  overflow-wrap: anywhere;
  min-width: 150px;
}
.tbl td .mono {
  overflow-wrap: anywhere;
}
/* 2nd+ group with the same message as an earlier one (server groups per
   page) — indented so repeats read as repeats, not new bugs. */
.tbl tr.vx-repeat > td:first-child {
  padding-left: 28px;
}
.tbl tr.vx-repeat .vx-strong {
  font-weight: 400;
}
.vx-actions-row {
  flex-wrap: nowrap;
}
.vx-table-wrap {
  min-width: 0;
}

/* ---------- Why-people-leave "New report" form ---------- */
/* Base dropdown style for every select in the dashboard. :where() keeps the
   specificity at zero classes, so area-specific rules (funnel filters, modals,
   step editor) still win. */
:where(.view) select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #e2e2e2;
  border-radius: 0;
  background-color: #fff;
  padding: 8px 12px;
  min-height: var(--ctl-h);
  font: inherit;
  font-size: 13px;
  color: #0a0a0a;
  cursor: pointer;
  max-width: 100%;
  box-sizing: border-box;
  transition: border-color 150ms ease;
}
:where(.view) select:hover {
  border-color: #c9c9c9;
}
:where(.view) select:focus {
  outline: 0;
  border-color: #0a0a0a;
}
:where(.view) select:disabled {
  color: #7a7a7a;
  background-color: #f6f6f6;
  cursor: default;
}

/* Base text-like input / textarea, matching the select base above so no
   field renders as a raw browser control (2px border, Arial, no padding).
   The whole selector is :where()-wrapped (zero specificity) so framed
   composites like .search input and every area rule keep winning. */
:where(
  .view
    input:not([type='checkbox']):not([type='radio']):not([type='hidden']):not(
      [type='file']
    ):not([type='range']),
  .view textarea
) {
  border: 1px solid #e2e2e2;
  border-radius: 0;
  background-color: #fff;
  padding: 8px 12px;
  min-height: var(--ctl-h);
  font: inherit;
  font-size: 13px;
  color: #0a0a0a;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  box-sizing: border-box;
  transition: border-color 150ms ease;
}
:where(.view) textarea {
  line-height: 1.5;
}
:where(.view) input:hover,
:where(.view) textarea:hover {
  border-color: #c9c9c9;
}
:where(.view) input:focus,
:where(.view) textarea:focus {
  outline: 0;
  border-color: #0a0a0a;
}
/* Disabled fields stay readable (never near-invisible). */
:where(.view) input:disabled,
:where(.view) textarea:disabled {
  background-color: #f6f6f6;
  color: #7a7a7a;
  cursor: default;
}
/* The search box draws its own frame; its inner input stays frameless. */
.view .search {
  min-height: var(--ctl-h);
  box-sizing: border-box;
}
.view .search input {
  border: 0;
  padding: 0;
  min-height: 0;
  background-color: transparent;
}

/* The chevron (appearance:none removes the native one) at class strength, so
   area rules that reset `background` or `padding` don't drop or cover it. */
.view select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237a7a7a' stroke-width='1.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}
.view select[multiple] {
  background-image: none;
  padding-right: 12px;
}

/* Checkboxes and radios in the ink colour rather than the browser's blue. */
:where(.view) input[type='checkbox'],
:where(.view) input[type='radio'] {
  accent-color: #0a0a0a;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Labelled field: small uppercase label above its control. */
.vx-field {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.vx-field-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a8a8a;
  line-height: 1.35;
}

.vx-report-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 20px;
  justify-content: flex-start;
  padding: 4px 0 2px;
}
.vx-report-form .vx-check-row {
  min-height: var(--ctl-h);
  font-size: 13px;
}
.vx-report-form .btn {
  margin-left: auto;
}
.vx-check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  cursor: pointer;
}
.vx-check-row > span {
  min-width: 0;
}

/* ---------- Goal editor: events seen on the site ---------- */
.goal-suggest {
  margin-top: 12px;
}
.goal-suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
/* Event names are shown as sent — no uppercase transform. */
.goal-suggest .chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  text-transform: none;
  letter-spacing: 0.01em;
  font-size: 12.5px;
}
.goal-suggest .chip .vx-meta {
  font-size: 11px;
}
.goal-suggest .chip.active .vx-meta {
  color: rgba(255, 255, 255, 0.7);
}

/* ---------- Phones ---------- */
@media (max-width: 780px) {
  .btn,
  .vx-menu-btn,
  .vx-menu-item,
  .vx-calc > summary,
  .chip,
  .pager button,
  .copy-btn,
  .panel-tab,
  .step-add,
  .icon-btn {
    min-height: 44px;
  }
  .icon-btn {
    min-width: 44px;
  }
  /* These carry a 32px desktop min-height at two-class strength in
     replay.css, so the phone bump repeats at the same strength. */
  .copy-block .copy-btn,
  .proj-key .copy-btn,
  .player-meta .pm-tag-edit {
    min-height: 44px;
  }
  /* Every button centres its label, so full-width phone buttons never
     read left-aligned (not only inside .page-cta). */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .page-head {
    padding: 20px 0 22px;
  }
  .page-cta {
    flex-wrap: wrap;
  }
  .page-cta .btn,
  .vx-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  /* Filter-row buttons stretch full-width in stacked filter columns. */
  .funnel-filters .btn,
  .filters-bar .btn {
    justify-content: center;
  }
  .tbl th,
  .tbl td {
    padding: 10px 8px;
  }
  .vx-info-btn {
    padding: 10px;
    margin: -10px -6px;
  }
  .vx-stats {
    gap: 8px 18px;
  }
  .vx-grow,
  .vx-grow-sm {
    min-width: 0;
    flex-basis: 100%;
  }
  select,
  input,
  textarea {
    max-width: 100%;
  }

  /* Wide tables become stacked cards: one bordered card per row, each cell
     a label/value line (label from data-label, matching the hidden header).
     Child combinators keep nested tables (error variants) untouched. */
  .vx-table-wrap {
    overflow-x: visible;
  }
  .tbl.vx-cards {
    display: block;
    width: 100%;
  }
  .tbl.vx-cards > thead {
    display: none;
  }
  .tbl.vx-cards > tbody {
    display: block;
  }
  .tbl.vx-cards > tbody > tr {
    display: block;
    border: 1px solid #ececec;
    padding: 10px 12px;
    margin: 0 0 10px;
    background: #fff;
  }
  .tbl.vx-cards > tbody > tr[hidden] {
    display: none;
  }
  .tbl.vx-cards > tbody > tr > td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px 16px;
    border: 0;
    padding: 5px 0;
    text-align: right;
    min-width: 0;
  }
  .tbl.vx-cards > tbody > tr > td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 auto;
    text-align: left;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #7a7a7a;
    padding-top: 2px;
  }
  /* First cell (route / form / what broke) stacks vertically, left-aligned. */
  .tbl.vx-cards > tbody > tr > td:first-child {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  .tbl.vx-cards > tbody > tr > td.vx-actions-cell {
    justify-content: flex-start;
    text-align: left;
    padding-top: 8px;
  }
  .tbl.vx-cards tr.vx-repeat > td:first-child {
    padding-left: 12px;
  }
  /* Expanded error variants sit under their card, not in a card of their own. */
  .tbl.vx-cards > tbody > tr.vx-detail-row {
    border: 0;
    padding: 0;
    margin: -6px 0 10px;
    background: transparent;
  }
  .tbl.vx-cards > tbody > tr.vx-detail-row > td {
    display: block;
    text-align: left;
    padding: 0;
    overflow-x: auto;
  }
  .tbl.vx-cards > tbody > tr.vx-detail-row > td::before {
    display: none;
  }
  .vx-actions-row {
    flex-wrap: wrap;
  }

  /* Filters and the New-report form stack full-width on phones. */
  .funnel-filters {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
  }
  .funnel-filters .ff-field {
    /* flex:none also cancels the grow helpers' flex-basis:100%, which in a
       column would mean height:100% and wrap fields into a second column. */
    flex: none;
    width: 100%;
  }
  .funnel-filters input,
  .funnel-filters select {
    width: 100%;
    box-sizing: border-box;
    min-height: var(--ctl-h);
  }
  .vx-report-form {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }
  .vx-report-form .vx-field {
    display: flex;
  }
  .vx-report-form .btn {
    margin-left: 0;
  }
  :where(.view) select {
    min-height: var(--ctl-h);
  }
  .vx-report-form select {
    width: 100%;
    box-sizing: border-box;
    min-height: var(--ctl-h);
  }
  .vx-check-row {
    min-height: var(--ctl-h);
  }
  .vx-report-form .btn {
    justify-content: center;
  }
  .card-head {
    flex-wrap: wrap;
    gap: 8px 12px;
  }
  .card-head select {
    max-width: 100%;
  }
}
