/* SPEEDACURE_MOBILE_FIT_V1_6
   Scoped, CSP-safe responsive corrections for the modern mobile home,
   prescription modal, GPS city dialog, and standalone Rx tracking page.
   No viewport-scale restrictions and no changes to checkout or business logic.
*/

@media screen and (max-width: 820px) {
  html.scm-mobile-modern,
  html.scm-mobile-modern body.scm-modern-active {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  /* clip rather than hidden: avoid turning body into a horizontal scroll container */
  html.scm-mobile-modern body.scm-modern-active {
    margin: 0 !important;
    overflow-x: clip;
  }

  html.scm-mobile-modern .scm-home,
  html.scm-mobile-modern .scm-header,
  html.scm-mobile-modern .scm-main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  /* Existing grid uses 118px + unconstrained location + action icons;
     those min-content sizes can force mobile viewport overflow. */
  html.scm-mobile-modern .scm-header-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 128px) auto;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }
  html.scm-mobile-modern .scm-brand,
  html.scm-mobile-modern .scm-brand img {
    min-width: 0;
    max-width: 100%;
  }
  html.scm-mobile-modern .scm-location-pill {
    display: flex;
    width: 100%;
    min-width: 0;
    max-width: 128px;
    gap: 3px;
    padding: 8px 6px;
    justify-content: center;
    overflow: hidden;
  }
  html.scm-mobile-modern .scm-location-pill > span {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  html.scm-mobile-modern .scm-location-pill > svg { flex: 0 0 auto; }
  html.scm-mobile-modern .scm-header-actions {
    min-width: 0;
    flex: 0 0 auto;
    gap: 4px;
  }
  html.scm-mobile-modern .scm-header-actions > a,
  html.scm-mobile-modern .scm-header-actions > button {
    flex: 0 0 32px;
    width: 32px;
    min-width: 32px;
    height: 32px;
  }
  html.scm-mobile-modern .scm-search {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: 22px minmax(0, 1fr) 28px 1px 28px;
    gap: 5px;
  }
  html.scm-mobile-modern .scm-search input {
    min-width: 0;
    max-width: 100%;
    text-overflow: ellipsis;
  }
  html.scm-mobile-modern .scm-search-action {
    min-width: 0;
    width: 28px;
  }

  html.scm-mobile-modern .scm-main > *,
  html.scm-mobile-modern .scm-section,
  html.scm-mobile-modern .scm-rx-hero,
  html.scm-mobile-modern .scm-carousel,
  html.scm-mobile-modern .scm-trust,
  html.scm-mobile-modern .scm-category-grid,
  html.scm-mobile-modern .scm-featured-grid {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  html.scm-mobile-modern .scm-slides {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto; /* Carousel must remain horizontally swipeable. */
  }
  html.scm-mobile-modern .scm-slide {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  html.scm-mobile-modern .scm-trust,
  html.scm-mobile-modern .scm-category-grid,
  html.scm-mobile-modern .scm-featured-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  html.scm-mobile-modern .scm-trust > div,
  html.scm-mobile-modern .scm-cat,
  html.scm-mobile-modern .scm-feature-card {
    min-width: 0;
    box-sizing: border-box;
  }
  html.scm-mobile-modern .scm-trust strong,
  html.scm-mobile-modern .scm-trust small {
    overflow-wrap: anywhere;
  }
  html.scm-mobile-modern .scm-cat > span {
    min-width: 0;
    max-width: 64%;
  }
  html.scm-mobile-modern .scm-cat strong {
    font-size: clamp(13px, 4.1vw, 17px);
    overflow-wrap: break-word;
    line-height: 1.05;
  }
  html.scm-mobile-modern .scm-cat small {
    max-width: 100%;
    font-size: clamp(10px, 2.7vw, 11px);
    overflow-wrap: anywhere;
  }
  html.scm-mobile-modern .scm-cat svg {
    max-width: 44%;
    right: 0;
  }
  html.scm-mobile-modern .scm-section-head {
    min-width: 0;
    gap: 8px;
  }
  html.scm-mobile-modern .scm-section-head h2 {
    min-width: 0;
    font-size: clamp(18px, 5.5vw, 22px);
    overflow-wrap: anywhere;
  }
  html.scm-mobile-modern .scm-section-head > a {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  html.scm-mobile-modern .scm-feature-card {
    grid-template-columns: clamp(48px, 17vw, 70px) minmax(0, 1fr);
    gap: 7px;
  }
  html.scm-mobile-modern .scm-feature-card > div {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  html.scm-mobile-modern .scm-feature-card img {
    display: block;
    width: 100%;
    max-width: 70px;
    aspect-ratio: 1 / 1;
    height: auto;
    object-fit: contain;
  }

  /* Keep the one existing five-item navigation fixed; no duplicate nav. */
  html.scm-mobile-modern .scm-bottom-nav {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    box-sizing: border-box;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding-bottom: calc(7px + env(safe-area-inset-bottom, 0px));
  }
  html.scm-mobile-modern .scm-bottom-nav > a,
  html.scm-mobile-modern .scm-bottom-nav > button {
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    text-align: center;
  }
  html.scm-mobile-modern .scm-bottom-nav > a > span:last-child,
  html.scm-mobile-modern .scm-bottom-nav > button > span:last-child {
    max-width: 100%;
    font-size: 10px;
    overflow-wrap: anywhere;
  }

  /* Dialogs must fit the visual viewport; inner content can scroll. */
  #locationDialog,
  #rxDialog {
    width: min(100%, 520px);
    max-width: 100vw;
    box-sizing: border-box;
  }
  #locationDialog .scm-sheet,
  #rxDialog .scm-sheet {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: calc(100dvh - 48px);
    overflow-x: clip;
    overflow-y: auto;
  }
  #locationDialog .scm-city-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #locationDialog .scm-city-list button {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  #rxDialog .sc-rx-intake-form,
  #rxDialog .sc-rx-fields,
  #rxDialog .sc-rx-file-area,
  #rxDialog .sc-rx-reference {
    min-width: 0;
    max-width: 100%;
  }
  #rxDialog .sc-rx-file-area input[type="file"] {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  #rxDialog .sc-rx-reference {
    flex-wrap: wrap;
  }
}

@media screen and (max-width: 380px) {
  html.scm-mobile-modern .scm-header-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 118px) auto;
    gap: 4px;
  }
  html.scm-mobile-modern .scm-header-actions > a:first-child {
    display: none;
  }
  html.scm-mobile-modern .scm-header-actions { gap: 4px; }
  html.scm-mobile-modern .scm-location-pill { max-width: 118px; }
  html.scm-mobile-modern .scm-cat > span { max-width: 66%; }
  #rxDialog .sc-rx-fields { grid-template-columns: 1fr; }
  #rxDialog .sc-rx-fields > :last-child { grid-column: auto; }
}

/* Standalone prescription tracking page: mobile-specific sizing only. */
@media screen and (max-width: 620px) {
  html:has(.sc-track-main),
  body:has(.sc-track-main) {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: clip;
  }
  .sc-track-header {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 13px 12px;
    gap: 8px;
  }
  .sc-track-header a:first-child { font-size: 18px; white-space: nowrap; }
  .sc-track-header a:last-child { font-size: 12px; text-align: right; }
  .sc-track-main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin: 14px auto 20px;
    padding: 0 12px;
  }
  .sc-track-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 17px 15px;
    border-radius: 17px;
  }
  .sc-track-card h1 { font-size: clamp(23px, 6vw, 30px); }
  #sc-track-form,
  #sc-track-form input,
  #sc-track-result {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  .sc-track-result strong { overflow-wrap: anywhere; }
  .sc-track-stages { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 8px; }
  .sc-track-stage { min-width: 0; }
  .sc-track-stage small { overflow-wrap: anywhere; }
}
