/* language: CSS, file: mobile-fit.css, target: all AI Pharma Hub clones
   Forces every page to fit phone screens (390px+) with no horizontal split.
   Loaded LAST so it overrides original template fixed-width rules. */

/* --- 1. Kill horizontal overflow at the root --- */
html {
  overflow-x: hidden !important;
  max-width: 100% !important;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
  position: relative;
}

/* --- 2. Nothing may exceed the viewport --- */
img,
svg,
video,
canvas,
picture,
iframe,
embed,
object,
audio {
  max-width: 100% !important;
  height: auto !important;
}
img,
picture,
video,
canvas {
  object-fit: contain;
}

/* Wide media wrappers used by the source templates */
.ocsr-capture,
.ocsr-capture img,
.canvas-showcase,
.canvas-showcase img,
.image-button,
.image-button img,
.norm-stage,
.norm-stage img,
.science-image,
.science-image img,
.hero-art,
.hero-art img,
.offline-sculpture,
.offline-sculpture img,
.figure,
figure {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
  transform: none !important;
}

/* Absolute-positioned art that bleeds off-canvas on desktop */
.hero-art,
.screen-left,
.screen-right,
.offline-sculpture {
  position: relative !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  inset: auto !important;
}

/* --- 3. Sections and containers shrink to the screen --- */
.section,
.container,
main,
main > section,
header,
footer,
nav,
article,
aside,
[role="main"] {
  max-width: 100% !important;
  box-sizing: border-box;
}
.section {
  padding-left: clamp(16px, 5vw, 32px) !important;
  padding-right: clamp(16px, 5vw, 32px) !important;
}
.container {
  padding-left: clamp(16px, 5vw, 32px) !important;
  padding-right: clamp(16px, 5vw, 32px) !important;
}

/* --- 4. Text never forces a horizontal split --- */
h1, h2, h3, h4, h5, h6, p, li, a, span, strong, small, td, th, blockquote, figcaption, label, button {
  max-width: 100% !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
}
h1 { font-size: clamp(28px, 7vw, 44px) !important; }
h2 { font-size: clamp(22px, 5.5vw, 34px) !important; }
h3 { font-size: clamp(18px, 4.5vw, 26px) !important; }

/* --- 5. Grids and flex rows collapse to one column on phones --- */
@media (max-width: 900px) {
  .three-details,
  .team-credit-grid,
  .role-credits,
  .manifesto-bottom,
  .chapter-index,
  .citation-card,
  .citation-actions,
  .download-actions,
  .about-grid,
  .about-stats,
  .news-grid,
  .footer-top,
  .footer-bottom,
  .footer-cols,
  .footer-grid,
  .partners-grid,
  .gallery-grid,
  .gallery-track,
  .grid,
  [class*="-grid"],
  [class*="-cols"],
  [class*="-track"] {
    grid-template-columns: 1fr !important;
    display: block !important;
  }
  .three-details article,
  .team-credit-grid article,
  .news-card,
  .role-credits p,
  .about-stats .stat-item {
    margin-bottom: 14px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .role-credits {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
  }
  .role-credits p {
    min-width: 100% !important;
    box-sizing: border-box;
  }
}

/* --- 6. Horizontal carousels stay swipeable but never widen the page --- */
.marquee-wrapper,
.marquee-content,
.journey-viewport,
.journey-track,
.science-viewport,
.science-track,
.swiper,
.swiper-wrapper,
.swiper-slide,
.logo-scroll {
  max-width: 100vw !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}
.journey-track,
.science-track,
.swiper-wrapper,
.marquee-content,
.logo-scroll {
  transform: none !important;
}

/* --- 7. Fixed / sticky bars fit the screen --- */
.fixed-bar,
.topbar,
.site-header,
.sticky,
[style*="position: fixed"],
[style*="position:fixed"] {
  max-width: 100vw !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  box-sizing: border-box;
}

/* --- 8. Tables scroll inside their own box --- */
table {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  border-collapse: collapse;
  box-sizing: border-box;
}
td, th { white-space: normal !important; }

/* --- 9. Buttons and inputs never overflow --- */
button,
input,
select,
textarea,
a.button,
.btn,
.button {
  max-width: 100% !important;
  box-sizing: border-box;
  white-space: normal !important;
}

/* --- 10. Headers and nav bars fit phones without squeezing or splitting --- */
@media (max-width: 900px) {
  header.global,
  .product-nav,
  .site-header,
  .top-bar,
  .main-navigation,
  .nav-header,
  .nav-menu-wrapper {
    max-width: 100vw !important;
    box-sizing: border-box;
    flex-wrap: wrap !important;
    gap: 10px !important;
  }

  /* Nav links: one swipeable row instead of a vertical squeeze */
  header.global nav,
  .product-nav nav,
  .main-menu,
  .nav-menu {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 14px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding-bottom: 4px;
  }
  header.global nav::-webkit-scrollbar,
  .product-nav nav::-webkit-scrollbar,
  .main-menu::-webkit-scrollbar { display: none; }

  header.global nav a,
  .product-nav nav a,
  .main-menu a,
  .main-menu li {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    max-width: none !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }

  /* Brand / logo never gets crushed into vertical letters */
  .brand,
  .site-logo,
  .product-name,
  .logo-text {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 48vw !important;
  }
  .brand span,
  .product-name span { max-width: none !important; overflow-wrap: normal !important; }

  .product-nav { padding-top: 10px !important; padding-bottom: 10px !important; }
  .button.small,
  .windows-button { font-size: 12px !important; padding: 8px 12px !important; white-space: nowrap !important; }

  /* cppsynd top bar: contact info wraps, search takes full width */
  .top-bar-content,
  .contact-info {
    flex-wrap: wrap !important;
    gap: 10px 16px !important;
  }
  .search-wrapper { width: 100% !important; max-width: 100% !important; }
  .search-input { width: 100% !important; max-width: 100% !important; }
}

/* --- 11. Very small phones (320px) --- */
@media (max-width: 400px) {
  .section { padding-left: 14px !important; padding-right: 14px !important; }
  .container { padding-left: 14px !important; padding-right: 14px !important; }
  h1 { font-size: 26px !important; }
  h2 { font-size: 21px !important; }
  .brand, .product-name { max-width: 42vw !important; }
  header.global nav a, .product-nav nav a, .main-menu a { font-size: 12px !important; }
}
