/* Energy Cost Calculator — dark, premium, self-contained. */

@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 300 600;
  font-display: swap;
  src: url("fonts/fraunces-italic.woff2") format("woff2");
}

:root {
  --ink: #0C0E11;          /* page */
  --surface: #14171D;      /* cards */
  --surface-2: #1B1F27;    /* raised */
  --line: #262C35;         /* hairlines */
  --text: #ECEEF2;
  --muted: #8B93A1;
  --faint: #59616E;
  --accent: #E9A845;       /* UI amber (text/hero) */
  --win: #5FB2E6;          /* savings hero — reads as the win against the amber burn */
  --bar: #C58117;          /* chart series — validated on dark */
  --solar: #4093C4;        /* overlay series — validated on dark */
  --radius: 20px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.app {
  max-width: 780px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 20px calc(env(safe-area-inset-bottom, 0px) + 28px);
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.top .overlay-toggle { margin-left: auto; }

.menu-btn {
  width: 40px; height: 40px;
  margin-left: -10px; /* optical: icon aligns with the content edge */
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--muted);
  transition: color 0.2s ease, background 0.2s ease, transform 0.25s ease;
}
.menu-btn:hover { color: var(--text); background: var(--surface-2); }
.menu-btn:active { transform: scale(0.92); }

.wordmark {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 460;
  font-size: 17px;
  letter-spacing: 0.01em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 9px;
}

.mark-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(233, 168, 69, 0.55);
}

/* the quiet corner switch — no label, dim until active */
.overlay-toggle {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--faint);
  opacity: 0.55;
  transition: color 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
}
.overlay-toggle:active { transform: scale(0.92); }
.overlay-toggle[aria-pressed="true"] {
  color: var(--accent);
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(233, 168, 69, 0.45));
}

/* ---------- menu drawer (views live behind the top-left hamburger) ---------- */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 7, 0.62);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  z-index: 40;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: min(78vw, 300px);
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: 24px 0 70px rgba(0, 0, 0, 0.45);
  transform: translateX(-106%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0.28, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 14px calc(env(safe-area-inset-bottom, 0px) + 20px);
}
.drawer.open { transform: none; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 2px 14px;
}
.drawer-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 460;
  font-size: 16px;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.drawer-nav { display: flex; flex-direction: column; gap: 4px; }

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 14px;
  border-radius: 12px;
  font-size: 15.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
  transition: background 0.2s ease, color 0.2s ease;
}
.drawer-item::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--line);
  flex: 0 0 auto;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.drawer-item:hover { background: var(--surface-2); color: var(--text); }
.drawer-item.is-active { background: var(--surface-2); color: var(--text); }
.drawer-item.is-active::before {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(233, 168, 69, 0.55);
}

/* ---------- hero ---------- */

.hero {
  text-align: center;
  padding: 10px 0 26px;
  position: relative;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -30px -10px 0;
  background: radial-gradient(ellipse 62% 60% at 50% 42%, rgba(233, 168, 69, 0.075), transparent 70%);
  pointer-events: none;
}

.hero-eyebrow {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(17px, 4.6vw, 21px);
  color: var(--muted);
  margin-bottom: 6px;
}

.hero-number {
  font-size: clamp(58px, 17.5vw, 118px);
  font-weight: 640;
  letter-spacing: -0.04em;
  line-height: 1.04;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 46px rgba(233, 168, 69, 0.22);
}

.hero-sub {
  margin-top: 8px;
  font-size: clamp(15px, 4vw, 17px);
  color: var(--muted);
}
.hero-sub strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* the second hero — the number the customer keeps */
.solar-hero { margin-top: 20px; position: relative; animation: rise 0.45s ease both; }
.solar-hero[hidden] { display: none; }
.solar-hero::before {
  content: "";
  position: absolute;
  inset: -14px -10px -18px;
  background: radial-gradient(ellipse 58% 62% at 50% 55%, rgba(95, 178, 230, 0.07), transparent 70%);
  pointer-events: none;
}

.solar-hero-label {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(16px, 4.2vw, 20px);
  color: var(--muted);
  margin-bottom: 2px;
}

.solar-hero-number {
  font-size: clamp(46px, 13.5vw, 92px);
  font-weight: 640;
  letter-spacing: -0.035em;
  line-height: 1.05;
  color: var(--win);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 40px rgba(95, 178, 230, 0.22);
}

.solar-hero-sub {
  margin-top: 4px;
  font-size: clamp(13.5px, 3.6vw, 15px);
  color: var(--muted);
}

.solar-hero.is-negative .solar-hero-number { color: var(--text); text-shadow: none; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.dot-utility { background: var(--bar); }
.dot-solar { background: var(--solar); }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- chart ---------- */

.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 12px 8px;
  margin-bottom: 26px;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 30px;
  padding: 0 6px 4px;
}

.legend { display: flex; gap: 16px; margin-right: auto; animation: rise 0.35s ease both; }
.legend[hidden] { display: none; }
.lg { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--faint);
  transition: color 0.2s ease, background 0.2s ease;
}
.icon-btn:hover, .icon-btn:active { color: var(--muted); background: var(--surface-2); }
.icon-btn svg[hidden] { display: none; }

.chart-wrap { position: relative; }

#chart { display: block; width: 100%; height: auto; animation: fadein 0.5s ease; }

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -100%);
  z-index: 5;
}
.tip strong { color: var(--text); font-variant-numeric: tabular-nums; }
.tip[hidden] { display: none; }

/* ---------- controls ---------- */

.controls { display: flex; flex-direction: column; gap: 8px; }

.ctl {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px 16px;
}
.ctl-solar { animation: rise 0.35s ease both; }
.ctl[hidden] { display: none; }

.ctl-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ctl-label { font-size: 14.5px; color: var(--muted); }

.ctl-val {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}
.ctl-val .unit { color: var(--faint); font-size: 15px; }
.ctl-val input {
  background: none;
  border: 0;
  width: 4.2ch;
  text-align: right;
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  border-radius: 6px;
  appearance: textfield;
  -moz-appearance: textfield;
}
.ctl-val input::-webkit-outer-spin-button,
.ctl-val input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ctl-val input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

/* sliders */
.range {
  --p: 50%;
  --fill: var(--accent);
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 30px;
  background: transparent;
}
.range-solar { --fill: var(--solar); }

.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--fill) var(--p), var(--line) var(--p));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  margin-top: -11px;
  border-radius: 50%;
  background: #F4F6F9;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.range::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--fill) var(--p), var(--line) var(--p));
}
.range::-moz-range-thumb {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #F4F6F9;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* ---------- reference (View 2) — deliberately quiet ---------- */

.ref-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 8px;
}

.ref-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.ref-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 460;
  font-size: 17px;
  color: var(--muted);
}

.ref-filter {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  width: 130px;
  font-size: 16px;
  color: var(--text);
}
.ref-filter::placeholder { color: var(--faint); }
.ref-filter:focus { outline: 2px solid var(--line); outline-offset: 0; }

.ref-cols {
  display: flex;
  justify-content: space-between;
  padding: 0 4px 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.ref-list { list-style: none; }

.ref-list li { border-top: 1px solid var(--line); }
.ref-list li[hidden] { display: none; }

.ref-row {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 4px;
  font-variant-numeric: tabular-nums;
  border-radius: 8px;
  transition: background 0.15s ease;
}
li.is-open .ref-row { background: var(--surface-2); }

.ref-kw { font-size: 15px; color: var(--text); font-weight: 500; }
.ref-kw small { color: var(--faint); font-weight: 400; font-size: 12.5px; margin-left: 3px; }
.ref-ppw { font-size: 15px; color: var(--muted); }

.ref-detail {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.22s ease, padding 0.22s ease;
  padding: 0 4px;
  font-size: 13.5px;
  color: var(--muted);
}
li.is-open .ref-detail { max-height: 44px; padding: 0 4px 12px; }
.ref-detail strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- footer ---------- */

.foot {
  margin-top: 26px;
  text-align: center;
  font-size: 12px;
  color: var(--faint);
}

/* ---------- larger screens ---------- */

@media (min-width: 700px) {
  .app { padding-top: 34px; }
  .hero { padding-bottom: 34px; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .ctl-solar { grid-column: 1 / -1; }
  .controls:has(.ctl-solar[hidden]) .ctl:nth-of-type(3) { grid-column: 1 / -1; }
  .ref-filter { width: 180px; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- payments (View 3) ---------- */

#viewPay .pay-card { margin-bottom: 10px; }

.pay-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
}

.pay-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.pay-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 460;
  font-size: 17px;
  color: var(--muted);
}

.pay-sub { font-size: 12px; color: var(--faint); }

.ctl-flat { background: none; border: 0; border-radius: 0; padding: 0; margin-bottom: 8px; }

.fld-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.fld {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
}

.fld label { font-size: 13.5px; color: var(--muted); }

.fld-val { display: flex; align-items: baseline; gap: 2px; }
.fld-val .unit { color: var(--faint); font-size: 13px; }
.fld-val input {
  background: none;
  border: 0;
  width: 4.2ch;
  text-align: right;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  border-radius: 6px;
  appearance: textfield;
  -moz-appearance: textfield;
}
.fld-val input::-webkit-outer-spin-button,
.fld-val input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fld-val input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

.ctl-val input.wide { width: 6.8ch; }

.pay-out {
  text-align: center;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  margin-top: 14px;
}

.pay-out-label { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.pay-out-label strong { color: var(--text); font-variant-numeric: tabular-nums; }

.pay-big {
  font-size: clamp(34px, 9vw, 44px);
  font-weight: 640;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.pay-quiet { color: var(--text); }

.pay-stats {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pay-stats strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.pay-warn {
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--accent);
  max-width: 36ch;
  margin-left: auto;
  margin-right: auto;
}
.pay-warn[hidden] { display: none; }

/* ---------- incentives (inside solar mode) ---------- */

.inc { margin-top: 12px; }

.inc-toggle {
  font-size: 12.5px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 5px 13px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.inc-toggle[aria-pressed="true"] { color: var(--solar); border-color: #2E5A75; }

.fld-col { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.fld-col[hidden] { display: none; }
.fld-col .fld { animation: rise 0.3s ease both; }
.fld label small { color: var(--faint); font-size: 11px; font-weight: 400; margin-left: 3px; }

/* ---------- editable-number affordance ---------- */

.ctl-val input, .fld-val input {
  border-bottom: 1px dashed #3A4250;
  border-radius: 6px 6px 0 0;
}
.ctl-val input:focus, .fld-val input:focus { border-bottom-color: transparent; }

/* ---------- copy feedback on PPW rows ---------- */

.ref-row { position: relative; }

.copy-toast {
  position: absolute;
  right: 72px;
  top: 50%;
  transform: translateY(-50%) translateY(3px);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 3px 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.copy-toast.show { opacity: 1; transform: translateY(-50%); }

/* ---------- payment-plan toggles (Payments tab) ---------- */

.plan-head { align-items: center; }
.plan-head .pay-sub { display: block; margin-top: 1px; }

.plan-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  padding: 6px 0 6px 8px;
  color: var(--faint);
  transition: color 0.2s ease, opacity 0.2s ease;
}
.plan-toggle:active .pt-track { transform: scale(0.95); }

.pt-lbl { font-size: 12px; letter-spacing: 0.02em; white-space: nowrap; }

.pt-track {
  width: 34px;
  height: 20px;
  border-radius: 100px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.pt-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--faint);
  transition: transform 0.2s ease, background 0.2s ease;
}

.plan-toggle[aria-pressed="true"] { color: var(--muted); }
.plan-toggle[aria-pressed="true"] .pt-track {
  background: rgba(233, 168, 69, 0.16);
  border-color: rgba(233, 168, 69, 0.55);
}
.plan-toggle[aria-pressed="true"] .pt-knob {
  transform: translateX(14px);
  background: var(--accent);
  box-shadow: 0 0 8px rgba(233, 168, 69, 0.5);
}

/* Section 3's payment doesn't cover interest — plan can't drive the calc */
.plan-toggle.is-invalid { opacity: 0.4; }

/* ---------- plan summary (calc tab, replaces the editable field) ---------- */

#solarManual[hidden] { display: none; }
.plan-summary[hidden] { display: none; }

.plan-summary .ctl-label { display: block; margin-bottom: 6px; }

.plan-summary-text {
  font-size: 15px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.55;
}
