/* ===================================================================
   FirmForte — Mobile refinements
   -------------------------------------------------------------------
   Loaded LAST in the cascade so it can override everything.
   Contents: mobile nav drawer, touch targets, hero/pricing/form/table
   mobile fixes, iOS safe-area, no-hover-on-touch, and per-section
   refinements for narrow screens.
   =================================================================== */

/* ============================================
   MOBILE NAV TOGGLE + DRAWER
   ============================================ */
.nav-toggle,
.mobile-menu,
.mobile-menu-backdrop { display: none; }

@media (max-width: 900px) {
  /* Desktop CTA and primary nav links both move into the drawer on mobile */
  .site-nav .btn-primary,
  .site-nav .nav-links { display: none; }

  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    padding: 0;
    margin-left: auto;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: calc(var(--z-modal) + 10);
    position: relative;
  }
  .nav-toggle span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--ink);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.2s ease;
    transform-origin: center;
  }
  .nav-toggle[aria-expanded="true"] {
    position: fixed;
    top: 24px;
    right: 20px;
  }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
  }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
  }
  .nav-toggle:focus-visible {
    outline: 2px solid var(--accent-deep);
    outline-offset: 6px;
    border-radius: 4px;
  }

  .mobile-menu {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(86vw, 360px);
    background: var(--bg);
    z-index: var(--z-modal);
    padding: 84px 28px max(40px, env(safe-area-inset-bottom));
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.14);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-menu[aria-hidden="false"] { transform: translateX(0); }

  .mobile-menu nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    margin-bottom: 28px;
  }
  .mobile-menu nav a {
    display: block;
    padding: 16px 0;
    font-size: 21px;
    font-weight: 500;
    color: var(--ink);
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.015em;
    transition: color var(--t-fast), padding-left var(--t-fast);
    min-height: 56px;
  }
  .mobile-menu nav a:hover,
  .mobile-menu nav a:focus,
  .mobile-menu nav a:active { color: var(--accent-deep); padding-left: 4px; }
  .mobile-menu nav a:focus-visible {
    outline: 2px solid var(--accent-deep);
    outline-offset: 2px;
    border-radius: 4px;
  }
  .mobile-menu .btn {
    width: 100%;
    justify-content: center;
    padding: 16px 22px;
    font-size: 16px;
    min-height: 52px;
  }
  .mobile-menu-foot {
    margin-top: 32px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
  }
  .mobile-menu-foot a {
    color: var(--ink);
    border-bottom: 1px solid var(--accent-deep);
  }

  .mobile-menu-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 21, 26, 0.45);
    z-index: calc(var(--z-modal) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .mobile-menu-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }
  body.menu-open { overflow: hidden; height: 100vh; }
}

/* ============================================
   TOUCH TARGETS (44px minimum — Apple HIG)
   ============================================ */
@media (max-width: 900px) {
  .btn { min-height: 46px; padding: 13px 22px; }
  .faq-q { min-height: 56px; padding: 20px 0; }
  .site-footer ul a,
  .footer-bottom-links a { display: inline-block; padding: 6px 0; }
  .nav-links a { padding: 8px 0; }
}

/* ============================================
   CONTAINER — tighter padding on small screens
   ============================================ */
@media (max-width: 540px) {
  .container,
  .container-narrow { padding: 0 18px; }
  section { padding: 56px 0; }
}
@media (max-width: 380px) {
  .container,
  .container-narrow { padding: 0 14px; }
}

/* ============================================
   HERO — mobile refinements
   ============================================ */
@media (max-width: 768px) {
  .hero { padding-top: 100px; padding-bottom: 48px; }
  .hero-grid { gap: 36px; }
  .hero h1 { margin-bottom: 18px; }
  .hero-sub { font-size: 16.5px; margin-bottom: 28px; }
  .hero-ctas {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 32px;
  }
  .hero-ctas .btn { width: 100%; justify-content: center; }

  .hero-visual { min-height: auto; padding: 12px 0; }
  .hero-visual::before { width: 280px; height: 280px; }
  .receipt { max-width: 360px; padding: 26px 22px; }
  .receipt-head-title { font-size: 18px; }
  .receipt-row { font-size: 13px; }
  .receipt-row .val { font-size: 11.5px; }
  .receipt-total .val { font-size: 26px; }

  .hero-meta-num { font-size: 24px; }
}

/* ============================================
   PRICING — disable scale on mobile (overflow fix)
   ============================================ */
@media (max-width: 900px) {
  .tier.featured { transform: none; }
  .tier.featured:hover { transform: translateY(-2px); }
}
@media (max-width: 768px) {
  .tier { padding: 30px 24px; }
  .tier-price .amount { font-size: 36px; }
  .tier-badge { left: 24px; }
}

/* ============================================
   FORMS — 16px min font (prevents iOS zoom on focus)
   ============================================ */
@media (max-width: 768px) {
  .form-row input,
  .form-row select,
  .form-row textarea {
    font-size: 16px;
    padding: 14px;
    min-height: 48px;
  }
  .form-row textarea { min-height: 96px; }
  .audit-form { padding: 28px 22px; }
  .form-row-split { gap: 14px; }
}

/* ============================================
   MOBILE STICKY CTA + back-to-top w/ iOS safe area
   ============================================ */
@media (max-width: 768px) {
  .mobile-cta-bar {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .mobile-cta-bar .btn {
    padding: 14px 22px;
    font-size: 15px;
    min-height: 48px;
  }
  .back-to-top {
    bottom: calc(82px + env(safe-area-inset-bottom));
    right: 16px;
    width: 44px;
    height: 44px;
  }
  .has-mobile-cta {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
}

/* ============================================
   PROCESS section visual
   ============================================ */
@media (max-width: 768px) {
  .process-step { margin-bottom: 44px; gap: 24px; }
  .process-visual { aspect-ratio: 16/10; }
  .process-visual-num { font-size: clamp(64px, 18vw, 96px); }
  .process-step-label { top: 14px; left: 14px; padding: 6px 11px; font-size: 10px; }
  .process-tags { margin-top: 16px; }
  .process-tag { font-size: 11.5px; padding: 6px 11px; }
  .process-body p { font-size: 15.5px; }
}

/* ============================================
   SERVICES grid
   ============================================ */
@media (max-width: 600px) {
  .service-card { min-height: auto; padding: 26px; }
  .service-card h3 { font-size: 20px; }
}

/* ============================================
   PROBLEM section
   ============================================ */
@media (max-width: 768px) {
  .problem-right { padding: 26px 22px; }
  .problem-stat-num { font-size: 20px; min-width: 60px; }
  .problem-list li { gap: 12px; }
}

/* ============================================
   FOUNDER
   ============================================ */
@media (max-width: 768px) {
  .founder-visual { aspect-ratio: 5/4; font-size: clamp(60px, 18vw, 90px); }
}

/* ============================================
   FAQ
   ============================================ */
@media (max-width: 768px) {
  .faq-q { font-size: 16px; gap: 14px; }
  .faq-a { font-size: 14.5px; line-height: 1.6; }
}

/* ============================================
   FINAL CTA
   ============================================ */
@media (max-width: 540px) {
  .final-cta h2 { font-size: clamp(28px, 7vw, 36px); }
  .final-cta p { font-size: 15px; }
  .final-cta-ctas { flex-direction: column; }
  .final-cta-ctas .btn { width: 100%; justify-content: center; }
}

/* ============================================
   FOOTER
   ============================================ */
@media (max-width: 768px) {
  .site-footer { padding: 56px 0 24px; }
  .footer-grid { gap: 32px; margin-bottom: 36px; }
}

/* ============================================
   BLOG LISTING (card grid)
   ============================================ */
@media (max-width: 768px) {
  .blog-hero { padding: 120px 0 36px; }
  .blog-hero h1 { font-size: clamp(32px, 8vw, 42px); margin-bottom: 16px; }
  .blog-hero p { font-size: 16.5px; }
  .blog-grid { gap: 18px; }
  .blog-card-body { padding: 22px 22px 26px; }
  .blog-card-title { font-size: 19px; }
  .blog-card-visual-mark { font-size: 64px; }
}

/* ============================================
   BLOG ARTICLE — reading experience on mobile
   ============================================ */
@media (max-width: 768px) {
  .breadcrumb { padding: 84px 0 0; font-size: 11px; }
  .article-header { padding: 24px 0 36px; }
  .article-header h1 {
    font-size: clamp(28px, 8vw, 40px);
    margin-bottom: 14px;
  }
  .article-deck { font-size: 17px; margin-bottom: 22px; }
  .article-meta { font-size: 11px; gap: 12px; }

  .article-visual { margin-bottom: 36px; aspect-ratio: 16/10; }
  .article-visual-mark { font-size: clamp(90px, 22vw, 140px); }

  .article-prose { font-size: 16.5px; line-height: 1.65; }
  .article-prose h2 {
    font-size: clamp(22px, 5.5vw, 28px);
    margin-top: 1.8em;
    line-height: 1.25;
  }
  .article-prose h3 { font-size: 18px; }
  .article-prose blockquote {
    font-size: 18px;
    padding-left: 18px;
    margin: 1.3em 0;
  }
  .article-prose .pull-stat { padding: 20px 22px; gap: 14px; }
  .article-prose .pull-stat-num { font-size: 32px; }

  .article-cta { padding: 30px 24px; margin-top: 48px; }
  .article-cta h3 { font-size: 22px; }
  .article-cta-ctas { flex-direction: column; }
  .article-cta-ctas .btn { width: 100%; justify-content: center; }

  .related-posts { margin-top: 56px; padding-top: 36px; }
}

/* ============================================
   TABLES — horizontal scroll wrapper on mobile
   JS adds .table-wrap around any <table> in .article-prose
   ============================================ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5em 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.table-wrap table {
  margin: 0 !important;
  min-width: 520px;
}
@media (max-width: 768px) {
  .article-prose table { font-size: 13.5px; }
  .article-prose th,
  .article-prose td { padding: 10px 12px; }
}

/* ============================================
   REMOVE HOVER ON TOUCH DEVICES
   (transforms feel broken on tap — devices that "stick" hover)
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  .service-card:hover,
  .tier:hover,
  .tier.featured:hover,
  .blog-card:hover,
  .included-card:hover {
    transform: none !important;
    box-shadow: var(--shadow-sm) !important;
    border-color: var(--border) !important;
  }
  .btn-primary:hover,
  .btn-accent:hover,
  .btn-secondary:hover,
  .btn-on-dark:hover,
  .back-to-top:hover {
    transform: none !important;
  }
  .blog-card:hover .blog-card-title { color: var(--ink); }
}

/* ============================================
   MINOR iOS / general mobile polish
   ============================================ */
html { -webkit-text-size-adjust: 100%; }

/* Smooth tap highlights instead of harsh blue boxes */
a, button { -webkit-tap-highlight-color: rgba(198, 255, 61, 0.2); }

/* Better selection on mobile */
::selection { background: var(--accent); color: var(--ink); }
