/*!
 * WBJ Foundation v1.0.0
 * Fluid, BEM CSS foundation for Websites by Jeremy marketing sites and web apps.
 * No Tailwind. Class names are always BEM. Tokens scale with the viewport (Automatic.css-style).
 *
 * Layers:
 *   1) Tokens (fluid type/space + theme colors/fonts)
 *   2) Reset + base element styles
 *   3) Layout + primitive blocks (BEM, wbj- prefix)
 *
 * Client / product themes override only the "Theme" :root block (or a later cascade file).
 */

/* ==========================================================================
   Tokens — fluid scale (do not fork per site)
   Viewport window: ~320px → ~1240px. Prefer clamp over per-breakpoint font/space rewrites.
   Layout breakpoints still use @media for structure (stack vs row), not for resizing type.
   ========================================================================== */

:root {
  /* Fluid type steps */
  --wbj-text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --wbj-text-sm: clamp(0.875rem, 0.84rem + 0.18vw, 0.9375rem);
  --wbj-text-md: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --wbj-text-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.375rem);
  --wbj-text-xl: clamp(1.375rem, 1.2rem + 0.75vw, 1.75rem);
  --wbj-text-2xl: clamp(1.75rem, 1.4rem + 1.4vw, 2.5rem);
  --wbj-text-3xl: clamp(2.25rem, 1.65rem + 2.4vw, 3.5rem);

  /* Fluid space steps */
  --wbj-space-1: clamp(0.25rem, 0.22rem + 0.15vw, 0.375rem);
  --wbj-space-2: clamp(0.5rem, 0.45rem + 0.2vw, 0.625rem);
  --wbj-space-3: clamp(0.75rem, 0.68rem + 0.3vw, 1rem);
  --wbj-space-4: clamp(1rem, 0.9rem + 0.4vw, 1.25rem);
  --wbj-space-5: clamp(1.5rem, 1.25rem + 0.8vw, 2rem);
  --wbj-space-6: clamp(2rem, 1.6rem + 1.2vw, 2.75rem);
  --wbj-space-7: clamp(2.75rem, 2.1rem + 2vw, 4rem);
  --wbj-space-8: clamp(3.5rem, 2.5rem + 3vw, 5.5rem);
  --wbj-space-0: 0.125rem;
  /* Section padding: 72px at a 390 viewport, 128px from 1440. */
  --wbj-space-section: clamp(4.5rem, 3.2rem + 5.3333vw, 8rem);

  /* Measure / radius / focus / motion */
  --wbj-measure: 65ch;
  --wbj-radius-sm: 0.25rem;
  --wbj-radius: 0.5rem;
  --wbj-radius-lg: 0.75rem;
  --wbj-radius-xl: 1rem;
  --wbj-radius-2xl: 1.5rem;
  --wbj-radius-pill: 999px;
  --wbj-shadow: 0 1px 3px rgb(0 0 0 / 0.12), 0 1px 2px rgb(0 0 0 / 0.08);

  /* Soft, wide shadows tinted navy. -on-light is for cards on cream or white. */
  --wbj-shadow-tint: 10 15 46;
  --wbj-shadow-soft: 0 1px 2px rgb(var(--wbj-shadow-tint) / 0.16), 0 18px 48px -12px rgb(var(--wbj-shadow-tint) / 0.42);
  --wbj-shadow-lift: 0 2px 6px rgb(var(--wbj-shadow-tint) / 0.22), 0 36px 80px -16px rgb(var(--wbj-shadow-tint) / 0.6);
  --wbj-shadow-on-light: 0 1px 2px rgb(33 44 94 / 0.06), 0 20px 48px -14px rgb(33 44 94 / 0.18);

  /* Hairlines: white at 10% on navy. */
  --wbj-hairline-color: rgb(255 255 255 / 0.1);
  --wbj-hairline: 1px solid var(--wbj-hairline-color);

  /* Motion: section reveals (src/scripts/reveal.ts). */
  --wbj-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --wbj-reveal-duration: 400ms;
  --wbj-reveal-shift: 8px;
  --wbj-reveal-stagger: 60ms;
  /* Longest stagger delay in any group, so a section settles within about 300ms of the first item. */
  --wbj-reveal-stagger-max: 240ms;
  --wbj-focus-ring: 2px solid var(--wbj-color-primary);
  --wbj-focus-offset: 2px;
  --wbj-transition: 150ms ease;

  /* Content widths */
  --wbj-width-narrow: 40rem;
  --wbj-width: 72rem;
  --wbj-width-wide: 90rem;

  /* Structural breakpoints (documentation; use in @media as literals)
     sm: 40rem (640px)  md: 64rem (1024px)  lg: 80rem (1280px) */
}

/* ==========================================================================
   Theme — override per client / product (colors + fonts only by default)
   ========================================================================== */

:root {
  --wbj-font-heading: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --wbj-font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --wbj-color-bg: #ffffff;
  --wbj-color-surface: #f4f4f5;
  --wbj-color-text: #18181b;
  --wbj-color-text-muted: #52525b;
  --wbj-color-primary: #1d4ed8;
  --wbj-color-primary-contrast: #ffffff;
  --wbj-color-accent: #1d4ed8;
  --wbj-color-border: #d4d4d8;
  --wbj-color-danger: #b91c1c;
  --wbj-color-success: #15803d;
}

/* ==========================================================================
   Reset + base
   ========================================================================== */

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

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd,
ul,
ol {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

body {
  min-height: 100vh;
  font-family: var(--wbj-font-body);
  font-size: var(--wbj-text-md);
  color: var(--wbj-color-text);
  background: var(--wbj-color-bg);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--wbj-font-heading);
  line-height: 1.2;
  text-wrap: balance;
}

h1 { font-size: var(--wbj-text-3xl); }
h2 { font-size: var(--wbj-text-2xl); }
h3 { font-size: var(--wbj-text-xl); }
h4 { font-size: var(--wbj-text-lg); }
h5,
h6 { font-size: var(--wbj-text-md); }

p,
li {
  max-width: var(--wbj-measure);
  text-wrap: pretty;
}

/* Line wrapping, site-wide. Running text uses pretty (no one-word last lines);
   headings and heading-styled text use balance. Long display quotes are paragraphs,
   so they stay on pretty, which reads better than balance in narrow columns. */
body,
dd,
blockquote,
figcaption {
  text-wrap: pretty;
}

[role="heading"],
.wbj-card__title,
.wbj-home-services__close,
.wbj-plans-signoff__title,
.wbj-faq-accordion__q-text {
  text-wrap: balance;
}

a {
  color: var(--wbj-color-primary);
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 0.08em;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: var(--wbj-focus-ring);
  outline-offset: var(--wbj-focus-offset);
}

::selection {
  background: var(--wbj-color-accent);
  color: var(--wbj-color-primary);
}

/* Section reveal. The hidden state exists only once JS has added .wbj-reveal-on to <html>,
   so content stays visible if the script never runs. Reduced motion shows everything. */
.wbj-reveal-on .wbj-reveal {
  opacity: 0;
  translate: 0 var(--wbj-reveal-shift);
  transition:
    opacity var(--wbj-reveal-duration) var(--wbj-ease-out),
    translate var(--wbj-reveal-duration) var(--wbj-ease-out);
  transition-delay: min(calc(var(--wbj-reveal-i, 0) * var(--wbj-reveal-stagger)), var(--wbj-reveal-stagger-max));
  /* Compositor-only: opacity and translate. Promote while hidden so the first frame doesn't stutter. */
  will-change: opacity, translate;
}

.wbj-reveal-on .wbj-reveal.is-revealed {
  opacity: 1;
  translate: none;
  will-change: auto;
}

@media (prefers-reduced-motion: reduce) {
  .wbj-reveal-on .wbj-reveal {
    opacity: 1;
    translate: none;
    transition: none;
  }
}

/* ==========================================================================
   Layout blocks
   ========================================================================== */

.wbj-container {
  width: min(100% - (var(--wbj-space-4) * 2), var(--wbj-width));
  margin-inline: auto;
}

.wbj-container--narrow {
  width: min(100% - (var(--wbj-space-4) * 2), var(--wbj-width-narrow));
}

.wbj-container--wide {
  width: min(100% - (var(--wbj-space-4) * 2), var(--wbj-width-wide));
}

.wbj-section {
  padding-block: var(--wbj-space-7);
}

.wbj-section--tight {
  padding-block: var(--wbj-space-5);
}

.wbj-section--loose {
  padding-block: var(--wbj-space-8);
}

.wbj-stack {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: var(--wbj-space-4);
}

.wbj-stack--xs { gap: var(--wbj-space-1); }
.wbj-stack--sm { gap: var(--wbj-space-2); }
.wbj-stack--md { gap: var(--wbj-space-4); }
.wbj-stack--lg { gap: var(--wbj-space-6); }
.wbj-stack--xl { gap: var(--wbj-space-8); }

.wbj-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wbj-space-3);
}

.wbj-cluster--sm { gap: var(--wbj-space-2); }
.wbj-cluster--lg { gap: var(--wbj-space-5); }

.wbj-grid {
  display: grid;
  gap: var(--wbj-space-5);
  grid-template-columns: 1fr;
}

@media (min-width: 40rem) {
  .wbj-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 64rem) {
  .wbj-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .wbj-grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.wbj-cluster > *,
.wbj-grid > * {
  min-width: 0;
}

/* ==========================================================================
   Primitives
   ========================================================================== */

.wbj-prose {
  display: flex;
  flex-direction: column;
  gap: var(--wbj-space-4);
  max-width: var(--wbj-measure);
}

.wbj-prose > * {
  max-width: none;
}

.wbj-lede {
  font-size: var(--wbj-text-lg);
  color: var(--wbj-color-text-muted);
}

.wbj-muted {
  color: var(--wbj-color-text-muted);
}

.wbj-surface {
  background: var(--wbj-color-surface);
  border: 1px solid var(--wbj-color-border);
  border-radius: var(--wbj-radius);
  padding: var(--wbj-space-5);
}

.wbj-card {
  background: var(--wbj-color-bg);
  border: 1px solid var(--wbj-color-border);
  border-radius: var(--wbj-radius);
  box-shadow: var(--wbj-shadow);
  padding: var(--wbj-space-5);
}

.wbj-card__title {
  font-family: var(--wbj-font-heading);
  font-size: var(--wbj-text-lg);
  margin-bottom: var(--wbj-space-2);
}

.wbj-card__body {
  color: var(--wbj-color-text-muted);
  font-size: var(--wbj-text-sm);
}

.wbj-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wbj-space-2);
  padding: var(--wbj-space-3) var(--wbj-space-5);
  border: 1px solid transparent;
  border-radius: var(--wbj-radius);
  background: var(--wbj-color-primary);
  color: var(--wbj-color-primary-contrast);
  font-size: var(--wbj-text-md);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color var(--wbj-transition), border-color var(--wbj-transition),
    color var(--wbj-transition), transform var(--wbj-transition);
}

.wbj-button:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.wbj-button--secondary {
  background: transparent;
  border-color: var(--wbj-color-border);
  color: var(--wbj-color-text);
}

.wbj-button--secondary:hover {
  border-color: var(--wbj-color-text-muted);
}

.wbj-button--ghost {
  background: transparent;
  color: var(--wbj-color-primary);
  padding-inline: var(--wbj-space-3);
}

.wbj-button--ghost:hover {
  background: var(--wbj-color-surface);
}

.wbj-field {
  display: flex;
  flex-direction: column;
  gap: var(--wbj-space-2);
  max-width: 28rem;
}

.wbj-field__label {
  font-size: var(--wbj-text-sm);
  font-weight: 600;
}

.wbj-field__hint {
  font-size: var(--wbj-text-xs);
  color: var(--wbj-color-text-muted);
}

.wbj-field__control {
  width: 100%;
  padding: var(--wbj-space-3) var(--wbj-space-4);
  border: 1px solid var(--wbj-color-border);
  border-radius: var(--wbj-radius);
  background: var(--wbj-color-bg);
}

.wbj-field__control:focus-visible {
  outline: var(--wbj-focus-ring);
  outline-offset: var(--wbj-focus-offset);
}

.wbj-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--wbj-space-1) var(--wbj-space-3);
  border-radius: 999px;
  background: var(--wbj-color-surface);
  border: 1px solid var(--wbj-color-border);
  font-size: var(--wbj-text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.wbj-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--wbj-color-border);
  border-radius: var(--wbj-radius);
}

.wbj-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--wbj-text-sm);
}

.wbj-table th,
.wbj-table td {
  padding: var(--wbj-space-3) var(--wbj-space-4);
  text-align: left;
  border-bottom: 1px solid var(--wbj-color-border);
  vertical-align: top;
}

.wbj-table th {
  background: var(--wbj-color-surface);
  font-weight: 600;
}

.wbj-table tr:last-child td {
  border-bottom: none;
}

.wbj-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wbj-rule {
  border: 0;
  border-top: 1px solid var(--wbj-color-border);
  margin-block: var(--wbj-space-6);
}
