/* Mobile Chart tab (mobile-job-chart.js): stacked per-channel strips, one open as the
   interactive chart, plus the channel picker sheet. Split from mobile.css so the
   shared sheet stays inside its size budget; loaded by mobile/index.html after it. */

/* Five window pills plus the actions fit a 390 px phone; narrower phones wrap the actions. */
.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.chart-window {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: #0b1328;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.chart-window button {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  min-height: 38px;
  padding: 0 0.6rem;
  border-radius: 999px;
  cursor: pointer;
}

.chart-window button.is-active {
  background: var(--accent);
  color: #fff;
}

.chart-window button:focus-visible,
.chart-auto-y:focus-visible,
.chart-icon-btn:focus-visible,
.chart-strip-head:focus-visible,
.chart-add-row:focus-visible,
.chart-sheet-row:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.chart-toolbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chart-auto-y {
  min-height: 40px;
  padding: 0 0.7rem 0 0.55rem;
}

.chart-auto-y svg {
  width: 14px;
  height: 14px;
}

.chart-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-alt);
  color: var(--text-soft);
  cursor: pointer;
}

.chart-icon-btn svg {
  width: 18px;
  height: 18px;
}

.chart-status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  min-height: 1.6rem;
}

.chart-status-row .status {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.chart-live-btn {
  font-size: 0.78rem;
  padding: 0.35rem 0.6rem;
  white-space: nowrap;
}

.chart-strips {
  display: grid;
  gap: 6px;
}

/* min-width: 0 keeps the ECharts root (an explicit-width div) from widening the
   strip; the strip follows the viewport and chart.resize() reads the real width. */
.chart-strip {
  min-width: 0;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px 2px;
}

.chart-strip.is-open {
  border-color: var(--strip-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--strip-color) 12%, transparent);
}

.chart-strip-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  padding: 4px 0 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chart-strip-key {
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: var(--strip-color);
  flex: 0 0 auto;
  align-self: center;
}

.chart-strip-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.chart-strip-range {
  font-size: 0.6rem;
  color: var(--text-faint);
  margin-left: 4px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-strip-value {
  margin-left: auto;
  font-size: 1.05rem;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
}

.chart-strip-unit {
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.chart-strip-caret {
  display: flex;
  align-self: center;
  margin-left: 4px;
  color: var(--text-faint);
  transition: transform 0.15s ease;
}

.chart-strip.is-open .chart-strip-caret {
  transform: rotate(180deg);
}

/* pan-y leaves vertical swipes to the page; horizontal drags and pinches reach
   the chart. Only the first child is the ECharts root — later children are its
   tooltip, which must keep its content width. */
.chart-strip-plot {
  position: relative;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  touch-action: pan-y;
}

.chart-strip-plot > div:first-child {
  touch-action: pan-y;
}

.chart-add-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.chart-add-row svg {
  width: 16px;
  height: 16px;
}

#tab-chart.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 150;
  overflow: auto;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}

#tab-chart.is-fullscreen .chart-strip.is-open .chart-strip-plot {
  height: max(184px, calc(100dvh - 300px)) !important;
}

body.chart-fullscreen-open {
  overflow: hidden;
}

/* Channel picker bottom sheet */
.chart-sheet-overlay {
  place-items: end stretch;
  padding: 0;
}

.chart-sheet {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 82vh;
  max-height: 82dvh;
  padding: 8px 14px calc(14px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -12px 32px rgba(2, 6, 23, 0.6);
}

.chart-sheet-handle {
  width: 36px;
  height: 4px;
  margin: 0 auto 2px;
  border-radius: 999px;
  background: #334155;
}

.chart-sheet-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.chart-sheet-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-strong);
}

.chart-sheet-count {
  font-size: 0.76rem;
  color: var(--muted);
}

.chart-sheet-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chart-sheet-section {
  margin: 10px 0 2px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.chart-sheet-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 0 4px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chart-sheet-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--strip-color);
  flex: 0 0 auto;
}

.chart-sheet-name {
  font-size: 0.875rem;
}

.chart-sheet-units {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.chart-sheet-value {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.chart-sheet-row.is-selected .chart-sheet-value {
  color: #f8fafc;
}

.chart-sheet-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1.5px solid #334155;
  color: transparent;
  flex: 0 0 auto;
}

.chart-sheet-row.is-selected .chart-sheet-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chart-sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.chart-sheet-actions .btn {
  min-height: 44px;
}

@media (prefers-reduced-motion: reduce) {
  .chart-strip-caret {
    transition: none;
  }
}
