/* solar.simonyou.dev — 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;
  --f-rooftop: #b07a00; --f-wind: #1f8f7a; --f-utility: #d9622b; --f-battery: #2f6fc4; --f-gas: #a1453a; --f-import: #9a938b;
  --neg: #a1453a; --night-band: rgba(29, 26, 23, 0.045);
}
: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;
  --f-rooftop: #b9861a; --f-wind: #2a9680; --f-utility: #c96d33; --f-battery: #4a80cc; --f-gas: #b85c52; --f-import: #6b7384;
  --neg: #d97b70; --night-band: rgba(232, 236, 243, 0.035);
}

*, *::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: 60ch; }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; margin: 0.25rem 0 0.75rem; font-family: var(--font-mono); font-size: 0.8rem; color: var(--dim); }
.legend li { display: inline-flex; align-items: baseline; gap: 0.5rem; }
.legend .sw { width: 12px; height: 12px; border-radius: 2px; align-self: center; flex: none; }
.legend .sw.line { width: 16px; height: 2px; border-radius: 1px; background: var(--ink); }
.legend b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.chart { position: relative; height: clamp(260px, 42vh, 440px); }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.layer { stroke: var(--bg); stroke-width: 2; stroke-linejoin: round; }
.layer-solar_rooftop { fill: var(--f-rooftop); }
.layer-wind { fill: var(--f-wind); }
.layer-solar_utility { fill: var(--f-utility); }
.layer-battery_discharging { fill: var(--f-battery); }
.layer-gas { fill: var(--f-gas); }
.layer-imports { fill: var(--f-import); }
.grid-line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.night-band { fill: var(--night-band); }
.consumption { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.crosshair { stroke: var(--ink); stroke-width: 1; opacity: 0.55; shape-rendering: crispEdges; }
.dot { stroke: var(--bg); stroke-width: 2; }
.direct-label { font-size: 11px; fill: var(--dim); }
.direct-label tspan.n { fill: var(--ink); }
.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(auto-fit, minmax(15rem, 1fr)); gap: clamp(0.75rem, 1.2vw, 1.25rem); padding: clamp(1rem, 3vh, 2rem) 0; border-top: 1px solid var(--line); }
.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; max-width: 78ch; }
.foot p + p { margin-top: 0.6rem; }

/* ---------- 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; }
}
