/**
 * Battery formation hero — scroll-scrubbed canvas sequence
 * Adapted from fireflyenergy.com homepage animation
 */

#batteryMain {
  --battery-header-offset: var(--ff-header-h, 118px);
  position: relative;
  overflow: visible;
  background: #000;
  color: #1e1e1e;
}

/* Keep formation stage fully below the fixed UK header */
body.has-battery-hero #mainContent {
  padding-top: var(--ff-header-h, 118px);
}

#batteryMain #page {
  position: relative;
  height: calc(100vh - var(--battery-header-offset));
  min-height: calc(100vh - var(--battery-header-offset));
  width: 100%;
  background: #000;
  overflow: hidden;
}

#batteryMain canvas {
  position: relative;
  z-index: 5;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  vertical-align: top;
}

#batteryMain .battery-fallback {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#batteryMain .battery-fallback.is-visible {
  opacity: 1;
}

#batteryMain.has-painted .battery-fallback {
  opacity: 0 !important;
}

/* Match source site: copy overlays are hidden */
#batteryMain #page > h3 {
  display: none;
}

#batteryMain .mouse-scroll-box {
  position: absolute;
  left: 50%;
  bottom: 1.5rem;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

#batteryMain .mouse-scroll-box.is-hidden {
  opacity: 0;
}

#batteryMain .mouse-scroll-box img {
  width: 22px;
  height: auto;
  opacity: 0.9;
  filter: invert(1);
  animation: batteryMouseBob 1.6s ease-in-out infinite;
}

@keyframes batteryMouseBob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}

#batteryMain .battery-loading {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

#batteryMain .battery-loading.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#batteryMain .battery-loading span {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
}

/* Final Carbon Foam feature frame */
#batteryMain .battery-finale {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem 2.5rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.45s ease, visibility 0.45s ease;
  background:
    radial-gradient(ellipse 80% 70% at 50% 40%, rgba(255, 255, 255, 0.92) 0%, rgba(210, 230, 235, 0.9) 45%, rgba(220, 230, 180, 0.88) 100%);
}

#batteryMain .battery-finale.is-visible {
  opacity: 1;
  visibility: visible;
}

#batteryMain .battery-finale-inner {
  width: min(1100px, 100%);
  text-align: center;
}

#batteryMain .battery-finale-title {
  margin: 0 0 1rem;
  font-family: var(--ff-font-display, 'Montserrat', sans-serif);
  font-size: clamp(1.75rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #123a7a;
  text-transform: uppercase;
}

#batteryMain .battery-finale-stage {
  position: relative;
  min-height: min(58vh, 520px);
  display: grid;
  place-items: center;
}

#batteryMain .battery-finale-core {
  width: min(42vw, 280px);
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  background: #111;
}

#batteryMain .battery-finale-core img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#batteryMain .battery-finale-point {
  position: absolute;
  margin: 0;
  max-width: 11rem;
  font-size: clamp(0.78rem, 1.35vw, 1rem);
  line-height: 1.25;
  font-weight: 600;
  color: #1a1a1a;
}

#batteryMain .battery-finale-point--tl { top: 8%; left: 4%; text-align: left; }
#batteryMain .battery-finale-point--tr { top: 8%; right: 4%; text-align: right; }
#batteryMain .battery-finale-point--ml {
  top: 42%;
  left: 2%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  text-align: left;
}
#batteryMain .battery-finale-point--mr {
  top: 38%;
  right: 2%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  text-align: right;
}
#batteryMain .battery-finale-point--bl {
  bottom: 10%;
  left: 6%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  text-align: left;
}
#batteryMain .battery-finale-point--bc {
  bottom: 2%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
}
#batteryMain .battery-finale-point--br1 {
  bottom: 18%;
  right: 18%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
}
#batteryMain .battery-finale-point--br2 {
  bottom: 8%;
  right: 4%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  text-align: right;
}

#batteryMain .battery-finale-icon {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  color: #222;
}

#batteryMain .battery-finale-icon svg {
  width: 100%;
  height: 100%;
}

@media (max-width: 768px) {
  #batteryMain .battery-finale-stage {
    min-height: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 0.5rem;
  }

  #batteryMain .battery-finale-core {
    width: min(56vw, 220px);
    order: 0;
  }

  #batteryMain .battery-finale-point {
    position: static;
    max-width: none;
    transform: none;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
  }

  #batteryMain .battery-finale-point--tl,
  #batteryMain .battery-finale-point--tr {
    order: -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  #batteryMain .mouse-scroll-box img {
    animation: none;
  }

  #batteryMain .battery-finale {
    transition: none;
  }
}

/* Homepage: keep ScrollTrigger pin/scrub reliable */
html:has(body.has-battery-hero) {
  scroll-behavior: auto;
}

body.has-battery-hero {
  overflow-x: hidden;
  scroll-behavior: auto;
}
