/* =====================================================================
   Colour carousel: on phones (<768px) the colour cards of a product page sit in ONE swipeable row with arrows and page dots.
   Shared by the retail PDP (.pdp-premium, colour-photo tiles) and the wholesale PDP (.wsl-pdp, Select Color card), for every store:
   the accent is the page's own brand variable, never a fixed colour. Behaviour: cdn/js/colour-carousel.js.
   From 768px up nothing here applies: the shell is display:contents and the arrows/dots are not shown.
===================================================================== */
.cc-shell { display: contents; }
.cc-arrow, .cc-dots { display: none; }

@media (max-width: 767.98px) {
  .cc-shell, [data-colour-carousel] { --cc-accent: var(--wsl-accent, var(--pdp-primary, var(--primary, #111))); --cc-n: 4; --cc-gap: 7px; --cc-gutter: 14px; }
  .pdp-premium .cc-shell, .pdp-premium [data-colour-carousel] { --cc-accent: var(--pdp-primary, var(--primary, #111)); }

  .cc-shell { position: relative; display: block; min-width: 0; max-width: 100%; }

  /* the row: about four cards, never wraps; only this strip scrolls sideways, never the page */
  :is(.pdp-premium, .wsl-pdp) [data-colour-carousel],
  #tbBuy .ub-colors[data-colour-carousel] {
    position: relative; display: flex !important; flex-wrap: nowrap !important; align-items: flex-start; gap: 0;
    width: auto; min-width: 0; margin: -4px var(--cc-gutter) 0; padding: 9px 7px 8px; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x proximity; scroll-padding-inline: 7px; overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  :is(.pdp-premium, .wsl-pdp) [data-colour-carousel]::-webkit-scrollbar { display: none; }
  :is(.pdp-premium, .wsl-pdp) .cc-shell.cc-fits > [data-colour-carousel],
  #tbBuy .cc-fits > .ub-colors[data-colour-carousel] { margin-inline: -7px; }      /* every colour is already visible: no arrows, so no gutters */

  :is(.pdp-premium, .wsl-pdp) [data-colour-carousel] > :is(button, label),
  #tbBuy .ub-colors[data-colour-carousel] > button {
    flex: 0 0 calc((100% - (var(--cc-n) - 1) * var(--cc-gap)) / var(--cc-n)) !important; width: auto; min-width: 0; max-width: none;
    margin: 0 0 0 var(--cc-gap) !important; scroll-snap-align: start;
  }
  :is(.pdp-premium, .wsl-pdp) [data-colour-carousel] > :is(button:first-child, input:first-child + label),
  #tbBuy .ub-colors[data-colour-carousel] > button:first-child { margin-inline-start: 0 !important; }
  /* the retail radios stay beside their own label (zero net width), so focusing one never scrolls the row back to the start */
  :is(.pdp-premium, .wsl-pdp) [data-colour-carousel] > input {
    position: relative !important; flex: 0 0 1px; width: 1px !important; height: 1px !important; min-width: 0;
    margin: 0 -1px 0 0 !important; padding: 0; opacity: 0; pointer-events: none;
  }

  /* arrows */
  .cc-arrow {
    position: absolute; top: var(--cc-arrow-top, 40px); z-index: 2; display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; min-width: 0; min-height: 0; margin: -14px 0 0; padding: 0; border: 1px solid #ececf1; border-radius: 50%;
    background: #fff; color: var(--cc-accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .14); cursor: pointer; line-height: 0;
    -webkit-tap-highlight-color: transparent; transition: opacity .15s ease;
  }
  .cc-arrow::after { content: ""; position: absolute; inset: -12px -4px; }      /* finger-sized target, the card beside it stays tappable */
  .cc-arrow--prev { left: -10px; }
  .cc-arrow--next { right: -10px; }
  .cc-arrow svg { width: 16px; height: 16px; pointer-events: none; }
  .cc-arrow:disabled { color: #b9b9c2; background: #fff; opacity: .7; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); cursor: default; }
  .cc-arrow:focus-visible { outline: 2px solid var(--cc-accent); outline-offset: 2px; }
  .cc-arrow[hidden], .cc-dots[hidden] { display: none; }

  /* page dots (decorative) */
  .cc-dots { display: flex; justify-content: center; gap: 9px; margin: 6px 0 0; }
  .cc-dots i { width: 7px; height: 7px; border-radius: 50%; background: #d5d5da; transition: background-color .15s ease; }
  .cc-dots i.is-on { background: var(--cc-accent); }

  /* ---- card look, both pages: white card, whole photo (no cropping), name below ---- */
  :is(.pdp-premium, .wsl-pdp) [data-colour-carousel] :is(.wsl-ctile__box, .pdp-tile__box) { border: 1.5px solid #dcdce0; border-radius: 12px; background: #fff; }
  :is(.pdp-premium, .wsl-pdp) [data-colour-carousel] :is(.wsl-ctile__box, .pdp-tile__box) img { inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); border-radius: 9px; object-fit: contain; }
  :is(.pdp-premium, .wsl-pdp) [data-colour-carousel] .wsl-ctile__fill { inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); border-radius: 9px; }
  :is(.pdp-premium, .wsl-pdp) [data-colour-carousel] :is(.wsl-ctile__check, .pdp-tile__check) { top: -7px; right: -6px; width: 20px; height: 20px; font-size: 12px; line-height: 20px; box-shadow: none; }
  :is(.pdp-premium, .wsl-pdp) [data-colour-carousel] :is(.wsl-ctile__name, .pdp-tile__name) {
    display: block; width: 100%; font-size: 12px; font-weight: 600; line-height: 1.25; color: #222; text-align: center;
    white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere;
  }
  :is(.pdp-premium, .wsl-pdp) [data-colour-carousel] .wsl-ctile.is-active .wsl-ctile__box { border-color: var(--cc-accent); box-shadow: 0 0 0 1px var(--cc-accent); }

  /* retail: only the photo is outlined, not the photo + name; keyboard focus still shows */
  .pdp-premium .option-selector [data-colour-carousel] .js-option.js-option + .opt-label--btn.opt-label--tile { border: 0 !important; box-shadow: none !important; outline: 0; }
  .pdp-premium [data-colour-carousel] .js-option:focus-visible + .opt-label--tile .pdp-tile__box { outline: 2px solid var(--cc-accent); outline-offset: 2px; }

  /* a retail colour with no photo of its own keeps its text, in a card of the same size */
  .pdp-premium [data-colour-carousel] > .opt-label--btn:not(.opt-label--tile) { aspect-ratio: 1; height: auto; padding: 4px; border-radius: 12px; font-size: 11.5px; line-height: 1.2; white-space: normal; overflow-wrap: anywhere; }

  /* ---- retail page: the same section card as the wholesale page (heading left, chosen colour's name right) ---- */
  .pdp-premium .option-selector:has([data-colour-carousel]) { box-sizing: border-box; margin: 4px 0 12px; padding: 13px 14px 12px; border: 1px solid #ebebe7; border-radius: 16px; background: #fafafa; }
  .pdp-premium .option-selector:has([data-colour-carousel]) .pdp-size-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 8px; font-size: 15px; font-weight: 700; }
  .pdp-premium .option-selector:has([data-colour-carousel]) .pdp-size-label > span:first-child::before { content: "Select "; }
  .pdp-premium .option-selector:has([data-colour-carousel]) .pdp-opt-selected { margin: 0; padding: 4px 12px; border-radius: 8px; background: color-mix(in srgb, var(--pdp-primary, #111) 13%, #fff); color: var(--pdp-primary, #111); font-size: 12.5px; font-weight: 800; line-height: 1.35; }
  .pdp-premium .option-selector:has([data-colour-carousel]) .pdp-opt-selected:empty { display: none; }
  .pdp-premium .option-selector:has([data-colour-carousel]) .pdp-opt-selected:not(:empty)::before { content: none; }

  /* ---- combo-pack box (retail, product with packs): same row; the tiles there are .ub-color and several may be chosen for a pack ---- */
  #tbBuy .ub-color .ub-sw { width: 100%; height: auto; aspect-ratio: 1; border: 1.5px solid #dcdce0; border-radius: 12px; background-color: #fff; }
  #tbBuy .ub-color .ub-sw img { border-radius: 9px; object-fit: contain; }
  #tbBuy .ub-color .ub-cn { margin-top: 5px; font-size: 12px; line-height: 1.25; text-transform: none; letter-spacing: normal; }
  #tbBuy .ub-color[aria-pressed="true"] .ub-sw { border-color: var(--ub); }
  #tbBuy .ub-color[aria-pressed="true"] .ub-sw::after { top: -7px; width: 20px; height: 20px; font-size: 12px; line-height: 20px; }
  #tbBuy .ub-color .ub-sw .ub-n { z-index: 2; }
  #tbBuy .cc-arrow { color: var(--cc-accent); }
  #tbBuy .cc-arrow:disabled { color: #b9b9c2; }
  #tbBuy .ub-picked:not(:empty) { display: inline-block; padding: 4px 12px; border-radius: 8px; background: color-mix(in srgb, var(--ub) 13%, #fff); color: var(--ub); font-size: 12.5px; font-weight: 800; line-height: 1.35; }

  /* ---- wholesale page: the heading keeps clear of the row ---- */
  .wsl-pdp #wslColorCard .wsl-card__head { margin-bottom: 8px; }

  /* ---- retail page, compact: about 30% less empty space above/below the heading, names and dots. The photos keep their size
     (same side padding, still ~4 per row); the row keeps 8px on top so the chosen card's check mark is never clipped. ---- */
  .pdp-premium .option-selector:has([data-colour-carousel]) { margin: 2px 0 10px; padding: 9px 14px 7px; }
  .pdp-premium .option-selector:has([data-colour-carousel]) .pdp-size-label { margin-bottom: 2px; line-height: 1.25; }
  .pdp-premium .option-selector:has([data-colour-carousel]) .pdp-opt-selected { padding-block: 3px; }
  .pdp-premium [data-colour-carousel] { margin-top: -2px; padding-block: 8px 3px; }
  .pdp-premium [data-colour-carousel] .opt-label--tile { gap: 4px; }
  .pdp-premium .option-selector:has([data-colour-carousel]) .cc-dots { margin-top: 3px; }
}

@media (max-width: 374.98px) { :is(.pdp-premium, .wsl-pdp) [data-colour-carousel] :is(.wsl-ctile__name, .pdp-tile__name) { font-size: 11.5px; } }
/* how many cards fit: fewer on the smallest phones, more on large ones / phones held sideways */
@media (max-width: 339.98px) { .cc-shell, [data-colour-carousel] { --cc-n: 3; } }
@media (min-width: 480px) and (max-width: 767.98px) { .cc-shell, [data-colour-carousel] { --cc-n: 5; --cc-gap: 10px; } }
@media (min-width: 600px) and (max-width: 767.98px) { .cc-shell, [data-colour-carousel] { --cc-n: 7; } }
@media (prefers-reduced-motion: reduce) { .cc-arrow, .cc-dots i { transition: none; } }
