/* ===== COUPONS (scoped) ===== */
#dbc-coupons.dbc, #dbc-coupons.dbc * { box-sizing: border-box; }

#dbc-coupons.dbc {
  --dbc-accent: #F1455F;
  --dbc-cta: #FF8080;
  --dbc-cta-text: #101017;
  --dbc-link: #1a4b9a;
  --dbc-border: #e6e6e6;
  --dbc-soft: #e7f0ff;
  --dbc-soft-border: #bcd0ff;
  --dbc-radius: 12px;
  --dbc-gap: 14px;

  display: grid;
  gap: var(--dbc-gap);
  margin: 0;
  padding: 0;
}

/* Section headings */
#dbc-coupons.dbc .dbc__heading {
  font-size: clamp(18px, 2.8vw, 22px);
  font-weight: 700;
  margin: 18px 0 6px;
  padding: 10px 12px;
  background: var(--dbc-accent);
  color: #fff;
  border-radius: 10px;
}

/* Coupon/offer cards */
#dbc-coupons.dbc .dbc-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--dbc-border);
  border-radius: var(--dbc-radius);
  background: #fff;
}
@media (min-width: 520px) {
  #dbc-coupons.dbc .dbc-card { grid-template-columns: 110px 1fr; align-items: start; }
}
#dbc-coupons.dbc .dbc-card__cta { display: flex; align-items: flex-start; justify-content: center; }

/* Local buttons (not Bootstrap .btn) */
#dbc-coupons.dbc .dbc-btn {
  display: inline-block;
  width: 100%;
  text-align: center;
  padding: 12px 10px;
  min-height: 44px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  line-height: 1.2;
  border: 1px solid transparent;
}
#dbc-coupons.dbc .dbc-btn--code  { background: var(--dbc-cta);  color: var(--dbc-cta-text); }
#dbc-coupons.dbc .dbc-btn--offer { background: var(--dbc-soft); color: var(--dbc-link); border-color: var(--dbc-soft-border); }
#dbc-coupons.dbc .dbc-btn:hover,
#dbc-coupons.dbc .dbc-btn:focus { filter: brightness(0.96); }

#dbc-coupons.dbc .dbc-card__body  { min-width: 0; }
#dbc-coupons.dbc .dbc-card__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
#dbc-coupons.dbc .dbc-chip        { border: 1px solid var(--dbc-border); border-radius: 999px; padding: 3px 8px; font-size: 12px; white-space: nowrap; }
#dbc-coupons.dbc .dbc-card__text  { margin: 4px 0 8px; font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
#dbc-coupons.dbc .dbc-card__meta  { font-size: 12px; color: #666; margin-bottom: 8px; }
#dbc-coupons.dbc .dbc-card__links .dbc-more { font-size: 14px; text-decoration: underline; color: var(--dbc-link); }

@media (max-width: 359px) {
  #dbc-coupons.dbc .dbc-card { padding: 10px; }
  #dbc-coupons.dbc .dbc-btn  { padding: 10px; }
}

/* ===== Modal ===== */
#dbcCouponModal.dbc-modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; z-index: 9999; }
#dbcCouponModal.dbc-modal.is-open { display: grid; place-items: center; }
#dbcCouponModal .dbc-modal__dialog { background:#fff; width:min(92vw,520px); border-radius:12px; padding:16px; box-shadow: 0 10px 40px rgba(0,0,0,.2); position: relative; }
#dbcCouponModal .dbc-modal__title { margin: 0 0 10px; font-size: 18px; }
#dbcCouponModal .dbc-modal__close { position:absolute; top:8px; right:10px; border:0; background:transparent; font-size:24px; line-height:1; cursor:pointer; }
#dbcCouponModal .dbc-code-row { display:flex; gap:8px; align-items:center; margin:8px 0 14px; }
#dbcCouponModal .dbc-code { font-size:18px; padding:6px 10px; background:#f6f7fb; border-radius:8px; }
#dbcCouponModal .dbc-copy { padding:8px 10px; border-radius:8px; border:1px solid var(--dbc-border, #e6e6e6); background:#fff; cursor:pointer; }
#dbcCouponModal .dbc-shop { display:inline-block; margin-top:4px; padding:10px 12px; border-radius:10px; background: var(--dbc-cta, #FF8080); color:#101017; font-weight:700; text-decoration:none; }
#dbcCouponModal .dbc-tip { font-size:12px; color:#666; margin-top:8px; }
#dbcCouponModal[hidden] { display: none !important; }
#dbcCouponModal.is-open { display: grid !important; }

/* ===== PRODUCTS (independent of #dbc-coupons) ===== */
#dbc-products, .dbc-products { container-type: inline-size; }
#dbc-products *, .dbc-products * { box-sizing: border-box; }

/* Base: 2 columns */
#dbc-products .dbc-grid, .dbc-products .dbc-grid {
  display: grid;
  gap: var(--dbc-gap, 14px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

/* 4 across at 900px container, 5 across at 1200px */
@container (min-width: 900px)  { .dbc-products .dbc-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@container (min-width: 1200px) { .dbc-products .dbc-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* Fallback for browsers without container queries */
@media (min-width: 900px)  { #dbc-products .dbc-grid, .dbc-products .dbc-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1200px) { #dbc-products .dbc-grid, .dbc-products .dbc-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* Equal-height product cards */
#dbc-products .dbc-pcard, .dbc-products .dbc-pcard {
  border: 1px solid var(--dbc-border, #e6e6e6);
  border-radius: var(--dbc-radius, 12px);
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

#dbc-products .dbc-pcard__imagewrap, .dbc-products .dbc-pcard__imagewrap {
  display: block;
  aspect-ratio: 4 / 3;   /* change to 1/1 for squares */
  background: #f8f8f8;
  overflow: hidden;
}
#dbc-products .dbc-pcard__image, .dbc-products .dbc-pcard__image {
  width: 100%; height: 100%; object-fit: contain; display: block;
}

#dbc-products .dbc-pcard__body, .dbc-products .dbc-pcard__body {
  padding: 10px 12px 12px;
  display: grid;
  grid-template-rows: auto auto 1fr; /* title | price | desc grows */
  gap: 6px;
  min-height: 0;
}

#dbc-products .dbc-pcard__title, .dbc-products .dbc-pcard__title {
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  color: inherit;            /* override Bootstrap link blue */
  display: -webkit-box;
  -webkit-line-clamp: 2;     /* keep heights aligned */
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(1em * 1.25 * 2);
  font-size: 20px;
}

#dbc-products .dbc-pcard__price, .dbc-products .dbc-pcard__price {
  display: flex; gap: 8px; align-items: baseline;
}
#dbc-products .dbc-price-main, .dbc-products .dbc-price-main { font-weight: 700; }
#dbc-products .dbc-price-sale, .dbc-products .dbc-price-sale { color: #c62828; font-weight: 700; }

#dbc-products .dbc-pcard__desc, .dbc-products .dbc-pcard__desc {
  font-size: 14px; color: #333; line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(1em * 1.4 * 2);
}
/* Fix product text cutting on narrow screens */
#dbc-products .dbc-pcard__body,
.dbc-products .dbc-pcard__body {
  min-width: 0;                  /* allow content to shrink instead of overflow */
}

#dbc-products .dbc-pcard__price,
.dbc-products .dbc-pcard__price {
  display: flex;
  flex-wrap: wrap;               /* let price pieces move to the next line */
  column-gap: 8px;
  row-gap: 2px;
}

#dbc-products .dbc-price-main,
.dbc-products .dbc-price-main,
#dbc-products .dbc-price-sale,
.dbc-products .dbc-price-sale {
  white-space: nowrap;           /* keep each token intact; wrap happens between them */
}

/* (Optional) make titles/price slightly smaller on very small phones */
@media (max-width: 380px) {
  #dbc-products .dbc-pcard__title,
  .dbc-products .dbc-pcard__title { font-size: 16px; }

  #dbc-products .dbc-pcard__price,
  .dbc-products .dbc-pcard__price { font-size: 15px; }
}

/* Let titles/desc wrap instead of clipping */
#dbc-products .dbc-pcard__title,
.dbc-products .dbc-pcard__title,
#dbc-products .dbc-pcard__desc,
.dbc-products .dbc-pcard__desc {
  overflow-wrap: anywhere;   /* break long tokens (e.g., model names) */
  word-break: normal;        /* avoid ugly mid-letter breaks unless needed */
  hyphens: auto;             /* requires <html lang="en"> (or your lang) */
}

/* Price row can wrap to a second line (you likely already added this) */
#dbc-products .dbc-pcard__price,
.dbc-products .dbc-pcard__price {
  display: flex;
  flex-wrap: wrap;
  column-gap: 8px;
  row-gap: 2px;
  min-width: 0;
}

/* Tighten typography at 4-up and 5-up so cards don't overflow */
@container (min-width: 900px) and (max-width: 1199px) {
  .dbc-products .dbc-pcard__title { font-size: 15.5px; }
  .dbc-products .dbc-pcard__price { font-size: 15px; }
  .dbc-products .dbc-pcard__desc  { font-size: 12.5px; }
}

@container (min-width: 1200px) {
  /* 5 across */
  .dbc-products .dbc-pcard__title { font-size: 14.5px; }
  .dbc-products .dbc-pcard__price { font-size: 14px; }
  .dbc-products .dbc-pcard__desc  { font-size: 12px;  -webkit-line-clamp: 2; }
}

/* ===== Desktop wrapping fix for product price row ===== */
#dbc-products .dbc-pcard__price,
.dbc-products .dbc-pcard__price {
  display: flex;
  flex-wrap: wrap;      /* allow price pieces to move to a 2nd line */
  column-gap: 8px;
  row-gap: 2px;
  min-width: 0;         /* let the flex child shrink inside the grid cell */
}

/* Allow line breaks inside the spans (override the earlier nowrap) */
#dbc-products .dbc-price-main,
#dbc-products .dbc-price-sale,
.dbc-products .dbc-price-main,
.dbc-products .dbc-price-sale {
  white-space: normal !important;  /* break between $ and “Sale” if needed */
  min-width: 0;
}

/* Keep titles/desc flexible on tight cards */
#dbc-products .dbc-pcard__title,
#dbc-products .dbc-pcard__desc,
.dbc-products .dbc-pcard__title,
.dbc-products .dbc-pcard__desc {
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}

/* ===== DEALS section rendered outside #dbc-coupons ===== */
#dbc-deals, .dbc-deals { }
#dbc-deals *, .dbc-deals * { box-sizing: border-box; }

#dbc-deals .dbc__heading, .dbc-deals .dbc__heading {
  font-size: clamp(18px, 2.8vw, 22px);
  font-weight: 700;
  margin: 18px 0 6px;
  padding: 10px 12px;
  background: var(--dbc-accent, #F1455F);
  color: #fff;
  border-radius: 10px;
}

#dbc-deals .dbc-card, .dbc-deals .dbc-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--dbc-border, #e6e6e6);
  border-radius: var(--dbc-radius, 12px);
  background: #fff;
  margin-bottom: var(--dbc-gap, 14px);
}
@media (min-width: 520px) {
  #dbc-deals .dbc-card, .dbc-deals .dbc-card { grid-template-columns: 110px 1fr; align-items: start; }
}
#dbc-deals .dbc-card__cta { display: flex; align-items: flex-start; justify-content: center; }
#dbc-deals .dbc-btn       { display:inline-block; width:100%; text-align:center; padding:12px 10px; min-height:44px; border-radius:10px; font-weight:700; text-decoration:none; border:1px solid transparent; }
#dbc-deals .dbc-btn--offer{ background: var(--dbc-soft, #e7f0ff); color: var(--dbc-link, #1a4b9a); border-color: var(--dbc-soft-border, #bcd0ff); }
#dbc-deals .dbc-card__chips { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:6px; }
#dbc-deals .dbc-chip { border:1px solid var(--dbc-border, #e6e6e6); border-radius:999px; padding:3px 8px; font-size:12px; white-space:nowrap; }
#dbc-deals .dbc-card__text { margin:4px 0 8px; font-size:16px; line-height:1.35; overflow-wrap:anywhere; }
#dbc-deals .dbc-card__links .dbc-more { font-size:14px; text-decoration:underline; color: var(--dbc-link, #1a4b9a); }
