/* ═══════════════════════════════════════════════════════════════════════════
   28-energy.css — the ENERGY + GRID research surface (#energy-root).
   ---------------------------------------------------------------------------
   Built by static/js/energy.js. Load order in static/css/app/ IS the cascade
   and this file is last, so nothing here needs to fight for specificity and
   nothing here may be renumbered.

   THE DIALECT IS OURS, taken from 07-command-center.css / 18-storms.css rather
   than invented: opaque --bg-tertiary cards, ONE hairline inset ring (never a
   1px border, which bowties in headless screenshots), --radius-lg, an in-card
   header shelf, the 60px page grid behind the scrolling content. Every colour
   resolves through tokens.css so both themes follow for free.

   COLOUR RULE
   -----------
   Blue vs bronze, never green vs red. Green/red collapses under deuteranopia;
   blue/orange does not. Both hues come from the research categorical ramp
   (--rsx-cat-4 / --rsx-cat-2), the only ramp overridden for the light theme
   with measured contrast on cream.

   And colour is REINFORCEMENT ONLY. Every verdict on this surface is a WORD at
   a fixed column position (DREW / BUILT / FLAT / HIGHER / LOWER / NO FIGURE /
   REVISED / FIRST PRINT / LATE). Desaturate a screenshot and nothing is lost.

   THE INLINE CAVEAT IS NOT DECORATION, AND IT LIVES AT TWO LEVELS
   ---------------------------------------------------------------
   Per the declutter spec's R3, anything that changes what a number MEANS is
   inline and never behind a toggle. This surface splits that across two
   classes, for a reason that was measured in the browser rather than assumed:

   `.en-th-rule` — the rule that governs EVERY cell in a column, stated once in
   the column heading. "NOT weather-adjusted", the missing confidence interval,
   what the trough and the tracked-region median actually are. Rendered per row
   these were three sentences × nine regions on one 1440 screen, which is the
   caveat wall the spec was written against. Same page, same un-toggleable
   status, one level up.

   `.en-caveat` — what VARIES per row and would change how that row is read:
   the coverage refusal on a region below the floor, the hours it never
   reported. Styled to be legible rather than to disappear (--text-secondary at
   0.6875rem, not --text-muted at 0.5rem).

   Anything that merely explains a SOURCE or a PROCESS lives in the one
   per-panel expander instead.
   ═══════════════════════════════════════════════════════════════════════════ */

#energy-root{
  position:absolute;inset:0;display:none;
  flex-direction:column;min-width:0;min-height:0;
  background:var(--bg-primary);

  /* State hues, declared once and consumed by every verdict cell. */
  --en-up:   var(--rsx-cat-4);      /* blue   — higher / built  */
  --en-down: var(--rsx-cat-2);      /* bronze — lower  / drew   */
  --en-mid:  var(--text-muted);
}
/* MPEnergy.show()/hide() owns this class, so the host needs no per-mode
   display rule of its own in 05-chart-panels.css. */
#energy-root.en-on{display:flex;}

/* The stage's OTHER layers, hidden while this surface owns it. Declared here
   rather than in 05-chart-panels.css so wiring this view is a class toggle in
   research.js and nothing else. !important matches the existing
   .research-panel rules it has to beat. */
#research-view.rsx-mode-energy #research-iframe,
#research-view.rsx-mode-energy #rsx-index,
#research-view.rsx-mode-energy .rf-surface,
#research-view.rsx-mode-energy .research-panel{display:none!important;}

/* ── Scroller ─────────────────────────────────────────────────────────────*/
.en-scroll{
  flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;
  scrollbar-width:thin;
  scrollbar-color:color-mix(in srgb, var(--accent) 22%, transparent) transparent;
}
.en-scroll::-webkit-scrollbar{width:0.375rem;height:0.375rem;}
.en-scroll::-webkit-scrollbar-track{background:transparent;}
.en-scroll::-webkit-scrollbar-thumb{background:var(--border-default);border-radius:0.25rem;}
.en-scroll:hover::-webkit-scrollbar-thumb{background:color-mix(in srgb, var(--accent) 28%, transparent);}

.en-inner{
  display:flex;flex-direction:column;gap:0.75rem;
  padding:0.75rem;min-height:100%;
  background-image:
    linear-gradient(color-mix(in srgb, var(--text-primary) 3.5%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--text-primary) 3.5%, transparent) 1px, transparent 1px);
  background-size:60px 60px;
}

/* ── Card chrome ──────────────────────────────────────────────────────────*/
.en-card{
  background:var(--bg-tertiary);
  border-radius:var(--radius-lg, 0.5rem);
  box-shadow:inset 0 0 0 1px var(--graph-card-ring, var(--border-default));
  overflow:hidden;
}
.en-card-alert{
  box-shadow:inset 0 0 0 1px var(--border-strong);
}
.en-card-head{
  display:flex;align-items:baseline;gap:0.625rem;flex-wrap:wrap;
  padding:0.625rem 0.875rem;
  background:var(--bg-secondary);
  box-shadow:inset 0 -1px 0 0 var(--border-subtle);
}
.en-card-title{
  margin:0;
  font-family:var(--font-sans);
  font-size:max(0.8125rem, var(--fs-floor));
  font-weight:700;letter-spacing:0.02em;
  color:var(--text-primary);
}
.en-card-sub{
  font-size:max(0.6875rem, var(--fs-floor));
  color:var(--text-secondary);
  min-width:0;
}
.en-card-body{padding:0.875rem;}
.en-empty{
  margin:0;padding:0.875rem;
  font-size:max(0.75rem, var(--fs-floor));color:var(--text-secondary);
}

/* ── R1: the verdict. The heaviest element, with no number beside it. ──────*/
.en-verdict .en-card-body{
  padding-left:1rem;
}

.en-verdict-word{
  margin:0 0 0.25rem;
  font-family:var(--font-sans);
  font-size:max(0.6875rem, var(--fs-floor));
  font-weight:800;letter-spacing:0.1em;
  color:var(--text-secondary);
}
.en-s-ok .en-verdict-word       { color:var(--en-up); }
.en-s-rejected .en-verdict-word { color:var(--en-down); }
.en-s-demo .en-verdict-word     { color:var(--rsx-cat-6); }

.en-verdict-line{
  margin:0;
  font-family:var(--font-sans);
  font-size:max(1rem, var(--fs-floor));
  font-weight:650;line-height:1.35;
  color:var(--text-primary);
  max-width:78ch;
}
.en-verdict-qual{
  margin:0.4375rem 0 0;
  font-size:max(0.75rem, var(--fs-floor));
  line-height:1.5;color:var(--text-secondary);
  max-width:82ch;
}

/* The context-not-signal line. Deliberately NOT inside a card: it applies to
   everything below it, and a card would make it look like one more panel. */
.en-scope{
  margin:0;padding:0 0.25rem;
  font-size:max(0.75rem, var(--fs-floor));
  line-height:1.5;color:var(--text-secondary);
  max-width:96ch;
}

/* ── Evidence strip ───────────────────────────────────────────────────────*/
.en-evidence{
  display:grid;grid-template-columns:repeat(auto-fit, minmax(11rem, 1fr));
  gap:0.5rem 1rem;margin:0;padding:0.75rem 0.875rem;
}
.en-ev{display:flex;flex-direction:column;gap:0.125rem;min-width:0;}
.en-ev dt{
  font-size:max(0.625rem, var(--fs-floor));
  letter-spacing:0.05em;text-transform:uppercase;
  color:var(--text-muted);
}
.en-ev dd{
  margin:0;
  font-family:var(--font-mono, ui-monospace, monospace);
  font-size:max(0.75rem, var(--fs-floor));
  color:var(--text-primary);
}

/* ── Tables ───────────────────────────────────────────────────────────────
   Wide content scrolls inside its own container; the surface never scrolls
   horizontally as a whole. */
.en-tablewrap{overflow-x:auto;}
.en-table{
  width:100%;border-collapse:collapse;
  font-size:max(0.75rem, var(--fs-floor));
}
.en-table thead th{
  position:sticky;top:0;z-index:1;
  padding:0.4375rem 0.75rem 0.5rem;
  text-align:left;vertical-align:top;
  background:var(--bg-secondary);
  box-shadow:inset 0 -1px 0 0 var(--border-subtle);
  white-space:normal;min-width:7rem;max-width:15rem;
}
.en-th{
  display:block;
  font-size:max(0.625rem, var(--fs-floor));
  font-weight:700;letter-spacing:0.04em;text-transform:uppercase;
  color:var(--text-muted);
}
/* The COLUMN's rule (R3). Inline, never behind a toggle, and stated once
   rather than once per row — a caveat printed nine times stops being read. */
.en-th-rule{
  display:block;margin-top:0.1875rem;
  font-size:max(0.625rem, var(--fs-floor));
  font-weight:400;letter-spacing:0;text-transform:none;
  line-height:1.4;color:var(--text-secondary);
}
.en-table tbody tr{box-shadow:inset 0 -1px 0 0 var(--border-subtle);}
.en-table tbody tr:last-child{box-shadow:none;}
.en-table tbody tr:hover{background:var(--bg-row-hover);}
.en-table td,.en-table th[scope="row"]{
  padding:0.5rem 0.75rem;vertical-align:top;text-align:left;
}

.en-name{min-width:13rem;}
.en-label{
  display:block;
  font-family:var(--font-sans);
  font-weight:650;color:var(--text-primary);
  font-size:max(0.8125rem, var(--fs-floor));
}
.en-numeric{min-width:9rem;color:var(--text-primary);}
.en-big{
  display:block;
  font-family:var(--font-mono, ui-monospace, monospace);
  font-size:max(0.875rem, var(--fs-floor));
  font-weight:600;color:var(--text-primary);
}
.en-mono{
  display:block;
  font-family:var(--font-mono, ui-monospace, monospace);
  font-size:max(0.8125rem, var(--fs-floor));
  color:var(--text-primary);
}
/* The verdict WORD. Fixed column position, always present, always a word. */
.en-word{
  display:block;
  font-family:var(--font-sans);
  font-size:max(0.6875rem, var(--fs-floor));
  font-weight:800;letter-spacing:0.06em;
  color:var(--en-mid);
}
.en-up   .en-word,.en-up   .en-bar{color:var(--en-up);}
.en-down .en-word,.en-down .en-bar{color:var(--en-down);}
.en-flat .en-word{color:var(--text-secondary);}
.en-none,.en-word.en-none{color:var(--text-muted);}
.en-quiet{color:var(--text-muted);}
.en-flag{color:var(--en-down);font-weight:800;}

.en-sub{
  display:block;margin-top:0.1875rem;
  font-size:max(0.625rem, var(--fs-floor));
  line-height:1.45;color:var(--text-muted);
}
/* R3 INLINE caveats. One step brighter and one step larger than .en-sub,
   because these change what the number means and must survive a screenshot. */
.en-caveat{
  color:var(--text-secondary);
  font-size:max(0.6875rem, var(--fs-floor));
  max-width:34ch;
}

/* ── Marks ────────────────────────────────────────────────────────────────*/
.en-sparkcell{min-width:8.5rem;color:var(--text-secondary);}
.en-spark{display:block;color:var(--text-secondary);opacity:0.9;}
.en-bar{display:block;margin-top:0.1875rem;color:var(--en-mid);}

/* ── R2/R3 expander ───────────────────────────────────────────────────────
   A real button, keyboard-reachable, with aria-expanded. Never a title=
   tooltip: a tooltip does not survive a screenshot, does not work on touch and
   is unreachable by keyboard. */
.en-expand{box-shadow:inset 0 1px 0 0 var(--border-subtle);}
.en-expand-btn{
  display:flex;align-items:center;gap:0.4375rem;
  width:100%;padding:0.5rem 0.875rem;
  background:transparent;border:0;cursor:pointer;
  text-align:left;
  font-family:var(--font-sans);
  font-size:max(0.6875rem, var(--fs-floor));
  font-weight:600;letter-spacing:0.02em;
  color:var(--text-secondary);
}
.en-expand-btn:hover{background:var(--bg-hover);color:var(--text-primary);}
.en-expand-btn:focus-visible{
  outline:none;
  box-shadow:inset 0 0 0 1px var(--accent);
}
.en-expand-caret{
  display:inline-block;transition:transform 0.14s ease;
  font-size:1rem;line-height:1;color:var(--text-muted);
}
.en-expand-btn[aria-expanded="true"] .en-expand-caret{transform:rotate(90deg);}
.en-expand-body{padding:0 0.875rem 0.75rem 1.875rem;}
.en-list{
  margin:0;padding-left:1rem;
  display:flex;flex-direction:column;gap:0.3125rem;
  font-size:max(0.6875rem, var(--fs-floor));
  line-height:1.5;color:var(--text-secondary);
  max-width:96ch;
}
.en-note{
  margin:0 0 0.5rem;
  font-size:max(0.75rem, var(--fs-floor));
  line-height:1.5;color:var(--text-secondary);max-width:88ch;
}
.en-note:last-child{margin-bottom:0;}
.en-link{color:var(--accent);text-decoration:underline;}
.en-link:hover{color:var(--accent-hover);}

/* ── Foot ─────────────────────────────────────────────────────────────────*/
.en-foot{
  margin:0;padding:0 0.25rem;
  font-size:max(0.625rem, var(--fs-floor));
  line-height:1.55;color:var(--text-muted);
  max-width:120ch;
}

/* ── Synthetic seed data ──────────────────────────────────────────────────
   Unmistakable, and not reliant on the reader noticing one chip. The hatch
   rides the whole surface, the banner is the first thing on it, and every
   panel header carries the word. */
.en-demo-banner{
  display:flex;align-items:center;gap:0.625rem;flex-wrap:wrap;
  padding:0.5rem 0.875rem;
  border-radius:var(--radius-lg, 0.5rem);
  background:var(--bg-tertiary);
  box-shadow:inset 0 0 0 1px var(--rsx-cat-6);
  font-size:max(0.75rem, var(--fs-floor));
  color:var(--text-primary);
}
.en-demo-chip{
  flex:none;
  padding:0.125rem 0.375rem;border-radius:0.1875rem;
  background:color-mix(in srgb, var(--rsx-cat-6) 18%, transparent);
  color:var(--rsx-cat-6);
  font-family:var(--font-sans);
  font-size:max(0.5625rem, var(--fs-floor));
  font-weight:800;letter-spacing:0.1em;
}
#energy-root.en-demo .en-inner{
  background-image:
    repeating-linear-gradient(
      135deg,
      color-mix(in srgb, var(--rsx-cat-6) 7%, transparent) 0 8px,
      transparent 8px 22px),
    linear-gradient(color-mix(in srgb, var(--text-primary) 3.5%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--text-primary) 3.5%, transparent) 1px, transparent 1px);
  background-size:auto, 60px 60px, 60px 60px;
}

/* ── Narrow widths ────────────────────────────────────────────────────────
   The table already scrolls inside .en-tablewrap; below 1100px the sparkline
   column is the first thing worth dropping — it is the only cell whose absence
   removes no stated fact. */
@media (max-width: 1100px){
  .en-table thead th:last-child,
  .en-table tbody td:last-child{display:none;}
}
@media (prefers-reduced-motion: reduce){
  .en-expand-caret{transition:none;}
}
