/* Bill analyzer page (/bill-analyzer/). Loaded after /preview.css.
   Colors come only from the --p-* tokens in /themes/white.css and
   /themes/black.css, so the page follows whichever theme is active. */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.analyzer-page a:focus-visible,
.analyzer-page input:focus-visible {
  outline: 2px solid var(--p-gold);
  outline-offset: 2px;
}

/* ---- Hero ------------------------------------------------- */
.ba-hero h1 { max-width: 16ch; }
.ba-hero .lead { margin-bottom: 1.75rem; }

/* ---- Layout ----------------------------------------------- */
.ba-section.section { padding-top: 4rem; }
/* The DOM follows the phone order (steps 1 and 2, estimate, months, chart)
   so tab order matches the screen. On desktop the estimate moves to the
   right column and spans the left column's rows. */
.ba-layout {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
  gap: 20px 40px;
  align-items: start;
}
.ba-layout > .ba-card { grid-column: 1; min-width: 0; }
.ba-layout > .ba-estimate { grid-column: 2; grid-row: 1 / span 4; align-self: start; }

.ba-noscript {
  border: 1px solid var(--p-gold);
  background: var(--p-gold-soft);
  color: var(--p-fg);
  padding: 14px 18px;
  margin: 0 0 24px;
  max-width: 70ch;
}
.ba-noscript a { color: var(--p-fg); text-decoration-color: var(--p-gold); }

/* ---- Cards ------------------------------------------------ */
.ba-card {
  min-width: 0;
  margin: 0;
  padding: 26px 26px 22px;
  background: var(--p-card);
  border: 1px solid var(--p-line);
  color: var(--p-fg);
}
.ba-card legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0 0 8px;
  font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  font-size: clamp(24px, 2.4vw, 30px);
  font-weight: 500;
  line-height: 1.15;
  color: var(--p-fg);
}
.ba-card legend + * { clear: both; }
.ba-step-num {
  display: block;
  margin-bottom: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--p-mut);
}
.ba-card .ba-help,
.analyzer-page .ba-help { color: var(--p-mut); font-size: 15px; margin: 0 0 18px; max-width: 60ch; }
.analyzer-page .ba-fine { color: var(--p-mut); font-size: 13px; line-height: 1.55; margin: 8px 0 0; }
.ba-fine a { color: var(--p-fg); text-decoration-color: var(--p-gold); text-underline-offset: 3px; }

.ba-card label,
.ba-chart figcaption {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--p-fg);
  margin: 0 0 8px;
}

/* ---- Inputs ----------------------------------------------- */
.ba-card input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--p-input-bg);
  color: var(--p-fg);
  border: 1px solid var(--p-input-br);
  border-radius: 0;
  font: inherit;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ba-card input[type="number"]:focus {
  outline: none;
  border-color: var(--p-gold);
  box-shadow: 0 0 0 3px var(--p-ring);
}
.ba-card input::placeholder { color: var(--p-mut); }
#annual-kwh { max-width: 18rem; }

.ba-upload {
  margin: 0 0 20px;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--p-line);
}
.analyzer-page .ba-upload-hint { margin: 0 0 12px; }
.ba-upload input[type="file"] {
  display: block;
  width: 100%;
  max-width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--p-mut);
}
.ba-upload input[type="file"]::file-selector-button {
  margin-right: 14px;
  padding: 11px 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--p-fg);
  background: transparent;
  border: 1px solid var(--p-gold);
  border-radius: 0;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
.ba-upload input[type="file"]::file-selector-button:hover { background: var(--p-gold-soft); }
.ba-read {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-left: 2px solid var(--p-gold);
  background: var(--p-gold-soft);
  color: var(--p-fg);
  font-size: 14px;
}
.ba-error {
  margin: 12px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--p-gold);
  color: var(--p-fg);
  font-size: 14px;
}
.ba-read[hidden], .ba-error[hidden] { display: none; }

/* ---- Choice cards (utility, mode) ------------------------- */
.ba-picks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ba-card .ba-pick {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  margin: 0;
  padding: 14px 16px;
  background: var(--p-input-bg);
  border: 1px solid var(--p-line);
  cursor: pointer;
  transition: border-color 0.25s ease, background-color 0.25s ease;
}
.ba-pick input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.ba-pick:hover { border-color: var(--p-input-br); }
.ba-pick:focus-within { outline: 2px solid var(--p-gold); outline-offset: 2px; }
.ba-pick.is-selected,
.ba-pick:has(input:checked) {
  border-color: var(--p-gold);
  background: var(--p-gold-soft);
  box-shadow: inset 0 0 0 1px var(--p-gold);
}
.ba-pick-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  line-height: 1;
  color: var(--p-fg);
}
.ba-pick-full { font-size: 13px; color: var(--p-mut); font-weight: 400; }
.ba-modes { margin-bottom: 20px; }
.ba-card .ba-mode { min-height: 50px; align-items: center; text-align: center; font-size: 15px; }

/* ---- Month editor ----------------------------------------- */
#month-editor[hidden] { display: none; }
.ba-month-total {
  margin: 0 0 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--p-fg);
}
.ba-months {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 28px;
}
.ba-month {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7rem;
  grid-template-areas: "label num" "range range";
  gap: 4px 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--p-line);
}
.ba-card .ba-month label { grid-area: label; margin: 0; font-weight: 400; }
.ba-unit { color: var(--p-mut); font-size: 12px; }
.ba-month .ba-month-num { grid-area: num; padding: 8px 10px; font-size: 15px; }
.ba-month .ba-month-range {
  grid-area: range;
  width: 100%;
  height: 32px;
  margin: 0;
  accent-color: var(--p-gold);
}

/* ---- Chart ------------------------------------------------ */
.ba-chart figcaption { font-size: 14px; margin-bottom: 14px; }
.ba-bars[hidden] { display: none; }
.ba-bar {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) 6.5rem;
  gap: 12px;
  align-items: center;
  margin: 6px 0;
  font-size: 13px;
}
.ba-bar-name { color: var(--p-mut); }
.ba-bar-track {
  display: block;
  height: 10px;
  background: var(--p-alt);
  overflow: hidden;
}
.ba-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--p-gold);
  transition: width 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ba-bar-val {
  color: var(--p-fg);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.ba-bar.is-missing .ba-bar-val,
.ba-bar.is-missing .ba-bar-name { color: var(--p-mut); font-style: italic; }

/* ---- Estimate --------------------------------------------- */
.ba-estimate {
  position: sticky;
  top: 96px;
  min-width: 0;
  padding: 28px 26px 26px;
  background: var(--p-alt);
  border: 1px solid var(--p-line);
  border-top: 2px solid var(--p-gold);
}
.ba-estimate .eyebrow { margin-bottom: 12px; }
.ba-estimate h3 { font-size: 22px; margin: 0 0 6px; color: var(--p-fg); }
.analyzer-page .ba-size {
  margin: 0 0 6px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(40px, 4.4vw, 56px);
  font-weight: 500;
  line-height: 1.02;
  color: var(--p-fg);
  font-variant-numeric: lining-nums tabular-nums;
}
.analyzer-page .ba-size.is-empty { font-size: 22px; line-height: 1.3; color: var(--p-mut); }
.analyzer-page .ba-panels { margin: 0 0 4px; font-weight: 500; color: var(--p-fg); }
.analyzer-page .ba-panels:empty, .analyzer-page .ba-estimate .ba-fine:empty { display: none; }
.ba-estimate-cta {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--p-line);
}
.ba-estimate-cta .btn { display: block; width: 100%; text-align: center; }

/* ---- Yield source ----------------------------------------- */
#yield-note:focus { outline: none; }
#yield-note { scroll-margin-top: 96px; }
.ba-yield a { color: var(--p-fg); text-decoration-color: var(--p-gold); text-underline-offset: 3px; }

/* ---- Final CTA -------------------------------------------- */
.analyzer-page .final-cta .lead { margin: 0 auto 1.75rem; text-align: center; max-width: 52ch; }

/* ---- Responsive ------------------------------------------- */
@media (max-width: 980px) {
  .ba-layout { grid-template-columns: 1fr; gap: 20px; }
  .ba-layout > .ba-card, .ba-layout > .ba-estimate { grid-column: 1; grid-row: auto; }
  .ba-estimate { position: static; }
}
@media (max-width: 767px) {
  .ba-section.section { padding-top: 2rem; }
  /* The sticky bar and the floating Text us link carry call and text here. */
  .ba-hero .btn-row .btn-outline { display: none; }
  .ba-hero .btn-row .btn-solid { flex: 1 1 100%; text-align: center; }
  .ba-months { grid-template-columns: 1fr; }
  .ba-month-total {
    position: sticky;
    top: 72px;
    z-index: 5;
    margin: 0 -18px 10px;
    padding: 10px 18px;
    background: var(--p-card);
    border-bottom: 1px solid var(--p-line);
  }
  .analyzer-page .final-cta .btn-row { display: grid; grid-template-columns: 1fr; }

  /* Clear the sticky bar (88px) plus the floating Text us link above it,
     which sits 104px from the bottom and is about 46px tall. */
  body.analyzer-page { padding-bottom: 168px; }
  .ba-read, .ba-error { scroll-margin-bottom: 250px; scroll-margin-top: 88px; }
  .ba-estimate-cta { margin-bottom: 8px; }
  /* The quote block already offers call and text, so the floating link
     steps aside while it is on screen instead of covering its last lines. */
  body.ba-cta-in-view .text-us { display: none; }
}
@media (max-width: 560px) {
  .ba-card { padding: 20px 18px 18px; }
  .ba-estimate { padding: 22px 18px; }
  .ba-picks { gap: 8px; }
  .ba-card .ba-pick { padding: 12px; }
  .ba-pick-name { font-size: 22px; }
  .ba-bar { grid-template-columns: 2.4rem minmax(0, 1fr) 5.8rem; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .ba-bar-fill, .ba-pick, .ba-card input[type="number"] { transition: none; }
}
