/*
 * The PDP разфасовка selector in a column too narrow for one row of options.
 *
 * The vendored selector is a single non-wrapping flex row, so every option's min-content
 * adds up into the grid track: four or five options widen the phone column past the
 * viewport (the bottle image slides out sideways) and, in the two-column hero, squeeze the
 * image column. `container-type: inline-size` removes the selector from that min-content
 * sum; the layout then follows the space the column actually gives it.
 *
 * Container widths, not the viewport ladder: the same column is ~330px in the two-column
 * hero at 800px and ~330px on a 360px phone. The thresholds allow ~7rem per option, the
 * width of „12 бутилки" with a four-digit total. Up to three options always fit one row.
 * The vendored `bundle-selector--stack` (four options, viewport ≤ 480px) sets the same
 * 2 × 2 grid, so the two rules agree on a phone.
 */
.pdp-packs {
    container-type: inline-size;
}

/* A foldable's cover screen: three options in a row need the narrower inline padding. */
@container (width < 21rem) {
    .pdp-packs .bundle-option {
        padding-inline: var(--spacing-sm);
    }
}

@container (width < 28rem) {
    .bundle-selector--count-4 {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .bundle-selector--count-4 .bundle-option:nth-child(odd) {
        border-inline-start: none;
    }

    .bundle-selector--count-4 .bundle-option:nth-child(-n + 2) {
        border-block-end: 1px solid var(--color-border-default);
    }
}

/* Five options: a row of three over a row of two, both full width (6 tracks, spans 2 and 3). */
@container (width < 35rem) {
    .bundle-selector--count-5 {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
    }

    .bundle-selector--count-5 .bundle-option {
        grid-column: span 2;
        padding-inline: var(--spacing-sm);
    }

    .bundle-selector--count-5 .bundle-option:nth-child(n + 4) {
        grid-column: span 3;
    }

    .bundle-selector--count-5 .bundle-option:nth-child(4) {
        border-inline-start: none;
    }

    .bundle-selector--count-5 .bundle-option:nth-child(-n + 3) {
        border-block-end: 1px solid var(--color-border-default);
    }
}
