/* Theme + layout based on the example aesthetic, now with larger vertical rhythm,
   section headers, and a property-type select.  */

/* =========================
   Design Tokens (Theme)
   ========================= */
:root {
  /* Brand palette */
  --brand-900: #0b3c5d;
  --brand-700: #155b8a;
  --brand:     #1d65a6;
  --brand-600: #165a96;

  /* Neutral / text */
  --ink-900: #0f172a;
  --ink:     #1f2a37;
  --muted:   #5b6b7b;

  /* Surfaces */
  --surface:   #ffffff;
  --bg:        #f6f9fc;
  --accent-bg: #eef5fc;

  /* UI chrome */
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  /* Status */
  --success: #0f766e;
  --warning: #b45309;

  /* Spacing scale */
  --space-1: 6px;
  --space-2: 12px;
  --space-3: 18px;
  --space-4: 24px;   /* ≈ one "empty line" */
  --space-5: 32px;
  --space-6: 40px;

  /* Layout */
  --container-max: 1200px;
  --radius: 12px;
  --shadow-elev: 0 8px 34px rgba(2, 6, 23, 0.06);
}

/* =========================
   Global Resets
   ========================= */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  padding: var(--space-5);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* "Empty line" between text sections */
p + p { margin-top: var(--space-4); }

/* Stack utilities for consistent vertical rhythm */
.stack { --stack-space: var(--space-4); }
.stack > * + * { margin-block-start: var(--stack-space); }
.stack--lg  { --stack-space: var(--space-5); }
.stack--xl  { --stack-space: var(--space-6); }
.stack--xxl { --stack-space: calc(var(--space-6) + 8px); }

/* =========================
   Container + Two-Column Layout
   ========================= */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  background: var(--surface);
  padding: var(--space-5);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-elev);
}

h1 {
  margin: 0;
  font-size: clamp(24px, 2.4vw, 32px);
  font-weight: 800;
  letter-spacing: .1px;
  color: var(--brand-900);
}

.page-header > p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

/* Grid for main / aside */
.page-grid {
  display: grid;
  grid-template-columns: 1fr; /* Map moved below results */
  gap: var(--space-6);
  align-items: start;
  margin-top: var(--space-5);
}
.providers-section {
  margin-top: var(--space-5);
  margin-bottom: var(--space-3);
}
.providers-section .providers-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-3);
  align-items: center;
}
.providers-section h2.providers-title {
  margin: 0;
  font-size: 22px;
  font-weight: 400;     /* preamble not bold */
  color: var(--ink-900); /* neutral ink color */
}
.providers-section .providers-agency {
  font-weight: 800;      /* agency name stands out */
  color: var(--brand-900); /* brand color for emphasis */
}
.providers-section .subline {
  margin-top: 6px;
  color: #444;
}
.providers-section .agency-logo { height: 78px; width: auto; max-width: 320px; }
.providers-section a.logo-link { display: inline-flex; align-items: center; }
.sticky { position: sticky; top: 16px; }

/* =========================
   Controls (Search)
   ========================= */
.controls {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

/* Tighten space between intro text and search box */
.page-header .search-intro + .controls { margin-top: 0 !important; }

input[type="text"] {
  flex: 1;
  width: 100%;
  padding: 14px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 15px;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="text"]::placeholder { color: #98a2b3; }
input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29,101,166,0.15);
}

button {
  background: var(--brand);
  color: #fff;
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: .2px;
  transition: background-color .15s ease, transform .05s ease, box-shadow .15s ease;
}
button:hover { background: var(--brand-600); }
button:active { transform: translateY(1px); }
button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Autocomplete dropdown (custom, shows ZIP) */
.ac-list {
  position: absolute;
  z-index: 1000;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16,24,40,0.12);
  overflow: hidden;
}
.ac-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
}
.ac-item:last-child { border-bottom: 0; }
.ac-item[aria-selected="true"], .ac-item:hover {
  background: #f5f9ff;
}
.ac-main { font-weight: 600; color: var(--ink-900); }
.ac-secondary { color: #475467; font-size: 13px; }
.ac-zip { margin-left: auto; font-variant-numeric: tabular-nums; color: #1d65a6; font-weight: 700; }

/* Ensure controls container can anchor absolute dropdown */
.controls { position: relative; }

/* =========================
   Filters (Property Type)
   ========================= */
.filters {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.form-label {
  display: block;
  font-weight: 700;
  color: var(--ink-900);
  margin-bottom: var(--space-1);
}
.form-label.required::after {
  content: " *";
  color: red;
}
select#building-type {
  appearance: none;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 15px;
  color: var(--ink);
}
select#building-type:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29,101,166,0.15);
}
.form-help {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;               /* keep help text tight under field */
}

/* =========================
   Update Form
   ========================= */
#update-form input[type="text"],
#update-form input[type="email"],
#update-form input[type="tel"],
#update-form input[type="url"],
#update-form input[type="number"],
#update-form input[type="date"],
#update-form textarea,
#update-form select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 15px;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}

#update-form input[type="file"] {
  font-size: 15px;
}

#update-form textarea {
  min-height: 120px;
  resize: vertical;
}

#update-form input:focus,
#update-form select:focus,
#update-form textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29,101,166,0.15);
}

fieldset.section-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
}

fieldset.section-block legend {
  font-weight: 800;
  color: var(--brand-900);
  padding: 0 var(--space-1);
}

#update-form .form-options {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
}

#update-form .form-options--column {
  flex-direction: column;
  align-items: flex-start;
}

#update-form .form-options label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* =========================
   Result Card
   ========================= */
.result-box { margin-top: 0; }

.card {
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: 12px;
  padding: var(--space-5);
}

/* Two-column section inside results card */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}
/* Ensure equal split even with long content inside columns */
.two-col > * { min-width: 0; }

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.card__title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--brand-900);
}

.updated {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

/* Plain intro text inside blue card background */
.rebate-intro {
  margin: 0 0 var(--space-3) 0;
  color: var(--ink);
}

/* Policy intro on blue card background */
.policy-intro {
  margin: 0 0 var(--space-3) 0;
  color: var(--ink);
}

/* Section headers inside the card */
.section-header {
  margin: var(--space-5) 0 var(--space-2) 0; /* ensure a visible blank line above */
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--brand-900);
}
.section-block + .section-block {
  margin-top: var(--space-5);                /* extra room between blocks */
}

/* Key / Value grid */
.kv {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0 var(--space-4) 0;
}
.kv .key {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}
.kv .val {
  color: var(--ink);
  line-height: 1.6;
}

/* Inline status chips for values */
.status { display: inline-block; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: #fff; font-size: 0.9rem; }
.status--muted { color: var(--muted); }
.status--ok { color: var(--success); border-color: rgba(15,118,110,.35); background: #f0fdf4; }
.status--warn { color: var(--warning); border-color: rgba(180,83,9,.35); background: #fffbeb; }

/* Notes variants */
.note--info { background: #fff; border-left: 4px solid var(--brand); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); overflow-wrap: anywhere; }
.updated--footer { color: var(--muted); font-size: 0.9rem; margin-top: var(--space-2); }

/* Emphasis stripe for total */
.callout {
  margin: var(--space-3) 0 var(--space-4) 0;
  padding: 12px 14px;
  background: #fff;
  border: 1px dashed var(--border);
  border-left: 4px solid var(--warning);
  border-radius: 10px;
  font-weight: 700;
  color: var(--ink-900);
}

/* Agency logo treatment */
.header-logo { display: flex; align-items: center; }
.agency-logo {
  height: 78px;
  width: auto;
  max-width: 320px;
  object-fit: contain;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  display: block;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

/* Last updated footer */
.updated--footer {
  display: block;
  margin-top: var(--space-4);
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}
/* As-of label shown at top-left of section */
.updated--header {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 var(--space-2) 0;
}

/* Subtle notes */
.note { color: var(--muted); font-size: 13px; margin-top: var(--space-2); }
/* Powered by branding inline layout */
.powered-by { display: inline-flex; align-items: center; gap: 8px; }
/* Ensure the brand link packs logo + text together */
.powered-by a { display: inline-flex; align-items: center; gap: 6px; }
.powered-logo { height: 20px; width: auto; display: inline-block; }

/* Dashboard charts */
.chart-block {
  margin-top: var(--space-4);
  max-width: 400px;
}

.data-warning {
  color: var(--warning);
  font-weight: 700;
}

/* =========================
   Link Buttons (Rebates / AB1572)
   ========================= */
.link-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.btn {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .5rem;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  min-height: 56px;
  white-space: normal;
  text-decoration: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink-900);
  font-weight: 700;
  transition: box-shadow .15s ease, transform .1s ease, border-color .15s ease, background-color .15s ease;
}
.btn:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  transform: translateY(-1px);
}
.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.btn__text { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.btn__label { font-weight: 800; text-wrap: balance; }
.btn__sub   { font-size: .875rem; font-weight: 600; opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon { font-size: 1rem; line-height: 1; }

/* Variants */
.btn--primary { background: var(--brand-900); color: #fff; border-color: var(--brand-900); }
.btn--outline { background: #fff; color: var(--ink-900); border: 1.5px solid var(--border-strong); }
.btn--info    { background: #ffffff; border: 1.5px solid var(--border-strong); color: var(--ink-900); }

/* =========================
   Estimator / Map
   ========================= */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.tool-btn {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-900);
  cursor: pointer;
  font-weight: 700;
  transition: box-shadow .15s ease, border-color .15s ease, transform .05s ease;
}
.tool-btn:hover { box-shadow: 0 1px 3px rgba(0,0,0,.08); border-color: var(--border-strong); }
.tool-btn:active { transform: translateY(1px); }
.tool-btn--primary { background: var(--brand); color: #fff; border-color: var(--brand); }

.map {
  width: 100%;
  height: clamp(380px, 66vh, 720px);
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #e5e7eb;
}

.map-intro {
  margin: 0 0 var(--space-3) 0;
  color: var(--ink);
}

.stats { margin-top: var(--space-2); }
.pill {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  margin-right: 6px;
  font-size: 0.9rem;
}
/* Address pill should not wrap awkwardly */
#address-badge { white-space: nowrap; }

/* =========================
   Accessibility Helpers
   ========================= */
.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden; clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap; clip-path: inset(50%);
}

/* =========================
   Responsive
   ========================= */
@media (max-width: 980px) {
  .page-grid { grid-template-columns: 1fr; }
  .sticky { position: static; top: auto; }
  .kv { grid-template-columns: 1fr; }
  .card__header { flex-direction: column; align-items: flex-start; }
  .two-col { grid-template-columns: 1fr; }
  .providers-section .providers-header { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .link-row { grid-template-columns: 1fr; }
  .agency-logo { height: 66px; max-width: 240px; }
}

/* =========================
   Footer
   ========================= */
.page-footer {
  text-align: center;
}

.links-section {
  margin-top: var(--space-5);
}

/* Full-width Links & Disclaimer */
.links-disclaimer {
  margin: var(--space-5) 0 0 0;
  padding: var(--space-5) 0;
  background: var(--accent-bg);
  border-top: 1px solid var(--border);
}
.links-disclaimer__inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

/* =========================
   Logo Overrides (Disable Logos)
   ========================= */
/* Hide provider logos throughout the site */
.header-logo,
.agency-logo,
.providers-section a.logo-link {
  display: none !important;
}
