/* ============================================================
 * Black Friday Vault: List / Grid view switch for deal feeds
 * (homepage feed, category pages). Added 29 Oct 2026.
 * Grid only applies on screens wider than 760px; phones always
 * get the normal list.
 * ============================================================ */

/* Site width. Also set in ph-global.css, but that file is cached by browsers
   under a fixed version number, so it is repeated here (this file is versioned
   by file time) to reach returning visitors straight away. */
html:root { --ph-max-w: 1440px; }

/* ---- the switch ---- */
.bfv-view {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border: 1px solid var(--color-border); border-radius: 10px; background: #fff;
  flex: 0 0 auto;
}
.bfv-view button {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 28px; padding: 0 9px; border: 0; border-radius: 7px; background: transparent;
  color: var(--color-text-muted); font: 700 12px/1 var(--font-heading, inherit); cursor: pointer;
  transition: background 120ms linear, color 120ms linear;
}
.bfv-view button:hover { color: var(--bfv-ink, #121316); }
.bfv-view button[aria-pressed="true"] { background: var(--bfv-ink, #121316); color: #fff; }
.bfv-view button:focus-visible { outline: 2px solid var(--bfv-gold, #ffc21a); outline-offset: 1px; }
.bfv-view svg { width: 15px; height: 15px; }
.bfv-view-wrap { display: inline-flex; align-items: center; gap: 12px; }
.bfv-view-row { display: flex; justify-content: flex-end; margin: -4px 0 10px; }

@media (max-width: 760px) {
  .bfv-view, .bfv-view-row { display: none; }
}

/* ---- grid layout ---- */
@media (min-width: 761px) {
  html.bfv-grid [data-ph-feed],
  html.bfv-grid .ph-tp__list,
  html.bfv-grid #ewb-block-2 [data-ph-feed],
  html.bfv-grid #ewb-block-2 .ph-tp__list {
    display: grid;
    /* at most 3 per row; drops to 2 when cards would get narrower than 290px */
    grid-template-columns: repeat(auto-fill, minmax(max(290px, calc((100% - 24px) / 3)), 1fr));
    gap: 12px;
    align-items: stretch;
  }
  /* section headings, ads, loaders and empty states span the full row */
  html.bfv-grid [data-ph-feed] > :not(.bfv-deal),
  html.bfv-grid .ph-tp__list > :not(.bfv-deal) { grid-column: 1 / -1; }

  html.bfv-grid .bfv-deal {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    grid-template-rows: 1fr auto;
    grid-template-areas: "logo body vote" "buy buy buy";
    align-items: start;
    gap: 10px 12px;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 14px;
  }
  html.bfv-grid .bfv-deal::before { display: none; }
  html.bfv-grid .bfv-deal:hover { border-color: var(--color-border-strong); }
  html.bfv-grid .bfv-deal .ph-ico { width: 44px !important; height: 44px !important; }
  html.bfv-grid .bfv-deal__name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  html.bfv-grid .bfv-deal__title { align-items: flex-start; flex-wrap: wrap; row-gap: 4px; }
  html.bfv-grid .bfv-deal__tag {
    white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  }
  html.bfv-grid .bfv-deal__buy {
    align-self: end;
    flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: 8px; padding-top: 10px; border-top: 1px dashed var(--color-border);
  }
  html.bfv-grid .bfv-deal__acts { flex-wrap: wrap; justify-content: flex-end; }
  html.bfv-grid .bfv-deal.is-featured {
    background: linear-gradient(180deg, var(--bfv-gold-wash), #fff 60%);
    border-color: var(--bfv-gold); box-shadow: none;
  }
  /* section headings (Live deals, Coming soon, Last year's offers): bigger so they stand out between cards */
  html.bfv-grid #ewb-block-2 [data-ph-feed] .ph-day { margin: 26px 0 2px; gap: 14px; }
  html.bfv-grid #ewb-block-2 [data-ph-feed] .ph-day:first-child { margin-top: 6px; }
  html.bfv-grid #ewb-block-2 [data-ph-feed] .ph-day h2 {
    font-size: 18px; letter-spacing: 0.3px; color: var(--bfv-ink, #121316);
  }
  html.bfv-grid #ewb-block-2 [data-ph-feed] .ph-day i { height: 2px; background: var(--color-border-strong, #d9d6cf); }
  html.bfv-grid #ewb-block-2 [data-ph-feed] .ph-day span { font-size: 14px; color: var(--color-text); }
}

/* ---- Single deal page: content column stays at 1152px (header/footer keep 1440) ---- */
#ewb-block-2 .ph-pd__wrap { max-width: 1152px; }

/* ---- Category rail: arrows + edge fades (homepage) ---- */
.bfv-rail { position: relative; }
#ewb-block-2 .bfv-rail .ph-home__rail {
  scroll-behavior: smooth;
  -webkit-mask-image: none; mask-image: none;
}
#ewb-block-2 .bfv-rail.has-left .ph-home__rail {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 64px, #000 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 64px, #000 100%);
}
#ewb-block-2 .bfv-rail.has-right .ph-home__rail {
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 64px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 64px), transparent 100%);
}
#ewb-block-2 .bfv-rail.has-left.has-right .ph-home__rail {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 64px, #000 calc(100% - 64px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 64px, #000 calc(100% - 64px), transparent 100%);
}
.bfv-rail__btn {
  position: absolute; top: calc(50% + 5px); transform: translateY(-50%); z-index: 2;
  display: none; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  border: 1px solid var(--color-border-strong, #d9d6cf); background: #fff; color: var(--bfv-ink, #121316);
  box-shadow: 0 2px 10px rgba(18, 19, 22, 0.12); cursor: pointer;
  transition: transform 120ms ease, box-shadow 160ms ease;
}
.bfv-rail__btn:hover { box-shadow: 0 4px 14px rgba(18, 19, 22, 0.2); transform: translateY(-50%) scale(1.06); }
.bfv-rail__btn:focus-visible { outline: 2px solid var(--bfv-gold, #ffc21a); outline-offset: 2px; }
.bfv-rail__btn svg { width: 16px; height: 16px; }
.bfv-rail__btn--prev { left: -4px; }
.bfv-rail__btn--next { right: -4px; }
.bfv-rail.has-left .bfv-rail__btn--prev, .bfv-rail.has-right .bfv-rail__btn--next { display: inline-flex; }
/* touch screens swipe naturally: no arrows there */
@media (hover: none) { .bfv-rail__btn { display: none !important; } }