/* Energy board. The map fills the window; a single side list sits beside it.
   Tokens, header and controls live in ../theme.css. */

.atlas { display: block; }
.map-area { position: relative; height: 62vh; min-height: 340px; background: var(--blush); }
#map { position: absolute; inset: 0; }
.side { background: var(--card); }

/* Wide screens: nothing scrolls but the side list, so the map keeps the whole window. */
@media (min-width: 900px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; overflow: hidden; }
  .atlas { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(420px, 30vw, 560px); }
  .map-area { height: auto; min-height: 0; }
  .side { min-height: 0; overflow-y: auto; box-shadow: -1px 0 0 var(--line); scrollbar-color: rgb(74 71 68 / 0.45) transparent; }
}

/* ---------- On the map: what it shows, and what the marks mean ---------- */
.layers { position: absolute; left: 14px; right: 14px; top: 14px; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; }
.layer { pointer-events: auto; min-height: 48px; padding: 0 20px; border: 0; border-radius: 6px; background: var(--card); color: var(--ink); font-family: var(--display); font-size: 16px; font-weight: 600; font-stretch: 104%; white-space: nowrap; box-shadow: var(--shadow-tag); transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1); }
.layer b { font-weight: 800; }
.layer:hover { background: var(--blush); transform: translateY(-1px); }
.layer.on { background: var(--cobalt); color: #fff; transform: none; }
@media (prefers-reduced-motion: reduce) { .layer { transition: none; } .layer:hover { transform: none; } }
/* The key keeps clear of the map's credit line, which shrinks to a button once the map is under 640px wide. */
.map-key { position: absolute; left: 14px; bottom: 14px; z-index: 2; display: flex; flex-wrap: wrap; gap: 4px 14px; max-width: calc(100% - 300px); padding: 10px 14px; border-radius: 6px; background: var(--card); box-shadow: var(--shadow-tag); font-size: 15px; }
.map-key:empty { display: none; }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 10px; height: 10px; border-radius: 50%; }
.key i.line { width: 16px; height: 3px; border-radius: 2px; }

/* ---------- Side list ---------- */
.side-head { padding: 26px 28px 20px; border-bottom: 1px solid var(--line); }
.side-head h1 { font-size: clamp(22px, 1.9vw, 30px); line-height: 1.2; font-weight: 800; font-stretch: 112%; letter-spacing: -0.02em; }
.side-head .hint { margin-top: 8px; }
.side .source-note:empty { display: none; }
#panel { padding: 20px 12px 8px; min-height: 240px; }
.panel-head { padding: 0 14px 14px; }
.panel-head h2 { font-size: 21px; line-height: 1.3; font-weight: 700; font-stretch: 108%; }
.panel-head .hint { margin-top: 4px; }
.group { padding: 18px 14px 8px; border-top: 1px solid var(--line); }
.panel-head + .group, .filters + .group { border-top: 0; padding-top: 4px; }
.side .source-note { margin: 0; padding: 18px 26px 28px; border-top: 1px solid var(--line); }

/* ---------- Rows: a button that opens in place and points the map at itself ---------- */
.rows li + li { border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; align-items: center; width: 100%; padding: 11px 14px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.row:hover, .row.on { background: var(--blush); }
.row-title { font-family: var(--display); font-size: 18px; line-height: 1.3; font-weight: 700; font-stretch: 104%; }
.row-meta { grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; font-size: 15px; color: var(--mist); }
.row-num { grid-column: 2; grid-row: 1 / span 2; min-width: 96px; text-align: right; font-size: 15px; color: var(--mist); white-space: nowrap; }
.row-num b { font-family: var(--display); font-size: 18px; font-weight: 700; color: var(--ink); }
.meter { display: block; height: 6px; margin-top: 5px; border-radius: 3px; background: var(--blush-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 0 3px 3px 0; background: var(--cobalt); }
.row-more { grid-column: 1 / -1; display: none; padding-top: 8px; font-size: 16px; line-height: 1.6; color: var(--ink); }
.row.on .row-more { display: block; }
/* How far a storage level is from a year ago: left of the middle line is less, right is more. */
.change { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) 7ch; align-items: center; gap: 10px; margin-top: 6px; }
.change-track { position: relative; height: 10px; background: linear-gradient(var(--line-ctl), var(--line-ctl)) center / 1px 100% no-repeat; }
.change-track i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.change-val { font-size: 16px; font-weight: 600; text-align: right; white-space: nowrap; }
.row-source { display: none; padding: 0 14px 12px; font-size: 14px; background: var(--blush); border-radius: 0 0 6px 6px; }
.row.on:not(:only-child) { border-radius: 6px 6px 0 0; }
.row.on + .row-source { display: block; }

/* ---------- How the whole network divides up ---------- */
.tally { width: calc(100% - 28px); margin: 0 14px 12px; border-collapse: collapse; font-size: 16px; }
.tally th, .tally td { padding: 11px 0 11px 16px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
.tally thead th { border-top: 0; padding-top: 0; }
.tally th:first-child { padding-left: 0; text-align: left; }
.tally td { font-family: var(--display); font-weight: 700; }

/* ---------- Map popup ---------- */
.maplibregl-popup-content { padding: 13px 15px; border-radius: 6px; background: var(--card); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.5; box-shadow: var(--shadow-lift); }
.maplibregl-popup-close-button { padding: 2px 8px; font-size: 18px; color: var(--mist); }
.pop-title { padding-right: 16px; font-family: var(--display); font-weight: 700; }
.pop-line { color: var(--mist); }
.pop-title + .tag { margin: 4px 0; }

/* Narrow screens: the layer buttons stay on one line and scroll sideways. */
/* On a phone the credit line and the zoom buttons take the bottom, so the key sits under the layer buttons. */
@media (max-width: 640px) {
  .map-key { top: 70px; bottom: auto; max-width: calc(100% - 28px); }
}
@media (max-width: 899px) {
  .layers { flex-wrap: nowrap; overflow-x: auto; left: 0; right: 0; top: 0; padding: 12px 14px 6px; scrollbar-width: none; pointer-events: auto; }
  .layer { flex: none; }
  .side-head { padding: 20px 20px 16px; }
  .side .source-note { padding: 18px 20px 28px; }
}
