/* The home solar production chart: the Today card of Brightfold, an invented home solar app, on a dark warm page with
   a low glow and a film of grain. The chart is one SVG measured in pixels (rebuilt on resize): the bell curve of the
   panels, the warm area under it, the house's consumption line, the energy sent to the grid lit where the panels
   make more than the house uses, and the dotted arc of the sun over everything. */
:root {
  --page: #0c0a09;          /* the page */
  --card: #15120f;          /* the body of the card */
  --card-top: #1c1813;      /* the top of the card, where the light falls */
  --edge: rgba(255, 238, 214, 0.09); /* its edge */
  --ink: #f3ece2;           /* the words */
  --muted: #8f857a;         /* the small words */
  --faint: rgba(255, 238, 214, 0.07); /* the grid lines */
  --sun: #ffad42;           /* the panels' production */
  --ember: #ff7a2f;         /* the deep end of the warm gradient */
  --glow: #ffd27a;          /* the light of the sun and of the energy sent to the grid */
  --home: #9db3c9;          /* the house's consumption */
  --pointer: #f7f2ea;       /* the drawn pointer */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  isolation: isolate;
}

/* a low warm light behind the card and the grain over the page */
.stage::before,
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.stage::before {
  background:
    radial-gradient(60% 46% at 50% 34%, rgba(255, 150, 60, 0.13), transparent 70%),
    radial-gradient(40% 30% at 22% 90%, rgba(157, 179, 201, 0.06), transparent 70%);
}

.stage::after {
  opacity: 0.32;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- the card */
.card {
  --mx: 30%;
  --my: 0%;
  position: relative;
  width: min(620px, 92vw, 100%);
  padding: clamp(14px, 3.4vh, 30px) clamp(14px, 4.4vw, 32px);
  border-radius: clamp(22px, 3vh, 28px);
  background:
    radial-gradient(120% 70% at var(--mx) var(--my), rgba(255, 190, 110, 0.07), transparent 60%),
    linear-gradient(180deg, var(--card-top), var(--card) 46%);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 240, 220, 0.08),
    0 1px 1px rgba(0, 0, 0, 0.4),
    0 18px 40px -18px rgba(0, 0, 0, 0.8),
    0 50px 90px -40px rgba(0, 0, 0, 0.9);
  display: grid;
  gap: clamp(8px, 2.2vh, 22px);
  opacity: 0;
  font-variant-numeric: tabular-nums;
}

/* the edge catches the light where the pointer is */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(160px 120px at var(--mx) var(--my), rgba(255, 205, 140, 0.42), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(13px, min(3.4vw, 2vh), 16px);
  font-weight: 600;
  font-stretch: 108%;
  letter-spacing: -0.01em;
}

.brand__mark {
  width: clamp(18px, 2.6vh, 22px);
  height: clamp(18px, 2.6vh, 22px);
  fill: none;
  stroke: var(--sun);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.brand__mark circle {
  fill: var(--sun);
  stroke: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: clamp(24px, 3.4vh, 30px);
  padding: 0 10px 0 12px;
  border-radius: 999px;
  font-size: clamp(11.5px, min(3vw, 1.7vh), 14px);
  color: var(--ink);
  background: rgba(255, 238, 214, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 238, 214, 0.08);
}

.chip__chev {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.label {
  display: block;
  font-size: clamp(11px, min(2.9vw, 1.65vh), 14px);
  letter-spacing: 0.01em;
  color: var(--muted);
}

/* ---------------------------------------------------------------- right now */
.now {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.now__time {
  color: var(--ink);
}

.big {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin: 4px 0 0;
  font-size: clamp(30px, min(10vw, 7.4vh), 64px);
  font-weight: 560;
  font-stretch: 92%;
  letter-spacing: -0.035em;
  line-height: 1;
}

.big__unit {
  font-size: 0.42em;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}

.now__side {
  display: grid;
  gap: 5px;
  margin: 0 0 3px;
}

.side {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: clamp(11.5px, min(3vw, 1.75vh), 14.5px);
}

.side__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.side__value {
  margin: 0;
  color: var(--ink);
  min-width: 4.6em;
  text-align: right;
}

.key {
  width: 12px;
  height: 4px;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.key--home {
  stroke: var(--home);
  stroke-dasharray: 2 2.4;
}

.key--grid {
  stroke: var(--glow);
}

.side--grid .side__value {
  transition: color 0.3s;
}

.side--grid.is-off .side__value {
  color: var(--muted);
}

/* the rolling digits: one column of figures per digit, moved by the script */
.roll {
  display: inline-flex;
}

.roll__col {
  display: inline-block;
  height: 1em;
  line-height: 1;
  overflow: hidden;
  -webkit-mask: linear-gradient(transparent, #000 18%, #000 82%, transparent);
  mask: linear-gradient(transparent, #000 18%, #000 82%, transparent);
}

.roll__strip {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.roll__strip span {
  height: 1em;
}

.roll__dot {
  line-height: 1;
}

/* ---------------------------------------------------------------- the chart */
.chart {
  position: relative;
  height: clamp(130px, 36vh, 300px);
  margin: 0 -4px;
}

.chart__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.grid line {
  stroke: var(--faint);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.grid text,
.ticks text {
  fill: var(--muted);
  font-size: clamp(9.5px, min(2.6vw, 1.45vh), 12.5px);
  font-family: inherit;
}

.ticks text {
  text-anchor: middle;
}

.base {
  stroke: rgba(255, 238, 214, 0.16);
  stroke-width: 1;
}

.arc {
  fill: none;
  stroke: rgba(255, 210, 140, 0.26);
  stroke-width: 1;
  stroke-dasharray: 1 4.5;
  stroke-linecap: round;
}

.prod {
  fill: none;
  stroke-width: 1.7;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.prod--soft {
  stroke: var(--sun);
  stroke-width: 7;
  opacity: 0.16;
  filter: blur(4px);
}

.home {
  fill: none;
  stroke: var(--home);
  stroke-width: 1.3;
  stroke-dasharray: 3 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.export {
  opacity: 0;
}

.export__hatch {
  mix-blend-mode: screen;
}

.scrub {
  opacity: 0;
}

.scrub__hair {
  stroke: rgba(255, 238, 214, 0.28);
  stroke-width: 1;
}

.scrub__dot {
  fill: #fff7ea;
  stroke: var(--sun);
  stroke-width: 1.6;
}

.scrub__halo {
  fill: url(#sf-disc);
  opacity: 0.5;
}

.scrub__home {
  fill: var(--card);
  stroke: var(--home);
  stroke-width: 1.3;
}

.sun {
  opacity: 0;
}

.sun__core {
  fill: #fff6e2;
}

/* the little flag over the energy sent to the grid */
.flag {
  position: absolute;
  left: 0;
  top: 0;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: clamp(10px, min(2.6vw, 1.5vh), 13px);
  font-weight: 560;
  color: #2a1704;
  background: linear-gradient(180deg, #ffe2a2, var(--glow));
  box-shadow: 0 4px 14px -4px rgba(255, 180, 80, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the day's totals */
.foot {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding-top: clamp(8px, 1.8vh, 14px);
  border-top: 1px solid rgba(255, 238, 214, 0.07);
}

.stat + .stat {
  padding-left: clamp(12px, 2.4vw, 20px);
  border-left: 1px solid rgba(255, 238, 214, 0.06);
}

.stat__value {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin: 3px 0 0;
  font-size: clamp(16px, min(5vw, 4.4vh), 30px);
  font-weight: 540;
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat__unit {
  font-size: 0.56em;
  color: var(--muted);
  letter-spacing: 0;
}

.stat__cur {
  font-size: 0.8em;
  margin-right: 1px;
}

.stat--save .stat__value {
  color: var(--glow);
}

/* ---------------------------------------------------------------- the drawn pointer */
.pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: clamp(18px, 2.8vh, 24px);
  height: clamp(22px, 3.4vh, 29px);
  fill: var(--pointer);
  stroke: #1a1410;
  stroke-width: 1.2;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.55));
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

@media (max-width: 380px) {
  .now__side {
    gap: 3px;
  }
  .side {
    font-size: 10.5px;
    gap: 8px;
  }
  .side__value {
    min-width: 46px;
  }
  .stat + .stat {
    padding-left: 9px;
  }
}

@media (max-height: 360px) {
  .foot .label {
    display: none;
  }
}
