/* solar.adelaidelive.app — South Australia's electricity, live.
   Two looks, chosen by the sun: day while rooftop solar is generating, night otherwise. */
:root {
  --font-sans: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.75, 0.2, 1);
  --gutter: clamp(1.25rem, 4vw, 3rem);
}
/* fuel colours were validated for colour-vision safety against each surface (see README) */
:root[data-theme="day"] {
  color-scheme: light;
  --bg: #f6f1e7; --surface: #fcf9f2; --ink: #1d1a17; --dim: #6b625a;
  --line: rgba(29, 26, 23, 0.12); --line-strong: rgba(29, 26, 23, 0.32); --accent: #b07a00;
  --r-rooftop: #dc9a1c; --r-utility: #e6743a; --r-wind: #2fa392; --r-battery: #6478dc;
  --r-gas: #9a8f85; --r-import: #b9b2aa; --r-import-line: #8f877e;
  --sky-night: #e4ded2; --sky-day: #fff5dc;
  --neg: #b5473c;
}
:root[data-theme="night"] {
  color-scheme: dark;
  --bg: #0f1626; --surface: #161f33; --ink: #e8ecf3; --dim: #9aa3b5;
  --line: rgba(232, 236, 243, 0.12); --line-strong: rgba(232, 236, 243, 0.32); --accent: #b9861a;
  --r-rooftop: #f0b53c; --r-utility: #f08a4f; --r-wind: #4fc2ad; --r-battery: #8797f0;
  --r-gas: #7c8497; --r-import: #4a5268; --r-import-line: #7a8398;
  --sky-night: #0b1020; --sky-day: #22304e;
  --neg: #d97b70;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: clamp(16px, 0.5vw + 10px, 19px);
  line-height: 1.5;
  font-variant-ligatures: none;
  transition: background-color 700ms ease, color 700ms ease;
}
body { margin: 0; font-variation-settings: "opsz" 14; }
a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; text-decoration-color: var(--line-strong); }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
svg text { font-family: var(--font-mono); font-size: 11px; fill: var(--dim); }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.9rem var(--gutter);
  font-family: var(--font-mono); font-size: 0.82rem;
}
.brand { text-decoration: none; font-weight: 500; }
.top nav { display: flex; align-items: center; gap: 1.25rem; }
.top nav a { color: var(--dim); text-decoration: none; }
.top nav a:hover { color: var(--ink); }
.theme {
  font: inherit; color: var(--dim); background: transparent;
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 0.25rem 0.8rem; cursor: pointer;
}
.theme:hover { color: var(--ink); border-color: var(--ink); }

main { width: min(100% - 2 * var(--gutter), 78rem); margin: 0 auto; padding-bottom: 3rem; }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 0.5rem clamp(1.5rem, 4vw, 3.5rem);
  padding: clamp(1.5rem, 5vh, 4rem) 0 clamp(1.5rem, 4vh, 3rem);
}
.when {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-mono); font-size: 0.82rem; color: var(--dim);
}
.live { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--dim); }
.live.is-on { background: var(--f-wind); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(31, 143, 122, 0.45); } 50% { box-shadow: 0 0 0 6px rgba(31, 143, 122, 0); } }
.hero-number {
  font-size: clamp(5.5rem, 16vw, 13rem);
  font-weight: 700;
  line-height: 0.85;
  letter-spacing: -0.045em;
  font-variation-settings: "opsz" 96;
  font-variant-numeric: proportional-nums;
}
.hero-number .unit { font-size: 0.42em; font-weight: 600; letter-spacing: -0.02em; margin-left: 0.05em; vertical-align: 0.05em; }
.hero-copy {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2.1rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  max-width: 24ch;
  font-variation-settings: "opsz" 40;
}
.hero-sub { margin-top: 0.75rem; color: var(--dim); max-width: 58ch; font-size: clamp(0.98rem, 1.1vw, 1.12rem); }
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero-copy { max-width: none; }
}

/* ---------- the chart ---------- */
.chart-block { padding: clamp(1rem, 3vh, 2rem) 0; border-top: 1px solid var(--line); }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.chart-head h2 { margin: 0; font-size: clamp(1.2rem, 1.6vw, 1.5rem); font-weight: 600; letter-spacing: -0.01em; }
.chart-sub { color: var(--dim); font-size: 0.9rem; max-width: 62ch; }
/* the horizon: one share curve on a sky that follows the sun, then one ribbon per source */
.viz {
  position: relative;
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  column-gap: 1.25rem;
  row-gap: 0.5rem;
  margin-top: 1rem;
}
.viz svg { display: block; width: 100%; overflow: visible; }
.viz-label { display: flex; flex-direction: column; justify-content: center; gap: 0.1rem; font-family: var(--font-mono); font-size: 0.74rem; line-height: 1.35; color: var(--dim); min-width: 0; }
.viz-label b { font-family: var(--font-sans); font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; color: var(--ink); font-variant-numeric: tabular-nums; }
.viz-label-main b { font-size: clamp(1.8rem, 2.4vw, 2.4rem); line-height: 1; margin-bottom: 0.2rem; }
.viz-label .peak { opacity: 0.85; }
.viz-main svg { height: clamp(190px, 28vh, 260px); }
.ribbons { display: contents; }
.ribbon svg { height: 50px; }
.viz-axis svg { height: 18px; }
.sky { rx: 8; ry: 8; }
.share-area { fill: url(#share-fill); }
.share-line { fill: none; stroke: var(--r-rooftop); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.share-dot { fill: var(--r-rooftop); stroke: var(--bg); stroke-width: 2.5; }
.share-stop-a { stop-color: var(--r-rooftop); stop-opacity: 0.55; }
.share-stop-b { stop-color: var(--r-rooftop); stop-opacity: 0.02; }
.pct-line { stroke: var(--ink); stroke-width: 1; opacity: 0.16; shape-rendering: crispEdges; }
.pct-label { font-size: 10px; fill: var(--dim); }
.sun-line { stroke: var(--ink); stroke-width: 1; opacity: 0.28; shape-rendering: crispEdges; }
.sun-label { font-size: 10px; fill: var(--dim); }
.ribbon .line { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.ribbon .base { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.ribbon .stop-a { stop-opacity: 0.75; }
.ribbon .stop-b { stop-opacity: 0.05; }
.r-rooftop .stop-a, .r-rooftop .stop-b, .r-rooftop .line { stop-color: var(--r-rooftop); stroke: var(--r-rooftop); }
.r-utility .stop-a, .r-utility .stop-b, .r-utility .line { stop-color: var(--r-utility); stroke: var(--r-utility); }
.r-wind .stop-a, .r-wind .stop-b, .r-wind .line { stop-color: var(--r-wind); stroke: var(--r-wind); }
.r-battery .stop-a, .r-battery .stop-b, .r-battery .line { stop-color: var(--r-battery); stroke: var(--r-battery); }
.r-gas .stop-a, .r-gas .stop-b, .r-gas .line { stop-color: var(--r-gas); stroke: var(--r-gas); }
.r-import .line { stroke: var(--r-import-line); }
.hatch-bg { fill: var(--r-import); }
.hatch-line { stroke: var(--r-import-line); stroke-width: 1; }
.viz-label .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.45rem; vertical-align: middle; }
.cursor-line { position: absolute; top: 0; width: 1px; background: var(--ink); opacity: 0.5; pointer-events: none; }
.axis text { font-size: 10.5px; }
@media (max-width: 640px) {
  .viz { grid-template-columns: 6.5rem minmax(0, 1fr); column-gap: 0.75rem; }
  .viz-label { font-size: 0.68rem; }
  .viz-label-main b { font-size: 1.5rem; }
}
.tip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 13rem; padding: 0.55rem 0.75rem;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px;
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--dim);
  box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.45);
}
.tip .tip-time { margin-bottom: 0.3rem; color: var(--ink); }
.tip .row { display: flex; align-items: center; gap: 0.5rem; padding: 0.05rem 0; }
.tip .row i { display: inline-block; width: 12px; height: 3px; border-radius: 1px; flex: none; }
.tip .row b { color: var(--ink); font-weight: 600; font-family: var(--font-sans); min-width: 4.5ch; text-align: right; font-variant-numeric: tabular-nums; }
.tip .row.total { border-top: 1px solid var(--line); margin-top: 0.25rem; padding-top: 0.3rem; }
.table-view { margin-top: 0.75rem; font-family: var(--font-mono); font-size: 0.78rem; color: var(--dim); }
.table-view summary { cursor: pointer; list-style: none; width: max-content; }
.table-view summary::before { content: "+ "; color: var(--accent); }
.table-view[open] summary::before { content: "− "; }
.table-view .wrap { overflow-x: auto; margin-top: 0.5rem; }
.tv { border-collapse: collapse; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tv th, .tv td { text-align: right; padding: 0.15rem 1.2ch 0.15rem 0; font-weight: 400; color: var(--ink); border-bottom: 1px solid var(--line); }
.tv th { color: var(--dim); }
.tv th:first-child, .tv td:first-child { text-align: left; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(0.75rem, 1.2vw, 1.25rem); padding: clamp(1rem, 3vh, 2rem) 0; border-top: 1px solid var(--line); }
@media (min-width: 1000px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tiles { grid-template-columns: minmax(0, 1fr); } }
.tile .value.small { font-size: clamp(1.35rem, 1.8vw, 1.7rem); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.15rem 1.1rem; min-width: 0; transition: background-color 700ms ease, border-color 700ms ease; }
.tile .label { color: var(--dim); font-size: 0.88rem; }
.tile .value { margin-top: 0.15rem; font-size: clamp(1.7rem, 2.2vw, 2.1rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: proportional-nums; }
.tile .value .unit { font-size: 0.5em; font-weight: 400; color: var(--dim); letter-spacing: 0; margin-left: 0.15ch; }
.tile .note { margin-top: 0.35rem; color: var(--dim); font-size: 0.85rem; line-height: 1.4; }
.tile .note b { color: var(--ink); font-weight: 500; }
.spark { display: block; width: 100%; height: 60px; margin-top: 0.7rem; overflow: visible; }
.spark .line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .line.forecast { stroke-dasharray: 4 4; }
.spark .wash { fill: var(--ink); opacity: 0.08; }
.spark .neg { fill: var(--neg); opacity: 0.18; }
.spark .zero { stroke: var(--line-strong); stroke-width: 1; shape-rendering: crispEdges; }
.spark .end { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.spark text { font-size: 10px; }

/* ---------- footer ---------- */
.foot { padding-top: 1.5rem; border-top: 1px solid var(--line); color: var(--dim); font-size: 0.85rem; }
.foot p { max-width: 70ch; }
.foot p + p { margin-top: 0.6rem; }
@media (min-width: 900px) {
  .foot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 clamp(2rem, 4vw, 4rem); }
  .foot p { max-width: none; }
  .foot p + p { margin-top: 0; }
}

/* ---------- motion ---------- */
.reveal { animation: fadein 500ms var(--ease) both; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  html, .tile { transition: none; }
  .live.is-on { animation: none; }
  .reveal { animation: none; }
}
