/* Styles for the rule_visualizer partial (base/templates/base/_rule_visualizer.html).
   The partial links this itself so any page including it picks the styles up;
   every include site is at top level, so the tag is emitted once per page. */

/* Both triggers are quiet text, not chrome. This is an aside — "show me what
   this rule is doing to the data" — offered next to the thing it describes,
   and a filled button gave it more weight on the page than Save. The edit
   form's used to be a solid teal box; it is the same link as the list page's
   now, one notch bolder because there it stands alone rather than sitting in
   a meta line. No icon: the words are the affordance. */
.viz-trigger, .viz-demo-btn {
  font: inherit; font-size: 0.85rem; color: var(--link); background: none;
  border: none; padding: 0; cursor: pointer; text-decoration: none;
}
.viz-trigger:hover, .viz-demo-btn:hover { text-decoration: underline; }
.viz-demo-btn { font-weight: 600; }
body.dark-mode .viz-trigger, body.dark-mode .viz-demo-btn { color: var(--link); }

.viz-form-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 2px 0 14px; }
.viz-form-hint { font-size: 0.82rem; color: var(--ink-3); }
body.dark-mode .viz-form-hint { color: var(--ink-3); }

.viz-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 2100;
}
.viz-backdrop[hidden] { display: none; }
.viz-modal {
  background: var(--surface); border-radius: var(--r-md); max-width: 880px; width: 100%;
  max-height: 88vh; overflow-y: auto; padding: 18px 22px 22px;
  box-shadow: 0 20px 45px rgba(0,0,0,0.28); color: var(--ink);
}
.viz-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.viz-modal h3 { margin: 0; font-size: 1.05rem; }
.viz-sub { font-size: 0.83rem; color: var(--ink-3); margin: 2px 0 10px; }
.viz-close {
  background: none; border: none; font-size: 1.4rem; line-height: 1; cursor: pointer;
  color: var(--ink-3); padding: 0 4px;
}
.viz-close:hover { color: var(--ink); }

.viz-controls { display: flex; gap: 6px; align-items: center; margin: 8px 0 10px; flex-wrap: wrap; }
.viz-win {
  font: inherit; font-size: 0.76rem; cursor: pointer; padding: 3px 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); border-radius: var(--r-pill);
}
.viz-win.on { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.viz-win-label { font-size: 0.76rem; color: var(--ink-3); margin-right: 2px; }

/* Per-variable tabs, for a rule that predicts several at once. A tab strip
   rather than the pill row above it, because these are VIEWS of one chart
   while the pills are settings for it — and because the first tab is the
   subject and the rest are its parts, which a row of equal pills would not
   say. */
.viz-tabs { display: flex; gap: 2px; flex-wrap: wrap; margin: 4px 0 10px;
            border-bottom: 1px solid var(--line); }
.viz-tab {
  font: inherit; font-size: 0.78rem; cursor: pointer; padding: 5px 12px;
  border: 1px solid transparent; border-bottom: none; background: none;
  color: var(--ink-2); border-radius: var(--r-sm) var(--r-sm) 0 0; margin-bottom: -1px;
}
.viz-tab:hover { background: var(--surface-2); }
.viz-tab.on {
  background: var(--surface); border-color: var(--line); border-bottom-color: #fff;
  color: var(--link); font-weight: 600;
}
body.dark-mode .viz-tabs { border-bottom-color: var(--line); }
body.dark-mode .viz-tab { color: var(--ink-2); }body.dark-mode .viz-tab.on { background: var(--surface-2); border-color: var(--line);
                             border-bottom-color: var(--line); color: var(--link); }

.viz-chart { width: 100%; height: 300px; }
.viz-chart .axis { stroke: #d1d5db; stroke-width: 1; }
.viz-chart .gridline { stroke: #eef2f7; stroke-width: 1; }
.viz-chart .tick { fill: var(--ink-3); font-size: 11px; }
.viz-chart .band { fill: rgba(37,99,235,.09); stroke: none; }
.viz-chart .bandline { fill: none; stroke: var(--critical-ink); stroke-width: 1.4; stroke-dasharray: 6 4; }
.viz-chart .clearline { fill: none; stroke: var(--warning-ink); stroke-width: 1.2; stroke-dasharray: 2 3; }
.viz-chart .estline { fill: none; stroke: #2E8B57; stroke-width: 1.2; stroke-dasharray: 4 3; }
.viz-chart .vline { fill: none; stroke: var(--link); stroke-width: 1.5; }
.viz-chart .vpt { fill: var(--critical-ink); }
.viz-chart .vpt.held { fill: var(--warning-ink); }
.viz-chart .vpt.suppressed { fill: #0891b2; }
.viz-chart .region { fill: rgba(14,165,233,.10); stroke: none; }
.viz-chart .region.fire { fill: rgba(185,28,28,.07); }
.viz-chart .region-label { fill: var(--link); font-size: 11px; font-weight: 600; }
.viz-chart .region-label.fire { fill: var(--critical-ink); }
.viz-chart .marker { stroke: var(--critical-ink); stroke-width: 1.2; stroke-dasharray: 3 3; }
.viz-chart .marker-label { fill: var(--critical-ink); font-size: 11px; font-weight: 600; }
.viz-chart .edge-label { font-size: 11px; font-weight: 600; fill: var(--critical-ink); }

.viz-stats { font-size: 0.8rem; color: var(--ink-2); margin: 6px 0 8px; }
.viz-legend { font-size: 0.78rem; color: var(--ink-3); margin: 4px 0 10px; line-height: 1.5; }
.viz-legend .key { display: inline-block; width: 9px; height: 9px; border-radius: var(--r-xs); margin: 0 3px 0 8px; vertical-align: baseline; }
.viz-legend .key.value { background: var(--accent); }
.viz-legend .key.bound { background: #b91c1c; }
.viz-legend .key.clear { background: #b45309; }
.viz-legend .key.est { background: #2E8B57; }   /* the same green as the line (Plotly + SVG) */
.viz-legend .key.rain { background: rgba(14,165,233,.45); }
.viz-msg { color: var(--ink-3); font-size: 0.9rem; padding: 14px 0; }
.viz-warn { color: var(--warning-ink); background: var(--warning-tint); border: 1px solid var(--warning);
  border-radius: var(--r-sm); padding: 8px 10px; font-size: 0.8rem; margin: 6px 0 10px; }

body.dark-mode .viz-modal { background: var(--surface-2); color: var(--ink); }
body.dark-mode .viz-sub, body.dark-mode .viz-legend, body.dark-mode .viz-msg,
body.dark-mode .viz-win-label { color: var(--ink-3); }
body.dark-mode .viz-stats { color: var(--ink-2); }
body.dark-mode .viz-close { color: var(--ink-3); }
body.dark-mode .viz-win { background: var(--field); color: var(--ink-2); border-color: var(--line); }
body.dark-mode .viz-chart .gridline { stroke: #3f4a5a; }
body.dark-mode .viz-chart .axis { stroke: #4a5568; }
body.dark-mode .viz-chart .vline { stroke: var(--link); }
body.dark-mode .viz-chart .band { fill: rgba(99,179,237,.12); }
body.dark-mode .viz-chart .bandline { stroke: var(--critical-ink); }
body.dark-mode .viz-chart .edge-label { fill: var(--critical-ink); }
body.dark-mode .viz-chart .clearline { stroke: var(--warning-ink); }
body.dark-mode .viz-chart .estline { stroke: #3fae72; }
body.dark-mode .viz-warn { background: var(--warning-tint); color: var(--warning-ink); border-color: var(--warning-ink); }

/* The interactive chart (Plotly); the SVG rules above are the fallback. */
.viz-plotly { width: 100%; min-height: 300px; }
