/*
 * ZibStore mobile layout — v238-mobile-layout-pass-1
 * Scope: catalog filters + product grid only.
 * Modal/mobile product details are intentionally left for the next pass.
 */

@media (max-width: 600px) {
  /* Keep the catalogue compact while preserving the existing desktop spacing. */
  #catalog {
    padding-top: 2rem;
    padding-bottom: 2.5rem;
  }

  /* Two equal quick-filter tiles instead of wrapping into a tall uneven stack. */
  #catalog-quick-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.5rem;
  }

  #catalog-quick-filters .catalog-quick-filter {
    width: 100%;
    min-width: 0;
    min-height: 58px;
    gap: 0.55rem;
    padding: 0.7rem 0.75rem;
  }

  #catalog-quick-filters .catalog-quick-filter > span:last-child {
    min-width: 0;
  }

  #catalog-quick-filters .catalog-quick-filter > span:last-child > span:first-child {
    font-size: 0.875rem;
    line-height: 1.15;
  }

  #catalog-quick-filters .catalog-quick-filter > span:last-child > span:last-child {
    margin-top: 0.15rem;
    font-size: 0.675rem;
    line-height: 1.2;
  }

  /* Categories get their own row; edition/sort no longer float on the right. */
  #category-strip {
    flex: 1 1 100%;
    width: 100%;
  }

  #catalog-controls {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    margin-left: 0 !important;
    gap: 0.625rem;
    justify-content: stretch !important;
  }

  #edition-filter-wrap,
  #sort-filter-wrap {
    width: 100% !important;
    max-width: none !important;
  }

  #edition-filter-button,
  #sort-filter-button {
    min-height: 48px;
  }

  #edition-filter-menu,
  #sort-filter-menu {
    left: 0;
    right: auto;
    width: 100%;
  }

  #catalog-toolbar {
    margin-bottom: 1rem;
  }

  /* A phone gets one readable card per row.  Max width prevents oversized cards
     on unusually wide phones while retaining the current card design intact. */
  #product-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 1rem;
  }

  #product-grid > .product-card-clickable {
    width: 100%;
    max-width: 430px;
    margin-inline: auto;
  }
}

@media (max-width: 350px) {
  #catalog-quick-filters {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* -------------------------------------------------------------------------
 * v239-mobile-modal-pass-1
 * Mobile product modal only. Desktop remains unchanged.
 * ---------------------------------------------------------------------- */
@media (max-width: 600px) {
  /* Give the dialog more usable width and reduce wasted outer padding. */
  #product-modal > .relative {
    padding: 0.5rem;
    align-items: flex-start;
  }

  #product-modal-panel {
    width: 100%;
    max-height: calc(100dvh - 1rem);
    border-radius: 1rem;
  }

  #product-modal-close {
    top: 0.5rem;
    right: 0.5rem;
    width: 2.25rem;
    height: 2.25rem;
    font-size: 1.15rem;
  }

  /* The poster should introduce the product, not consume the first screen. */
  #product-modal-art {
    max-width: 210px;
    border-radius: 0.875rem;
  }

  #product-modal-localization {
    max-width: 280px;
    margin-top: 0.625rem;
  }

  /* Compact the two stacked sections in the upper modal. */
  #product-modal-panel > .grid > div:first-child,
  #product-modal-panel > .grid > div:last-child {
    padding: 0.875rem;
  }

  #product-modal-title {
    font-size: 1.45rem;
    line-height: 1.16;
  }

  #product-modal-release {
    align-items: flex-start;
    line-height: 1.35;
  }

  #product-modal-subtitle {
    font-size: 0.875rem;
    line-height: 1.6;
  }

  /* All three tabs fit on screen. Reviews gets a shorter mobile label. */
  #product-modal-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  #product-modal-tabs > button {
    min-width: 0;
    padding: 0.72rem 0.35rem;
    font-size: 0.78rem;
    line-height: 1.15;
    text-align: center;
  }

  #product-modal-tabs .product-tab-label-desktop {
    display: none;
  }

  #product-modal-tabs .product-tab-label-mobile {
    display: inline;
  }

  /* One scroll container only: the modal itself. */
  #product-modal-description-scroll,
  #product-reviews-list {
    max-height: none !important;
    overflow: visible !important;
    padding-right: 0 !important;
  }

  #product-tab-panel-description,
  #product-tab-panel-reviews,
  #product-tab-panel-history {
    padding: 0.875rem;
  }

  #product-reviews-controls > div {
    gap: 0.5rem;
  }

  #product-reviews-controls .review-filter {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  /* Mobile chart gets its own compact 360px coordinate system in JS. */
  #product-history-legend {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.625rem;
    font-size: 0.65rem;
  }

  #product-history-content {
    min-height: 220px;
  }

  #product-history-content svg {
    min-height: 220px;
  }

  #product-history-minimum {
    font-size: 0.72rem;
    line-height: 1.45;
  }

  /* Keep the content card close to the dialog edges on small screens. */
  #product-modal-panel > .m-4 {
    margin: 0.75rem;
    margin-top: 0.75rem;
  }
}
