/* Home solar hero: "Power that follows the sun". An illustrated home energy system (solar array, inverter, battery,
   home) pops up from the bottom of the hero. A little later the sun rises on the left and, driven by scroll, crosses
   to the right: the panels send current through the inverter, the battery charges and the home's lights come on.
   After sunset the scroll holds a little longer while the battery alone powers the home. JavaScript sets the numbers
   on .homehero-pin: --sx/--sy (sun), --sunV (sun visible), --day (0 night to 1 midday), --dusk (sunset glow),
   --stars, --fA/--fB/--fC (current: panels>inverter, inverter>battery, battery>home), --lit (home lights) and --soc
   (battery level). Without JavaScript, or with reduced motion, it shows the daytime, charging state. */

.homehero{--scene-h:clamp(130px,19vh,230px);--day:.6;--gnd:#0a1226;--gnd:color-mix(in srgb,#2f6240 calc(var(--day)*100%),#0a1226);position:relative;background:#0a1226;background:var(--gnd)}
.homehero-pin{--sx:50%;--sy:15%;--sunV:1;--day:.6;--dusk:0;--stars:0;--fA:1;--fB:.6;--fC:1;--lit:1;--soc:.82;--fg:#fff;--tsh:0 1px 14px rgba(0,0,0,.55);
  --gnd:#0a1226;--gnd:color-mix(in srgb,#2f6240 calc(var(--day)*100%),#0a1226);
  position:relative;display:flex;flex-direction:column;overflow:hidden;
  min-height:max(calc(100vh - var(--hh,90px) - var(--tb,36px) - 10px),580px);   /* fills the first screen exactly */
  min-height:max(calc(100svh - var(--hh,90px) - var(--tb,36px) - 10px),580px);
  background:#274f9a;
  background:linear-gradient(180deg,color-mix(in srgb,#2a62c4 calc(var(--day)*100%),#060818) 0,color-mix(in srgb,#74abef calc(var(--day)*100%),#161b40) 100%)}
.homehero.is-pinned{height:calc(max(calc(100vh - var(--hh,90px) - var(--tb,36px)),580px) + var(--travel,100vh))}
.homehero.is-pinned{height:calc(max(calc(100svh - var(--hh,90px) - var(--tb,36px)),580px) + var(--travel,100vh))}
.homehero.is-pinned .homehero-pin{position:sticky;top:var(--hh,90px)}

/* sky: sunset glow, stars, the sun */
.homehero-sky{position:absolute;inset:0;z-index:0;pointer-events:none}
.hh-skylight{position:absolute;inset:0;opacity:var(--dusk);
  background:radial-gradient(1000px 520px at var(--sx) var(--sy),rgba(255,122,58,.7),rgba(255,84,110,.24) 46%,transparent 74%)}
.homehero-sky .stars{position:absolute;inset:0;opacity:var(--stars);
  background:
    radial-gradient(1.4px 1.4px at 6% 14%,#fff 50%,transparent 51%),radial-gradient(1px 1px at 17% 40%,#cfd6ff 50%,transparent 51%),
    radial-gradient(1.5px 1.5px at 29% 9%,#fff 50%,transparent 51%),radial-gradient(1px 1px at 41% 28%,#cfd6ff 50%,transparent 51%),
    radial-gradient(1.2px 1.2px at 53% 12%,#fff 50%,transparent 51%),radial-gradient(1px 1px at 66% 33%,#cfd6ff 50%,transparent 51%),
    radial-gradient(1.4px 1.4px at 77% 10%,#fff 50%,transparent 51%),radial-gradient(1px 1px at 87% 38%,#cfd6ff 50%,transparent 51%),
    radial-gradient(1.2px 1.2px at 94% 20%,#fff 50%,transparent 51%)}
.hh-sun{position:absolute;left:var(--sx);top:var(--sy);width:0;height:0;z-index:1;opacity:var(--sunV)}
.hh-sun-glow{position:absolute;left:-480px;top:-480px;width:960px;height:960px;border-radius:50%;
  background:radial-gradient(circle,rgba(255,214,120,.62) 0,rgba(255,170,70,.28) 22%,rgba(255,140,60,.09) 46%,transparent 68%)}
.hh-sun-disc{position:absolute;left:-30px;top:-30px;width:60px;height:60px;border-radius:50%;
  background:radial-gradient(circle at 38% 36%,#fff5cf 0,#ffc65a 40%,#ff8a2e 100%);
  box-shadow:0 0 30px 12px rgba(255,170,70,.75),0 0 100px 46px rgba(255,130,50,.3)}

/* the illustration: full width ground, the system standing on it */
.homehero-scene{position:absolute;left:50%;bottom:0;transform:translateX(-50%);width:min(100vw,calc(var(--scene-h)*4.5));height:var(--scene-h);z-index:2;pointer-events:none}
.hh-ground{position:absolute;left:50%;bottom:0;width:100vw;height:calc(var(--scene-h)*.149);transform:translateX(-50%);background:var(--gnd)}
.hf{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
.hf-ground{fill:var(--gnd)}
.hf-horizon{fill:none;stroke:rgba(255,255,255,.22);stroke-width:1.2}

.hf-post{stroke:#8c93ad;stroke-width:3;fill:none}
.hf-pv{fill:#1e2d6e;fill:url(#hfGlass);stroke:#a9b6ff;stroke-width:1.2}
.hf-pvl{fill:none;stroke:rgba(255,255,255,.35);stroke-width:.8}
.hf-pvglow{fill:#ffd36b;opacity:calc(var(--fA)*.42)}
.hf-box{fill:#1b2147;stroke:#7d89d6;stroke-width:2}
.hf-icon{fill:none;stroke:#ffd23f;stroke-width:3;stroke-linecap:round;opacity:calc(.3 + var(--fA)*.7)}
.hf-led{fill:#3cff8a}
.hf-cap{fill:#7d89d6}
.hf-soc{fill:#3cff8a;transform-box:fill-box;transform-origin:50% 100%;transform:scaleY(var(--soc));opacity:.9}
.is-discharging .hf-soc{fill:#ffb15c}
.hf-pct{fill:#fff;font:800 25px/1 inherit;font-family:inherit;text-anchor:middle;paint-order:stroke;stroke:rgba(5,8,30,.55);stroke-width:3px}
.hf-status{fill:#3cff8a;font:800 11px/1 inherit;font-family:inherit;letter-spacing:.14em;text-anchor:middle}
.is-discharging .hf-status{fill:#ffb15c}
.hf-lbl{fill:rgba(255,255,255,.72);font:700 10.5px/1 inherit;font-family:inherit;letter-spacing:.16em;text-anchor:middle}

.hf-wire{fill:none;stroke:rgba(255,255,255,.25);stroke-width:3.5;stroke-linecap:round}
.hf-flow{fill:none;stroke:#ffd23f;stroke-width:3.5;stroke-linecap:round;stroke-dasharray:2 9;animation:hfFlow .7s linear infinite;filter:drop-shadow(0 0 3px rgba(255,210,63,.8))}
.is-discharging .hf-flow{stroke:#ffb15c}
@keyframes hfFlow{to{stroke-dashoffset:-11}}

/* the home: dark when the lights are off, windows glow with --lit */
.hf-house{fill:#232a55;fill:color-mix(in srgb,#e8ecf8 calc(var(--day)*100%),#1b2147);stroke:rgba(255,255,255,.18);stroke-width:1}
.hf-roof{fill:#2b3160}
.hf-win{fill:#1c2447;fill:color-mix(in srgb,#ffd56b calc(var(--lit)*100%),#1c2447);stroke:rgba(0,0,0,.35);stroke-width:1.2;
  filter:drop-shadow(0 0 calc(var(--lit)*7px) rgba(255,205,90,.9))}
.hf-mull{stroke:rgba(40,30,10,.45);stroke-width:1.5}
.hf-door{fill:#3a2f4a}
.hf-meter{fill:#cfd5ee;stroke:#6f78a8;stroke-width:1}
.hf-spill{fill:#ffd56b;opacity:calc(var(--lit)*.3)}
.hf-tree{fill:#1f4a33;fill:color-mix(in srgb,#2f7a4d calc(var(--day)*100%),#0f2a22)}

/* pop-up from the bottom of the hero, parts staggered left to right */
.hf-pop{opacity:0;transform:translateY(90px)}
.is-in .hf-pop{animation:hfPop .95s cubic-bezier(.2,.9,.25,1.12) var(--d,0s) both}
@keyframes hfPop{0%{opacity:0;transform:translateY(90px)}55%{opacity:1}100%{opacity:1;transform:none}}
.hh-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* copy */
.homehero-grid{position:relative;z-index:3;flex:1;min-height:0;display:grid;grid-template-columns:1.05fr .95fr;gap:clamp(28px,5vw,64px);align-items:center;
  padding-top:20px;padding-bottom:calc(var(--scene-h) + 4px)}
.homehero-copy .eyebrow,.homehero-copy h1,.homehero-copy .sub,.homehero-copy .lp-points li{color:var(--fg);text-shadow:var(--tsh)}
.homehero-copy .eyebrow{opacity:.9}
.homehero-copy h1{font-size:clamp(28px,min(3.7vw,6vh),46px);font-weight:800;line-height:1.1;max-width:17ch}
.homehero-copy h1::after{content:"";display:block;width:70px;height:4px;border-radius:4px;background:var(--red);margin-top:18px}
.homehero-copy .sub{margin-top:16px;max-width:54ch;font-size:clamp(15px,1.4vw,18px)}
.homehero-copy .lp-points{margin-top:18px}
.homehero-copy .lp-points li{font-weight:600}
.homehero-copy .lp-points li::before{background-color:#ffd23f;box-shadow:0 0 0 1.5px rgba(29,29,27,.5)}
.homehero .calc{box-shadow:0 24px 60px rgba(0,0,0,.35)}
.homehero-mobile-cta{display:none}

@media(max-height:700px){
  .homehero{--scene-h:118px}
  .homehero-copy .eyebrow{display:none}
  .homehero-copy .lp-points li:nth-child(3){display:none}
  .homehero-copy .sub{margin-top:12px}
}
/* phones and small tablets: pitch, illustration, then the calculator; the sunset plays once on load */
@media(max-width:900px){
  .homehero-pin{min-height:0}
  .homehero{--scene-h:calc(100vw/4.5)}
  .homehero.is-pinned{height:auto}
  .homehero.is-pinned .homehero-pin{position:relative;top:auto}
  .homehero-grid{grid-template-columns:1fr;padding-top:30px;padding-bottom:30px;row-gap:22px}
  .homehero-scene{position:relative;left:auto;bottom:auto;transform:none;width:100vw;margin-left:calc(50% - 50vw);height:var(--scene-h)}
  .homehero-mobile-cta{display:inline-flex;margin-top:18px}
  .hf-lbl{display:none}
}
/* landscape phones: pitch and calculator side by side, the illustration underneath */
@media(max-width:900px) and (max-height:520px){
  .homehero{--scene-h:min(calc(100vw/4.5),120px)}
  .homehero-grid{grid-template-columns:1fr 1fr;align-items:start;padding-top:20px;padding-bottom:18px;column-gap:24px;row-gap:14px}
  .homehero-copy{grid-column:1;grid-row:1}
  #calculator{grid-column:2;grid-row:1}
  .homehero-scene{grid-column:1/-1;grid-row:2;left:auto;width:var(--scene-w,min(100vw,calc(var(--scene-h)*4.5)));margin-left:auto;margin-right:auto}
  .homehero-mobile-cta,.homehero-copy .lp-points,.homehero-copy .eyebrow{display:none}
  .homehero-copy h1{font-size:clamp(22px,4vw,30px)}
  .homehero-copy .sub{font-size:14px;margin-top:10px}
}
@media(prefers-reduced-motion:reduce){
  .hf-flow{animation:none}
  .hf-pop,.is-in .hf-pop{animation:none;opacity:1;transform:none}
}
