/* Bayrabbit engine-log charts (log-chart.js). Site tokens from styles.css plus chart roles.
   Series colours: the validated eight-slot categorical palette, stepped per theme and checked
   against each chart surface (graphite #272b30, light #ffffff). */
:root {
  --lc-surface: #272b30;
  --lc-grid: #343a41;
  --lc-axis: #5a626b;
  --lc-ink: #b5bbc2;
  --lc-cursor: rgba(245, 244, 242, .62);
  --lc-select: rgba(203, 35, 51, .22);
  --lc-s1: #3987e5;
  --lc-s2: #d95926;
  --lc-s3: #199e70;
  --lc-s4: #c98500;
  --lc-s5: #d55181;
  --lc-s6: #0ca30c;
  --lc-s7: #9085e9;
  --lc-s8: #e66767;
}
:root[data-theme="light"] {
  --lc-surface: #ffffff;
  --lc-grid: #eceeec;
  --lc-axis: #b7bfbd;
  --lc-ink: #555f62;
  --lc-cursor: rgba(32, 38, 39, .55);
  --lc-select: rgba(181, 28, 45, .1);
  --lc-s1: #2a78d6;
  --lc-s2: #eb6834;
  --lc-s3: #1baf7a;
  --lc-s4: #eda100;
  --lc-s5: #e87ba4;
  --lc-s6: #008300;
  --lc-s7: #6250d6;
  --lc-s8: #e34948;
}
:root[data-theme="light"][data-theme-variant="white"] {
  --lc-surface: #ffffff;
  --lc-grid: #dce5f2;
  --lc-axis: #8fa6c4;
  --lc-ink: #334155;
  --lc-select: rgba(29, 78, 216, .14);
}

/* "Chart" and "Download" stay together as the row's actions */
.file-row .file-actions { display: inline-flex; align-items: center; gap: 14px; margin-left: auto; }
.file-row .chart-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; cursor: pointer;
  color: var(--text); background: var(--red-soft); border: 1px solid var(--red);
  font: 600 11px/1.2 var(--font); letter-spacing: .14em; text-transform: uppercase;
}
.file-row .chart-btn svg { width: 15px; height: 15px; color: var(--red-2); }
.file-row .chart-btn:hover { background: var(--red); color: #fff; }
.file-row .chart-btn:hover svg { color: #fff; }

/* the viewer: a full-screen sheet over the account */
.lc {
  position: fixed; inset: 0; z-index: 80; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); color: var(--text); font-family: var(--font);
}
.lc-sheet {
  max-width: 1320px; margin: 0 auto; display: grid; gap: 14px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(36px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
/* grid tracks never grow past the screen: a long row of switches scrolls inside itself instead */
.lc-sheet, .lc-body, .lc-panes { grid-template-columns: minmax(0, 1fr); }
.lc-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 24px; }
.lc-titles { display: grid; gap: 6px; min-width: 0; }
.lc-kicker {
  display: flex; align-items: center; gap: 12px; margin: 0;
  font-size: 11px; font-weight: 500; letter-spacing: .3em; text-transform: uppercase; color: var(--muted);
}
.lc-kicker::before { content: ""; width: 24px; height: 2px; background: var(--red); flex: none; }
.lc-title {
  margin: 0; font-size: clamp(20px, 3vw, 30px); line-height: 1.1; font-weight: 800; font-style: italic;
  font-stretch: 110%; text-transform: uppercase; overflow-wrap: anywhere;
}
.lc-sub { margin: 0; font-size: 13px; color: var(--dim); }
.lc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lc-btn {
  min-height: 38px; padding: 8px 14px; cursor: pointer;
  font: 600 11px/1.2 var(--font); letter-spacing: .14em; text-transform: uppercase;
  color: var(--text); background: var(--bg-1); border: 1px solid var(--line-2);
}
.lc-btn:hover:not(:disabled) { border-color: var(--red); }
.lc-btn:disabled { opacity: .45; cursor: default; }
.lc-btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.lc-btn-primary:hover:not(:disabled) { background: var(--red-hover); border-color: var(--red-hover); }
.lc :focus-visible { outline: 2px solid var(--brand-red); outline-offset: 2px; }

/* one row of controls above everything it scopes */
.lc-bar {
  position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--line);
}
.lc-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 520px; min-width: 0; }
.lc-chip {
  padding: 6px 10px; cursor: pointer; font: 600 11px/1.2 var(--font); letter-spacing: .08em; text-transform: uppercase;
  color: var(--dim); background: transparent; border: 1px solid var(--line-2);
}
.lc-chip[aria-pressed="true"] { color: var(--text); border-color: var(--red); background: var(--red-soft); }
.lc-chip:hover { color: var(--text); }
.lc-zoom { display: flex; gap: 6px; flex-wrap: wrap; }
.lc-readout { flex: 1 1 100%; margin: 0; min-height: 1.5em; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.lc-more-sum { color: var(--muted); border-style: dashed; }
.lc-more-sum::after { content: " +"; }
.lc-more-sum[aria-expanded="true"]::after { content: " −"; }
.lc-more-chips { flex: 1 1 100%; }
.lc-more-chips[hidden] { display: none !important; }

/* headline figures: the numbers a tuner looks at first; each jumps to its moment */
.lc-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.lc-tile {
  display: grid; gap: 4px; align-content: start; padding: 14px 16px 13px; text-align: left; cursor: pointer;
  color: var(--text); background: var(--bg-1); border: 1px solid var(--line); font: inherit;
  transition: border-color .15s, transform .15s;
}
.lc-tile:hover { border-color: var(--red); }
.lc-tile-label { font-size: 10.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.lc-tile-value { font-size: 27px; line-height: 1.1; font-weight: 800; font-style: italic; font-stretch: 110%; white-space: nowrap; }
.lc-tile-value small { font-size: 13px; font-weight: 600; font-style: normal; color: var(--muted); }
.lc-tile-detail { font-size: 12px; color: var(--muted); }
@media (prefers-reduced-motion: no-preference) { .lc-tile:hover { transform: translateY(-1px); } }

.lc-body { display: grid; gap: 12px; }
.lc-panes { display: grid; gap: 12px; }
.lc-pane { display: grid; gap: 8px; padding: 12px 14px; background: var(--lc-surface); border: 1px solid var(--line); }
.lc-pane-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.lc-pane-head h3 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: .02em; }
.lc-pane-sub { margin: 0; font-size: 12px; color: var(--dim); }
.lc-pane-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 340px); gap: 16px; align-items: start; }
.lc-plot { position: relative; height: 190px; cursor: crosshair; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.lc-plot canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* the legend is also the table view: value at the cursor, min and max over the visible time */
.lc-legend-wrap { min-width: 0; overflow-x: auto; }
.lc-legend { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.lc-legend th {
  padding: 0 6px 6px; text-align: right; white-space: nowrap;
  font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--dim);
}
.lc-legend th:first-child { text-align: left; padding-left: 0; }
.lc-legend td { padding: 4px 6px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lc-legend td.lc-name { padding-left: 0; text-align: left; white-space: normal; width: 100%; }
.lc-key {
  display: flex; align-items: flex-start; gap: 8px; padding: 0; cursor: pointer; text-align: left;
  color: var(--text); background: none; border: 0; font: inherit; line-height: 1.35;
}
.lc-line { flex: none; width: 18px; margin-top: .62em; border-top: 2px solid var(--c); }
.lc-line.lc-dashed { border-top-style: dashed; }
.lc-off .lc-key, .lc-off td { color: var(--dim); }
.lc-off .lc-line { opacity: .3; }

.lc-hint { margin: 0; font-size: 12.5px; color: var(--dim); }
.lc-msg { margin: 0; padding: 18px; background: var(--bg-1); border: 1px solid var(--line); color: var(--muted); }
.lc-msg-err { border-left: 3px solid var(--red); color: var(--text); }

@media (max-width: 820px) {
  .lc-pane-body { grid-template-columns: minmax(0, 1fr); }
  .lc-plot { height: 170px; }
}
@media (max-width: 600px) {
  /* one swipeable row of chart switches instead of a wall of them */
  .lc-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; flex-basis: 100%; margin-inline: -2px; padding-inline: 2px; }
  .lc-chips::-webkit-scrollbar { display: none; }
  .lc-chip { flex: none; }
  .lc-more-chips { display: contents; }
  .lc-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lc-tile { padding: 11px 12px; }
  .lc-tile-value { font-size: 21px; white-space: normal; }
}
@media (max-width: 480px) {
  .lc-bar { position: static; }
  .lc-pane { padding: 10px; }
  .lc-plot { height: 160px; }
}
