/*
 * Fenvic Financial — cross-site quality pass
 *
 * Shared visual rules for the homepage, product templates, editorial pages,
 * forms and legal content. This file is intentionally additive: it keeps the
 * existing source-of-truth copy and product terms intact while fixing common
 * layout, focus, motion and responsive failure modes.
 */

:root {
  --fenvic-motion-fast: 160ms cubic-bezier(0.16, 1, 0.3, 1);
  --fenvic-motion-ui: 220ms cubic-bezier(0.16, 1, 0.3, 1);
  --fenvic-focus: 0 0 0 3px rgba(22, 119, 200, 0.24);
}

html {
  scroll-padding-block-start: 84px;
  text-rendering: optimizeLegibility;
}

body {
  min-width: 320px;
}

/* Keyboard users should always know where focus is. */
:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--primary-blue, #1677c8);
  outline-offset: 3px;
  box-shadow: var(--fenvic-focus);
}

:where(button, input, select, textarea) {
  font: inherit;
}

:where(.home-v2-container, .container, .container-wide, .article-wrap, .apply-wrap) > * {
  min-width: 0;
}

/* Buttons and compact controls share one tactile interaction model. */
:where(.btn, .btn-bright-primary, .btn-bright-secondary, .btn-primary, .btn-secondary,
  .nav-cta-btn, .f-submit, .btn-next, .bar-btn, .bar-call, .review-carousel-arrow,
  .blog-filter-btn, .persona-tab-btn):active {
  transform: scale(0.97);
}

:where(.btn, .btn-bright-primary, .btn-bright-secondary, .btn-primary, .btn-secondary,
  .nav-cta-btn, .f-submit, .btn-next, .bar-btn, .bar-call) {
  min-height: 44px;
}

/* The mobile navigation is an actual state, not an abrupt display toggle. */
.nav-burger {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  min-width: 44px;
  min-height: 44px;
}

.nav-burger span {
  transform-origin: center;
  transition: transform var(--fenvic-motion-fast), opacity var(--fenvic-motion-fast);
}

.nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-mobile {
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: max-height var(--fenvic-motion-ui), opacity var(--fenvic-motion-fast),
    transform var(--fenvic-motion-ui), visibility 0s linear 220ms;
}

.nav-mobile.open {
  max-height: min(70vh, 520px);
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0s;
  overflow-y: auto;
}

@media (min-width: 769px) {
  .nav-mobile { display: none !important; }
}

/* Editorial rhythm: readable measure and predictable section boundaries. */
:where(.entry-content, .article-body, .contact-editor-box, .inner-v2-story-copy) p,
:where(.entry-content, .article-body) li {
  max-width: 72ch;
}

:where(.article-body, .entry-content) h2 {
  text-wrap: balance;
  margin-block: 2.5rem 0.9rem;
}

:where(.article-body, .entry-content) h3 {
  text-wrap: balance;
  margin-block: 2rem 0.7rem;
}

:where(.hero-arch-title, .inner-v2-hero h1, .page-hero h1, .post-title, .home-v2-section-heading h2) {
  text-wrap: balance;
}

/* Long labels and tables may wrap instead of breaking the page at 320px. */
:where(.metric-block, .hero-floating-badge, .prod-specs-bar, .product-row-clean,
  .home-v2-blog-card, .review-card-v3, .disclosure-item, .footer-col) {
  min-width: 0;
}

:where(.product-row-clean, .product-showcase-card, .article-body table, .wp-block-table) {
  overflow-wrap: anywhere;
}

:where(.article-body table, .wp-block-table) {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Shared card polish: quiet depth, never a layout jump. */
@media (hover: hover) and (pointer: fine) {
  :where(.product-showcase-card, .product-row-clean, .home-v2-blog-card,
    .funding-need-card, .industry-grid-v2 a, .review-card-v3, .disclosure-item) {
    transition: transform var(--fenvic-motion-ui), box-shadow var(--fenvic-motion-ui),
      border-color var(--fenvic-motion-ui), background-color var(--fenvic-motion-ui);
  }
}

/* The small-screen layout keeps content in source order and keeps buttons inset. */
@media (max-width: 768px) {
  .nav-inner,
  .home-v2-container,
  .hero-container,
  .container,
  .container-wide,
  .article-wrap,
  .apply-wrap {
    width: min(100% - 2rem, 1220px);
    padding-inline: 0;
  }

  .hero-arch-title { font-size: clamp(2.15rem, 10vw, 3rem); }

  :where(.hero-button-group, .final-cta-btn-group, .btn-group) > a,
  :where(.f-submit, .btn-next) {
    width: 100%;
  }

  .home-v2-blog-grid,
  .disclosures-grid,
  .inner-v2-value-grid,
  .contact-grid,
  .article-grid {
    grid-template-columns: 1fr !important;
  }

  .footer-grid { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr !important; }
  .hero-metrics-container { grid-template-columns: 1fr 1fr !important; gap: 1rem !important; }
  .metric-val { font-size: clamp(1.35rem, 7vw, 2rem) !important; }
  :where(.contact-form-card, .apply-tracker, .product-showcase-card, .article-body) {
    padding-inline: 1rem !important;
  }
}

/* Scroll reveals stay composited and disappear entirely for reduced-motion users. */
.fenvic-motion-reveal,
.fenvic-motion-item {
  will-change: transform, opacity;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .nav-mobile { transform: none; }
  .fenvic-motion-reveal,
  .fenvic-motion-item {
    opacity: 1 !important;
    transform: none !important;
    will-change: auto;
  }
}

/* Chat and floating actions remain usable above the safe-area inset. */
#chat-bubble,
#float-call {
  min-width: 48px;
  min-height: 48px;
  bottom: max(1rem, env(safe-area-inset-bottom));
}

#chat-bubble {
  cursor: pointer;
  appearance: none;
  border: 0;
  color: inherit;
  padding: 0;
}

.chat-head-close,
#exit-modal-close,
.bar-close {
  min-width: 44px;
  min-height: 44px;
}

/* Form controls: persistent labels, 16px text, visible invalid state. */
:where(.f-input, .em-input, #chat-input, .wpforms-form input, .wpforms-form select,
  .wpforms-form textarea, .wpcf7 input, .wpcf7 select, .wpcf7 textarea) {
  min-height: 44px;
  font-size: 16px !important;
}

:where(.f-input, .em-input, #chat-input):user-invalid {
  border-color: #b42318;
}

:where(.f-input, .em-input, #chat-input):user-invalid:focus {
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.16);
}

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