/* power.css — the power visualiser page only.
 *
 * Loaded after style.css and adds nothing to it: the sidebar, panels, rows,
 * buttons, presets and .calc blocks are the map tool's, unchanged, so the two
 * pages cannot drift apart visually. What is here is the stage — a column of
 * canvas cards and a strip of derived figures above them — because the map
 * tool's #stage is a single full-bleed Leaflet map and this one is not.
 */

/* The page-switching nav in the sidebar header lives in style.css, since both
 * pages carry it and only power.html loads this file. */

/* ---------- stage: figures over stacked canvas cards ---------- */

#pv-stage {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  gap: 10px; padding: 10px; overflow: hidden;
}

#figs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.fig {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 11px 9px; min-width: 0;
}
.fig .lbl {
  font-size: 9.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-dim);
}
.fig .val {
  font-size: 21px; font-weight: 700; line-height: 1.15; margin-top: 2px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.fig .val .un { font-size: 11px; font-weight: 600; color: var(--ink-dim); margin-left: 3px; }
.fig .sub {
  font-size: 10.5px; color: var(--ink-dim); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Each figure keeps the colour it is drawn in on the canvases. */
.fig.f-p   .val { color: #4be0a8; }
.fig.f-s   .val { color: var(--ink); }
.fig.f-q   .val { color: #ff6b6b; }
.fig.f-i   .val { color: var(--accent); }
.fig.f-pf  .val { color: #f0c040; }
.fig .sub.hot { color: #ff9f43; }

/* The canvases size themselves to these boxes via ResizeObserver, so the
 * flex-basis split here is what decides the panel proportions. min-height
 * stops the phasor wheel collapsing to nothing on a short window. */
/* The max-heights matter more than they look: the phasor wheel's radius is the
 * waveform's amplitude (see js/power/main.js), so a panel stretched to fill a
 * very tall window would give the dial a 300 px radius and leave the waveform
 * squeezed for width. Capped, they stay in proportion and the stage simply
 * leaves space below. */
.cwrap { position: relative; min-height: 0; }
#scopeWrap { flex: 1 1 56%; min-height: 240px; max-height: 560px; }
#powerWrap { flex: 1 1 44%; min-height: 190px; max-height: 440px; }
.cwrap canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; cursor: crosshair;
}

/* ---------- the power factor readout ---------- */

.pfbox {
  background: #141821; border: 1px solid var(--line); border-radius: 5px;
  padding: 9px 10px 8px; margin-bottom: 9px; text-align: center;
}
.pfbox .n {
  font-size: 30px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; color: #f0c040;
}
.pfbox .s { font-size: 11px; margin-top: 4px; color: var(--ink-dim); }
.pfbox .s b { font-weight: 700; }
/* Empty unless a compensation bank is fitted, so it must collapse rather than
 * leave a gap under the power factor. */
.pfbox .s2:not(:empty) {
  font-size: 11px; margin-top: 5px; padding-top: 5px;
  border-top: 1px solid var(--line); color: var(--accent); font-weight: 600;
}
.pfbox.lag  .s b { color: #ff9f43; }
.pfbox.lead .s b { color: var(--accent); }
.pfbox.unity .s b { color: #4be0a8; }

/* A slider that runs from leading through unity to lagging wants its two ends
 * named, or the sign convention is a guess. */
.slider-ends {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--ink-dim); margin: -6px 0 6px;
}

.preset .pf {
  font-size: 10.5px; color: var(--ink-dim); font-variant-numeric: tabular-nums;
}

@media (max-width: 1100px) {
  #figs { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  #app { flex-direction: column; }
  #side { width: 100%; flex: 0 0 auto; height: 44%; border-right: none;
          border-bottom: 1px solid var(--line); }
  #pv-stage { flex: 1; overflow: auto; }
  #figs { grid-template-columns: repeat(2, 1fr); }
}
