/* Buzz's stylesheet, the /power views' only one (SPEC.md `## Experience`, the Buzz bullet): the
   retro terminal look of design/buzz.html. Its :root is the mockup's, copied verbatim
   (crates/viz-power/tests/style.rs checks it); none of the app's tokens or fonts are here, and
   this file is on no other page. The server builds it in and serves it under a hashed name
   (climate_web_shell::OwnStyle). */
:root{
  color-scheme:dark;
  /* Buzz's own tokens, from the old page */
  --bz-bg:rgb(32,43,59);
  --bz-text:rgb(100,200,255);        /* header text, links, table head */
  --bz-border:rgb(60,120,153);       /* the boxes */
  --bz-renewable:rgb(255,140,0);
  --bz-fossil:rgb(140,150,180);
  --bz-other:rgb(200,200,200);       /* battery, body text */
  --bz-quiet:rgb(140,150,180);       /* footer text, links at rest */
  --bz-track:rgba(100,100,100,.35);  /* an empty bar's outline */
  --bz-warn:#ffa500; --bz-error:#ff6b6b; --bz-ok:#51cf66;
  --bz-scan:rgba(0,0,0,.2);
  --bz-glow:rgba(100,200,255,.15);
  --bz-font:"JetBrains Mono","SF Mono",Menlo,Monaco,"Courier New",monospace;
  --bz-fs:14px; --bz-fs-label:18px; --bz-fs-pc:16px; --bz-fs-small:12px;
  --bz-column:800px; --bz-pad:20px; --bz-gap:10px; --bz-tap:44px;
  --bz-bar-h:40px; --bz-bar-w:50px; --bz-bp-phone:600px;
  /* the LED meters (M73): a segment and its gap, along a bar, up a vertical one (7 scanlines)
     and along the mix table's; every unlit segment's grey; the lit segments' glow */
  --bz-seg:10px; --bz-seg-v:14px; --bz-seg-small:6px;
  --bz-seg-gap:3px; --bz-seg-gap-small:2px;
  --bz-unlit:rgba(100,100,100,.25);
  --bz-bloom:3px; --bz-bloom-mix:30%;
}

/* Self hosted (public/fonts/, SIL Open Font License, its text beside it in
   jetbrains-mono-OFL.txt): Google Fonts' variable Latin subset of JetBrains Mono, requested for
   weights 300 to 700 (family=JetBrains+Mono:wght@300..700), so one file covers the light body,
   the regular links and the bold labels. Nothing is loaded from another site. */
@font-face{
  font-family:"JetBrains Mono";
  font-style:normal;
  font-weight:300 700;
  font-display:swap;
  src:url("/fonts/jetbrains-mono-latin.woff2") format("woff2");
}

/* The page, as design/buzz.html draws it (its mockup controls left out). */
*{box-sizing:border-box;margin:0;padding:0}
body{background:var(--bz-bg);color:var(--bz-other);font:300 var(--bz-fs)/1.3 var(--bz-font)}
/* The page's padding is on the shell's wrapper around the frame (M66), so on a phone the wrapper
   can be the screen's height with the padding inside it and the frame grow to fill the rest. */
.wrap{padding-block:16px 28px;
  padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
a{color:inherit;text-decoration:none}
button{font:inherit;color:inherit;background:none;border:none;cursor:pointer}
:focus-visible{outline:1px solid var(--bz-text);outline-offset:3px}

.app{max-width:var(--bz-column);margin:0 auto;display:flex;flex-direction:column;gap:var(--bz-gap);position:relative;
  text-shadow:0 0 2px var(--bz-glow)}
.app::after{content:"";position:absolute;inset:-8px;pointer-events:none;z-index:5;
  background:repeating-linear-gradient(0deg,var(--bz-scan),var(--bz-scan) 1px,transparent 1px,transparent 2px)}
.box{border:1px solid var(--bz-border);padding:8px 12px}
.header{color:var(--bz-text)}
/* The title "buzz" is the link to the index (M65): it keeps the header's colour and the h1's size,
   and takes the shared focus ring. */
.header h1{font-size:var(--bz-fs);font-weight:400}
.home:hover,.nav a:hover,.timing:hover{color:cyan}

/* The views line (M66): the four view links from the boxes' text, then [REFRESH] pushed to its
   end, its text's right edge on the main box's right border. */
.nav{display:flex;padding-left:12px;color:var(--bz-quiet)}
.nav a{display:inline-flex;align-items:center;min-height:28px;padding:0 2ch}
.nav a[aria-current="page"]{color:var(--bz-text)}
/* The current link's brackets are in its text ("[now]"), so it reads so with no stylesheet; the
   others get a character more padding either side, to the same width. */
.nav a[aria-current="page"]{padding:0 1ch}
.nav .refresh{margin-left:auto;padding:0;letter-spacing:.5px;font-weight:400}

.main{padding:var(--bz-pad);min-height:440px;display:flex;flex-direction:column;justify-content:center;
  flex-grow:1;position:relative}
.main[data-view="mix"]{justify-content:flex-start}
/* The panel title (M73): the main box names its view on its top border near its left end, as a
   terminal panel does, "┤ generation now ├", quiet and small, its ground hiding the border line
   behind it. Out of the flow, so the box's layout stays as it was. */
.panel-title{position:absolute;top:-.68em;left:10px;background:var(--bz-bg);color:var(--bz-quiet);
  font-size:var(--bz-fs-small);line-height:1.2;font-weight:400;white-space:nowrap}
.panel-title::before{content:"┤ "}
.panel-title::after{content:" ├"}
.empty{text-align:center;color:var(--bz-quiet)}

/* now: rows on a wide screen, columns on a phone */
.rows{display:flex;flex-direction:column;gap:25px}
.row{display:grid;grid-template-columns:140px 80px 1fr;align-items:center;gap:20px;padding:10px 0}
.row .name{font-size:var(--bz-fs-label);font-weight:700}
.row .pc{font-size:var(--bz-fs-pc);text-align:right}
.cols{display:none}
.renewable{color:var(--bz-renewable)} .fossil{color:var(--bz-fossil)} .other{color:var(--bz-other)}

/* The LED meters (M73), the explore's "picked" look with one grey for every unlit segment. Each
   bar is cut across its length into whole segments, one every --seg with a --gap in the
   ground's colour, from its left end (from its bottom up a vertical bar, in the phone's rules).
   The bar paints its unlit segments, --bz-unlit whatever its category, and has no outline. Its
   lit segments are the fill, in the category's colour, cut the same way by a mask, inside .lit,
   which gives them their glow: the mask is on the fill, so it does not clip the glow, and the
   unlit segments have none. The fill rounds its exact share (--share, from the server) to the
   nearest whole segment, never past the bar's last one; a browser without round() shows the
   exact share (the @supports rule at the end). */
.bar{--seg:var(--bz-seg);--gap:var(--bz-seg-gap);height:var(--bz-bar-h);position:relative;
  background:linear-gradient(90deg,var(--bz-unlit) calc(100% - var(--gap)),var(--bz-bg) 0) 0 0/var(--seg) 100% repeat-x}
.lit{position:absolute;left:0;top:0;width:100%;height:100%;
  filter:drop-shadow(0 0 var(--bz-bloom) color-mix(in srgb,currentcolor var(--bz-bloom-mix),transparent))}
.bar i{position:absolute;left:0;top:0;height:100%;display:block;
  mask:linear-gradient(90deg,#000 calc(100% - var(--gap)),transparent 0) 0 0/var(--seg) 100% repeat-x;
  width:min(round(var(--share),var(--seg)),round(down,100%,var(--seg)))!important}
.renewable i{background:var(--bz-renewable)} .fossil i{background:var(--bz-fossil)} .other i{background:var(--bz-other)}
/* The words glow faintly in their own colour (M73): the header, the current view's link and the
   now view's names and shares. */
.header,.nav a[aria-current="page"],.row .name,.row .pc,.col .name,.col .pc{
  text-shadow:0 0 var(--bz-bloom) color-mix(in srgb,currentcolor var(--bz-bloom-mix),transparent)}

/* mix: the table of categories, groups and technologies, and the incomplete note under it */
table{width:100%;border-collapse:collapse;table-layout:fixed;font-variant-numeric:tabular-nums}
th{color:var(--bz-text);font-weight:700;text-align:left;padding:0 8px 8px 0}
td{padding:2px 8px 2px 0;line-height:1.4;white-space:nowrap}
/* The name column takes what the others leave, 30% (M73: the bar column's width is set instead,
   so no width here reads as a meter token's value). */
th:nth-child(2),td:nth-child(2){width:15%;text-align:right}
th:nth-child(3),td:nth-child(3){width:10%;text-align:right}
th:nth-child(4),td:nth-child(4){width:45%}
td:nth-child(4){padding-left:15px}
tr.cat td{font-weight:700;padding-top:16px}
tr.cat:first-child td{padding-top:0}
tr.grp td:first-child{padding-left:20px}
tr.tech td:first-child{padding-left:40px}
td .bar{--seg:var(--bz-seg-small);--gap:var(--bz-seg-gap-small);height:25px}
.note{text-align:right;color:var(--bz-quiet);font-size:var(--bz-fs-small);padding-top:8px}

/* 24h (M59): the day's two drawings, the 720 wide one above 600 px and the 360 wide one up to
   it (below), then the legend, bold in the categories' colours. Each drawing gives its text's
   size and colours inline, the 360 one larger so its labels stay legible on a phone, so no rule
   here sets the text's font or size (the mockup's ".chart text" would undo that). */
.chart{width:100%;height:auto;display:block}
.chart-narrow{display:none}
.legend{display:flex;gap:3ch;justify-content:center;padding-top:12px;font-weight:700}

/* about */
.about{max-width:62ch;margin:0 auto;display:grid;gap:14px;line-height:1.6;font-weight:400}
.about a{color:var(--bz-text);text-decoration:underline}

/* The thin footer (M66): the status at the left, free to wrap there, and the timing then the
   version (M65) at the bottom right, so a longer time grows to the left and the version stays
   put. Both in the small size. */
.footer{color:var(--bz-quiet);font-size:var(--bz-fs-small);padding-block:6px;display:flex;
  align-items:flex-end;gap:12px}
.status{flex-grow:1}
.version{text-align:right;white-space:nowrap}
.status.warn{color:var(--bz-warn);font-weight:700}

/* The timing readout (M61): before the version (M65), the page load's time as a quiet button in the
   footer's grey and font, opening its split in the browser's own popover, a thin Buzz box above
   the number (below it when there is no room), its right edge under the number's so it stays on
   a 390 px screen. A fine pointer shows it on hover too, by CSS alone. A browser without anchor
   positioning centres the box on the screen. Its bottom margin (12 px: past the footer's 1 px
   border and 6 px padding, about half the 10 px gap) ends it between the main box and the footer,
   clear of both borders. Each part is one row: its div hands its label and value to the list's
   grid as the row's two cells. Its focus ring sits 1 px out (M57 AC-401), clear of the status
   line under it. */
.timing{padding:0;anchor-name:--readout}
.timing:focus-visible{outline-offset:1px}
.timing-box{position:absolute;position-anchor:--readout;position-area:top span-left;position-try-fallbacks:flip-block;
  inset:auto;z-index:6;width:max-content;max-width:calc(100vw - 32px);height:auto;margin:0 0 12px;padding:8px 12px;
  overflow:visible;font:inherit;color:var(--bz-other);background:var(--bz-bg);border:1px solid var(--bz-border)}
.timing-box dl{display:grid;grid-template-columns:auto auto;gap:0 2ch}
.timing-box dl>div{display:contents}
.timing-box dd{text-align:right;font-variant-numeric:tabular-nums}
@media (hover:hover) and (pointer:fine){
  .timing:hover + .timing-box{display:block}
}
@supports not (position-area:top){
  .timing-box{position:fixed;inset:0;height:fit-content;margin:auto}
}

@media (max-width:600px){
  /* The phone's frame fills the screen (M66): the wrapper is the screen's height (100vh for a
     browser without dvh, then the visible area's), the frame grows in it, and the main box takes
     what the header, the views line and the footer leave. A taller view grows the page, which
     scrolls, the footer after it. */
  .wrap{min-height:100vh;min-height:100dvh;display:flex;flex-direction:column}
  .app{flex-grow:1;width:100%}
  .main{padding:14px;min-height:0}
  .rows{display:none}
  .chart-wide{display:none}
  .chart-narrow{display:block}
  /* The vertical bars take the box's height. */
  .cols{display:flex;justify-content:space-around;flex-grow:1;padding:10px 0}
  .col{display:flex;flex-direction:column;align-items:center;flex:1;max-width:120px}
  /* The vertical meters (M73) are cut from their bottom: --seg is a whole number of the
     scanlines' 2 px, so every segment carries the same scanlines. */
  .vbar{--seg:var(--bz-seg-v);--gap:var(--bz-seg-gap);flex:1;width:var(--bz-bar-w);position:relative;
    background:linear-gradient(0deg,var(--bz-unlit) calc(100% - var(--gap)),var(--bz-bg) 0) 0 100%/100% var(--seg) repeat-y}
  .vbar i{position:absolute;left:0;bottom:0;width:100%;display:block;
    mask:linear-gradient(0deg,#000 calc(100% - var(--gap)),transparent 0) 0 100%/100% var(--seg) repeat-y;
    height:min(round(var(--share),var(--seg)),round(down,100%,var(--seg)))!important}
  .col .pc{margin-top:5px}
  .col .name{margin-top:10px;font-size:16px;font-weight:700}
  /* mix: the bar column goes and the name, MW and % columns split 50, 25 and 25, as the
     mockup's rule gives them. The longest name, late ("└ coal mine waste *", 19 characters),
     fits the 164 px name column at 390 px in the small size (7.2 px a character), indented in
     whole characters a step of 1ch (crates/viz-power/tests/style.rs works it out); a narrower
     phone cuts a name with an ellipsis rather than over the numbers. */
  th:nth-child(4),td:nth-child(4){display:none}
  th:nth-child(1),td:nth-child(1){width:50%}
  th:nth-child(2),td:nth-child(2),th:nth-child(3),td:nth-child(3){width:25%}
  table{font-size:var(--bz-fs-small)}
  th,td{padding-right:4px}
  td:first-child{overflow:hidden;text-overflow:ellipsis}
  tr.grp td:first-child{padding-left:1ch}
  tr.tech td:first-child{padding-left:2ch}
}
@media (prefers-reduced-motion:no-preference){.bar i,.vbar i{transition:width .3s ease,height .3s ease}}
/* A browser without round() lights the exact share, unrounded (M73). */
@supports not (width:round(1px,1px)){
  .bar i{width:var(--share)!important}
  .vbar i{height:var(--share)!important}
}

/* Touch: the header's "buzz", the view links and [REFRESH], the timing readout's number and the
   about view's link get a --bz-tap tall tap area from a pseudo element centred on them, so their
   look and the layout stay as they are: the views line keeps its text's height, close to the
   boxes (M66). */
@media (pointer:coarse){
  .nav a{min-height:0}
  .home,.nav a,.timing,.about a{position:relative}
  .home::after,.nav a::after,.refresh::after,.timing::after,.about a::after{content:"";position:absolute;top:50%;left:0;
    width:max(100%,var(--bz-tap));height:var(--bz-tap);transform:translateY(-50%)}
}
