/* Michigan Energy Files: project map + tracker table. All classes are prefixed mef-.
   Reads the site tokens from solar/assets/editorial.css:
   --page --paper --paper-2 --ink --ink-2 --muted --line --line-soft --accent --accent-text
   --lake --flame --pine --shadow. Nothing here sets them. */

.mef {
  /* status colours: site tokens only. Amber and land switch with the theme (below). */
  --mef-amber: var(--accent);
  --mef-land: var(--paper-2);
  --mef-water: color-mix(in srgb, var(--lake) 3%, var(--page));
  --mef-track: color-mix(in srgb, var(--lake) 22%, var(--mef-land));
  --mef-hit: 32px;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.55;
}
[data-theme="light"] .mef {
  --mef-amber: var(--accent-text);
  --mef-land: var(--paper);
  --mef-water: color-mix(in srgb, var(--lake) 14%, var(--page));
  --mef-track: color-mix(in srgb, var(--lake) 16%, var(--mef-land));
}
.mef *, .mef *::before, .mef *::after { box-sizing: border-box; }
.mef-box { container: mef / inline-size; }
.mef-sprite { position: absolute; }
.mef-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mef [hidden] { display: none !important; }
.mef-js-only { display: none; }
.mef-js .mef-js-only { display: revert; }
.mef-js .mef-js-only[hidden] { display: none; }

[data-status="announced"] { --st: var(--ink-2); }
[data-status="local-review"] { --st: var(--mef-amber); }
[data-status="approved-locally"] { --st: var(--pine); }
[data-status="denied-locally"] { --st: var(--flame); }
[data-status="at-mpsc"] { --st: var(--lake); }
[data-status="certificate-granted"] { --st: var(--pine); }
[data-status="construction"] { --st: var(--mef-amber); }
[data-status="operating"] { --st: var(--ink); }
[data-status="withdrawn"] { --st: var(--muted); }
[data-status="moratorium"] { --st: var(--flame); }
[data-status="unknown"] { --st: var(--muted); }
[data-status="mixed"] { --st: var(--mef-amber); }

/* ---------- type ---------- */
.mef-eyebrow { margin: 0 0 .35rem; font: 600 .8125rem/1.3 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); }
.mef + .mef { margin-top: 2.5rem; }
.mef .mef-title { margin: 0 0 .5rem; font: 700 clamp(1.6rem, 1.1rem + 2cqi, 2.3rem)/1.05 "Source Serif 4", "Iowan Old Style", Charter, "Palatino Linotype", Georgia, serif;
  letter-spacing: -.02em; text-wrap: balance; }
.mef-lede { margin: 0 0 1.25rem; max-width: 62ch; color: var(--ink-2); }
.mef .mef-h3 { margin: 1.4rem 0 .5rem; font: 700 .8125rem/1.3 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mef-fine { display: block; margin: .15rem 0 0; font-size: .8125rem; line-height: 1.45; color: var(--muted); }
p.mef-fine { margin: .6rem 0 0; max-width: 70ch; }
.mef-fine strong { color: var(--ink-2); }
.mef a { color: var(--lake); text-underline-offset: .15em; }
.mef a:hover { color: var(--ink); }
.mef :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.mef-n { display: inline-block; min-width: 1.5em; padding: 0 .4em; border-radius: 999px; background: var(--line-soft);
  color: var(--ink-2); font-size: .8125rem; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.mef-glyph { flex: none; width: 20px; height: 20px; color: var(--st); overflow: visible; }

/* ---------- buttons ---------- */
.mef-btn { min-height: 44px; padding: 0 .9rem; border: 1px solid var(--line); border-radius: 999px; background: transparent;
  color: var(--ink); font: inherit; font-size: .875rem; cursor: pointer; }
.mef-btn:hover { border-color: var(--ink-2); background: var(--line-soft); }
.mef-btn[disabled] { opacity: .45; cursor: default; }
.mef-btn--on { background: var(--ink); color: var(--page); border-color: var(--ink); }
.mef-btn--on:hover { background: var(--ink-2); }

/* ---------- map ---------- */
.mef-grid { display: grid; gap: 1.25rem; }
.mef-stagewrap { position: relative; min-width: 0; }
.mef-stage { position: relative; aspect-ratio: 1000 / 1147; border: 1px solid var(--line-soft); border-radius: 12px;
  background: var(--mef-water); }
.mef-counties { position: absolute; inset: 0; width: 100%; height: 100%; }
.mef-c { fill: var(--mef-land); stroke: var(--line); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke;
  transition: fill .25s; }
.mef-c--on { fill: var(--mef-track); stroke: var(--muted); }
.mef-pins { position: absolute; inset: 0; }
.mef-pin { position: absolute; display: grid; place-items: center; width: var(--mef-hit); height: var(--mef-hit);
  margin: calc(var(--mef-hit) / -2) 0 0 calc(var(--mef-hit) / -2); padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--st); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.mef-pin svg { width: 20px; height: 20px; overflow: visible; pointer-events: none; transition: transform .15s; }
.mef-pin:hover svg, .mef-pin:focus-visible svg { transform: scale(1.25); }
.mef-pin:hover, .mef-pin:focus-visible { z-index: 3; }
.mef-pin[hidden] { display: none; }
.mef-pin--sel { z-index: 4; }
.mef-pin--sel svg { transform: scale(1.35); }
.mef-pin--sel::after { content: ""; position: absolute; inset: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 2px solid var(--ink); border-radius: 50%; pointer-events: none; }
.mef-pin--in svg { animation: mef-pop .35s ease-out; }
@keyframes mef-pop { from { transform: scale(.2); opacity: 0; } }

/* ---------- card ---------- */
.mef-card { position: absolute; z-index: 6; width: min(300px, calc(100% - 16px)); padding: .9rem 1rem 1rem;
  border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); font-size: .875rem; }
.mef-card[hidden] { display: none; }
.mef-card h4 { margin: 0 2rem .1rem 0; font: 700 1.15rem/1.15 "Source Serif 4", "Iowan Old Style", Charter, Georgia, serif; }
.mef-card-dev { margin: 0 0 .6rem; color: var(--ink-2); }
.mef-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .3rem .7rem; }
.mef-card dt { color: var(--muted); font-size: .8125rem; padding-top: .08rem; }
.mef-card dd { margin: 0; min-width: 0; }
.mef-card-st { display: flex; gap: .45rem; align-items: flex-start; margin: .7rem 0 .2rem; font-weight: 700; }
.mef-card-note { margin: 0 0 .6rem; color: var(--ink-2); }
.mef-card-asof { margin: 0 0 .5rem; padding: .3rem .5rem; border-left: 3px solid var(--accent); background: var(--line-soft); font-size: .8125rem; }
.mef-card-link { display: inline-block; margin-top: .7rem; padding: .35rem 0; font-weight: 600; }
.mef-card-x { position: absolute; top: 2px; right: 2px; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-2); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.mef-card-x:hover { color: var(--ink); background: var(--line-soft); }
.mef-card--dock { position: sticky; bottom: 8px; width: auto; margin: .75rem 0 0; max-height: 62vh; overflow: auto; }

/* ---------- time ---------- */
.mef-time { padding: 1rem; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--paper); }
.mef-time-head { display: flex; flex-wrap: wrap; gap: .2rem .6rem; align-items: baseline; justify-content: space-between; }
.mef-time-head label { font-size: .875rem; color: var(--ink-2); }
.mef-date { font: 700 1.25rem/1.2 "Source Serif 4", "Iowan Old Style", Charter, Georgia, serif; font-variant-numeric: tabular-nums; }
.mef-range-wrap { position: relative; margin-top: .3rem; }
.mef-time input[type="range"] { display: block; width: 100%; height: 44px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.mef-ticks { position: relative; height: 8px; margin: -6px 10px 0; }
.mef-ticks i { position: absolute; top: 0; width: 2px; height: 8px; margin-left: -1px; border-radius: 1px; background: var(--muted); }
.mef-range-ends { display: flex; justify-content: space-between; font-size: .8125rem; color: var(--muted); }
.mef-time-btns { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.mef-now { margin: .85rem 0 0; font-size: .9375rem; }
.mef-now b { font-variant-numeric: tabular-nums; }

/* ---------- legend + status list ---------- */
.mef-legend, .mef-bar-labels, .mef-lg ul { list-style: none; margin: 0; padding: 0; }
.mef-legend { display: grid; gap: .55rem 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); font-size: .8125rem; color: var(--ink-2); }
.mef-legend li { display: flex; gap: .55rem; align-items: flex-start; }
.mef-legend strong { color: var(--ink); font-size: .875rem; }
.mef-side { display: flex; flex-direction: column; }
.mef-side > * { order: 2; }
.mef-side > .mef-time { order: 0; }
.mef-list { display: none; }
.mef-lg h4 { display: flex; gap: .5rem; align-items: center; margin: 1rem 0 .3rem; font-size: .9375rem; }
.mef-li { display: flex; flex-wrap: wrap; gap: 0 .6rem; align-items: center; justify-content: space-between; width: 100%; min-height: 44px;
  padding: .45rem .7rem; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--paper); color: var(--ink);
  font: inherit; font-size: .9375rem; text-align: left; text-decoration: none; cursor: pointer; }
.mef a.mef-li { color: var(--ink); }
.mef-li span { color: var(--muted); font-size: .8125rem; }
.mef-lg li + li { margin-top: .3rem; }
.mef-li--sel { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); }

.mef-how { margin-top: 1.5rem; padding-top: .25rem; border-top: 1px solid var(--line-soft); }
.mef-how p { margin: 0 0 .6rem; max-width: 72ch; color: var(--ink-2); font-size: .9375rem; }
.mef-source { margin: 1rem 0 0; max-width: 80ch; font-size: .8125rem; color: var(--muted); }

/* ---------- MW strip ---------- */
.mef-mw { margin: 1rem 0 1.5rem; padding: 1rem; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--paper); }
.mef-mw .mef-h3 { margin-top: 0; }
.mef-mw-total { margin: 0 0 .6rem; color: var(--ink-2); }
.mef-mw-total strong { font: 700 1.5rem/1 "Source Serif 4", "Iowan Old Style", Charter, Georgia, serif; color: var(--ink); margin-right: .25rem; }
.mef-bar { display: flex; gap: 2px; height: 24px; }
.mef-seg { flex: 0 1 0; min-width: 5px; display: grid; place-items: center start; background: var(--st); }
.mef-seg:first-child { border-radius: 4px 0 0 4px; }
.mef-seg:last-child { border-radius: 0 4px 4px 0; }
.mef-seg-l { padding-left: .5rem; color: var(--page); font-size: .8125rem; font-weight: 700; white-space: nowrap; }
.mef-bar-labels { display: grid; gap: .5rem 1.25rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-top: .8rem; font-size: .875rem; }
.mef-bar-labels li { display: flex; gap: .5rem; align-items: flex-start; }

/* ---------- filters ---------- */
.mef-js .mef-filters { display: grid; gap: .6rem .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.mef-f { display: grid; gap: .2rem; font-size: .8125rem; color: var(--muted); }
.mef-f--q { grid-column: span 2; }
.mef-f input, .mef-f select { width: 100%; min-height: 44px; padding: 0 .65rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 1rem; }
.mef-tablebar { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; justify-content: space-between; margin: 1rem 0 .4rem; }
.mef-count { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.mef-js a.mef-csv { display: inline-flex; align-items: center; min-height: 44px; font-size: .9375rem; font-weight: 600; }

/* ---------- table ---------- */
.mef-tablewrap { border: 1px solid var(--line-soft); border-radius: 12px; background: var(--paper); overflow-x: auto; }
.mef-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.mef-table th, .mef-table td { padding: .7rem .75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.mef-table thead th { position: relative; font-size: .8125rem; font-weight: 700; color: var(--muted); white-space: nowrap; vertical-align: bottom;
  border-bottom: 1px solid var(--line); }
.mef-table tbody tr:last-child td { border-bottom: 0; }
.mef-table th:nth-child(5) { width: 25%; }
.mef-table th:nth-child(7) { width: 17%; }
.mef-table td a.mef-fine { white-space: nowrap; }
.mef-table .mef-num { text-align: right; font-variant-numeric: tabular-nums; }
.mef-th { display: inline-flex; gap: .3rem; align-items: center; min-height: 44px; margin: -.7rem 0; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; cursor: pointer; }
.mef-th::after { content: "↕"; opacity: .45; }
[aria-sort="ascending"] > .mef-th { color: var(--ink); }
[aria-sort="ascending"] > .mef-th::after { content: "▲"; opacity: 1; font-size: .7em; }
[aria-sort="descending"] > .mef-th { color: var(--ink); }
[aria-sort="descending"] > .mef-th::after { content: "▼"; opacity: 1; font-size: .7em; }
.mef-name { display: block; font-size: 1rem; font-weight: 700; }
.mef-st { display: flex; gap: .45rem; align-items: flex-start; }
.mef-na { color: var(--muted); }
.mef-tier { display: inline-block; margin-top: .35rem; padding: .05rem .5rem; border: 1px solid var(--line); border-radius: 999px;
  font-size: .8125rem; color: var(--ink-2); }
.mef-tier--full { border-color: var(--accent); color: var(--accent-text); }
.mef-show { display: block; min-height: 32px; margin-top: .35rem; padding: 0; border: 0; background: none; color: var(--lake);
  font: inherit; font-size: .8125rem; text-decoration: underline; text-underline-offset: .15em; cursor: pointer; }
.mef-table tbody tr[hidden] { display: none; }
.mef-js .mef-table tbody tr { cursor: pointer; }
.mef-table tbody tr:hover { background: var(--line-soft); }
.mef-table tbody tr:target, .mef-row--sel { background: color-mix(in srgb, var(--accent) 13%, transparent); box-shadow: inset 4px 0 0 var(--accent); }
.mef-table tbody tr:target { scroll-margin-top: 5rem; }
.mef-empty { margin: 0; padding: 1.5rem; text-align: center; color: var(--ink-2); }
.mef-empty[hidden] { display: none; }

/* ---------- widths (container, not viewport) ---------- */
@container mef (min-width: 960px) {
  .mef-grid { grid-template-columns: minmax(0, 1.12fr) minmax(320px, .88fr); align-items: start; gap: 1.75rem; }
  .mef-legend { grid-template-columns: 1fr; }
  .mef-side > .mef-h3:first-child { margin-top: 0; }
}
@container mef (min-width: 600px) and (max-width: 959.98px) {
  .mef-stagewrap { max-width: 720px; }
}
@container mef (max-width: 599.98px) {
  /* pins are too close for separate 44px targets at this size: the status list is the control */
  .mef-pin { --mef-hit: 20px; pointer-events: none; }
  .mef-pin svg { width: 15px; height: 15px; }
  .mef-pin--sel::after { width: 26px; height: 26px; margin: -13px 0 0 -13px; }
  .mef-list { display: block; order: 1; }
  .mef-list .mef-h3:first-child { margin-top: 1.1rem; }
  .mef-f--q { grid-column: 1 / -1; }
}
@container mef (max-width: 819.98px) {
  .mef-tablewrap { border: 0; background: none; overflow: visible; }
  .mef-table, .mef-table tbody, .mef-table tr, .mef-table td { display: block; }
  .mef-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .mef-table tbody tr { margin-bottom: .75rem; padding: .35rem .9rem .6rem; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--paper); }
  .mef-table tbody tr[hidden] { display: none; }
  .mef-table td { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: .1rem .75rem; padding: .45rem 0; }
  .mef-table td > * { grid-column: 2; justify-self: start; }
  .mef-table td::before { content: attr(data-label); grid-column: 1; grid-row: 1 / span 6; color: var(--muted); font-size: .8125rem; padding-top: .1rem; }
  .mef-table td:last-child { border-bottom: 0; }
  .mef-table .mef-num { text-align: left; }
  .mef-show { min-height: 44px; }
}
@media (pointer: coarse) {
  .mef { --mef-hit: 44px; }
  .mef-list { display: block; }
  .mef-show { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .mef *, .mef *::before, .mef *::after { transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
  .mef-seg { border: 1px solid CanvasText; }
  .mef-c--on { stroke-width: 2; }
}
