/* JOPUJA Home Mobile Layout V8
   Limited scope: quick links and marketplace product presentation only.
   The existing theme colours, dark/light variables and purchase handlers remain in control. */

@media (max-width: 900px) {
  body.home-page .hero .quick-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important;
    width: 100%;
    gap: 10px !important;
    margin-inline: 0 !important;
    align-items: stretch;
  }

  body.home-page .hero .quick-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start;
    gap: 9px !important;
    width: 100%;
    min-width: 0;
    min-height: 76px;
    padding: 10px !important;
    box-sizing: border-box;
    overflow: hidden;
  }

  body.home-page .hero .quick-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    font-size: 17px;
  }

  body.home-page .hero .quick-card > span:last-child {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    overflow-wrap: anywhere;
  }

  body.home-page .hero .quick-card b {
    display: block;
    font-size: clamp(12px, 2.8vw, 14px);
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  body.home-page .hero .quick-card small {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
}

/* A single horizontal rail is used for mobile/tablet marketplace results.
   JS groups four product cards into one 2-by-2 slide, preserving DOM order. */
@media (max-width: 900px) {
  body.home-page #marketplace #productGrid.marketplace-mobile-rail {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch;
    gap: 12px !important;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: none !important;
    grid-auto-flow: initial !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 2px 1px 12px;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 1px;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary, #c61e35) var(--panel2, #e9edf3);
    touch-action: pan-x pan-y;
  }

  body.home-page #marketplace #productGrid.marketplace-mobile-rail::-webkit-scrollbar {
    height: 5px;
  }

  body.home-page #marketplace #productGrid.marketplace-mobile-rail::-webkit-scrollbar-thumb {
    background: var(--primary, #c61e35);
    border-radius: 99px;
  }

  body.home-page #marketplace #productGrid .market-product-slide {
    display: grid;
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, auto));
    grid-auto-flow: row;
    align-content: start;
    align-items: stretch;
    gap: 10px;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  body.home-page #marketplace #productGrid .market-product-slide > .product-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    box-sizing: border-box;
  }

  body.home-page #marketplace #productGrid .market-product-slide .product-detail-link,
  body.home-page #marketplace #productGrid .market-product-slide .product-img {
    min-width: 0;
    max-width: 100%;
  }

  body.home-page #marketplace #productGrid .market-product-slide .product-img {
    width: 100%;
    aspect-ratio: 1.6 / 1;
    min-height: 78px;
    max-height: 155px;
  }

  body.home-page #marketplace #productGrid .market-product-slide .product-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    padding: 9px;
    overflow-wrap: anywhere;
  }

  body.home-page #marketplace #productGrid .market-product-slide .product-body > .pill {
    align-self: flex-start;
    max-width: 100%;
    padding: 4px 6px;
    font-size: 9px;
    overflow-wrap: anywhere;
  }

  body.home-page #marketplace #productGrid .market-product-slide .product-body h3 {
    margin: 7px 0 4px;
    font-size: clamp(12px, 3.15vw, 14px);
    line-height: 1.28;
    overflow-wrap: anywhere;
  }

  body.home-page #marketplace #productGrid .market-product-slide .product-description {
    height: auto;
    min-height: 0;
    max-height: 2.8em;
    margin: 4px 0 6px;
    font-size: 10px;
    line-height: 1.4;
    -webkit-line-clamp: 2;
  }

  body.home-page #marketplace #productGrid .market-product-slide .product-buyline {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    margin-top: auto;
    padding-top: 8px;
  }

  body.home-page #marketplace #productGrid .market-product-slide .product-price {
    font-size: clamp(13px, 3.5vw, 16px);
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  body.home-page #marketplace #productGrid .market-product-slide .product-buyline small {
    font-size: 9px;
  }

  body.home-page #marketplace #productGrid .market-product-slide .product-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    min-width: 0;
  }

  body.home-page #marketplace #productGrid .market-product-slide .product-actions .btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    width: 100%;
    min-height: 34px;
    margin: 0;
    padding: 6px 4px;
    font-size: 10px;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* The empty-state message should occupy the available width, not half a card. */
  body.home-page #marketplace #productGrid > .card:only-child {
    grid-column: 1 / -1;
    flex: 0 0 100%;
    width: 100%;
  }
}

@media (max-width: 380px) {
  body.home-page .hero .quick-grid { gap: 8px !important; }
  body.home-page .hero .quick-card { gap: 7px !important; padding: 8px !important; min-height: 72px; }
  body.home-page .hero .quick-icon { width: 30px; height: 30px; min-width: 30px; flex-basis: 30px; }
  body.home-page #marketplace #productGrid .market-product-slide { gap: 8px; }
  body.home-page #marketplace #productGrid .market-product-slide .product-body { padding: 7px; }
  body.home-page #marketplace #productGrid .market-product-slide .product-actions { gap: 4px; }
  body.home-page #marketplace #productGrid .market-product-slide .product-actions .btn { font-size: 9px; padding-inline: 3px; }
}
