/*
 * 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;
  }
}

/* -------------------------------------------------------------------------
 * v243-card-grid-801-breakpoint
 * Keep the catalogue at two columns through 800px so the price, benefit badge
 * and Steam comparison text retain comfortable width. The existing
 * sm:grid-cols-3 layout resumes from 801px.
 * ---------------------------------------------------------------------- */
@media (min-width: 601px) and (max-width: 800px) {
  #product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* -------------------------------------------------------------------------
 * v241-narrow-reviews-scroll
 * On narrow non-phone viewports, keep a single vertical scroll container.
 * The modal itself scrolls; the reviews list grows naturally with its content.
 * Desktop widths above 720px keep the existing bounded reviews scroller.
 * ---------------------------------------------------------------------- */
@media (min-width: 601px) and (max-width: 720px) {
  #product-reviews-list {
    max-height: none !important;
    overflow-y: visible !important;
    padding-right: 0 !important;
  }
}

/* -------------------------------------------------------------------------
 * v244-narrow-modal-balance
 * Better use of narrow/tablet modal space. From 640px through 1023px
 * the artwork/localization sits beside the product controls instead of in a
 * small isolated centered stack. Reviews use the modal as the only vertical
 * scroll container through 1023px.
 * ---------------------------------------------------------------------- */
@media (min-width: 640px) and (max-width: 1023px) {
  #product-modal-panel > .grid {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  #product-modal-panel > .grid > div:first-child {
    border-right: 1px solid rgb(43 39 36 / var(--tw-border-opacity, 1));
  }

  #product-modal-art {
    max-width: 280px;
  }

  #product-modal-localization {
    max-width: 280px;
  }
}

@media (min-width: 601px) and (max-width: 1023px) {
  #product-reviews-list {
    max-height: none !important;
    overflow-y: visible !important;
    padding-right: 0 !important;
  }
}

/* -------------------------------------------------------------------------
 * v245-narrow-modal-commercial-stack
 * The two-column modal introduced in v244 gives artwork proper presence on
 * 640-1023px screens, but below 900px the right column is too narrow for the
 * desktop two-column price and delivery controls. Stack those controls only
 * in the tight 640-899px range. Also keep Description and Reviews free of
 * nested vertical scrolling through 1023px; the modal itself owns scrolling.
 * ---------------------------------------------------------------------- */
@media (min-width: 640px) and (max-width: 899px) {
  /* Price offer / Steam price: one full-width row each. */
  #product-modal-price-box > .grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #product-modal-price-box > .grid > div:first-child {
    border-right: 0 !important;
  }

  #product-modal-price-box > .grid > div:last-child {
    border-top: 1px solid rgb(43 39 36 / var(--tw-border-opacity, 1)) !important;
  }

  /* Allow the saving badge to wrap below the price rather than collide. */
  #product-modal-price + #product-modal-saving,
  #product-modal-saving {
    min-width: 0;
  }

  #product-modal-price {
    min-width: 0;
  }

  #product-modal-price + #product-modal-saving {
    flex: 0 1 auto;
  }

  #product-modal-offer-price-row {
    flex-wrap: wrap;
    row-gap: 0.35rem;
  }

  /* Delivery methods also get the full right-column width. */
  #product-modal-delivery-switch {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #product-modal-delivery-switch button span.block {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
}

@media (min-width: 601px) and (max-width: 1023px) {
  /* One vertical scroll container: the product modal itself. */
  #product-modal-description-scroll,
  #product-reviews-list {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding-right: 0 !important;
  }
}


/* -------------------------------------------------------------------------
 * v246-modal-layout-from-640
 * Start the balanced two-column product modal at 640px instead of 768px.
 * The commercial controls keep their stacked narrow-column layout through
 * 899px. Catalogue grid breakpoints are unchanged.
 * ---------------------------------------------------------------------- */
\n\n/* -------------------------------------------------------------------------\n * v247-narrow-modal-region-compact\n * Long activation-region lists should not determine the height of the narrow\n * two-column modal. Between 640px and 899px JS uses a compact one-region +N\n * label while the full normalized list remains available in the title tooltip.\n * ---------------------------------------------------------------------- */\n@media (min-width: 640px) and (max-width: 899px) {\n  #product-modal-seller-region {\n    gap: 0.4rem;\n  }\n\n  #product-modal-seller-region [data-region-value] {\n    overflow-wrap: anywhere;\n  }\n}\n
/* -------------------------------------------------------------------------
 * v248-single-column-media-scale-test
 * Test a larger artwork/localization block in the one-column product modal.
 * Keep the current 640px two-column breakpoint unchanged; only <=639px is
 * affected. The poster and localization card share the same responsive width.
 * ---------------------------------------------------------------------- */
@media (max-width: 639px) {
  #product-modal-art,
  #product-modal-localization {
    width: 100% !important;
    max-width: min(78vw, 360px) !important;
  }
}


/* -------------------------------------------------------------------------
 * v249-single-column-through-720-test
 * Keep the enlarged v248 one-column product modal through 720px inclusive.
 * The existing v244/v245 two-column layout now becomes visually effective
 * from 721px. Catalogue grid breakpoints remain unchanged (3 cards from 801px).
 * ---------------------------------------------------------------------- */
@media (min-width: 640px) and (max-width: 720px) {
  #product-modal-panel > .grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #product-modal-panel > .grid > div:first-child {
    border-right: 0 !important;
  }

  #product-modal-art,
  #product-modal-localization {
    width: 100% !important;
    max-width: min(78vw, 360px) !important;
  }
}

/* -------------------------------------------------------------------------
 * v252-gift-layout-stability
 * Gift-only checkout parameters used to be two tall stacked cards. Switching
 * Key <-> Gift therefore changed the upper modal height and pushed the tabs /
 * lower interface down. Keep those parameters in one compact row on tablet /
 * desktop and reserve a small amount of upper-panel height for product groups
 * that have a Gift alternative. The existing one-scroll-container rules stay
 * unchanged.
 * ---------------------------------------------------------------------- */
@media (min-width: 640px) {
  #product-modal-gift-options {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem;
  }

  #product-modal-gift-region-wrap,
  #product-modal-checkout-fields-wrap {
    min-width: 0;
    padding: 0.55rem 0.65rem;
  }

  #product-modal-gift-region-wrap > label,
  #product-modal-checkout-fields-wrap label {
    line-height: 1.1;
  }

  #product-modal-gift-region-wrap .relative,
  #product-modal-checkout-fields-wrap [data-modal-checkout-text-option] {
    margin-top: 0.35rem;
  }

  #product-modal-gift-region,
  #product-modal-checkout-fields-wrap [data-modal-checkout-text-option] {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  #product-modal-gift-region-note,
  #product-modal-checkout-fields-wrap .product-modal-checkout-comment {
    display: none;
  }
}

/* On the two-column modal the artwork/localization column already needs about
   this much height. Reserving it for groups with Key + Gift means the async
   appearance/disappearance of Gift parameters consumes free space above the
   commercial block instead of moving Description / Reviews / History. */
@media (min-width: 721px) {
  #product-modal-panel.product-modal-has-gift-alternative > div.grid:first-of-type {
    min-height: 600px;
  }
}

/* 721-899px uses the narrow commercial stack, so it needs a little more room
   than the >=900px two-column price/delivery arrangement. */
@media (min-width: 721px) and (max-width: 899px) {
  #product-modal-panel.product-modal-has-gift-alternative > div.grid:first-of-type {
    min-height: 650px;
  }
}


/* -------------------------------------------------------------------------
 * v253-close-button-selector-fix
 * v252 used `.grid:first-of-type` for the reserved-height rule. The close
 * button itself also has Tailwind's `grid` utility and is the first <button>
 * of its type, so the rule accidentally gave it a 600/650px min-height.
 * Scope the rule to the upper DIV grid only and harden the close control.
 * ---------------------------------------------------------------------- */
@media (min-width: 721px) {
  #product-modal-close {
    min-width: 2.5rem;
    min-height: 2.5rem;
    width: 2.5rem;
    height: 2.5rem;
  }
}


/* -------------------------------------------------------------------------
 * v254-gift-context-slot
 * Gift checkout controls now replace the activation-region row instead of
 * being inserted below the delivery switch. This keeps the commercial block
 * and the Description / Reviews / Price History section stationary when the
 * user switches Key <-> Gift.
 * ---------------------------------------------------------------------- */
@media (min-width: 640px) {
  #product-modal-panel.product-modal-has-gift-alternative #product-modal-context-slot {
    min-height: 4.15rem;
  }

  #product-modal-gift-options {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
    gap: 0.5rem;
  }

  #product-modal-gift-region-wrap,
  #product-modal-checkout-fields-wrap {
    padding: 0.45rem 0.6rem;
  }

  #product-modal-gift-region,
  #product-modal-checkout-fields-wrap [data-modal-checkout-text-option] {
    padding-top: 0.42rem;
    padding-bottom: 0.42rem;
  }
}

/* v252 reserved the height of the whole upper modal panel. With the new
   context slot that is no longer necessary and created excess empty space. */
@media (min-width: 721px) {
  #product-modal-panel.product-modal-has-gift-alternative > div.grid:first-of-type {
    min-height: 0;
  }
}

@media (min-width: 640px) {
  #product-modal-gift-region-wrap > label,
  #product-modal-checkout-fields-wrap label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
