/* ==========================================================================
   Marketing responsive remediation layer
   --------------------------------------------------------------------------
   Loaded LAST in <head> by src/routes/marketing.js so it wins over both
   css/marketing.css and the per-page <style> blocks embedded in the legacy
   campaign/legal content templates.

   Evidence: docs/proof/marketing-responsive/<brand>/responsive-audit-*.json
   Harness:  scripts/proof/marketing/responsive-audit.cjs

   Section 1 is a correctness fix and applies at every width.
   Sections 2+ are scoped to <=1024px so desktop rendering is untouched.
   ========================================================================== */

/* ==========================================================================
   1. LIGHT-SURFACE TEXT CONTRACT
   --------------------------------------------------------------------------
   css/marketing.css defines a dark canvas (--text-dark: #f0f0f5 is a LIGHT
   ink meant for black backgrounds). The legacy campaign/legal templates paint
   their own white/#f8f9fa surfaces via embedded <style> and inline
   style="background: white". Where the two meet, light ink lands on a light
   surface and the copy disappears (measured 1.01:1–1.14:1 contrast).

   Rather than fight the page's background, re-point the ink tokens to dark
   values inside those surfaces. Descendants that reference var(--text-*)
   inherit accessible colors, while intentional accent colors (semantic green
   / red / brand purple) are left alone.
   ========================================================================== */
/* NOTE: `.pricing-card` / `.pricing-section` are deliberately NOT in this list.
   The pricing grid is hydrated at runtime into the dark shared component
   (`.pricing-grid--hydrated`), so re-pointing ink to dark there makes the plan
   names and prices invisible against the dark card. */
.before-after,
.problem-solution,
.comparison-section,
.scenario-card,
.problem-card,
.solution-card,
.comparison-card,
.ticket-demo,
.ticket-list,
.ticket-item,
.intake-demo,
.phone-call,
.call-message,
.demo-widget,
.chat-demo,
.chat-message.bob,
.integration-logos,
.important-note,
.team-member,
.value-card,
.content-section,
.roi-calculator,
body > .container > .content,
[style*="background: white"],
[style*="background:#fff"],
[style*="background: #fff"] {
    --text-dark: #111827;
    --text-light: #4b5563;
    --text-muted: #6b7280;
    --text-primary: #111827;
    --text-secondary: #374151;
    --white: #ffffff;
    --bg-light: #f8f9fa;
    --bg-surface: #ffffff;
    color: #1f2937;
}

/* Headings inside light surfaces: css/marketing.css:769 sets
   `.features h2, .section-title { color: var(--text-dark) }` and several
   component rules hard-code `color: #fff`, which the token re-point above
   cannot reach. Re-assert an accessible ink for those specific cases. */
.before-after :is(h1, h2, h3, h4, h5, h6),
.problem-solution :is(h1, h2, h3, h4, h5, h6),
.comparison-section :is(h1, h2, h3, h4, h5, h6),
.scenario-card :is(h3, h4),
.problem-card :is(h3, h4),
.solution-card :is(h3, h4),
.comparison-card :is(h3, h4),
.ticket-demo :is(h3, h4),
.intake-demo :is(h3, h4),
.demo-widget :is(h3, h4),
.integration-logos :is(h3, h4),
.important-note :is(h3, h4, p, li, strong),
[style*="background: white"] > .container > :is(h2, h3),
[style*="background: white"] .section-title {
    color: #111827;
}

/* Muted supporting copy on light surfaces still needs to clear 4.5:1. */
.before-after :is(.section-subtitle, .features-subtitle),
.problem-solution :is(.section-subtitle, .features-subtitle),
.comparison-section :is(.section-subtitle, .features-subtitle),
[style*="background: white"] :is(.section-subtitle, .features-subtitle) {
    color: #4b5563;
}

/* The `.flow-*` and `.*-card` glass components assume a dark canvas
   (rgba(255,255,255,0.05) over black). On a light section that resolves to
   near-white on white. Give them a real surface plus real ink. */
.integration-logos .integration-logo,
.integration-logos :is(span, div, li) {
    color: #374151;
}

/* ==========================================================================
   2. HERO / PRIMARY CTA SIZING  ("the get started button is all blown up")
   --------------------------------------------------------------------------
   css/marketing.css:1394 forces `.hero-cta-main { width: 100%;
   font-size: 1.5rem }` and :691 forces `.hero-waitlist-pill { width: 100% }`
   under 768px. Measured result: 211 `effectively_full_bleed` CTA findings and
   a 24px label inside a 63px control. A primary CTA should read as a button,
   not a banner: cap the width, keep the label at a normal reading size, and
   centre it in its own row.
   ========================================================================== */
@media (max-width: 1024px) {
    .hero-cta-main,
    .hero-waitlist-pill,
    .btn.btn-large,
    .hero-cta .btn,
    .cta-buttons .btn,
    .campaign-hero .hero-cta .btn {
        width: auto;
        max-width: min(100%, 22rem);
        min-width: 0;
        font-size: clamp(1rem, 0.95rem + 0.5vw, 1.125rem);
        line-height: 1.3;
        padding: 0.875rem 1.5rem;
        min-height: 48px;
        white-space: normal;
        text-align: center;
        justify-content: center;
    }

    /* The pill keeps its trailing chevron badge, so let it size to content
       but never exceed the readable cap above. */
    .hero-waitlist-pill {
        padding: 0.5rem 0.5rem 0.5rem 1.25rem;
    }

    /* Stack CTA rows instead of letting them stretch edge to edge. */
    .hero-cta,
    .cta-buttons {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
        max-width: 100%;
    }

    /* Slide CTAs stay anchored to the slot the slide artwork was composed
       around; they only needed a width cap, not a new position. Shrink the box
       to its content so it no longer spans the slide. */
    .hero-slide-cta {
        width: auto;
        max-width: min(88vw, 22rem);
    }
}

/* ==========================================================================
   3. FEATURED IMAGERY  ("the featured images are tiny")
   --------------------------------------------------------------------------
   266 `rendered_far_below_intrinsic` + `oversized_download_for_slot` findings:
   full-resolution artwork squeezed into a small slot by a fixed-width rule.
   Let feature/hero imagery use the column it has been given.
   ========================================================================== */
@media (max-width: 1024px) {
    .feature-card img,
    .feature-image img,
    .feature-visual img,
    .hero-visual img,
    .hero-image img,
    .hero-media img,
    .showcase-image img,
    .screenshot img,
    figure img,
    .blog-card-image img,
    .blog-post-content > p > img {
        width: 100%;
        height: auto;
        max-width: 100%;
        min-width: 0;
        object-fit: contain;
    }

    /* Icon-scale imagery must NOT be stretched by the rule above. `object-fit`
       defaults to `fill`, so an inline icon inheriting a taller line box gets
       squashed; `contain` keeps it square. */
    .feature-icon img,
    .docs-checklist__mark img,
    .status-section__icon img,
    .status-chip img,
    .docs-eyebrow__icon img,
    .docs-search__icon img,
    .docs-sidebar-head__icon img,
    .brand-icon,
    .logo-icon {
        width: auto;
        max-width: 100%;
        object-fit: contain;
    }
}

/* The 1485 measured CLS risks come from <img> tags with no width/height
   attributes; that needs an HTML change per template and cannot be fixed
   here. Reserving height for the two logo slots is the part CSS can do. */
.brand-icon {
    height: 44px;
}

.logo-icon {
    height: 36px;
}

/* ==========================================================================
   4. TAP TARGETS  (WCAG 2.5.8 — 24px minimum, 44px recommended)
   --------------------------------------------------------------------------
   Highest-volume finding in the sweep: footer link rows, nav CTA, breadcrumb
   links and blog lead-form controls all measured under the threshold.
   ========================================================================== */
@media (max-width: 1024px) {
    .footer-bottom-links a,
    .footer-cross-links a,
    .footer-column ul li a,
    .breadcrumbs a,
    .docs-nav-group a,
    .blog-card-link,
    .nav-auth-login,
    .auth-link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        padding-block: 0.25rem;
    }

    .footer-bottom-links,
    .footer-cross-links {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem 1rem;
    }

    .blog-lead-form input,
    .blog-lead-form button,
    .contact-field input,
    .contact-field select,
    .contact-field textarea {
        min-height: 44px;
        font-size: 1rem; /* also prevents iOS Safari zoom-on-focus */
    }

    .nav-waitlist-cta {
        min-height: 44px;
    }

    .docs-copy-button,
    .faq-question {
        min-height: 44px;
    }
}

/* ==========================================================================
   5. TABLE OVERFLOW
   --------------------------------------------------------------------------
   `table.compare-table` and `table.comparison-table` are unwrapped, so their
   rows drive horizontal page scroll (43 measured row-level overflows).
   Make the table itself the scroll container.
   ========================================================================== */
@media (max-width: 1024px) {
    .compare-container,
    .seo-container,
    .blog-post-content {
        max-width: 100%;
        overflow-x: hidden;
    }

    table.compare-table,
    table.comparison-table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    table.compare-table :is(td, th),
    table.comparison-table :is(td, th) {
        white-space: normal;
        min-width: 8rem;
    }
}

/* ==========================================================================
   6. TYPOGRAPHY FLOOR AND CEILING
   --------------------------------------------------------------------------
   224 `below_12px`, 468 `line_height_under_1_15` and 292
   `headline_over_40px_on_mobile` findings. Set a readable floor for small
   text, a sane leading floor, and cap display headlines so a single long
   word cannot force a horizontal scroll.
   ========================================================================== */
@media (max-width: 1024px) {
    .pillar-hero h1,
    .campaign-hero h1,
    .hero h1,
    .docs-hero h1 {
        font-size: clamp(1.75rem, 1.25rem + 3.2vw, 2.5rem);
        line-height: 1.2;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    .status-chip,
    .help-topic-link__badge,
    .contact-field span,
    .footer-bottom,
    small,
    .badge {
        font-size: max(0.75rem, 1em);
        line-height: 1.4;
    }

    /* Leading floor for body-scale copy. */
    p,
    li,
    dd,
    .contact-method__body strong,
    .contact-help-stats strong {
        line-height: 1.5;
    }
}

/* ==========================================================================
   7. FIXED-ELEMENT OCCLUSION
   --------------------------------------------------------------------------
   The floating chat launcher (`button.chat-demo`) overlaps footer links and
   bottom-anchored CTAs on short viewports. Keep it clear of both.
   ========================================================================== */
@media (max-width: 1024px) {
    button.chat-demo,
    .chat-fab,
    #askbob-widget-launcher {
        font-size: 1.25rem;
        min-width: 48px;
        min-height: 48px;
    }

    .unified-footer {
        padding-bottom: max(env(safe-area-inset-bottom), 5.5rem);
    }
}
