/* Power Grid Manager: the city grid control room (dispatch desk on the left; the valley, plant cards and grid board on
   the right). Scene by art.js, colors from the --pgm-* properties below (light and dark). */
html {
  --pgm-ground1: #6f9a4e; --pgm-ground2: #4a6e33; --pgm-hill1: #7fa77c; --pgm-hill2: #567d55; --pgm-line: #1b2530;
  --pgm-bldg1: #4a5a78; --pgm-bldg2: #2f3a52; --pgm-win: #ffd84a; --pgm-win-off: #1a2030; --pgm-wire: #2a2f36; --pgm-hot: #ffcf3a;
  --pgm-ink: #17242c; --pgm-panel1: #f5f8fb; --pgm-panel2: #e4ecf2; --pgm-accent: #1d4f73; --pgm-ok: #13704a; --pgm-bad: #b3261e;
  --pgm-chip: #ffffff; --pgm-chip-on: #d4e6f2; --pgm-card: #ffffff; --pgm-track: #e3e9ee; --pgm-warn: #8a4b00; --pgm-warn-bg: #fff1d6;
  --pgm-solar: #e8b21a; --pgm-wind: #2f8fb0; --pgm-gas: #c2552d; --pgm-nuke: #6b4fa8;
}
html[data-theme="dark"] {
  --pgm-ground1: #3f5a2e; --pgm-ground2: #29401d; --pgm-hill1: #4a6648; --pgm-hill2: #304a30; --pgm-line: #05090c;
  --pgm-bldg1: #36445e; --pgm-bldg2: #222b3e; --pgm-win-off: #0d1018; --pgm-wire: #0b0e12;
  --pgm-ink: #e8eff3; --pgm-panel1: #1b2832; --pgm-panel2: #142029; --pgm-accent: #8cc4ea; --pgm-ok: #4fd08c; --pgm-bad: #ff8a80;
  --pgm-chip: #172027; --pgm-chip-on: #1b3d52; --pgm-card: #18232b; --pgm-track: #26323b; --pgm-warn: #ffc874; --pgm-warn-bg: #3a2a10;
}
.pgm { position: absolute; inset: 0; display: grid; grid-template-columns: 344px minmax(0, 1fr); gap: 10px; padding: 8px 10px; color: var(--tlg-text); font-size: 16px; }
.pgm input, .pgm button { font: inherit; }
.pgm-controls { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: auto; padding: 8px 12px;
  background: linear-gradient(var(--pgm-panel1), var(--pgm-panel2)); color: var(--pgm-ink); border: 3px solid var(--pgm-accent); border-radius: 14px; box-shadow: 0 3px 8px rgba(0,0,0,.16); }
.pgm-right { display: flex; flex-direction: column; gap: 5px; min-width: 0; min-height: 0; overflow: auto; }
.pgm-kicker { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--pgm-accent); }
.pgm-step, .pgm-step-b { display: grid; gap: 3px; }
.pgm-step-h { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 17px; line-height: 1.2; }
.pgm-n { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--pgm-accent); color: #fff; font-size: 16px; font-weight: 800; }
html[data-theme="dark"] .pgm-n { color: #0d1a24; }
.pgm-step.is-done .pgm-n { background: var(--pgm-ok); }
.pgm-mark { margin-left: auto; font-weight: 800; white-space: nowrap; }
.pgm-mark.is-ok, .pgm-fmark.is-ok { color: var(--pgm-ok); }
.pgm-mark.is-bad, .pgm-fmark.is-bad { color: var(--pgm-bad); }

/* swatches: color + pattern, so a source is never told apart by color alone */
.pgm-sw { display: inline-block; flex: none; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--pgm-line); vertical-align: -3px; }
.pgm-sw--solar, .pgm-seg--solar { background: repeating-linear-gradient(45deg, #e8b21a 0 5px, #b98a00 5px 8px); }
.pgm-sw--wind, .pgm-seg--wind { background: radial-gradient(circle, #cdeefa 2px, transparent 2.5px) 0 0 / 9px 9px, #2f8fb0; }
.pgm-sw--gas, .pgm-seg--gas { background: repeating-linear-gradient(-45deg, #c2552d 0 5px, #82300f 5px 8px); }
.pgm-sw--nuclear, .pgm-seg--nuclear { background: repeating-linear-gradient(0deg, #6b4fa8 0 5px, #45307a 5px 8px); }

.pgm-dial { display: grid; gap: 0; }
.pgm-dial-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; }
.pgm-dial-n { display: inline-flex; align-items: center; gap: 6px; }
.pgm-dial-v { font-weight: 800; color: var(--pgm-accent); white-space: nowrap; }
.pgm-dial.is-unset .pgm-dial-v { font-weight: 600; font-style: italic; color: var(--pgm-ink); opacity: .8; }
.pgm-dial-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; gap: 6px; }
.pgm-dial input { width: 100%; min-height: 30px; margin: 0; font-size: 16px; accent-color: var(--pgm-accent); cursor: pointer; }
.pgm-dial.is-unset input { opacity: .55; }
.pgm-step-btn { min-height: 36px; border-radius: 10px; border: 2px solid var(--pgm-accent); background: var(--pgm-chip); color: var(--pgm-ink); font-size: 20px; font-weight: 800; line-height: 1; cursor: pointer; }
.pgm-step-btn:disabled { opacity: .45; cursor: default; }
.pgm input:focus-visible, .pgm button:focus-visible { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 2px; }
.pgm-fixed { display: flex; align-items: center; gap: 6px; margin: 2px 0 0; font-size: 16px; }
.pgm-fixed span:last-child { opacity: .8; font-style: italic; }

.pgm-chips { display: grid; gap: 4px; }
.pgm-chips--row { grid-template-columns: repeat(3, minmax(0, 1fr)); }   /* General higher / lower / same */
.pgm-chip { position: relative; display: flex; align-items: center; min-height: 38px; padding: 3px 26px 3px 9px; border: 2px solid #9fb0bc; border-radius: 10px;
  background: var(--pgm-chip); color: var(--pgm-ink); font-size: 16px; line-height: 1.15; text-align: left; cursor: pointer; }
.pgm-chip:hover:not(:disabled) { border-color: var(--pgm-accent); }
.pgm-chip.is-on { border-color: var(--pgm-accent); background: var(--pgm-chip-on); font-weight: 700; box-shadow: inset 4px 0 0 var(--pgm-accent); }
.pgm-chip:disabled { cursor: default; opacity: 1; }
.pgm-chip-m { position: absolute; right: 8px; font-weight: 800; }
.pgm-chip.is-key { border-color: var(--pgm-ok); box-shadow: inset 4px 0 0 var(--pgm-ok); }
.pgm-chip.is-key .pgm-chip-m { color: var(--pgm-ok); }
.pgm-chip.is-wrong { border-color: var(--pgm-bad); border-style: dashed; }
.pgm-chip.is-wrong .pgm-chip-m { color: var(--pgm-bad); }

.pgm-num { display: grid; gap: 2px; }
.pgm-num-row { display: flex; align-items: center; gap: 6px; }
.pgm-num input { flex: 1 1 auto; min-width: 0; width: 100%; font-size: 17px; min-height: 38px; padding: 3px 8px; border: 2px solid #8796a1; border-radius: 8px; background: #fff; color: #17242c; }
html[data-theme="dark"] .pgm-num input { background: #10171c; color: #eef3f6; border-color: #6d7f8c; }
.pgm-num input:disabled { opacity: .85; }
.pgm-unit { flex: none; font-weight: 700; }
.pgm-fmark { font-weight: 800; }
.pgm-note { font-size: 16px; line-height: 1.2; opacity: .85; }

/* right column */
.pgm-conds { display: flex; flex-wrap: wrap; gap: 6px; }
.pgm-cond { padding: 3px 10px; border-radius: 999px; background: var(--pgm-card); border: 2px solid var(--pgm-accent); color: var(--pgm-ink); font-size: 16px; line-height: 1.3; }
.pgm-cond.is-warn { border-color: var(--pgm-warn); background: var(--pgm-warn-bg); }
.pgm-scene { position: relative; border-radius: 12px; overflow: hidden; border: 3px solid var(--pgm-accent); flex: none; background: #0b1330; }
.pgm-svg { display: block; width: 100%; height: auto; max-height: 232px; }
.pgm-tag-bg { fill: rgba(10, 18, 30, .72); }
.pgm-tag { fill: #fff; font: 700 24px var(--tlg-font, system-ui), sans-serif; }
.pgm-panel-face { fill: url(#pgm-g-panel-off); stroke: var(--pgm-line); stroke-width: 1.2; transition: fill .2s; }
.pgm-panel.is-on .pgm-panel-face { fill: url(#pgm-g-panel); }
.pgm-panel-grid { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 1; }
.pgm-panel-leg { stroke: #59636d; stroke-width: 2.5; }
.pgm-panel.is-nosun .pgm-panel-face { fill: url(#pgm-g-panel-off); stroke: var(--pgm-bad); stroke-width: 3; stroke-dasharray: 4 3; }
.is-h0 .pgm-panel.is-on .pgm-panel-face, .is-h18 .pgm-panel.is-on .pgm-panel-face { filter: brightness(.7); }
.pgm-gas-win { fill: #3a2a20; }
.pgm-gas-win.is-on { fill: #ffb347; }
.pgm-pylon { fill: none; stroke: #59636d; stroke-width: 2.5; stroke-linejoin: round; }
.pgm-wire { fill: none; stroke: var(--pgm-wire); stroke-width: 2.5; }
.pgm-wire-hot { fill: none; stroke: var(--pgm-hot); stroke-width: 2; opacity: .35; }
.pgm-dot { fill: #fff3a0; stroke: #a87800; stroke-width: 1.5; }
.pgm-city-win { fill: var(--pgm-win-off); transition: fill .25s; }
.pgm-city-win.is-on { fill: var(--pgm-win); }

.pgm-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.pgm-card { padding: 4px 8px; border-radius: 10px; background: var(--pgm-card); border: 2px solid #b8c6d0; color: var(--pgm-ink); font-size: 16px; line-height: 1.22; }
html[data-theme="dark"] .pgm-card { border-color: #3b4b57; }
.pgm-card p { margin: 0; }
.pgm-card-h { display: flex; align-items: center; gap: 6px; font-weight: 800; }
.pgm-card-f { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 8px; opacity: .85; }
.pgm-card-m { margin-left: auto; color: var(--pgm-bad); white-space: nowrap; }
.pgm-card.is-bad { border-color: var(--pgm-bad); border-style: dashed; }
.pgm-cf { margin: 0; font-size: 16px; line-height: 1.25; opacity: .85; }

.pgm-board { display: grid; gap: 4px; padding: 6px 10px; border-radius: 12px; background: linear-gradient(var(--pgm-panel1), var(--pgm-panel2)); border: 2px solid #b8c6d0; color: var(--pgm-ink); }
html[data-theme="dark"] .pgm-board { border-color: #3b4b57; }
.pgm-meter { display: grid; grid-template-columns: 186px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 10px; align-items: center; }
.pgm-meter-h { display: contents; }
.pgm-meter-t { grid-row: 1 / span 2; font-weight: 800; line-height: 1.15; }
.pgm-meter-v { font-size: 16px; line-height: 1.2; }
.pgm-track { position: relative; display: flex; height: 24px; border-radius: 6px; background: var(--pgm-track); border: 1.5px solid var(--pgm-line); overflow: visible; }
.pgm-seg { display: block; height: 100%; color: #fff; font-size: 16px; font-weight: 800; line-height: 22px; text-align: center; text-shadow: 0 1px 2px #000; transition: width .25s; overflow: hidden; }
.pgm-seg:first-child { border-radius: 4px 0 0 4px; }
.pgm-seg--one { background: repeating-linear-gradient(90deg, var(--pgm-accent) 0 10px, color-mix(in srgb, var(--pgm-accent) 75%, #000) 10px 12px); border-radius: 4px; }
.pgm-marker { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 3px solid var(--pgm-ink); }
.pgm-marker::before { content: ''; position: absolute; top: -2px; left: -7px; border: 5px solid transparent; border-top: 7px solid var(--pgm-ink); }
.pgm-marker-l { position: absolute; top: 4px; left: 6px; padding: 0 4px; border-radius: 4px; background: var(--pgm-panel1); font-size: 16px; font-weight: 700; line-height: 20px; white-space: nowrap; }
.pgm-marker.is-left .pgm-marker-l { left: auto; right: 6px; }
.pgm-meter.is-bad .pgm-track { border: 2.5px dashed var(--pgm-bad); }
.pgm-board.is-empty .pgm-seg { width: 0 !important; }

.pgm-readout { padding: 6px 10px; border-radius: 10px; background: var(--pgm-card); border: 2px solid var(--pgm-accent); color: var(--pgm-ink); font-size: 16px; line-height: 1.3; }
.pgm-readout p, .pgm-readout ul { margin: 0; }
.pgm-readout ul { list-style: none; padding: 0; display: grid; gap: 2px; }
.pgm-readout li.is-ok > span { color: var(--pgm-ok); font-weight: 800; }
.pgm-readout li.is-bad > span { color: var(--pgm-bad); font-weight: 800; }
.pgm-readout li.is-info > span { color: var(--pgm-accent); }
/* after Check the readout replaces the plant cards and capacity note so the stage never scrolls */
.pgm.is-revealed .pgm-cf, .pgm.is-revealed .pgm-conds, .pgm.is-revealed .pgm-about { display: none; }
.pgm-about { padding: 4px 10px; border: 1px solid var(--tlg-border, #ccd); border-radius: 8px; font-size: 16px; }
.pgm-about summary { cursor: pointer; min-height: 28px; font-weight: 700; }
.pgm-about p { margin: 4px 0; }

/* Briefing worked example */
.pgm-ex { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; align-items: center; }
.pgm-ex-art svg { width: 150px; height: 150px; display: block; }
.pgm-ex-t { border-collapse: collapse; font-size: 16px; width: 100%; }
.pgm-ex-t th, .pgm-ex-t td { padding: 3px 8px; border-bottom: 1px solid var(--tlg-border, #ccd); text-align: right; }
.pgm-ex-t th[scope="row"], .pgm-ex-t thead th:first-child { text-align: left; }
.pgm-ex-sum th, .pgm-ex-sum td { border-top: 2px solid currentColor; }

@media (max-width: 900px) {
  .pgm { position: static; grid-template-columns: 1fr; }
  .pgm-controls, .pgm-right { overflow: visible; }
  .pgm-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pgm-meter { grid-template-columns: 1fr; }
  .pgm-meter-t { grid-row: auto; }
  .pgm-ex { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .pgm * { transition: none !important; animation: none !important; }
}
