/*
 * mobile-fixes.css — overlay stylesheet loaded AFTER style.css on every
 * xraygraphdb.emtailabs.com page. Targets the patterns that broke on
 * small viewports: fixed-min tables, wide pre/code blocks, hero grids
 * that didn't stack tightly enough, undersized touch targets, and
 * the 1539-line demos / 9680-line docs pages that have hand-written
 * inline layouts not covered by style.css's breakpoints.
 *
 * Strategy: pure overlay, no edits to style.css. Anything we ship here
 * either tightens the existing breakpoints or wraps offending elements
 * defensively. Easy to roll back by removing the <link rel="stylesheet"
 * href="mobile-fixes.css"> tag from each page.
 *
 * Audit: 2026-05-16 — user reported "not mobile ready at all" against
 * the full marketing site.
 */

/* ---------- ROOT — make the whole site horizontal-scroll-safe ----- */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

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

/* ---------- TYPOGRAPHY — fluid sizing on every heading -------------
 * style.css's largest headings were fixed at 3-5 rem which overflows
 * a 360 px viewport. clamp() keeps them readable across screens. */
h1 { font-size: clamp(1.85rem, 5.5vw + 1rem, 4rem); line-height: 1.15; }
h2 { font-size: clamp(1.45rem, 3.5vw + 0.5rem, 2.5rem); line-height: 1.2; }
h3 { font-size: clamp(1.15rem, 2vw + 0.5rem, 1.5rem); line-height: 1.3; }

/* hero-tagline and section-subtitle: keep within viewport */
.hero-tagline, .section-subtitle, .lead {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* ---------- CODE / PRE — never overflow the page ------------------ */
pre, code, .code-block, .docker-oneliner pre {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  word-break: normal;
  max-width: 100%;
}
pre {
  font-size: clamp(0.7rem, 1vw + 0.5rem, 0.9rem);
}
code:not(pre code) {
  word-break: break-word;
}

/* ---------- TABLES — every table gets a horizontal-scroll guard ---- *
 * Wraps work when explicitly added, but page authors often forget.
 * Force scroll on the table itself for direct-styling safety. */
.comparison-table,
table.benchmark-table,
table.metric-table,
table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  width: 100%;
}
/* Restore proper table semantics when there's a container wrapping it */
.table-wrap, .table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin: 0 -16px;
  padding: 0 16px;
}
.table-wrap table, .table-scroll table {
  display: table;
  width: 100%;
}

/* ---------- NAV — hamburger menu open state polish ---------------- */
@media (max-width: 767px) {
  .nav { padding: 0; z-index: 1001 !important; }
  .nav-inner { padding: 12px 16px; }
  .nav-logo { font-size: 1.15rem; }
  .nav-toggle { padding: 10px; min-width: 44px; min-height: 44px; }
  .nav-mobile a {
    padding: 14px 8px;
    min-height: 48px;
    font-size: 1.05rem;
  }
  /* Hide the in-page overlay panel entirely on mobile — we route the
   * hamburger to /menu.html instead (a dedicated full page with a
   * guaranteed solid background). The overlay's z-index / opacity
   * was fightable in CSS but never reliably across browsers and CDN
   * cache states, and the user reported the "muddy bleed-through"
   * persisted even after the z-index/background fixes. The page
   * approach is bulletproof. */
  .nav-mobile, .nav-mobile.open {
    display: none !important;
  }
  /* Hero glow / radial gradients sometimes paint above static text
   * because they use position:absolute. Cap their z-index here. */
  .hero-bg, .hero-bg::before, .hero-bg::after { z-index: 0 !important; }
}

/* ---------- HERO — stack stats on phones, button-block ------------- */
@media (max-width: 640px) {
  .hero { padding-top: 60px; padding-bottom: 40px; }
  .hero h1 { margin-bottom: 12px; }
  .hero-tagline { font-size: 1.05rem !important; }
  .hero-buttons {
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 320px;
    margin: 24px auto 0;
  }
  .hero-buttons .btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 0.95rem;
  }
  .hero-stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 28px;
  }
  .hero-stat-value { font-size: 1.4rem; }
  .hero-stat-label { font-size: 0.7rem; }
}

/* ---------- PERF / TEASER GRIDS — stack 1-col on phones ------------ */
@media (max-width: 640px) {
  .perf-grid, .teaser-grid, .demo-grid, .feature-grid, .pricing-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }
  .perf-card, .teaser-card, .demo-card, .feature-card, .pricing-card {
    padding: 18px;
  }
  .perf-value { font-size: 1.6rem; }
}

/* ---------- BUTTONS — touch-friendly minimums ---------------------- */
.btn {
  min-height: 44px;
  white-space: nowrap;
}
@media (max-width: 480px) {
  .btn { padding: 12px 18px; font-size: 0.9rem; }
}

/* ---------- CONTAINER — saner padding on phones -------------------- */
.container {
  padding-left: 16px;
  padding-right: 16px;
  max-width: 100%;
}
@media (min-width: 640px) { .container { padding-left: 24px; padding-right: 24px; } }
@media (min-width: 1024px) { .container { max-width: 1200px; margin: 0 auto; } }

/* ---------- FOOTER — stack columns, center on small ---------------- */
@media (max-width: 640px) {
  .footer-content {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
  .footer-links {
    flex-direction: column;
    gap: 10px;
    padding: 0;
  }
  .footer-links li { margin: 0; }
  .footer-links a { padding: 8px; display: inline-block; min-height: 44px; }
}

/* ---------- CTA BANNER — readable on phones ------------------------ */
@media (max-width: 640px) {
  .cta-banner {
    padding: 28px 18px !important;
  }
  .cta-banner h2 { font-size: 1.4rem; }
  .cta-banner p  { font-size: 0.95rem; margin-bottom: 18px; }
}

/* ---------- HERO BACKGROUND — clamp the 800px gradient ------------- */
@media (max-width: 800px) {
  .hero-bg::before {
    width: 100% !important;
    height: 100vw !important;
    max-width: 600px;
    max-height: 600px;
  }
}

/* ---------- DOCS PAGE — sidebar collapses on phones --------------- *
 * docs.html has 9680 lines; the historical sidebar nav was a fixed
 * 280px column that ate half the viewport on a phone. Convert to a
 * top-of-page expand/collapse below 800px. */
@media (max-width: 800px) {
  .docs-layout, .docs-grid, .docs-with-sidebar {
    grid-template-columns: 1fr !important;
    display: block !important;
  }
  .docs-sidebar, .sidebar {
    position: static !important;
    width: 100% !important;
    max-height: none !important;
    margin-bottom: 24px;
    border-right: none !important;
    border-bottom: 1px solid var(--border-subtle, #1a3a5c);
    padding-bottom: 18px;
  }
}

/* ---------- DEMOS PAGE — iframe cards stack -----------------------
 * demos.html embeds demos as <iframe> + side-panel description. On
 * narrow viewports stack vertically and let iframes use 100% width. */
@media (max-width: 768px) {
  .demo-row, .demo-card-wide {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .demo-iframe-wrap, .demo-iframe {
    width: 100% !important;
    height: 60vh !important;
    min-height: 360px;
  }
}

/* ---------- HORIZONTAL OVERFLOW DEBUG (commented) ------------------ */
/* Uncomment this to find offenders during testing:
 * { outline: 1px solid rgba(255,0,0,0.3) !important; }
*/
