/* Bundle Deals Pro - storefront.
   The sets are an accordion: a closed row (pictures, name, price, "choose" button) and a panel
   with the items, their options, the total and the buy button. Notes, progress bars and the
   timer come from the OCMOD.NET library ocmod-ui-1.0.css.
   Colours, sizes and borders are set in the module (Text and page - Block design): the module
   writes them as --bpd-* variables on the block, the values after the commas are the defaults.
   Fonts are inherited from the theme: no font family is set here.
   Every selector starts with .ocmod-bundle. */

/* the values of the block, one place; --bpd-* come from the style attribute of the block */
.ocmod-bundle {
  --b-acc: var(--bpd-accent, #b3123f);
  --b-ink: var(--bpd-ink, #141414);
  --b-mute: var(--bpd-muted, #5f5f68);
  --b-line: var(--bpd-line, #d9d9e0);
  --b-chip: var(--bpd-chip, #ffffff);
  --b-hd: var(--bpd-header-bg, #eeeff3);
  --b-pn: var(--bpd-panel-bg, #ffffff);
  --b-sel: var(--bpd-field-bg, #ffffff);
  --b-cta: var(--bpd-cta, #1f0a10);
  --b-cta-text: var(--bpd-cta-text, #ffffff);
  --b-ok: var(--bpd-ok, #1b6b3a);
  --b-bw: var(--bpd-border-width, 1px);
  --b-name: var(--bpd-name-size, 13px);
  --b-text: var(--bpd-text-size, 13px);
  --b-price: var(--bpd-price-size, 16px);
  --b-total: var(--bpd-total-size, 20px);
  --b-badge: var(--bpd-badge-size, 12px);
  --b-cta-size: var(--bpd-cta-size, 16px);
  --b-r-set: var(--bpd-radius-set, 12px);
  --b-r-thumb: var(--bpd-radius-thumb, 6px);
  --b-r-btn: var(--bpd-radius-button, 8px);
  --b-r-field: var(--bpd-radius-field, 6px);
  --b-r-badge: var(--bpd-radius-badge, 5px);

  max-width: 100%;
  min-width: 0;
  margin: 0 0 calc(var(--ocm-gap) * 2);
  overflow-x: clip;
}
.ocmod-bundle[hidden] { display: none; }
.ocmod-bundle > :last-child { margin-bottom: 0; }
/* .ocmod-bundle button,
.ocmod-bundle select { font: inherit; color: inherit; } */

/* ---------- set: a row of the accordion --------------------------------- */
.ocmod-bundle__set {
  container: ocmod-set / inline-size;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 10px;
  border-radius: var(--b-r-set);
  background: var(--b-pn);
  color: var(--b-ink);
  overflow: hidden;
}

/* the closed row: pictures and info, the "choose" button under them (beside them when wide) */
.ocmod-bundle__header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px 12px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 12px 14px;
  border: 0;
  background: var(--b-hd);
  text-align: left;
  cursor: pointer;
}
.ocmod-bundle__header:focus-visible { outline: 2px solid var(--b-ink); outline-offset: 2px; }

/* pictures lie one over another, three at most; the rest is the "+N" on the third */
.ocmod-bundle__thumbs { display: flex; }
.ocmod-bundle__mini {
  position: relative;
  display: block;
  width: var(--bpd-thumb-width, 38px);
  height: var(--bpd-thumb-height, 48px);
  margin-left: calc(var(--bpd-thumb-overlap, 12px) * -1);
  border: var(--bpd-thumb-border, 2px) solid var(--b-hd);
  border-radius: var(--b-r-thumb);
  background: var(--b-chip);
  overflow: hidden;
}
.ocmod-bundle__mini:first-child { margin-left: 0; }
.ocmod-bundle__mini img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ocmod-bundle__more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 20, .62);
  color: #fff;
  font-size: var(--b-text);
  font-weight: 700;
}

/* info: name with the count, note, price - one under another */
.ocmod-bundle__teaser { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ocmod-bundle__name {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--b-ink);
  font-size: var(--b-name);
  font-weight: var(--bpd-name-weight, 700);
  text-transform: uppercase;
  white-space: nowrap;
}
.ocmod-bundle__count {
  flex: none;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--b-chip);
  font-size: calc(var(--b-name) - 1px);
  font-style: normal;
  font-weight: 600;
  text-transform: none;
}
.ocmod-bundle__note {
  display: block;
  overflow: hidden;
  color: var(--b-mute);
  font-size: var(--b-text);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ocmod-bundle__sum { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.ocmod-bundle__now { color: var(--b-ink); font-size: var(--b-price); font-weight: var(--bpd-price-weight, 700); }
.ocmod-bundle__old { color: var(--b-mute); font-size: var(--b-text); }
.ocmod-bundle__badge {
  padding: 1px 6px;
  border-radius: var(--b-r-badge);
  background: var(--b-acc);
  color: #fff;
  font-size: var(--b-badge);
  font-style: normal;
  font-weight: 700;
}
.ocmod-bundle__sum--total .ocmod-bundle__now { font-size: var(--b-total); }

/* the "choose" button: the saving on the left, the word and the arrow on the right */
.ocmod-bundle__pick {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-sizing: border-box;
  height: var(--bpd-pick-height, 44px);
  padding: 0 14px;
  background: transparent;
  border: var(--b-bw) solid var(--b-ink);
  border-radius: var(--b-r-btn);
}
.ocmod-bundle__save { font-size: var(--b-text); font-weight: 600; }
.ocmod-bundle__go { display: flex; align-items: center; gap: 4px; font-weight: 700; }
.ocmod-bundle__go .ocm-icon { width: 16px; height: 16px; transition: transform .2s; }
.ocmod-bundle__lbl--open { display: none; }
.ocmod-bundle__set.is-open .ocmod-bundle__lbl--open { display: inline; }
.ocmod-bundle__set.is-open .ocmod-bundle__lbl--closed { display: none; }
.ocmod-bundle__set.is-open .ocmod-bundle__pick { background: var(--b-ink); color: var(--b-pn); }
.ocmod-bundle__set.is-open .ocmod-bundle__chevron { transform: rotate(180deg); }

/* ---------- panel: opens by rows, so no height is measured ---------------- */
.ocmod-bundle__panel {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows .25s, visibility .25s;
}
.ocmod-bundle__set.is-open .ocmod-bundle__panel { grid-template-rows: 1fr; visibility: visible; background: rgba(1, 1, 1, 0.02);}
.ocmod-bundle__panel-inner { min-height: 0; overflow: hidden; padding: 0 14px; }

.ocmod-bundle__lead { margin: 12px 0 10px; color: var(--b-mute); font-size: var(--b-text); }
.ocmod-bundle__lead b { color: var(--b-ink); }

/* ---------- items: a row on a narrow set, columns on a wide one ---------------- */
.ocmod-bundle__grid { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.ocmod-bundle__tile {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 140px;
  align-items: start;
  gap: 4px 12px;
  min-width: 0;
}
.ocmod-bundle__options { align-self: center; }
.ocmod-bundle__visual {
  align-self: start;
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  border-radius: var(--b-r-thumb);
  background: var(--b-chip);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
}
.ocmod-bundle__visual img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ocmod-bundle__title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-top: 2px;
  color: var(--b-ink);
  font-size: var(--b-text);
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-decoration: none;
}
.ocmod-bundle__item-price { color: var(--b-mute); font-weight: 400; }

.ocmod-bundle__qty,
.ocmod-bundle__state {
  position: absolute;
  top: 3px;
  padding: 0 4px;
  border-radius: var(--b-r-badge);
  background: var(--b-pn);
  color: var(--b-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
}
.ocmod-bundle__qty { right: 3px; }
.ocmod-bundle__state { left: 3px; color: var(--b-ok); }
.ocmod-bundle__state .ocm-icon { width: 12px; height: 12px; vertical-align: -2px; }

/* ---------- options ------------------------------------------------------ */
.ocmod-bundle__options { width: 100%; text-align: left; }
.ocmod-bundle__options .ocm-field { display: block; margin: 0 0 6px; }
.ocmod-bundle__options .ocm-field:last-child { margin-bottom: 0; }
.ocmod-bundle__options .ocm-field__label { display: none; }
.ocmod-bundle__options .ocm-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: var(--bpd-field-height, 44px);
  padding: 0 6px;
  border: var(--b-bw) solid var(--b-mute);
  border-radius: var(--b-r-field);
  background: var(--b-sel);
  color: var(--b-ink);
}
.ocmod-bundle__options textarea.ocm-input { height: auto; padding: 6px; }
.ocmod-bundle__options .ocm-field--error .ocm-input { border-color: var(--b-acc); box-shadow: 0 0 0 1px var(--b-acc); }
.ocmod-bundle__options .ocm-check { font-size: var(--b-text); }
.ocmod-bundle__options .ocm-field__hint { margin-top: 3px; color: var(--b-acc); font-size: var(--b-text); font-weight: 600; }

/* the product form of the page already asks for the options of the open product */
.ocmod-bundle__options.ocm-hide { display: none; }

/* ---------- total, timer and button -------------------------------------- */
.ocmod-bundle__details { display: flex; flex-direction: column; gap: 10px; padding: 2px 0 16px; }
.ocmod-bundle__total { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ocmod-bundle__cta {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: var(--bpd-cta-height, 52px);
  padding: 0 16px;
  border: 0;
  border-radius: var(--b-r-btn);
  background: var(--b-cta);
  color: var(--b-cta-text);
  font-size: var(--b-cta-size);
  font-weight: 700;
  line-height: var(--bpd-cta-height, 52px);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.ocmod-bundle__cta:disabled { opacity: .6; cursor: default; }
.ocmod-bundle__cta:focus-visible { outline: 2px solid var(--b-ink); outline-offset: 2px; }

.ocmod-bundle__message { margin: 0; font-size: var(--b-text); font-weight: 600; }
.ocmod-bundle__message:empty { display: none; }
.ocmod-bundle__message.ocm-bad { color: var(--b-acc); }
.ocmod-bundle__message.ocm-good { color: var(--b-ok); }
.ocmod-bundle__message a { color: inherit; text-decoration: underline; }

/* the progress bar of a note starts under the title text, like the note text does */
.ocmod-bundle .ocm-note > .ocm-goal { margin: 6px 0 0 24px; }

/* ---------- narrow set ----------------------------------------------------- */
@container ocmod-set (max-width: 350px) {
  .ocmod-bundle__mini { width: calc(var(--bpd-thumb-width, 38px) * .84); height: calc(var(--bpd-thumb-height, 48px) * .875); margin-left: calc(var(--bpd-thumb-overlap, 12px) * -.83); }
  .ocmod-bundle__mini:first-child { margin-left: 0; }
  .ocmod-bundle__tile { grid-template-columns: 48px minmax(0, 1fr) 130px; gap: 4px 10px; }
}

/* very narrow set: the select goes under the picture and the name */
@container ocmod-set (max-width: 340px) {
  .ocmod-bundle__tile { grid-template-columns: 48px minmax(0, 1fr); gap: 8px 10px; }
  .ocmod-bundle__options { grid-column: 1 / -1; }
  .ocmod-bundle__title { align-self: center; padding-top: 0; }
}

/* ---------- medium set: the button beside the info, two lines in it ---------- */
@container ocmod-set (min-width: 460px) {
  .ocmod-bundle__header { grid-template-columns: auto minmax(0, 1fr) auto; }
  .ocmod-bundle__pick {
    grid-column: auto;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    height: auto;
    min-height: 58px;
    padding: 8px 16px;
  }
  .ocmod-bundle__save { font-size: calc(var(--b-text) - 1px); text-align: center; }
}

/* ---------- wide set: the button in one line ---------------------------------- */
@container ocmod-set (min-width: 640px) {
  .ocmod-bundle__pick {
    flex-direction: row;
    min-width: 300px;
    height: var(--bpd-pick-height, 44px);
    min-height: 0;
    padding: 0 14px;
  }
  .ocmod-bundle__save { font-size: var(--b-text); }
}

/* ---------- from 460px: the items in columns, the total beside the button ------ */
@container ocmod-set (min-width: 460px) {
  .ocmod-bundle__grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px 12px; }
  .ocmod-bundle__tile { display: flex; flex-direction: column; align-items: stretch; gap: 6px; grid-column: span 4; }
  .ocmod-bundle__grid:has(> :nth-child(2):last-child) .ocmod-bundle__tile { grid-column: span 6; }
  .ocmod-bundle__grid:has(> :nth-child(4):last-child) .ocmod-bundle__tile { grid-column: span 3; }
  .ocmod-bundle__grid:has(> :nth-child(5):last-child) .ocmod-bundle__tile:nth-child(n+4) { grid-column: span 6; }
  .ocmod-bundle__visual { aspect-ratio: 4 / 5; }
  .ocmod-bundle__title { flex: 1; padding-top: 0; align-self: auto; }
  .ocmod-bundle__options { align-self: stretch; grid-column: auto; }
  .ocmod-bundle__options .ocm-field__label {
    display: block;
    margin: 0 0 2px;
    color: var(--b-mute);
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
  }

  .ocmod-bundle__details { flex-direction: row; align-items: center; }
  .ocmod-bundle__total { flex: 1; }
  .ocmod-bundle__cta { flex: none; width: 260px; margin-left: auto; }
}

@media (max-width: 479px) {
  .ocmod-bundle .ocm-note > .ocm-goal { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ocmod-bundle__panel,
  .ocmod-bundle__go .ocm-icon { transition: none; }
}
