/* Elasticity & Total Revenue (economics/elasticity-revenue.php). Builds on market-graph.css (the curves'
   colours, the controls, the indicator table). On a laptop or desktop: two diagrams side by side,
   filling the height, and the controls and results in a column on the right (scrolling inside it if
   they must). On tablets and phones it stacks and the page scrolls. Theme tokens only, plus the page
   tokens below. */

/* page tokens: the elastic and inelastic ranges, the TR curve, the bars; deeper in light mode */
:root{
  --er-elastic:#7c3aed;  --er-elastic-tint:rgba(124,58,237,.07);
  --er-inelastic:#0f766e;--er-inelastic-tint:rgba(15,118,110,.07);
  --er-unit:#b45309;
  --er-tr:#7c2d12;
  --er-bar-p:#dc2626;    --er-bar-q:#2563eb;
}
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --er-elastic:#c4b5fd;--er-elastic-tint:rgba(196,181,253,.08);
    --er-inelastic:#5eead4;--er-inelastic-tint:rgba(94,234,212,.07);
    --er-unit:#fbbf24;--er-tr:#fdba74;--er-bar-p:#f87171;--er-bar-q:#60a5fa;
  }
}
:root[data-theme="dark"]{
  --er-elastic:#c4b5fd;--er-elastic-tint:rgba(196,181,253,.08);
  --er-inelastic:#5eead4;--er-inelastic-tint:rgba(94,234,212,.07);
  --er-unit:#fbbf24;--er-tr:#fdba74;--er-bar-p:#f87171;--er-bar-q:#60a5fa;
}

/* ---------- the stage ---------- */
.er-stage{flex:1;min-height:0;display:grid;grid-template-columns:minmax(0,1fr) minmax(300px,350px);gap:12px}
.er-graphs{display:flex;flex-direction:column;gap:6px;padding:10px 12px;min-height:0;min-width:0}
.er-graph-head{display:flex;align-items:center;justify-content:space-between;gap:6px 14px;flex-wrap:wrap;flex:none}
.er-graph-head [hidden]{display:none}
.er-pair{flex:1;min-height:0;display:grid;grid-template-columns:1fr 1fr;gap:10px}
.er-pair[hidden]{display:none}
.er-box{position:relative;min-height:0;min-width:0;margin:0}
.er-box svg{position:absolute;inset:0;width:100%;height:100%;display:block;background:var(--panel);border-radius:6px;touch-action:none;user-select:none;-webkit-user-select:none}
#svg-demand,#svg-tr{cursor:grab}
#svg-demand:active,#svg-tr:active{cursor:grabbing}

.er-side{gap:10px}
.er-side > div{display:flex;flex-direction:column;gap:12px}
.er-side > div[hidden]{display:none}
.er-side section{display:flex;flex-direction:column;gap:7px}
.er-side section + section{border-top:1px solid var(--line);padding-top:10px}
.er-chips{display:flex;flex-wrap:wrap;gap:6px}
.er-chips .btn{white-space:normal;text-align:left}
.er-chip{font:600 13px/1.2 var(--font-display);padding:7px 11px;border-radius:999px;border:1px solid var(--line-strong);background:var(--panel-2);color:var(--ink-soft);cursor:pointer;min-height:34px}
.er-chip:hover{color:var(--ink);border-color:var(--accent)}
.er-chip[aria-pressed="true"]{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}
.er-chip:focus-visible{outline:2px solid var(--focus);outline-offset:2px}

.er-working{margin:0;padding:0 0 0 16px;font-size:12.5px;line-height:1.5;color:var(--ink-soft);display:flex;flex-direction:column;gap:3px}
.er-working b{color:var(--ink);font-family:var(--font-mono);font-weight:600}
.er-working .er-aside{color:var(--muted)}
.er-working .er-warn{display:block;color:var(--ink);background:var(--warn-tint);border-left:3px solid var(--warn);padding:4px 8px;border-radius:4px}

/* the legend's swatches */
.mg-legend i.er-sw-kept{background:var(--area-cs)}
.mg-legend i.er-sw-gain{background:var(--area-gov)}
.mg-legend i.er-sw-loss{background:var(--area-dwl)}
.mg-legend i.er-sw-band{background:linear-gradient(90deg,var(--er-elastic) 50%,var(--er-inelastic) 50%)}
.mg-legend i.er-sw-p{background:var(--er-bar-p)}
.mg-legend i.er-sw-q{background:var(--er-bar-q)}

/* ---------- the diagrams ---------- */
.er-grid{stroke-width:1;stroke-dasharray:3 5;opacity:.7}
.er-curve{fill:none;stroke-linejoin:round}
.er-band{stroke-width:11;stroke-linecap:round;opacity:.3}
.er-band-el{stroke:var(--er-elastic)}
.er-band-in{stroke:var(--er-inelastic)}
.er-unit-dot{fill:var(--er-unit);stroke:var(--panel);stroke-width:2}
.er-t-el{fill:var(--er-elastic);font-weight:600}
.er-t-in{fill:var(--er-inelastic);font-weight:600}
.er-t-unit{fill:var(--er-unit);font-weight:600}
.er-t-tr{fill:var(--er-tr)}
.er-bold{font-weight:700}
.er-kept{fill:var(--area-cs);stroke:var(--curve-s);stroke-width:1}
.er-gain{fill:var(--area-gov);stroke:var(--curve-s2);stroke-width:1}
.er-loss{fill:var(--area-dwl);stroke:var(--bad);stroke-width:1}
.er-trlabel{fill:var(--ink);opacity:.75}
.er-drop{stroke-width:1.3}
.er-drop-2{opacity:.6}
.er-dot1{cursor:grab}
.er-halo{fill:var(--accent);opacity:.16}
.er-dot2{fill:var(--panel);stroke:var(--ink);stroke-width:2}
.er-move{stroke:var(--ink-soft);stroke-width:2}
.er-arrowhead{fill:var(--ink-soft)}
.er-shift{stroke:var(--hint);stroke-width:3}
#svg-sd .er-arrowhead{fill:var(--hint)}
.er-pedtag{font-family:var(--font-mono);font-weight:600;fill:var(--accent-deep)}
.er-zone-el{fill:var(--er-elastic-tint)}
.er-zone-in{fill:var(--er-inelastic-tint)}
.er-mid{stroke:var(--er-unit)}
.er-trcurve{fill:none;stroke:var(--er-tr);stroke-width:3;stroke-linejoin:round}
.er-dot-tr{fill:var(--er-tr)}
.er-bar-p{fill:var(--er-bar-p)}
.er-bar-q{fill:var(--er-bar-q)}
.er-bar-val{font:600 11.5px/1 var(--font-mono);fill:var(--ink)}
.er-bar-hl{fill:var(--accent-tint);stroke:var(--accent);stroke-width:1.5}
.er-bar-hit{fill:transparent;cursor:pointer}
.er-bar-name{fill:var(--ink-soft);font:500 12px/1 var(--font-body)}
.er-bar-period{font-weight:700;fill:var(--accent-deep)}

/* ---------- laptops: a narrower side column ---------- */
@media (max-width:1300px){
  .er-stage{grid-template-columns:minmax(0,1fr) minmax(290px,320px)}
}

/* ---------- tablets and phones: everything stacks and the page scrolls ---------- */
@media (max-width:900px){
  .er-stage{display:flex;flex-direction:column}
  .er-pair{display:flex;flex-direction:column}
  .er-box svg{position:static;height:auto}
  .er-chip{min-height:40px;padding:8px 13px}
  #svg-demand,#svg-tr{touch-action:pan-y}
}
@media (max-width:640px){
  .er-graphs{padding:8px 6px}
  .er-graph-head{padding:0 4px}
  .er-bar-val{font-size:15px}
  .er-bar-period{font-size:15px}
  .er-bar-name{font-size:14px}
}

/* the results strip under the diagrams */
.er-stats{flex:none;margin:0;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}
.er-stats[hidden]{display:none}
.er-stats > div{background:var(--panel-2);border:1px solid var(--line);border-radius:5px;padding:5px 9px;min-width:0}
.er-stats dt{font:600 11.5px/1.25 var(--font-display);color:var(--muted)}
.er-stats dd{margin:2px 0 0;font:600 14px/1.3 var(--font-mono);font-variant-numeric:tabular-nums;color:var(--ink);overflow-wrap:anywhere}
.er-stats dd .badge{font-family:var(--font-body);vertical-align:1px}
.er-stats .er-up{color:var(--ok)}
.er-stats .er-down{color:var(--bad)}
@media (max-width:900px){ .er-stats{grid-template-columns:repeat(2,minmax(0,1fr))} .er-stats > div:last-child{grid-column:1 / -1} }
@media (min-width:901px) and (max-width:1150px){
  .er-stage{grid-template-columns:minmax(0,1fr) 280px}
  .er-stats dd{font-size:12.5px}
  .er-stats dt{font-size:11px}
}
@media (min-width:901px) and (max-height:700px){
  .er-graphs .mg-note{font-size:12.5px;line-height:1.35}
  .er-stats > div{padding:3px 8px}
}
.er-graph-head > *{min-width:0;max-width:100%}
.er-graph-head .mg-legend li{min-width:0}
