/* =====================================================
   DESIGN SYSTEM — soft (neumorphic) surfaces
   One cool-grey surface; depth comes only from paired
   light/shade shadows. Brand color is reserved for
   actions and key figures. Per-company colors are set by
   brand.js on --brand, --brand-dark and --brand-accent.
===================================================== */

:root {
  color-scheme: light;

  /* Brand (overridden per company) */
  --brand:        #1f7ae0;
  --brand-dark:   #0b2f63;
  --brand-accent: #f5b301;
  --brand-ink:    color-mix(in srgb, var(--brand) 72%, #1e2a38);  /* brand text on surface */
  --on-brand:     #ffffff;

  /* Surface + depth */
  --surface:  #e7ecf2;
  --shade:    #c3ccd8;
  --light:    #ffffff;
  --raised:     7px 7px 16px var(--shade), -7px -7px 16px var(--light);
  --raised-sm:  4px 4px 9px var(--shade), -4px -4px 9px var(--light);
  --inset:      inset 4px 4px 9px var(--shade), inset -4px -4px 9px var(--light);
  --inset-sm:   inset 2px 2px 5px var(--shade), inset -2px -2px 5px var(--light);
  --brand-lift: 5px 5px 12px color-mix(in srgb, var(--brand-dark) 30%, var(--shade)), -5px -5px 12px var(--light);

  /* Ink */
  --ink:    #1e2a38;
  --ink-2:  #4c5a6c;
  --ink-3:  #66748a;
  --danger: #b42318;
  --ok:     #18794e;

  /* Type */
  --font-display: "Gabarito", "Figtree", system-ui, sans-serif;
  --font-body:    "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data:    "Azeret Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  /* Shape + space */
  --r-lg: 24px;
  --r-md: 16px;
  --r-sm: 12px;
  --gutter: clamp(16px, 4vw, 40px);

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font: 400 16px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}

p { margin: 0; }

a { color: var(--brand-ink); }

img, svg { display: block; max-width: 100%; }

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, white);
  outline-offset: 3px;
}

.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;
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Brand-bound content stays hidden until brand.js applies the company config */
/* platform wordmark: "You" in sunshine orange */
.wm-you {
  color: #ff8a00;
  background: linear-gradient(100deg, #ffb800, #ff7a00);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 900;
}

html.brand-loading [data-brand],
html.brand-loading [data-brand-tpl],
html.brand-loading [data-brand-logo] { visibility: hidden; }

/* ---------- surfaces ---------- */

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--raised);
}

.well {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--inset);
}

/* --logo-scale: the logo size each company picks in Settings (customer pages) */
.logo {
  display: block;
  height: calc(40px * var(--logo-scale, 1));
  width: auto;
  max-width: min(calc(180px * var(--logo-scale, 1)), 62vw);
  object-fit: contain;
}

/* ---------- type helpers ---------- */

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.fine { font-size: 13px; line-height: 1.5; color: var(--ink-3); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--raised-sm);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
  transition: box-shadow 0.18s var(--ease), color 0.18s var(--ease), background-color 0.18s var(--ease);
}

.btn:hover { color: var(--brand-ink); }
.btn:active { box-shadow: var(--inset-sm); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: var(--brand-lift);
}

.btn-primary:hover {
  color: var(--on-brand);
  background: color-mix(in srgb, var(--brand) 86%, black);
}

.btn-primary:active {
  box-shadow: inset 3px 3px 7px color-mix(in srgb, var(--brand-dark) 55%, transparent);
}

.btn-lg { min-height: 56px; padding: 0 28px; font-size: 16px; border-radius: 16px; }
/* full-width buttons may wrap long text onto two lines on small phones */
.btn-block { width: 100%; white-space: normal; text-align: center; line-height: 1.25; }
.btn { max-width: 100%; }

.btn-icon {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
}

.btn-quiet {
  background: transparent;
  box-shadow: none;
  color: var(--ink-2);
  padding: 0 10px;
  min-height: 40px;
}

.btn-quiet:hover { color: var(--brand-ink); }
.btn-quiet:active { box-shadow: var(--inset-sm); }

.btn-danger:hover { color: var(--danger); }

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

.field { display: grid; gap: 8px; }

.label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.hint { font-size: 13px; color: var(--ink-3); }

.field-error { font-size: 13px; font-weight: 600; color: var(--danger); }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--inset);
  font-size: 16px;   /* 16px stops iOS zooming into the field */
  color: var(--ink);
}

.textarea { min-height: 120px; padding: 14px 16px; resize: vertical; line-height: 1.5; }

.input::placeholder,
.textarea::placeholder { color: #8a96a6; }

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  box-shadow: var(--inset), 0 0 0 3px color-mix(in srgb, var(--brand) 40%, transparent);
}

.input[aria-invalid="true"] {
  box-shadow: var(--inset), 0 0 0 2px color-mix(in srgb, var(--danger) 60%, transparent);
}

.select {
  appearance: none;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%234c5a6c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  cursor: pointer;
}

/* Input with a fixed prefix or suffix, e.g. ₱ [ 5,000 ] */
.affix {
  display: flex;
  align-items: center;
  border-radius: 14px;
  box-shadow: var(--inset);
  background: var(--surface);
}

.affix:focus-within { box-shadow: var(--inset), 0 0 0 3px color-mix(in srgb, var(--brand) 40%, transparent); }

.affix > span {
  padding: 0 4px 0 18px;
  font-family: var(--font-data);
  font-weight: 600;
  color: var(--ink-3);
}

.affix > span:last-child { padding: 0 18px 0 4px; }

/* inputs inside an affix may shrink below their default width on small phones */
.affix .input {
  min-width: 0;
  box-shadow: none;
  background: transparent;
  padding-left: 8px;
}

.affix .input:focus { box-shadow: none; }

/* Segmented control: a pressed track holding raised options */
.segmented {
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 16px;
  box-shadow: var(--inset);
}

.segmented button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
  transition: box-shadow 0.18s var(--ease), color 0.18s var(--ease);
}

.segmented button:hover { color: var(--ink); }

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  box-shadow: var(--raised-sm);
  color: var(--brand-ink);
}

/* Toggle switch: <input type="checkbox" class="toggle"> */
.toggle {
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--inset-sm);
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}

.toggle::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 2px 2px 4px var(--shade), -1px -1px 3px var(--light);
  transition: transform 0.2s var(--ease);
}

.toggle:checked { background: var(--brand); box-shadow: inset 2px 2px 5px color-mix(in srgb, var(--brand-dark) 45%, transparent); }
.toggle:checked::before { transform: translateX(20px); background: #fff; box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.25); }

/* Checkbox */
.check {
  appearance: none;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--inset-sm);
  cursor: pointer;
  display: grid;
  place-content: center;
}

.check::after {
  content: "";
  width: 11px;
  height: 6px;
  border: solid #fff;
  border-width: 0 0 2.4px 2.4px;
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
}

.check:checked { background: var(--brand); box-shadow: none; }
.check:checked::after { opacity: 1; }

/* Chips: small quick-pick buttons */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }

.chip {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--raised-sm);
  color: var(--ink-2);
  font-family: var(--font-data);
  font-size: 13px;
  font-weight: 600;
  transition: box-shadow 0.18s var(--ease), color 0.18s var(--ease);
}

.chip:hover { color: var(--brand-ink); }

.chip[aria-pressed="true"] {
  box-shadow: var(--inset-sm);
  color: var(--brand-ink);
}

/* ---------- dialog (centered on desktop, bottom sheet on phones) ---------- */

.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(30, 42, 56, 0.28);
  overflow: auto;
}

.dialog::backdrop {
  background: rgba(30, 42, 56, 0.38);
  backdrop-filter: blur(3px);
}

.dialog[open] { animation: dialog-in 0.28s var(--ease); }

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

@media (max-width: 640px) {
  .dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }

  @keyframes dialog-in {
    from { transform: translateY(100%); }
    to   { transform: none; }
  }
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translate(-50%, 24px);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- lead form (lead.js) ---------- */

.lead { padding: 20px 24px 28px; }

.lead-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 20px;
}

.lead-head .logo { height: calc(36px * var(--logo-scale, 1)); }

.lead-form { display: grid; gap: 18px; }

.lead-intro { display: grid; gap: 8px; }
.lead-intro h2 { font-size: 26px; }
.lead-intro p { color: var(--ink-2); font-size: 15px; }

.lead-estimate { padding: 14px 16px; display: grid; gap: 6px; }

.lead-estimate-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  font-size: 15px;
  color: var(--ink-2);
}

.lead-estimate-row b { color: var(--ink); font-weight: 600; }

.lead-consent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  cursor: pointer;
}

.lead-form-error { margin-top: -4px; }

.lead-done {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px 0 8px;
  text-align: center;
}

.lead-done h2 { font-size: 26px; }
.lead-done p { max-width: 34ch; color: var(--ink-2); }

.lead-done-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin-bottom: 8px;
  border-radius: 50%;
  box-shadow: var(--raised);
  color: var(--ok);
}

.lead-done-mark .icon { width: 32px; height: 32px; stroke-width: 2.2; }

.lead-done .btn { margin-top: 8px; }

/* ---------- meter (calc.js setMeter) ---------- */

.meter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 20px;
  box-shadow: var(--inset);
  font-family: var(--font-data);
  font-weight: 600;
  font-size: var(--meter-size, 44px);
  line-height: 1;
  color: var(--ink);
  max-width: 100%;
}

.meter-unit {
  font-size: 0.55em;
  color: var(--ink-3);
}

.meter-digits { display: inline-flex; align-items: center; gap: 0.08em; }

.meter-cell {
  display: inline-block;
  height: 1.2em;
  width: 0.78em;
  overflow: hidden;
  border-radius: 0.16em;
  background: var(--surface);
  box-shadow: 1px 1px 3px var(--shade), -1px -1px 3px var(--light);
  text-align: center;
}

.meter-strip {
  display: flex;
  flex-direction: column;
  transform: translateY(calc(var(--d, 0) * -1.2em));
  transition: transform 0.7s var(--ease);
}

.meter-strip > span { height: 1.2em; line-height: 1.2em; }

.meter-sep { width: 0.32em; text-align: center; color: var(--ink-3); }

/* ---------- energy flow (calc.js mountFlow / setFlow) ----------
   off  : a muted, still scene
   on   : the sun ignites, the panel catches the light, the home glows
          and energy travels sun → panel → home (→ grid when exporting)
   grid : solar switched off; the panel is dull and red energy flows
          from the grid into the home (everything is bought) */

.flow {
  --flow-speed: 1.2s;
  --export-opacity: 0;
  --buy: #d4532b;
  display: grid;
  gap: 4px;
  padding: 12px 10px 10px;
  border-radius: var(--r-md);
  box-shadow: var(--inset-sm);
}

.flow-art { width: 100%; height: auto; overflow: visible; }

.flow-label { font: 600 11px var(--font-body); fill: var(--ink-3); }

.flow-caption {
  min-height: 2.6em;
  padding: 0 6px;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  color: var(--ink-2);
}

.flow[data-state="grid"] .flow-caption { color: var(--buy); font-weight: 600; }

.flow-path {
  fill: none;
  stroke: var(--shade);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-dasharray: 0.1 10;
  opacity: 0;
  transition: stroke 0.4s var(--ease), opacity 0.4s var(--ease);
}

.flow-sun-glow, .flow-home-glow { opacity: 0; transition: opacity 0.6s var(--ease); }
.flow-sun, .flow-home, .flow-grid, .flow-panel { transition: filter 0.5s var(--ease), opacity 0.5s var(--ease); }

.flow-panel-grid  { fill: none; stroke: #fff; stroke-width: 0.9; opacity: 0.45; }
.flow-panel-shine { opacity: 0; }
.flow-panel-stand { fill: none; stroke: #8a95a5; stroke-width: 3; stroke-linecap: round; }

/* home battery: shown for hybrid systems, gently "charging" while solar runs */
.flow-battery { opacity: 0; transition: opacity 0.4s var(--ease); }
.flow[data-battery="on"] .flow-battery { opacity: 1; }
.flow[data-battery="on"][data-state="on"] .flow-battery { animation: flow-charge 2s ease-in-out infinite; }
.flow[data-battery="on"][data-state="grid"] .flow-battery { filter: grayscale(1); opacity: 0.5; }
@keyframes flow-charge { 0%, 100% { opacity: 1; } 50% { opacity: 0.65; } }

/* off */
.flow[data-state="off"] .flow-sun,
.flow[data-state="off"] .flow-panel,
.flow[data-state="off"] .flow-home,
.flow[data-state="off"] .flow-grid { filter: grayscale(1); opacity: 0.55; }

/* on */
.flow[data-state="on"] .flow-sun-glow  { opacity: 1; animation: flow-glow 3.2s ease-in-out infinite; }
.flow[data-state="on"] .flow-home-glow { opacity: 1; }
.flow[data-state="on"] .flow-path--sun,
.flow[data-state="on"] .flow-path--home { opacity: 1; animation: flow-dash var(--flow-speed) linear infinite; }
.flow[data-state="on"] .flow-path--sun  { stroke: #f2a900; }
.flow[data-state="on"] .flow-path--home { stroke: var(--brand); }
.flow[data-state="on"] .flow-path--grid {
  opacity: var(--export-opacity);
  stroke: var(--brand-accent);
  animation: flow-dash var(--flow-speed) linear infinite;
}
.flow[data-state="on"] .flow-sun-img { animation: flow-bob 4s ease-in-out infinite; }

/* grid: solar off, buying everything */
.flow[data-state="grid"] .flow-panel { filter: grayscale(1) brightness(0.9); opacity: 0.45; }
.flow[data-state="grid"] .flow-sun   { opacity: 0.8; }
.flow[data-state="grid"] .flow-home-glow { opacity: 0.5; }
.flow[data-state="grid"] .flow-path--buy {
  opacity: 1;
  stroke: var(--buy);
  animation: flow-dash 0.9s linear infinite;
}

/* activation */
.flow.is-igniting .flow-sun-img     { animation: flow-ignite 0.9s var(--ease), flow-bob 4s ease-in-out 0.9s infinite; }
.flow.is-igniting .flow-panel-shine { animation: flow-shine 1s ease-out 0.45s; }
.flow.is-igniting .flow-home-glow   { animation: flow-light 1.1s var(--ease) 0.6s both; }
.flow.is-pulse .flow-sun-img        { animation: flow-pulse 0.5s var(--ease); }

.flow-sun-img { transform-box: fill-box; transform-origin: center; }
.flow-sun-glow { transform-box: fill-box; transform-origin: center; }

@keyframes flow-dash   { to { stroke-dashoffset: -20.2; } }
@keyframes flow-glow   { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes flow-bob    { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-2px) rotate(6deg); } }
@keyframes flow-ignite { 0% { transform: scale(0.6); filter: grayscale(1); } 60% { transform: scale(1.18); } 100% { transform: scale(1); filter: none; } }
@keyframes flow-shine  { 0% { opacity: 0; } 35% { opacity: 0.85; } 100% { opacity: 0; } }
@keyframes flow-light  { 0% { opacity: 0; } 60% { opacity: 1; } 80% { opacity: 0.7; } 100% { opacity: 1; } }
@keyframes flow-pulse  { 50% { transform: scale(1.12); } }

@media (prefers-reduced-motion: reduce) {
  .flow .flow-path { stroke-dasharray: none; }
}

/* ---------- demo banner (brand.js) ---------- */

.demo-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 2px 10px;
  padding: 10px var(--gutter);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.demo-banner b { font-weight: 700; }
.demo-banner span { color: rgba(255, 255, 255, 0.78); }

/* ---------- calculator unavailable (paused or expired demo) ---------- */

.unavailable {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  min-height: 100dvh;
  padding: 24px;
  text-align: center;
}

.unavailable .logo { height: calc(48px * var(--logo-scale, 1)); margin-bottom: 8px; }
.unavailable h1 { font-size: 24px; }
.unavailable p { color: var(--ink-2); max-width: 36ch; }
