/* Controls, breadcrumbs, tables and detail drawer for assets/viz. */
.viz-range {
  display: inline-flex;
  border: 1px solid var(--calc-rule);
  user-select: none;
  touch-action: none;
}
.viz-range button {
  padding: 4px 9px;
  color: var(--calc-muted);
  border-right: 1px solid var(--calc-rule);
  cursor: pointer;
  white-space: nowrap;
}
.viz-range button:last-child {
  border-right: 0;
}
.viz-range button.on {
  background: var(--calc-ink);
  color: var(--calc-bg);
}

.viz-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.viz-chips button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--calc-rule);
  border-radius: 999px;
  color: var(--calc-muted);
  cursor: pointer;
  font-size: 0.78rem;
  white-space: nowrap;
}
.viz-chips button i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  opacity: 0.35;
}
.viz-chips button.on {
  color: var(--calc-ink);
  border-color: var(--calc-ink);
}
.viz-chips button.on i {
  opacity: 1;
}

.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 0.76rem;
  color: var(--calc-muted);
  margin: 6px 0 10px;
}
.viz-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.viz-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.viz-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 7px;
  font-size: 0.84rem;
  margin: 0 0 8px;
  min-height: 30px;
  line-height: 1.5;
}
.viz-crumbs button {
  color: var(--calc-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.viz-crumbs button.viz-back {
  text-decoration: none;
  background: var(--calc-ink);
  color: var(--calc-bg);
  border-radius: 999px;
  padding: 3px 13px 3px 11px;
  margin-right: 6px;
  font-size: 0.78rem;
}
.viz-crumbs span {
  color: var(--calc-muted);
}
.viz-crumbs b {
  font-weight: 400;
  color: var(--calc-ink);
}


.viz-table-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin: 0 0 8px;
}
.viz-table-top input {
  font: inherit;
  font-size: 0.84rem;
  color: var(--calc-ink);
  background: var(--calc-bg);
  border: 1px solid var(--calc-rule);
  border-radius: 0;
  padding: 5px 9px;
  flex: 1 1 220px;
  max-width: 360px;
  min-width: 0;
}

.viz-table-count {
  font-size: 0.76rem;
  color: var(--calc-muted);
}

.viz-table-wrap {
  overflow-x: auto;
}
.viz-table-wrap:focus-visible {
  outline: 2px solid var(--calc-accent);
  outline-offset: 2px;
}


.viz-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  line-height: 1.35;
  margin: 0;
}

/* the table and its cells take the page colour from the theme, never a framework's white: a transparent cell can
   show a white table background in dark mode (the doubled class outweighs Bootstrap's table rules) */
main .viz-table.viz-table :is(table, td) {
  background-color: var(--calc-bg);
}
main .viz-table.viz-table :is(tbody, tr) {
  background-color: transparent;
}

.viz-table td {
  color: var(--calc-ink);
}

.viz-table th {
  background-color: var(--calc-bg);
}

.viz-table :is(th, td) {
  position: relative;
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid var(--calc-rule);
  font-variant-numeric: tabular-nums;
  vertical-align: top;
}

.viz-table :is(th, td).l {
  text-align: left;
}

.viz-table th {
  font-weight: 400;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--calc-muted);
  white-space: nowrap;
  border-bottom-color: var(--calc-ink);
}
/* a sortable heading is a button that fills its cell (and gives the cell's padding to the button, so the whole
   cell can be clicked and the target is at least 24px tall) */
.viz-table th:has(> button) {
  padding: 0;
}
.viz-table th > button {
  display: block;
  width: 100%;
  min-height: 24px;
  padding: 6px 8px;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  user-select: none;
}
.viz-table th > button:focus-visible {
  outline-offset: -2px;   /* inside the cell, where the scrolling box can't clip it */
}
/* the arrow is drawn only: the heading's aria-sort already tells a screen reader the order (the second declaration
   hides the arrow from it; browsers that can't read that form keep the first) */
.viz-table th[aria-sort=ascending] > button::after {
  content: " ↑";
  content: " ↑" / "";
}
.viz-table th[aria-sort=descending] > button::after {
  content: " ↓";
  content: " ↓" / "";
}

.viz-table td span {
  position: relative;
}

.viz-table td.l {
  color: var(--calc-ink);
  hyphens: none;
  min-width: 130px;
}

.viz-table tr.viz-pick:hover td {
  background: color-mix(in srgb, var(--calc-accent) 8%, var(--calc-bg));
}

.viz-table tr.viz-pick:hover td.l:first-child {
  color: var(--calc-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.viz-cell-bar {
  position: absolute;
  right: 0;
  top: 4px;
  height: calc(1.35em + 4px);
  opacity: 0.22;
}

.viz-empty {
  color: var(--calc-muted);
}

.viz-more {
  display: block;
  margin: 10px 0 0 !important;
  padding: 5px 14px !important;
  border: 1px solid var(--calc-rule) !important;
  font-size: 0.78rem;
  color: var(--calc-accent) !important;
  cursor: pointer;
}

/* drawer(): a <dialog> opened with showModal(). It sits off screen to the right and slides in when it gets .on;
   the ::backdrop shades the page behind. Only an open dialog is display: flex, so a closed one stays hidden. */
.viz-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(560px, 100vw);
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--calc-bg);
  color: var(--calc-text);
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.22);
  transform: translateX(104%);
  transition: transform 0.32s cubic-bezier(0.2, 0.7, 0.2, 1);
  flex-direction: column;
  overflow: hidden;
  outline: 0;
  overscroll-behavior: contain;
}
.viz-drawer[open] {
  display: flex;
}
.viz-drawer.on {
  transform: none;
}
.viz-drawer::backdrop {
  background: rgba(10, 14, 10, 0.42);
  opacity: 0;
  transition: opacity 0.25s;
  overflow: hidden;
  overscroll-behavior: contain;
}
.viz-drawer.on::backdrop {
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .viz-drawer, .viz-drawer::backdrop {
    transition: none;
  }
}

.viz-drawer-close {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 34px;
  height: 34px;
  font-size: 1.5rem !important;
  line-height: 1;
  color: var(--calc-muted) !important;
  cursor: pointer;
  text-align: center !important;
  z-index: 1;
}

.viz-drawer-body {
  overflow-y: auto;
  padding: 26px 28px 40px;
  font-size: 0.86rem;
  line-height: 1.5;
}
.viz-drawer-body h3 {
  font-size: 1.45rem;
  line-height: 1.15;
  margin: 0 40px 8px 0;
  color: var(--calc-ink);
}
.viz-drawer-body h4 {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--calc-muted);
  margin: 22px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--calc-rule);
  font-weight: 400;
}
.viz-drawer-body p {
  margin: 0 0 8px;
}
.viz-drawer-body ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.viz-drawer-body li {
  margin: 0 0 9px;
}
.viz-drawer-body .viz-big {
  font-size: 2rem;
  line-height: 1.05;
  color: var(--calc-ink);
  display: block;
}
.viz-drawer-body .viz-muted {
  color: var(--calc-muted);
}
@media (max-width: 560px) {
  .viz-drawer-body {
    padding: 22px 18px 36px;
  }
}


/* Accessible tab strip for dashboards (tabs()) */
.viz-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--calc-rule);
  margin: 0 0 18px;
  padding: 0 0 8px;
}
.viz-tabs button {
  font: inherit;
  font-size: 0.86rem;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--calc-rule);
  border-radius: 999px;
  background: var(--calc-bg);
  color: var(--calc-muted);
  cursor: pointer;
}
.viz-tabs button:hover {
  color: var(--calc-ink);
  border-color: var(--calc-muted);
}
.viz-tabs button[aria-selected="true"] {
  color: var(--calc-bg);
  background: var(--calc-ink);
  border-color: var(--calc-ink);
}
.viz-tabs button:focus-visible {
  outline: 2px solid var(--calc-accent);
  outline-offset: 2px;
}
