/* Mobile-first usability pass for the active Astro storefront.
 * Loaded last so these narrow-screen rules reliably refine the legacy desktop-first styles.
 */
html {
  -webkit-text-size-adjust: 100%;
}

body,
main {
  min-width: 0;
}

body {
  overflow-x: hidden;
}

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

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

@media (max-width: 760px) {
  .announce {
    padding: 0.45rem 0.75rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  body > header {
    gap: 0.55rem;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
  }

  body > header .brand {
    min-width: 0;
    flex: 0 1 auto;
  }

  body > header .brand > img {
    width: min(116px, 31vw);
    min-width: 0;
  }

  #menu,
  .cart {
    min-height: 44px;
    flex-shrink: 0;
  }

  #menu {
    min-width: 44px;
    padding: 0.5rem 0.65rem;
  }

  .cart {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  body > header nav.open {
    max-height: calc(100dvh - 74px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.75rem 1rem 1rem;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 35px rgba(7, 36, 80, 0.12);
  }

  body > header nav.open a {
    display: flex;
    min-height: 44px;
    align-items: center;
    padding: 0.35rem 0;
  }

  .store-hero {
    padding: 2.35rem 1rem;
  }

  .store-hero > div,
  .store-hero > aside {
    min-width: 0;
  }

  .store-hero h1 {
    font-size: clamp(2.15rem, 10vw, 3.1rem);
    overflow-wrap: anywhere;
  }

  .store-hero > aside {
    width: 100%;
    margin-top: 1.25rem;
  }

  .store {
    padding: 1rem 0.75rem 5.75rem;
  }

  .filters {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
  }

  .filters input,
  .filters select,
  .result-bar select,
  .actions input,
  .detail-add input,
  .checkout input,
  .checkout select,
  .checkout textarea,
  .cart-item input {
    min-height: 44px;
    font-size: 16px;
  }

  .result-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .result-bar label {
    display: grid;
    width: 100%;
    gap: 0.35rem;
  }

  .result-bar select {
    width: 100%;
  }

  .product-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .product-card,
  .product-info {
    min-width: 0;
  }

  .product-image {
    height: 220px;
  }

  .product-image img {
    width: 180px;
    height: 180px;
    max-width: 82%;
    max-height: 82%;
  }

  .product-info {
    padding: 1rem;
  }

  .product-info .badges {
    flex-wrap: wrap;
    row-gap: 0.35rem;
  }

  .product-info .badges em {
    margin-left: 0;
  }

  .product-info h2 {
    margin-top: 0.45rem;
    font-size: 1.2rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .product-info .actions {
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: end;
  }

  .product-info .actions button {
    min-height: 44px;
  }

  .pagination {
    gap: 0.4rem;
    margin-top: 1.5rem;
  }

  .pagination button {
    min-width: 44px;
    min-height: 44px;
    padding: 0.55rem 0.7rem;
  }

  .mobile-cart {
    width: calc(100% - 1.5rem);
    max-width: 420px;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    padding: 0.8rem 1rem;
    text-align: center;
  }

  body:has(.mobile-cart) .messenger-fab {
    bottom: max(5.25rem, calc(env(safe-area-inset-bottom) + 5.25rem));
  }

  body:has(.mobile-cart) .toast {
    bottom: max(5.5rem, calc(env(safe-area-inset-bottom) + 5.5rem));
  }

  .crumb {
    max-width: 100%;
    overflow-x: auto;
    padding: 1.25rem 1rem 0.25rem;
    white-space: nowrap;
    scrollbar-width: thin;
  }

  .detail {
    gap: 1.5rem;
    padding: 1.5rem 1rem 2.5rem;
  }

  .detail-image {
    height: min(360px, 88vw);
    border-radius: 18px;
  }

  .detail h1 {
    margin-top: 0.45rem;
    font-size: clamp(2.15rem, 10vw, 3.1rem);
    overflow-wrap: anywhere;
  }

  .meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .meta span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .detail-add {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    align-items: end;
  }

  .detail-add input {
    width: 100%;
  }

  .detail-add button {
    min-height: 44px;
  }

  .prose {
    margin: 1rem 0.75rem 3rem;
    padding: 1.25rem;
    border-radius: 18px;
    overflow-wrap: anywhere;
  }

  .content-head {
    padding: 3rem 1rem;
  }

  .content-head h1,
  .page-head h1,
  .success h1 {
    overflow-wrap: anywhere;
  }

  .page-head {
    padding: 2rem 1rem 1rem;
  }

  .page-head h1 {
    margin-bottom: 0.75rem;
    font-size: clamp(2.15rem, 10vw, 3rem);
  }

  .cart-layout {
    gap: 1.25rem;
    padding: 1rem 1rem 4.5rem;
  }

  .cart-item {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
  }

  .cart-item > img {
    width: 56px;
    height: 56px;
    grid-row: 1 / span 2;
  }

  .cart-item > div {
    min-width: 0;
  }

  .cart-item h2,
  .cart-item p {
    overflow-wrap: anywhere;
  }

  .cart-item > label,
  .cart-item > b,
  .cart-item > button {
    grid-column: 2;
  }

  .cart-item > label {
    display: grid;
    width: 100%;
    gap: 0.25rem;
  }

  .cart-item > label input {
    width: 100%;
  }

  .cart-item > b,
  .cart-item > button {
    justify-self: start;
  }

  .cart-item > button {
    min-height: 44px;
    padding: 0.6rem 0.95rem;
  }

  .cart-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    margin-top: 1rem;
  }

  .cart-links a,
  .cart-links button {
    min-height: 44px;
  }

  .cart-links a {
    display: flex;
    align-items: center;
  }

  .cart-links button {
    justify-content: flex-start;
  }

  .summary {
    min-width: 0;
    padding: 1rem;
    overflow-wrap: anywhere;
  }

  .summary > div,
  .summary #checkout-items p {
    min-width: 0;
  }

  .checkout {
    padding: 2rem 1rem 4.5rem;
  }

  .checkout > .page-head {
    padding: 0 0 1.25rem;
  }

  .checkout-layout {
    gap: 1.25rem;
  }

  .checkout fieldset {
    min-width: 0;
    padding: 1rem;
  }

  .checkout legend {
    max-width: 100%;
    font-size: 1.2rem;
    line-height: 1.25;
  }

  .checkout label {
    min-width: 0;
  }

  .checkout textarea {
    resize: vertical;
  }

  .consent {
    margin: 0.8rem 0;
    line-height: 1.45;
  }

  .consent input {
    flex: 0 0 auto;
    margin-top: 0.2rem;
  }

  .success {
    padding: 2rem 1rem 4.5rem;
  }

  .reference {
    max-width: 100%;
    margin: 1rem 0;
    padding: 1rem;
    overflow-wrap: anywhere;
  }

  body > footer {
    gap: 1.75rem;
    padding: 3rem 1rem calc(5rem + env(safe-area-inset-bottom));
  }

  body > footer > div,
  .legal {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* Home */
  .home-hero-content {
    padding: 3rem 1.25rem 1.5rem;
  }

  .home-hero-content h1 {
    font-size: clamp(2.15rem, 10vw, 3.1rem);
    line-height: 1.02;
    overflow-wrap: anywhere;
  }

  .home-hero-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    gap: 0.6rem;
    margin-top: 1.5rem;
  }

  .home-hero-primary,
  .home-hero-secondary {
    width: 100%;
    min-height: 48px;
  }

  .home-hero-media {
    min-height: 230px;
    padding: 0 1.5rem 3.25rem;
  }

  .home-hero-arrow {
    width: 36px;
    height: 36px;
    font-size: 1.35rem;
  }

  .home-hero-prev {
    left: 0.5rem;
  }

  .home-hero-next {
    right: 0.5rem;
  }

  .home-section {
    padding: 3rem 1rem;
  }

  .home-section-heading {
    gap: 1rem;
    margin-bottom: 1.35rem;
  }

  .home-slider-actions {
    align-self: flex-start;
  }

  .home-product-track {
    grid-auto-columns: clamp(240px, 82vw, 320px);
    margin-right: -1rem;
    padding-right: 1rem;
  }

  .home-product-image {
    flex-basis: 220px;
    height: 220px;
    min-height: 220px;
  }

  .home-help > .outline {
    width: 100%;
    min-height: 48px;
  }
}

@media (max-width: 390px) {
  .announce {
    font-size: 0.68rem;
  }

  body > header {
    gap: 0.4rem;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
  }

  body > header .brand > img {
    width: min(96px, 30vw);
  }

  #menu {
    padding-right: 0.55rem;
    padding-left: 0.55rem;
    font-size: 0.82rem;
  }

  .cart {
    font-size: 0.76rem;
  }

  .meta,
  .product-info .actions,
  .detail-add {
    grid-template-columns: 1fr;
  }

  .detail-add input {
    width: 100%;
  }

  .cart-item {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .cart-item > img {
    width: 48px;
    height: 48px;
  }

  .home-hero-content {
    padding: 2.5rem 1rem 1.25rem;
  }

  .home-hero-media {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .home-product-track {
    grid-auto-columns: calc(100vw - 2rem);
  }
}
