/* ==========================================================================
   Bucks Heat Pumps — Design System
   Brand direction: "engineered warmth"
   Precision heating technology for affluent rural homeowners.
   Tokens first; page styling consumes tokens only — no raw values below
   the tokens block.
   ========================================================================== */

/* Fonts (Sora + Source Serif 4) load via <link> in each page's head with
   display=swap — kept out of this file so CSS parsing never blocks on them. */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* Palette */
  --ink:        #1E2A32;  /* deep slate — primary text, footer */
  --warm-white: #FAF8F5;  /* page background */
  --copper:     #B4642D;  /* accent — decorative uses only (rules, borders, markers) */
  --copper-deep:#8F4E21;  /* copper for TEXT and CTA backgrounds — 6.0:1 on warm-white */
  --copper-cta-hover:#6E3C19; /* CTA hover — 8.5:1 with white text */
  --sage:       #7A8B6F;  /* secondary — decorative only (3.1:1, fails as text) */
  --sage-text:  #5D6B52;  /* sage for text — 4.8:1 on frost */
  --frost:      #E8EDF0;  /* section alternation, cool contrast */

  /* Derived tints (stay within palette family) */
  --ink-soft:   #46555F;  /* muted text on warm-white */
  --line:       #DCE3E7;  /* hairline borders (frost-adjacent) */

  /* Typography */
  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "Source Serif 4", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* Type scale (1.25 ratio, fluid at display sizes) */
  --text-sm:   1rem;      /* 16px floor on mobile; 0.875rem from 768px (see media) */
  --text-base: 1.0625rem;                      /* serif body reads best slightly larger */
  --text-lg:   1.25rem;
  --text-xl:   1.5625rem;
  --text-2xl:  clamp(1.75rem, 1.4rem + 1.5vw, 1.953rem);
  --text-3xl:  clamp(1.75rem, 1.3rem + 2.2vw, 2.441rem);
  --text-4xl:  clamp(2rem, 1.35rem + 3vw, 3.052rem);

  --leading-tight: 1.15;
  --leading-body: 1.65;

  /* Spacing scale — 4px base */
  --space-1:  0.25rem;   /*  4px */
  --space-2:  0.5rem;    /*  8px */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */
  --space-24: 6rem;      /* 96px */

  /* Radius — engineered, not bubbly */
  --radius-sm: 3px;
  --radius-md: 6px;      /* maximum anywhere on the site */

  /* Signature element: temperature gradient rule (ink → copper) */
  --temp-rule: linear-gradient(90deg, var(--ink) 0%, var(--copper) 100%);
  --temp-rule-height: 2px;
  --temp-rule-width: 4.5rem;

  /* Layout */
  --max-width: 72rem;
  --focus-ring: 3px solid var(--copper);
  --focus-offset: 2px;

  /* Motion */
  --transition-quick: 150ms ease;
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--ink);
  background: var(--warm-white);
}

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

.container {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

/* --------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--ink);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-2xl); margin-bottom: var(--space-4); }
h3 { font-size: var(--text-lg); margin-bottom: var(--space-2); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

a { color: var(--copper-deep); }
a:hover { color: var(--copper-cta-hover); }

/* Data callouts — prices, temperatures, flow rates. Mono for precision. */
.data {
  font-family: var(--font-mono);
  font-size: 1em; /* 0.9em from 768px */
  font-weight: 600;
  color: var(--copper-deep);
  white-space: nowrap;
}

/* Signature element: temperature gradient rule.
   Used under H1s and section headers ONLY — no other decoration. */
h1::after {
  content: "";
  display: block;
  width: var(--temp-rule-width);
  height: var(--temp-rule-height);
  margin-top: var(--space-3);
  background: var(--temp-rule);
  border-radius: var(--radius-sm);
}

/* Skip-to-content: visually hidden until keyboard focus */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: var(--warm-white);
  padding: var(--space-3) var(--space-4);
  border-radius: 0 0 var(--radius-md) 0;
  font-family: var(--font-display);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  left: 0;
  color: var(--warm-white);
}

/* --------------------------------------------------------------------------
   4. Buttons & focus
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px; /* tap target */
  padding: var(--space-3) var(--space-6);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition-quick), color var(--transition-quick);
}

.btn-primary {
  background: var(--copper-deep);
  color: var(--warm-white);
}
.btn-primary:hover { background: var(--copper-cta-hover); color: var(--warm-white); }

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}
.btn-secondary:hover { color: var(--copper-deep); border-color: var(--copper-deep); }

/* Visible focus for every interactive element */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex="0"]:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* --------------------------------------------------------------------------
   5. Header & navigation (mobile-first)
   -------------------------------------------------------------------------- */
.site-header {
  background: var(--warm-white);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  padding-block: var(--space-2);
}

/* Tap-to-call — pinned top-right at every viewport width */
.header-phone {
  order: 2;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--warm-white);
  background: var(--copper-deep);
  text-decoration: none;
  white-space: nowrap;
}
.header-phone:hover { background: var(--copper-cta-hover); color: var(--warm-white); }

/* Very narrow screens: drop the decorative icon so the phone keeps its
   top-right slot beside the logo at 16px text */
@media (max-width: 419px) {
  .site-header .container { column-gap: var(--space-2); }
  .logo { font-size: 1rem; }
  .header-phone { padding-inline: var(--space-2); }
  .header-phone span[aria-hidden] { display: none; }
}

/* Mobile: nav's toggle and menu participate directly in the header row,
   so the order is logo | phone (top-right) | toggle, menu drops below. */
.main-nav { display: contents; }
.nav-toggle { order: 3; }
.main-nav ul { order: 4; flex-basis: 100%; }

.logo {
  order: 1;
  display: inline-flex;
  align-items: center;
  min-height: 44px; /* tap target */
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--ink);
  text-decoration: none;
}

.nav-toggle {
  display: block;
  background: none;
  border: 1px solid var(--ink-soft);
  border-radius: var(--radius-sm);
  min-height: 44px; /* tap target */
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--ink);
  cursor: pointer;
}

.main-nav ul {
  list-style: none;
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding-block: var(--space-3);
}
.main-nav ul.open { display: flex; }

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px; /* tap target */
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.main-nav a:hover { color: var(--copper-deep); }

.nav-cta {
  background: var(--copper-deep);
  color: var(--warm-white) !important;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
}
.nav-cta:hover { background: var(--copper-cta-hover); }

/* --------------------------------------------------------------------------
   6. Sections
   -------------------------------------------------------------------------- */
section { padding-block: var(--space-12); }

.hero {
  background: var(--frost);
  padding-block: var(--space-6) var(--space-8); /* fits one 360x740 viewport with header */
}
.hero-sub {
  max-width: 44rem;
  margin-block: var(--space-3) var(--space-4); /* larger from 768px */
  font-size: var(--text-base); /* var(--text-lg) from 768px */
  color: var(--ink-soft);
}
.hero-ctas { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.cta-center { justify-content: center; }

/* Inline trust markers under the hero CTAs */
.hero-trust {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  margin-top: var(--space-4); /* space-6 from 768px */
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--sage-text);
}
.hero-trust li { display: flex; align-items: center; gap: var(--space-2); }
.hero-trust li + li::before { content: "·"; color: var(--ink-soft); }

/* Alternating section background */
.alt { background: var(--frost); }

/* Internal page hero (smaller than homepage hero) */
.page-hero {
  background: var(--frost);
  padding-block: var(--space-8); /* var(--space-12) from 768px */
}
.page-hero h1 { font-size: var(--text-3xl); }

.breadcrumb {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--ink-soft);
  margin-bottom: var(--space-4);
}

/* Freshness line on guides */
.last-updated {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--ink-soft);
  margin-bottom: var(--space-3);
}
.breadcrumb a {
  color: var(--ink-soft);
  display: inline-block;
  padding-block: var(--space-3); /* 44px hit area */
  margin-block: calc(-1 * var(--space-3));
}
.breadcrumb span { color: var(--ink-soft); padding-inline: var(--space-1); }

/* Long-form article layout */
.prose { padding-block: var(--space-12); }
.prose .container > p,
.prose .faq-answer { max-width: 46rem; }
.prose h2 { margin-top: var(--space-12); }
.prose h2:first-of-type { margin-top: 0; }
.prose .process-steps,
.prose .compare { margin-bottom: var(--space-8); }
.prose details { border-bottom: 1px solid var(--line); }
.prose details:first-of-type { border-top: 1px solid var(--line); }
.prose summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 44px;
  padding: var(--space-4) var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.prose summary::-webkit-details-marker { display: none; }
.prose summary::after {
  content: "+";
  font-family: var(--font-mono);
  color: var(--copper-deep);
  flex-shrink: 0;
}
.prose details[open] summary::after { content: "–"; }
.prose .faq-answer {
  padding: 0 var(--space-2) var(--space-4);
  color: var(--ink-soft);
}

/* Contact page: form + info columns */
.contact-body { padding-block: var(--space-12); }
.contact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-12);
}
.contact-grid > * { min-width: 0; } /* prevent grid blowout from long unbreakable links */
.contact-info-col a { overflow-wrap: anywhere; }
.contact-info-col h3 {
  margin-top: var(--space-8);
  margin-bottom: var(--space-2);
}
.contact-info-col address { font-style: normal; margin-bottom: var(--space-4); }
.contact-info-col .process-steps { margin-top: var(--space-4); grid-template-columns: 1fr; gap: var(--space-4); }
.contact-info-col .process-steps h3 { margin-top: 0; }

.quote-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-top: var(--space-6);
}
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field label {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
}
.field .optional { color: var(--ink-soft); font-weight: 400; }
.quote-form input,
.quote-form select,
.quote-form textarea {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--warm-white);
  border: 1px solid var(--ink-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  min-height: 44px; /* tap target */
}
.quote-form textarea { min-height: auto; resize: vertical; }
.quote-form button { justify-self: start; }
.form-note {
  font-size: var(--text-sm);
  color: var(--ink-soft);
  margin: 0;
}

/* Mobile-only sticky tap-to-call bar */
.sticky-call {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: var(--space-2) var(--space-4);
  background: var(--warm-white);
  border-top: 1px solid var(--line);
}
.sticky-call .btn { width: 100%; justify-content: center; }
/* keep page content clear of the bar */
body:has(.sticky-call) { padding-bottom: var(--space-16); }

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  margin-top: var(--space-6);
}
.card {
  background: var(--frost);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  border-top: var(--temp-rule-height) solid var(--sage);
}
.card a {
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
  padding-block: var(--space-3); /* 44px hit area */
  margin-block: calc(-1 * var(--space-3));
}
.card a:hover { color: var(--copper-deep); }
.card p { color: var(--ink-soft); font-size: var(--text-base); }

.grant-deadline {
  background: var(--ink);
  color: var(--frost);
}
.grant-deadline h2 { color: var(--warm-white); }
.grant-deadline p { max-width: 46rem; margin-bottom: var(--space-6); }
.grant-deadline .data { color: var(--warm-white); }

.why-switch p { max-width: 46rem; }

/* Running-cost comparison — mono data on hairline table */
.compare { margin-top: var(--space-6); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) {
  /* 3+ column tables keep readable columns and scroll instead of crushing */
  .table-scroll:has(th:nth-child(3)) .compare-table { min-width: 560px; }
  .compare:has(th:nth-child(3))::before {
    content: "Swipe to see the full table \2192";
    display: block;
    font-family: var(--font-display);
    font-size: var(--text-sm);
    color: var(--ink-soft);
    margin-bottom: var(--space-2);
  }
}
.compare figcaption {
  font-size: var(--text-sm);
  color: var(--ink-soft);
  margin-bottom: var(--space-3);
  max-width: 40rem;
}
.compare-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--warm-white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.compare-table th,
.compare-table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
}
.compare-table thead th {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  background: var(--frost);
}
.compare-table tbody th[scope="row"],
.compare-table tfoot th[scope="row"] {
  font-family: var(--font-body);
  font-weight: 600;
}
.compare-table tfoot td,
.compare-table tfoot th { border-bottom: none; background: var(--frost); }
.compare-note {
  font-size: var(--text-sm);
  color: var(--ink-soft);
  margin-top: var(--space-3);
}

/* Process steps */
.process-steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  margin-top: var(--space-6);
}
.process-steps li { counter-increment: step; }
.process-steps h3::before {
  content: counter(step, decimal-leading-zero);
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--copper-deep);
  margin-bottom: var(--space-1);
}
.process-steps p { color: var(--ink-soft); font-size: var(--text-base); }

.areas p { max-width: 46rem; color: var(--ink-soft); }

/* FAQ — details/summary, 44px+ tap targets */
.faq details {
  border-bottom: 1px solid var(--line);
}
.faq details:first-of-type { border-top: 1px solid var(--line); }
.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 44px;
  padding: var(--space-4) var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  font-family: var(--font-mono);
  color: var(--copper-deep);
  flex-shrink: 0;
}
.faq details[open] summary::after { content: "–"; }
.faq-answer {
  padding: 0 var(--space-2) var(--space-4);
  max-width: 46rem;
  color: var(--ink-soft);
}

.cta-final { text-align: center; }
.cta-final p {
  max-width: 40rem;
  margin-inline: auto;
  margin-bottom: var(--space-6);
  color: var(--ink-soft);
}

.site-footer {
  background: var(--ink);
  color: var(--frost);
  padding-block: var(--space-12);
  font-size: var(--text-sm);
}
.site-footer a {
  color: var(--frost);
  display: inline-block;
  padding-block: var(--space-3); /* 44px+ hit area */
  margin-block: calc(-1 * var(--space-2));
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
}
.footer-grid > * { min-width: 0; }
.site-footer address a { overflow-wrap: anywhere; }
.footer-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--warm-white);
  margin-bottom: var(--space-2);
}
.footer-desc {
  max-width: 26rem;
  margin-bottom: var(--space-2);
}
.footer-heading {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--warm-white);
  margin-bottom: var(--space-2);
}
.site-footer address { font-style: normal; }
.footer-links { list-style: none; }
.footer-legal {
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 1px solid var(--ink-soft);
  color: var(--frost);
}

/* --------------------------------------------------------------------------
   7. Breakpoints — mobile-first: 480 / 768 / 1100
   -------------------------------------------------------------------------- */
@media (min-width: 480px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .process-steps { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
  :root { --text-sm: 0.875rem; }
  .data { font-size: 0.9em; }
  .page-hero { padding-block: var(--space-12); }
  .hero-sub { font-size: var(--text-lg); margin-block: var(--space-4) var(--space-6); }
  .hero-trust { margin-top: var(--space-6); }

  .container { padding-inline: var(--space-6); }

  /* Sticky call bar is mobile-only; header phone takes over */
  .sticky-call { display: none; }
  body:has(.sticky-call) { padding-bottom: 0; }

  .contact-grid { grid-template-columns: 3fr 2fr; }
  .quote-form { grid-template-columns: 1fr 1fr; }
  .field-wide, .quote-form button, .form-note { grid-column: 1 / -1; }

  .nav-toggle { display: none; }
  .logo { font-size: var(--text-lg); }
  /* Tablet: logo left + phone top-right on row 1; nav on its own row */
  .main-nav ul {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-6);
    padding-block: 0;
  }

  section { padding-block: var(--space-16); }
  .hero { padding-block: var(--space-24); }
}

@media (min-width: 1100px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .process-steps { grid-template-columns: repeat(4, 1fr); }
  .footer-grid { grid-template-columns: 2fr 2fr 1.2fr 1.2fr; }
}

/* --------------------------------------------------------------------------
   8. Motion preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
