/* Shared responsive polish for phones and tablets. */
html { -webkit-text-size-adjust: 100%; }
img, svg, canvas { max-width: 100%; }
button, input, select, textarea { max-width: 100%; }

.jump { padding: 4px; gap: 4px; }
.jump-group { display: contents; }

@media (max-width: 700px) {
  .jump {
    position: relative;
    top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 14px;
    padding: 4px;
    border-radius: 14px;
    scroll-margin-top: 12px;
  }
  .jump-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: 100%;
  }
  .jump a {
    flex: 0 0 auto;
    width: auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0 4px;
    font-size: .875rem;
    line-height: 1.2;
    white-space: nowrap;
  }
}

@media (max-width: 340px) {
  .jump { width: calc(100% - 16px); max-width: none; margin-inline: 8px; }
  .jump a { padding-inline: 2px; font-size: .8rem; }
}

/*
 * Product cards must grow with their real content. Previous fixed heights
 * clipped the availability line or the action on devices with larger text.
 * Flexbox still stretches every card in a row to the height of the tallest
 * one, so the catalogue remains visually even without fragile pixel heights.
 */
.product-grid,
#macro .product-grid { align-items: stretch; }
.product-grid .product,
#macro .product-grid .product {
  height: auto !important;
  min-height: 0 !important;
  align-self: stretch;
}
.product-grid .product-info {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}
.product-grid .product-meta,
.product-grid .product-note,
.product-grid .availability-pill,
.product-grid .product-price,
.product-grid .product-action {
  max-width: 100%;
  overflow-wrap: anywhere;
}
.product-grid .availability-pill {
  flex-wrap: wrap;
  justify-content: center;
  white-space: normal;
  line-height: 1.35;
}
.product-grid .product-bottom {
  flex: 0 0 auto;
  margin-top: auto;
}

@media (min-width: 701px) and (max-width: 1024px) {
  /* Two complete catalogue cards are more legible than three narrow cards. */
  .product-grid .product,
  #macro .product-grid .product {
    flex-basis: calc((100% - 18px) / 2);
    width: calc((100% - 18px) / 2);
  }

  .product-grid .product-shot { aspect-ratio: 4 / 4.7; }

  /* Keep the catalogue index from covering product photography on tablets. */
  .jump { position: relative; top: auto; }
}

@media (max-width: 800px) {
  /* Product pages: keep the photography complete and the form comfortably sized. */
  .product-hero { gap: 8px; }
  .product-hero .main-image,
  body[data-product="secos"] .product-hero .main-image {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 5;
    max-height: 620px;
  }
  .product-hero .main-image img { object-position: center; }
  .buybox h1 { max-width: 100%; overflow-wrap: break-word; }
  .buybox,
  .buybox .lead,
  .buybox .product-tags,
  .configurator > *,
  .selection-price,
  .selection-price > *,
  .cart-add,
  .cart-add > * { min-width: 0; }
  .config-field select,
  .config-field input[type="number"],
  .strain-picker select { width: 100%; }
  .quick > *,
  .selection-price > span,
  .cart-add button,
  .cart-add a { overflow-wrap: anywhere; }
  .configurator,
  .dose-configurator,
  .price-system-configurator,
  .price-system-configurator.has-product-strain { width: 100%; }
  .content .table,
  .content .equivalence-table { display: block; width: 100%; overflow-x: auto; }
  .related-card { min-width: 0; }

  /* Resource and orientation cards should never force horizontal scrolling. */
  .route,
  .panel,
  .format,
  .network article,
  .route-form,
  .route-result { min-width: 0; }
}

@media (min-width: 601px) and (max-width: 800px) {
  /* At tablet widths the image should fill its column instead of stopping at
     the phone-oriented height cap and leaving a large empty area beside it. */
  .product-hero .main-image,
  body[data-product="secos"] .product-hero .main-image {
    aspect-ratio: 4 / 3;
    max-height: none;
  }
}

@media (min-width: 801px) and (max-width: 960px) {
  /* Keep the product presentation comfortable on portrait tablets. */
  .product-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding-bottom: 64px;
  }
  .product-hero .gallery { position: static; }
  .product-hero .main-image,
  body[data-product="secos"] .product-hero .main-image {
    width: 100%;
    height: auto !important;
    aspect-ratio: 4 / 3;
    max-height: none;
  }
  .product-hero .buybox { padding-inline: 0; }
}

@media (max-width: 600px) {
  /* Centre the active product card within the mobile slider viewport. */
  .product-grid,
  #macro .product-grid {
    padding-inline: max(4px, calc((100% - min(82vw, 320px)) / 2));
    scroll-padding-inline: max(4px, calc((100% - min(82vw, 320px)) / 2));
  }
  .product-grid .product,
  #macro .product-grid .product { scroll-snap-align: center; }

  .product-grid .product-info { padding-bottom: 25px; }

  /* Give product-page navigation a dedicated, balanced second row. */
  .top.shell:has(.top-links) {
    height: auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 10px 0 9px;
  }
  .top.shell:has(.top-links) .brand { justify-self: center; }
  .top-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }
  .top-links > a,
  .top-links > a:not(.back),
  .top-links .back {
    display: inline-flex !important;
    width: 100%;
    min-width: 0;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 7px 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .62rem;
    line-height: 1.15;
    letter-spacing: .02em;
    text-align: center;
  }
  .top-links > a:not(.back) { background: rgba(255, 255, 255, .32); }
  .top-links .cart-link { gap: 5px; }

  .product-hero { padding-top: 10px; }
  .product-hero .main-image,
  body[data-product="secos"] .product-hero .main-image {
    aspect-ratio: 4 / 5;
    border-radius: 20px 20px 48px 20px;
  }
  .buybox { padding-top: 18px; }
  .buybox h1 { font-size: clamp(3.25rem, 17vw, 4.6rem); line-height: .9; }
  .buybox .lead { font-size: .96rem; }
  .content section { overflow-wrap: anywhere; }
  .selection-price { gap: 12px; }
  .selection-price > span { max-width: 55%; }
  .selection-price .price { flex: 0 0 auto; }

  /* Stable tap targets and single-column actions on small screens. */
  .form-actions,
  .result-tools { gap: 8px; }
  .form-actions button,
  .result-tools button,
  .cart-add button,
  .cart-add a { min-height: 48px; }
  .route-result h2 { overflow-wrap: anywhere; }
}

@media (min-width: 601px) and (max-width: 700px) {
  .jump { position: relative; top: auto; }
}

@media (max-width: 430px) {
  .top-links > a,
  .top-links > a:not(.back),
  .top-links .back { font-size: .58rem; }

  .cart-header .brand span,
  .top .brand span { font-size: 1.7rem; }
  .cart-header .back { max-width: 55%; text-align: center; line-height: 1.15; }
  .cart-panel { padding-inline: 16px; }

  .route-form .step,
  .route-result { padding-inline: 20px; }
  .step legend { font-size: 2.25rem; }
  .choice span { padding: 16px; }

  /* Long prices and labels should reflow rather than leave the card. */
  .selection-price {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .selection-price > span { max-width: 100%; }
  .configurator .selection-price .price {
    margin-left: auto;
    max-width: 100%;
  }
}

/* Shared fixes for secondary layouts at intermediate widths. */
@media (max-width: 960px) {
  .cart-layout { grid-template-columns: minmax(0, 1fr); }
  .summary-panel { position: static; }
}

.delivery-options.is-disabled { opacity: .55; }
.has-hash-target .routes-section,
.has-hash-target .visual-archive,
.has-hash-target .soft,
.has-hash-target .resource-guides { content-visibility: visible; }
