/* ============================================================
   Device - Buy 1 Free 1 widget (ADO #124643, SRS Part14)
   Scope: .b1f1 (section[data-b1f1])
   Fonts 'Unbeatable' / 'UMobile Display' are loaded globally — no @font-face here.
   ============================================================ */

.b1f1 {
    padding: 56px 0;
    overflow: hidden;
}

.b1f1__inner {
    /* Figma 3088:117532 — the card row is exactly 1248px wide:
       4 cards × 294px + 3 gaps × 24px = 1248. The site reset is border-box, so the
       max-width must carry the 32px gutters too: 1248 + 2 × 32 = 1312.
       Sizing it this way makes 4 cards fit without overflow, which in turn keeps the
       arrows hidden until there are MORE than 4 devices (SRS #2). */
    max-width: 1312px;
    margin: 0 auto;
    padding: 0 32px;
}

.b1f1__header {
    text-align: center;
    /* 40px title → card is the cross-widget rule BA settled (see the title/desc block in
       layout-shell.css, "bug chỉ chốt title → card"). It used to be composed as 32px here
       plus 8px of .b1f1__track padding, which made it invisible from either rule alone and
       meant touching the track silently changed a spec'd gap. The whole 40px lives here now. */
    margin-bottom: 40px;
}

.b1f1__title {
    margin: 0 0 12px;
    font-family: 'UMobile Display', 'Unbeatable', sans-serif;
    font-weight: 700;
    font-size: 44px;
    line-height: 1.1;
    color: #1a1a1a;
}

.b1f1__subtitle {
    margin: 0;
    font-family: 'Unbeatable', sans-serif;
    font-size: 18px;
    line-height: 1.5;
    color: #555;
}

/* ── Carousel viewport / track ─────────────────────────────── */

.b1f1__viewport {
    position: relative;
}

.b1f1__track {
    display: flex;
    gap: 24px; /* Figma itemSpacing of the card row */
    overflow-x: auto;
    scroll-behavior: smooth;
    /* AB#140659: stays `mandatory` with the mouse drag too. The track follows the cursor
       while dragging (the JS lifts snap for the duration); on release it pages like the
       mobile swipe — past half a card it moves on, short of that it returns. `proximity` was
       measured in Chrome at 1440/920px and behaves identically (same half-card threshold),
       and `none` would leave the row resting mid-card, so every arrow step after a drag would
       keep a clipped card at both edges. */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
    /* AB#134818 — the track carries no padding, and so needs neither the compensating
       negative margin nor the matching scroll-padding it used to carry. The three worked
       as a set: `padding: 8px 4px 16px` nominally as card-shadow room, `margin: 0 -4px`
       to hand the 8px back horizontally so four cards still fit 1248px, and
       `scroll-padding: 0 4px` to match the side padding so the mandatory snap rested at
       scrollLeft 0 instead of ~4px — which the JS "at the left edge" check read as
       not-at-the-edge, leaving the prev arrow lit on page one (#133647).

       Horizontal maths is unchanged: with neither padding nor negative margin the content
       box is the same 1248px the pair existed to preserve, so `maxScroll` for exactly four
       cards is still 0 and the arrows still stay hidden. With no side padding there is no
       snap offset left to match, which makes the scroll-padding dead rather than harmful —
       keeping it would have shifted intermediate snap stops by 4px without touching either
       edge check, so #133647 was never at risk either way.

       The shadow room was worth less than the comment implied. A 12px blur extends about
       6px past the box (the gradient straddles the edge), so the old 8px top padding was
       never clipping and the 4px sides clipped 2px. All four edges clip ~6px now, because
       `overflow-x: auto` computes `overflow-y` to `auto` too and box-shadow is ink overflow
       that gets clipped at the scrollport rather than scrolled to. At rgba(0,0,0,.04) that
       edge is not perceptible.

       Vertical spacing did NOT disappear with the padding — it moved to the rules that own
       it: `.b1f1__header { margin-bottom: 40px }` and `.b1f1__nav { margin-top: 32px }`.
       The 8px/16px here were halves of those two gaps, which is exactly why removing them
       silently broke a spec'd 40px. Widget height is unchanged; the spacing is just legible
       from one place now.

       Worth a glance on SIT after deploy: prev arrow disabled on page one, and a row of
       exactly four cards not triggering the arrows. */
    scrollbar-width: none; /* Firefox */
}

/* #133939 (Common rule #8): with 1–2 cards the row must be centered, not pinned left.
   justify-content:center would make the left edge unreachable once the row overflows,
   so center via auto margins instead: they absorb the free space when everything fits
   and resolve to 0 as soon as the track overflows, leaving scrolling untouched. */
.b1f1__card:first-child {
    margin-left: auto;
}

.b1f1__card:last-child {
    margin-right: auto;
}

.b1f1__track::-webkit-scrollbar {
    display: none;
}

/* Set only while the JS drag handler is dragging; `user-select: none` lives here rather than
   on the base rule so the card text stays selectable otherwise. */
.b1f1__track--dragging {
    cursor: grabbing;
    user-select: none;
}

/* ── Card (SRS #3): 294px wide, radius 8, white, soft shadow ─ */

.b1f1__card {
    flex: 0 0 294px;
    width: 294px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px 18px;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.04);
    scroll-snap-align: start;
    text-align: center;
    cursor: pointer;
}

/* ── 0. Top badge (AB#135929, Figma node 3087-116928) ──────────────
   Figma puts the badge in a 294x26 "Header" frame that sits ON TOP of the card body and
   PUSHES it down — not an overlay, so absolute positioning would be wrong (it would eat
   6px of the body's 20px padding-top).
   The card is already a flex column with padding-top 20 and gap 20, so one negative margin
   is the whole trick: -20px lifts the badge to the card's top edge (y0..y26), and the next
   child then starts at y26 + gap20 = y46 — exactly the image top in Figma.
   Empty value → Razor renders no element, so the card falls back to its normal 20px padding
   with no leftover gap — unless another card in the widget has a badge (AB#140850), then an
   invisible placeholder (below) keeps the images aligned. */

.b1f1__top-badge {
    margin-top: -20px;
    max-width: 100%;
    box-sizing: border-box;        /* AEM-mode pages ship no preflight, so declare it like .b1f1__arrow does */
    /* Block, not flex: the card is only ever 294px wide, so a long label overruns the badge box —
       measured 280px of text in a 256px box. text-overflow needs a block container to bite (on a
       flex container the text becomes an anonymous flex item and the ellipsis never appears).
       Label only, no icon, so nothing here needs flex. Centring comes from text-align plus the
       card's own align-items:center. */
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    /* 4 + 18 (line-height) + 3 + 1 (border-bottom) = 26, the Figma frame height, which puts the
       image at y46. Plain `4px 8px` measures 27 and pushes the image to y47: box-sizing does not
       fold the border in when no height is set. */
    padding: 4px 8px 3px;
    background: #ffffff;
    border: 1px solid #e6e6e6;
    border-top: 0;                 /* Figma: open at the top, it reads as a tab */
    border-radius: 0 0 4px 4px;    /* bottom corners only */
    font-family: 'UMobile Display', 'Unbeatable', sans-serif;
    font-weight: 600;
    font-size: 14px;
    line-height: 18px;
    letter-spacing: 0;
    color: #00253d;
    text-align: center;
    white-space: nowrap;
}

/* AB#140850 — slot for a card without a top badge, rendered only when another card in the widget
   has one. It IS the badge box (same class, a no-break space for the line box), so its height tracks
   the real badge with no copied number; hidden rather than removed so the next child still starts
   at y46. visibility also drops it from hit-testing, so a click still lands on the card body. */
.b1f1__top-badge--placeholder {
    visibility: hidden;
}

/* AB#140850 round 2 — the same idea for blocks 2/4/6 (promo badge, offer icon, price): a card
   without the block gets an invisible copy of its box when another card has it, and
   buy-1-free-1-slot-equalizer.js sizes every copy of a block to the tallest one. No box-sizing
   is forced here: that would change the badge height on AEM-mode pages without a preflight; the
   script compensates for content-box instead. */
.b1f1__slot-placeholder {
    visibility: hidden;
}

/* ── 1. Product image mini-carousel (SRS #4): 256×192, radius 8 ── */

.b1f1__media {
    width: 100%;
}

/* AB#140850 round 3 — placeholder for a card with no image: an empty box has no height, so give it
   the image's 192px (keep in sync with .b1f1__img); the equalizer then adds the dots row when
   another card has a carousel. */
.b1f1__media.b1f1__slot-placeholder {
    min-height: 192px;
}

.b1f1__media-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    border-radius: 8px;
    scrollbar-width: none;
}

.b1f1__media-track::-webkit-scrollbar {
    display: none;
}

.b1f1__img {
    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
    height: 192px;
    /* AB#154211 (BA 04/11): show the whole product shot — portrait phone images were cropped by cover. */
    object-fit: contain;
    border-radius: 8px;
    scroll-snap-align: center;
}

.b1f1__dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
}

/* Figma: inactive = 8×8 circle #fee1bc, active = 24×8 orange pill (radius 8). */
.b1f1__dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #fee1bc;
    cursor: pointer;
    transition: width 0.2s, border-radius 0.2s, background 0.2s;
}

.b1f1__dot.is-active {
    width: 24px;
    border-radius: 8px;
    background: #ff7300;
}

/* ── 2. Promotional badge (SRS #5): dark navy pill ─────────── */

.b1f1__badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 4px 16px;
    border-radius: 8px;
    background: #170f4f;
}

.b1f1__badge-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    object-fit: contain;
}

.b1f1__badge-label {
    font-family: 'Unbeatable', sans-serif;
    font-weight: 600;
    font-size: 18px;
    line-height: 24px;
    letter-spacing: -0.01em;
    color: #ffffff;
    /* Maximum 2 rows (SRS #5) */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── 3/5. Device information blocks (SRS #6/#8) ────────────── */

.b1f1__primary,
.b1f1__secondary {
    width: 100%;
}

/* Device names print as the editor typed them (AB#155243): no text-transform, the live site keeps "Samsung Galaxy Z Fold8 Ultra". */
.b1f1__primary-name {
    font-family: 'Unbeatable', sans-serif;
    font-weight: 600;
    font-size: 20px;
    line-height: 24px;
    letter-spacing: -0.01em;
    color: #1a1a1a;
}

.b1f1__secondary-name {
    font-family: 'Unbeatable', sans-serif;
    font-weight: 600;
    font-size: 18px;
    line-height: 18px;
    color: #000000;
}

.b1f1__rrp {
    margin-top: 4px;
    font-family: 'Unbeatable', sans-serif;
    font-weight: 600;
    font-size: 14px;
    line-height: 16px;
    text-decoration: line-through;
    color: #666666;
}

/* ── 4. Offer icon (SRS #7): 24×24 as uploaded ─────────────── */

.b1f1__offer-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* ── 6. Monthly price (SRS #9): {prefix}{amount}{unit} ─────── */

.b1f1__price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    color: #000000;
    font-family: 'Unbeatable', sans-serif;
}

.b1f1__price-prefix,
.b1f1__price-unit {
    font-weight: 400;
    font-size: 16px;
    line-height: 24px;
}

.b1f1__price-amount {
    font-weight: 600;
    font-size: 30px;
    line-height: 36px;
    margin: 0 2px;
}

/* ── 7. CTA buttons (SRS #10/#11): max 3, stacked ──────────── */

.b1f1__ctas {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: auto; /* pin CTA block to the card bottom for equal-height cards */
}

.b1f1__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 999px; /* radius/radius-3xl */
    font-family: 'Unbeatable', sans-serif;
    font-weight: 700;
    font-size: 16px;
    line-height: 24px;
    text-decoration: none;
    transition: opacity 0.2s;
}

.b1f1__cta--orange {
    background: #ff7300;
    color: #ffffff;
}

.b1f1__cta--white {
    background: #ffffff;
    color: #ff7300;
    border: 1px solid #ff7300;
}

/* CTA configured without an action URL — same pill, but not clickable. */
.b1f1__cta--inert {
    cursor: default;
}

.b1f1__cta:hover {
    text-decoration: none;
    opacity: 0.92;
}

.b1f1__cta--inert:hover {
    opacity: 1;
}

/* AB#152898 â€” hover follows PROD (wiki D14). PROD galaxy-unpacked "Buy Now" (.custom-bottom-button .btn:hover)
   goes #FF7B00 -> #FF9C40 over 0.3s; the 0.92 opacity fade above was barely visible. Inert CTAs keep their colour. */
.b1f1__cta--orange {
    transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.b1f1__cta--orange:not(.b1f1__cta--inert):hover {
    background: #ff9c40;
    opacity: 1;
}

.b1f1__cta--orange:hover,
.b1f1__cta--orange:focus,
.b1f1__cta--orange:visited {
    color: #ffffff;
}

.b1f1__cta--white:hover,
.b1f1__cta--white:focus,
.b1f1__cta--white:visited {
    color: #ff7300;
}

/* ── Navigation arrows (SRS #2): 36px, disable at edge ─────── */

.b1f1__nav {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    /* Was 16px here plus 16px of .b1f1__track padding-bottom = 32px card → arrows.
       Same consolidation as .b1f1__header: the gap belongs to the rule that means it,
       not to the scrollport that happened to sit above it. */
    margin-top: 32px;
}

.b1f1__nav.is-hidden {
    display: none;
}

.b1f1__arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 10px 12px;
    box-sizing: border-box;
    border: 1px solid #ff7300;
    border-radius: 999px; /* radius/radius-3xl */
    background: #ffffff;
    color: #ff7300;
    cursor: pointer;
    transition: opacity 0.2s;
}

.b1f1__arrow:disabled {
    opacity: 0.45;
    border-color: #dddddd;
    color: #bbbbbb;
    cursor: default;
}

/* ── Mobile (SRS #1): one full card centered + partial next ── */

@media (max-width: 767px) {
    .b1f1 {
        padding: 40px 0;
    }

    .b1f1__inner {
        padding: 0 18px;
    }

    .b1f1__title {
        font-size: 32px;
    }

    .b1f1__subtitle {
        font-size: 15px;
    }

    .b1f1__track {
        gap: 14px;
        /* One full card visible, partial next card peeking at the right edge — the peek comes from the
           294px card being narrower than the row. AB#154495: no extra 40px end padding, which left the
           last card with a right gutter much wider than the first card's left one. */
        padding-right: 0;
    }

    .b1f1__card {
        flex-basis: 294px;
        scroll-snap-align: center;
    }

    /* AB#154495: arrows sit at the right on phones (Figma mobile 3119-137118), as on wider screens.
       QC 04/11 corrected the bug's Expected, which first said left. */
    .b1f1__nav {
        justify-content: flex-end;
    }
}

@media (max-width: 360px) {
    .b1f1__card {
        flex-basis: calc(100vw - 76px);
        width: calc(100vw - 76px);
    }
}

/* ── category tabs (AB#146700) ──
   Same class names as the other tabbed widgets (widget-cat-tabs / widget-cat-underline-tabs /
   widget-cat-tab-panel); styled here, scoped under .b1f1, so the widget ships one stylesheet.
   Pill bar centred above the carousels; one panel (= one carousel) visible at a time. */
.b1f1 .widget-cat-tabs,
.b1f1 .widget-cat-underline-tabs {
    margin-bottom: 24px;
    text-align: center;
}

.b1f1 .widget-cat-tabs button {
    margin: 0 6px 8px;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    color: #222;
    background: #eee;
    border: none;
    border-radius: 20px;
    cursor: pointer;
}

.b1f1 .widget-cat-tabs button.active {
    color: #fff;
    background: #ff7300;
}

.b1f1 .widget-cat-underline-tabs {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.b1f1 .widget-cat-underline-tabs button {
    padding: 0 0 10px;
    font-size: 15px;
    font-weight: 600;
    color: #666;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.b1f1 .widget-cat-underline-tabs button.active {
    color: #ff7300;
    border-bottom-color: #ff7300;
}

.b1f1 .widget-cat-tab-panel {
    display: none;
}

.b1f1 .widget-cat-tab-panel.active {
    display: block;
}

/* AB#152899 â€” Figma b1f1 mobile (3119-137118): the category pills sit side by side on one row. Long labels
   ("Samsung Galaxy Z Series" 214px + "Samsung Galaxy Watch" 204px at 375) used to wrap onto two rows; keep one row and
   scroll it sideways, as the plan-container pills do on mobile (ADO #115065). A row that fits stays centred. */
@media (max-width: 767px) {
    .b1f1 .widget-cat-tabs {
        display: flex;
        flex-wrap: nowrap;
        justify-content: flex-start;
        justify-content: safe center;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #ff7300 transparent;
        padding-bottom: 8px;
    }
    .b1f1 .widget-cat-tabs::-webkit-scrollbar { height: 4px; }
    .b1f1 .widget-cat-tabs::-webkit-scrollbar-thumb { background: #ff7300; border-radius: 4px; }
    .b1f1 .widget-cat-tabs button {
        flex: 0 0 auto;
        white-space: nowrap;
        margin: 0;
    }
}
