/* Treehouse Insurance — design system */

:root {
  --bg: #F7F3EB;
  --bg-alt: #EFE8D9;
  --surface: #FFFFFF;
  --ink: #1C2A1E;
  --ink-2: #3A4A3C;
  --ink-muted: #6B7A6E;
  --line: #D9D0BC;
  --line-soft: #E6DFCE;

  --primary: #1F3A29;       /* deep forest */
  --primary-600: #2A4A35;
  --primary-300: #5C7A63;
  --primary-100: #C8D4C9;

  --accent: #C8841A;        /* warm amber */
  --accent-soft: #F2DBA8;

  --danger: #8A2B1F;

  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 20px;
  --radius-xl: 32px;

  --shadow-sm: 0 1px 2px rgba(28,42,30,.06), 0 1px 1px rgba(28,42,30,.04);
  --shadow: 0 4px 14px rgba(28,42,30,.08), 0 2px 4px rgba(28,42,30,.04);
  --shadow-lg: 0 24px 60px -20px rgba(28,42,30,.25), 0 8px 20px -10px rgba(28,42,30,.15);

  --font-display: 'Fraunces', ui-serif, Georgia, serif;
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --density: 1;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

a { color: inherit; text-decoration: none; }

/* ——— Type ——— */
.display {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.02;
  font-variation-settings: "opsz" 144, "SOFT" 20;
}
.eyebrow {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-300);
}
.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  text-transform: uppercase;
}

/* ——— Layout ——— */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 32px;
}
.section {
  padding: calc(96px * var(--density)) 0;
  position: relative;
}
.section-sm {
  padding: calc(56px * var(--density)) 0;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 15px;
  padding: 14px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  line-height: 1;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary);
  color: #F7F3EB;
}
.btn-primary:hover {
  background: var(--primary-600);
  box-shadow: var(--shadow);
}
.btn-accent {
  background: var(--accent);
  color: #1C2A1E;
}
.btn-accent:hover {
  background: #B5761A;
  box-shadow: var(--shadow);
}
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover {
  border-color: var(--primary);
  background: rgba(31, 58, 41, 0.04);
}
.btn-sm { padding: 10px 16px; font-size: 13px; }
.btn-lg { padding: 18px 28px; font-size: 16px; }

/* ——— Inputs ——— */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}
.field input, .field select, .field textarea {
  font-family: var(--font-sans);
  font-size: 15px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(31, 58, 41, 0.1);
}

/* ——— Cards ——— */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.card-hover:hover {
  border-color: var(--primary-300);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* ——— Chip / Badge ——— */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--bg-alt);
  border: 1px solid var(--line-soft);
  color: var(--ink-2);
}
.chip-accent {
  background: var(--accent-soft);
  border-color: transparent;
  color: #6D4A0E;
}
.chip-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

/* ——— Divider ——— */
.hr {
  height: 1px;
  background: var(--line-soft);
  border: 0;
  margin: 0;
}

/* ——— Link underline ——— */
.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-weight: 600;
  border-bottom: 1px solid var(--primary-100);
  padding-bottom: 1px;
}
.link:hover { border-color: var(--primary); }

/* ——— Grid helpers ——— */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .container { padding: 0 20px; }
  .section { padding: calc(64px * var(--density)) 0; }
  .display-xl { font-size: 48px !important; }
}

/* ═══════════════════════════════════════════════
   MOBILE RESPONSIVE OVERRIDES
   Forces inline-styled grids + flex layouts to stack
   and shrinks hardcoded font/padding sizes.
   ═══════════════════════════════════════════════ */

@media (max-width: 900px) {
  /* Collapse multi-column inline grids to one column.
     React serializes inline styles as kebab-case with no quotes, so we match
     the rendered form. We explicitly exclude narrow button-row patterns like
     "auto 1fr" / "1fr auto" which are icon+label patterns that must stay inline. */
  [style*="grid-template-columns: repeat"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 1fr 1.1fr"],
  [style*="grid-template-columns: 1fr 1.2fr"],
  [style*="grid-template-columns: 1fr 1.3fr"],
  [style*="grid-template-columns: 1.1fr"],
  [style*="grid-template-columns: 1.15fr"],
  [style*="grid-template-columns: 1.2fr"],
  [style*="grid-template-columns: 1.3fr"],
  [style*="grid-template-columns: 2fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Section headers: bring clamp floor down */
  .display { font-size: clamp(32px, 8vw, 56px) !important; letter-spacing: -0.02em !important; }

  /* Default gaps get oversized on mobile — shrink them */
  [style*="gap: 72px"],
  [style*="gap:72px"],
  [style*="gap: 80px"],
  [style*="gap:80px"],
  [style*="gap: 64px"],
  [style*="gap:64px"] { gap: 40px !important; }

  /* Large paddings inside dense sections */
  .card[style*="padding: 48px"],
  .card[style*="padding:48px"] { padding: 28px !important; }

  /* Sticky positioning breaks when grid flattens to 1 col — turn it off */
  [style*="position: 'sticky'"],
  [style*="position:'sticky'"] { position: static !important; }

  /* Hero padding shrink */
  section[style*="padding: '96px"] { padding: 56px 0 !important; }

  /* Hero quote card: shrink padding & remove offset backdrop on mobile */
  section > .container > div[style*="grid-template-columns"] .card[style*="padding: 32"] { padding: 22px !important; }
  section > .container > div[style*="grid-template-columns"] .card[style*="padding: 32"] + div,
  section > .container > div[style*="grid-template-columns"] .card[style*="padding: 32"] ~ div { display: none; }
  /* Kill decorative backdrops causing horizontal overflow */
  [style*="position: 'absolute'"][style*="top: -20"],
  [style*="position:'absolute'"][style*="top: -20"] { display: none !important; }

  /* Prevent horizontal scroll */
  html, body { overflow-x: hidden; max-width: 100vw; }
  body { font-size: 15px; }

  /* Re-order founder grid so portrait shows first */
  .founder-grid > :nth-child(1) { order: 1; }
  .founder-grid > :nth-child(2) { order: 2; }
}

@media (max-width: 720px) {
  .container { padding: 0 18px; }
  .section { padding: 56px 0; }
  .btn { font-size: 14px; padding: 12px 18px; }
  .btn-lg { padding: 15px 22px; font-size: 15px; }
}

@media (max-width: 560px) {
  .display { font-size: clamp(28px, 9vw, 42px) !important; }
  .section { padding: 44px 0; }
}

/* Mobile header — compact */
.mobile-menu-btn { display: none; }

@media (max-width: 900px) {
  .nav-desktop { display: none !important; }
  .nav-cta-desktop { display: none !important; }
  .mobile-menu-btn { display: inline-flex !important; }
}

.mobile-menu { display: none !important; }

/* New inline mobile menu — no fullscreen takeover */
.mobile-menu-inline {
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 8px 24px 20px;
  display: flex;
  flex-direction: column;
  animation: menuSlide 0.2s ease;
}
@keyframes menuSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.mobile-menu-inline > a {
  padding: 14px 0;
  font-size: 16px;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  text-decoration: none;
}
.mobile-submenu-toggle {
  padding: 14px 0;
  font-size: 16px;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--ink);
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.mobile-submenu {
  padding: 6px 0 10px 12px;
  display: grid;
  gap: 2px;
  border-bottom: 1px solid var(--line-soft);
}
.mobile-submenu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 14px;
  color: var(--ink-2);
  text-decoration: none;
  cursor: pointer;
}
.mobile-cta-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 16px;
}
.mobile-cta-row .btn { padding: 12px 16px; font-size: 14px; }

/* Marquee slower on mobile */
@media (max-width: 600px) {
  .marquee-track { animation-duration: 28s; }
}

/* Quote form shell card padding on mobile */
@media (max-width: 700px) {
  .card[style*="padding: 48px"] { padding: 24px !important; }
}

/* ——— Scroll reveal ——— */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

/* ——— Noise/paper texture ——— */
.paper {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(28,42,30,0.035) 1px, transparent 0);
  background-size: 24px 24px;
}

/* ——— Marquee ——— */
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 40s linear infinite;
}

/* Quote form compact */
.quote-form {
  display: grid;
  gap: 14px;
}
.quote-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) {
  .quote-form .row { grid-template-columns: 1fr; }
}

/* FAQ accordion */
.faq-item {
  border-bottom: 1px solid var(--line-soft);
}
.faq-q {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 24px 0;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.faq-a {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.4s ease, padding 0.3s ease;
  color: var(--ink-2);
  line-height: 1.7;
}
.faq-item.open .faq-a {
  max-height: 500px;
  padding-bottom: 24px;
}
.faq-item.open .faq-plus { transform: rotate(45deg); }
.faq-plus {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background 0.2s ease;
  color: var(--primary);
}

/* Sticky call bar */
.call-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  color: #F7F3EB;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 80;
  font-size: 14px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(.2,.7,.2,1);
  box-shadow: 0 -10px 40px -10px rgba(0,0,0,0.2);
}
.call-bar.show { transform: translateY(0); }
.call-bar .phone-link {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--accent-soft);
  border-bottom: 1px solid rgba(242, 219, 168, 0.4);
}

/* Product tile SVG framing */
.tile-illus {
  width: 100%;
  aspect-ratio: 16/10;
  border-radius: var(--radius);
  overflow: hidden;
  display: block;
}

/* Dense mode overrides */
body[data-density="compact"] {
  --density: 0.75;
}
body[data-density="compact"] .card { padding: 20px; }
body[data-density="compact"] .display-xl { font-size: 64px; }

/* ═══════════════════════════════════════════════
   MOBILE POLISH — targeted fixes, final pass
   ═══════════════════════════════════════════════ */

@media (max-width: 900px) {
  /* Collapse large horizontal section padding on mobile */
  [style*="padding: 96px 72px"],
  [style*="padding: 80px 64px"],
  [style*="padding: 72px 56px"] {
    padding: 56px 24px !important;
  }

  /* Hero 'Editorial' variant — massive clamp floor shrinks */
  h1.display[style*="font-size: clamp(64px"] {
    font-size: clamp(42px, 11vw, 72px) !important;
  }
  h2.display[style*="font-size: clamp(48px"] {
    font-size: clamp(34px, 9vw, 56px) !important;
  }

  /* Hero 'Editorial' pill input + button — let them stack gracefully */
  div[style*="inline-flex"][style*="borderRadius: 999"][style*="padding: 6"] {
    display: flex !important;
    flex-direction: column !important;
    border-radius: 16px !important;
    padding: 10px !important;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
  }
  div[style*="inline-flex"][style*="borderRadius: 999"] input {
    width: 100% !important;
    text-align: center;
  }

  /* "How it works" step tiles — restore vertical dividers as horizontal */
  [style*="grid-template-columns: repeat(3, 1fr)"][style*="background: rgb"] > div,
  [style*="grid-template-columns: repeat(3, 1fr)"][style*="border-radius"] > div {
    border-right: 0 !important;
    border-bottom: 1px solid var(--line-soft);
  }
  [style*="grid-template-columns: repeat(3, 1fr)"][style*="background: rgb"] > div:last-child,
  [style*="grid-template-columns: repeat(3, 1fr)"][style*="border-radius"] > div:last-child {
    border-bottom: 0 !important;
  }

  /* Stats bar (primary bg) — 2 cols on mobile instead of 1, otherwise too tall */
  [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 24px 16px !important;
  }

  /* Founder portrait — cap width so it doesn't dominate the fold */
  .founder-grid > :first-child > div[style*="aspect-ratio"] {
    max-width: 400px;
    margin: 0 auto;
  }

  /* Blog grids — already handled inline, but reinforce */
  .blog-grid {
    grid-template-columns: 1fr !important;
  }
  .blog-featured {
    grid-template-columns: 1fr !important;
  }

  /* Blog featured card hero-image side — cap aspect on mobile so it's not giant */
  .blog-featured > a > div:first-child,
  .blog-featured > div:first-child {
    aspect-ratio: 16/10 !important;
    min-height: 0 !important;
  }

  /* Blog body — tighten side paddings */
  .container[style*="max-width: 720px"] {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  /* Footer — tighten columns */
  footer .container > div[style*="grid-template-columns"] {
    gap: 32px !important;
  }

  /* Nav: tighten side padding */
  nav .container {
    padding: 0 16px !important;
  }
}

@media (max-width: 560px) {
  /* Hero heading — aggressive floor */
  h1.display,
  .display {
    font-size: clamp(30px, 10vw, 44px) !important;
    letter-spacing: -0.02em !important;
  }
  h2.display {
    font-size: clamp(28px, 9vw, 40px) !important;
  }

  /* Section headers — shrink SectionHeader h2 */
  h2[style*="font-size: clamp(36px"] {
    font-size: clamp(26px, 8vw, 38px) !important;
  }

  /* Reduce big inline font-size like 40px phone numbers in hero */
  a[href^="tel:"][style*="font-size: 40px"] {
    font-size: 28px !important;
  }

  /* Blog title */
  h1[style*="font-size: clamp(34px"] {
    font-size: clamp(28px, 8vw, 42px) !important;
  }

  /* Blog article body font size — from 18 to 16 */
  .container p[style*="font-size: 18px"] {
    font-size: 16px !important;
  }

  /* Tighten container padding even more on tiny screens */
  .container {
    padding: 0 16px !important;
  }

  /* Section padding */
  section[style*="padding: 72px 0"],
  section[style*="padding: 80px 0"],
  section[style*="padding: 96px 0"] {
    padding: 40px 0 !important;
  }

  /* Chips — shrink */
  .chip {
    font-size: 11px !important;
    padding: 6px 12px !important;
  }

  /* Reduce all padding: 40 / 48 cards */
  .card[style*="padding: 40px"],
  .card[style*="padding: 32px"],
  .card[style*="padding: 48px"] {
    padding: 22px !important;
  }

  /* Buttons: full-width when stacked in CTA sections */
  [style*="background: rgb"] > .container .btn-lg,
  section[style*="color: rgb(247, 243, 235)"] .btn-lg {
    /* primary-bg CTA sections with dark bg — keep native sizing but allow wrap */
  }

  /* Marquee: keep visible but shrink */
  .marquee img {
    height: 24px !important;
  }
}

/* Prevent accidental horizontal scroll on every page */
@media (max-width: 900px) {
  main, section, footer, nav {
    max-width: 100vw;
  }
  img, svg {
    max-width: 100%;
  }
}
