/*
  Peckham Crystals — mobile overflow repair
  Load AFTER assets/style.css.
  Desktop styling is untouched; all layout overrides are mobile/tablet only.
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  overflow-x: clip;
}

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

img,
video,
canvas,
svg {
  height: auto;
}

@supports not (overflow: clip) {
  html,
  body {
    overflow-x: hidden;
  }
}

@media (max-width: 900px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body,
  header,
  nav,
  main,
  section,
  article,
  aside,
  footer,
  form,
  fieldset,
  header *,
  main *,
  footer * {
    min-width: 0;
  }

  body > *,
  header,
  nav,
  main,
  section,
  footer,
  .container,
  .wrapper,
  .wrap,
  .inner,
  .site-width,
  .page-width,
  .content-width,
  .header-inner,
  .nav-inner,
  .hero-inner,
  .footer-inner {
    max-width: 100%;
  }

  /* Header and navigation: wrap rather than force a desktop-width row. */
  header,
  .site-header,
  .header-inner,
  .topbar,
  .navbar,
  .nav-inner,
  nav,
  nav ul,
  .nav-links,
  .menu,
  .main-menu {
    flex-wrap: wrap;
  }

  nav,
  nav ul,
  .nav-links,
  .menu,
  .main-menu {
    width: 100%;
    max-width: 100%;
  }

  nav ul,
  .nav-links,
  .menu,
  .main-menu {
    gap: 0.45rem 0.7rem;
    padding-left: 0;
  }

  nav a,
  .nav-links a,
  .menu a,
  .main-menu a {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* Search controls must be allowed to shrink inside the header. */
  .search,
  .search-form,
  form[role="search"] {
    display: flex;
    width: 100%;
    max-width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  input,
  select,
  textarea,
  button {
    max-width: 100%;
    min-width: 0;
  }

  .search input,
  .search-form input,
  form[role="search"] input,
  input[type="search"] {
    flex: 1 1 12rem;
    width: auto;
  }

  /* Hero, statistic and feature rows become fluid. */
  .hero,
  .hero-grid,
  .hero-content,
  .hero-copy,
  .hero-media,
  .stats,
  .stat-grid,
  .feature,
  .feature-grid,
  .network-feature,
  .rhapsode,
  .rhapsode-feature {
    width: 100%;
    max-width: 100%;
  }

  .hero-grid,
  .stat-grid,
  .feature-grid,
  .network-feature,
  .rhapsode-feature {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Category links wrap inside the viewport instead of widening the page. */
  .categories,
  .category-list,
  .category-links,
  .category-filter,
  .filters,
  .filter-list,
  .chips,
  .pills,
  [class*="categor"] ul {
    max-width: 100%;
    flex-wrap: wrap;
    white-space: normal;
  }

  .categories a,
  .category-list a,
  .category-links a,
  .category-filter a,
  .filters a,
  .filter-list a,
  .chips a,
  .pills a {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* Product and shop collections: two columns on tablets. */
  .products,
  .product-grid,
  .products-grid,
  .catalogue-grid,
  .catalog-grid,
  .shop-grid,
  .store-grid,
  .amazon-grid,
  .cards,
  .card-grid {
    width: 100%;
    max-width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product,
  .product-card,
  .catalogue-card,
  .catalog-card,
  .shop-card,
  .store-card,
  .amazon-card,
  .card {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  .product img,
  .product-card img,
  .catalogue-card img,
  .catalog-card img,
  .shop-card img,
  .store-card img,
  .amazon-card img,
  .card img {
    display: block;
    width: 100%;
    max-width: 100%;
    object-fit: cover;
  }

  h1,
  h2,
  h3,
  h4,
  p,
  li,
  a,
  span,
  strong,
  small {
    overflow-wrap: anywhere;
    word-break: normal;
  }

  pre,
  code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  [width] {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  /* One clean product column on phones. */
  .products,
  .product-grid,
  .products-grid,
  .catalogue-grid,
  .catalog-grid,
  .shop-grid,
  .store-grid,
  .amazon-grid,
  .cards,
  .card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .container,
  .wrapper,
  .wrap,
  .inner,
  .site-width,
  .page-width,
  .content-width,
  main > section {
    width: 100%;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  h1 {
    font-size: clamp(1.8rem, 9vw, 2.7rem);
    line-height: 1.05;
  }

  h2 {
    font-size: clamp(1.35rem, 7vw, 2rem);
    line-height: 1.12;
  }

  .button,
  .btn,
  button,
  input[type="submit"] {
    min-height: 44px;
  }
}
