/* ==========================================================================
   Core Coatings: colours.css. Colours page only.
   Loaded after site.css. The surround is always --paper (white),
   every swatch has a 1px --line border, picked = --blue-5 ring.
   Tokens only; no hard-coded colours.
   ========================================================================== */

/* ---------- Intro */
.cf-intro { padding: var(--s-8) 0 var(--s-6); }
.cf-intro__lead { margin-top: var(--s-4); max-width: 640px; }

/* ---------- Layout: grid + "Your colours" beside it */
.cf { padding: 0 0 var(--s-9); background: var(--paper); }
.cf__layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-7); align-items: start; }
.cf__main { min-width: 0; }

/* ---------- Search */
.cf__search { max-width: 560px; }
.cf-searchbox { position: relative; }
.cf-searchbox > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.cf-searchbox .input { padding-left: 44px; padding-right: 48px; min-height: 52px; font-size: 17px; }
.cf-searchbox .input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.cf-searchbox__clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: var(--radius);
}
.cf-searchbox__clear:hover { color: var(--ink); }

/* ---------- Collection chips (one at a time; real radios underneath) */
.cf-chips { min-width: 0; margin-top: var(--s-5); }
.cf-chips .chip span { white-space: nowrap; }
.cf-chips .chip i { font-style: normal; font-size: 13px; color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }

/* ---------- "Can't find your colour?" (always visible) */
.cf-custom { margin-top: var(--s-5); border: 1px solid var(--line); background: var(--paper); }
.cf-custom__open {
  display: flex; align-items: center; gap: var(--s-4); width: 100%; min-height: 64px;
  padding: var(--s-3) var(--s-5); border: 0; background: transparent; cursor: pointer; text-align: left;
  font: inherit; color: var(--ink);
}
.cf-custom__open > .icon:first-child { flex: none; width: 28px; height: 28px; color: var(--blue); }
.cf-custom__text { flex: 1; min-width: 0; font-size: 16px; line-height: 1.4; }
.cf-custom__text strong { font-weight: 600; }
.cf-custom__text span { color: var(--muted); }
.cf-custom__plus { flex: none; color: var(--blue); transition: transform .2s var(--ease); }
.cf-custom__open[aria-expanded="true"] .cf-custom__plus { transform: rotate(45deg); }
.cf-custom__open:hover { background: var(--blue-5); }
.cf-custom__open:focus-visible { outline-offset: -3px; }
.cf-custom__form { padding: 0 var(--s-5) var(--s-5); }
.cf-custom__row { display: flex; gap: var(--s-3); }
.cf-custom__row .input { flex: 1; min-width: 0; }
.cf-custom__row .btn { flex: none; }

.cf__count { margin: var(--s-5) 0 var(--s-4); font-size: 15px; color: var(--muted); }
.cf__count strong { color: var(--ink); font-weight: 600; }

/* ---------- Swatch grid */
.cf-grid {
  list-style: none; display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.cf-sw {
  position: relative; display: flex; flex-direction: column; width: 100%; height: 100%;
  padding: 0; margin: 0; text-align: left; cursor: pointer;
  background: var(--paper); border: 1px solid var(--line); border-radius: 0;
  transition: border-color .15s, box-shadow .15s;
}
.cf-sw:hover { border-color: var(--muted); }
.cf-sw__chip { display: block; aspect-ratio: 4 / 3; min-height: 90px; border-bottom: 1px solid var(--line); }
.cf-sw__name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  padding: var(--s-3) var(--s-3) 2px; font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--ink);
}
.cf-sw .label { display: block; padding: 0 var(--s-3) var(--s-3); margin-top: auto; overflow-wrap: anywhere; }
.cf-sw__tick {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  background: var(--paper); color: var(--blue); border: 1px solid var(--blue);
}
.cf-sw__tick .icon { width: 16px; height: 16px; stroke-width: 2.25; }
.cf-sw[aria-pressed="true"] { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-5); }
.cf-sw[aria-pressed="true"] .cf-sw__tick { display: inline-flex; }

/* ---------- Empty state, load more, notes */
.cf-empty { padding: var(--s-6) 0; border-top: 1px solid var(--line); display: grid; gap: var(--s-3); max-width: 560px; }
.cf-empty .btn-row { margin-top: var(--s-2); }
.cf-more { margin-top: var(--s-6); display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.cf__note { margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--line); font-size: 15px; }
.cf__legal { margin-top: var(--s-3); font-size: 13px; color: var(--muted); max-width: 760px; }

/* ---------- "Your colours" (beside the grid on desktop) */
.cf-list {
  position: sticky; top: calc(var(--header-h) + var(--s-5));
  border: 1px solid var(--line); background: var(--paper);
}
.cf-list__toggle { display: none; }
.cf-list__body { padding: var(--s-5); display: grid; gap: var(--s-4); align-content: start; max-height: calc(100vh - var(--header-h) - var(--s-7)); overflow-y: auto; }
.cf-list__n { color: var(--muted); font-weight: 400; }
.cf-list__items { list-style: none; display: grid; }
.cf-item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; border-top: 1px solid var(--line); }
.cf-item:last-child { border-bottom: 1px solid var(--line); }
.cf-item__chip { flex: none; width: 32px; height: 32px; border: 1px solid var(--line); }
.cf-item__chip--blank { background: var(--paper); border-style: dashed; border-color: var(--muted); }
.cf-item { flex-wrap: wrap; }
.cf-item__text { flex: 1; min-width: 0; display: grid; }
.cf-item__product { order: 3; flex: 1 0 100%; padding-left: calc(32px + var(--s-3)); padding-bottom: var(--s-1); font-size: 14px; font-weight: 600; color: var(--navy); }
.cf-item__in { font-weight: 400; color: var(--muted); }
.cf-item__select {
  width: 100%; height: 36px; padding: 0 30px 0 var(--s-3); font: inherit; font-size: 14px; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); background-color: var(--paper);
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.cf-item__select:hover { border-color: var(--muted); }
.cf-item__select:focus-visible { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-5); }
.cf-item__name { font-size: 15px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.cf-item__remove {
  flex: none; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: var(--radius);
}
.cf-item__remove:hover { color: var(--ink); }
.cf-list__after { margin-top: calc(-1 * var(--s-2)); }
.cf-scrim { display: none; }

/* ---------- Quote form inside the panel */
.cf-quote { display: grid; gap: var(--s-4); padding-top: var(--s-4); border-top: 2px solid var(--ink); }
.cf-quote__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.cf-quote__title { font-size: 18px; font-weight: 700; }
.cf-quote__back { border: 0; background: none; padding: 0; font: inherit; font-size: 14px; color: var(--blue); text-decoration: underline; cursor: pointer; }
.cf-quote__form { gap: var(--s-4); }
.cf-quote .form-sent { margin-top: 0; align-self: start; }
.cf-quote:has(.form-sent) { border-top-color: var(--line); }
.cf-quote__picked { margin: calc(-1 * var(--s-2)) 0 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cf-quote__form .form__row { gap: var(--s-3); }
.cf-quote .textarea { min-height: 72px; }
.cf-list__quick { display: none; }

/* ---------- Below 1024px: "Your colours" becomes a bottom sheet */
@media (max-width: 1023px) {
  .cf__layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .cf-list {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 55;
    border: 0; border-top: 1px solid var(--line);
    box-shadow: 0 -10px 30px -12px rgba(11, 14, 18, 0.22);
    display: none;
  }
  .cf-has-picks .cf-list { display: block; }
  .cf-list__toggle {
    display: flex; align-items: center; justify-content: space-between; width: 100%; height: 56px;
    padding: 0 var(--gutter); border: 0; background: var(--paper); cursor: pointer; font-size: 16px; text-align: left;
  }
  .cf-list__toggle .icon { transition: transform .2s var(--ease); }
  .cf-list__toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
  .cf-list__toggle:focus-visible { outline-offset: -4px; }
  /* "Get a quote" sits in the bar beside "Your colours", so the next step is one tap */
  .cf-list__toggle { padding-right: calc(var(--gutter) + 150px); }
  .cf-list__quick {
    display: inline-flex; align-items: center; justify-content: center; position: absolute; top: 6px; right: var(--gutter);
    height: 44px; min-width: 136px; padding: 0 var(--s-4); border: 0; border-radius: var(--radius);
    background: var(--blue); color: var(--paper); font: 600 15px var(--sans); cursor: pointer;
  }
  .cf-list__quick:hover { background: var(--blue-hover); }
  .cf-list.is-quoting .cf-list__quick { display: none; }
  .cf-list__quick-long { display: none; }
  .cf-list__badge {
    display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px;
    margin-left: var(--s-2); border-radius: 999px; background: var(--blue); color: var(--paper);
    font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  }
  .cf-list__title { display: none; }
  .cf-list__body { display: none; max-height: 60vh; padding: 0 var(--gutter) var(--s-5); }
  .cf-list.is-open .cf-list__body { display: grid; }
  /* Quoting on a phone or tablet: the sheet goes full height */
  .cf-list.is-quoting.is-open { top: 0; display: flex; flex-direction: column; z-index: 61; }
  .cf-list.is-quoting.is-open .cf-list__body { flex: 1; max-height: none; min-height: 0; padding-bottom: var(--s-7); }
  body.cf-has-picks { padding-bottom: 56px; }
  .cf-scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 54; background: rgba(11, 14, 18, 0.4); }
}
@media (min-width: 1024px) {
  .cf-list__badge { display: none; }
  /* The quote button stays pinned to the bottom of "Your colours", so it is always in view however long the list */
  .cf-list__send { position: sticky; bottom: 0; z-index: 2; box-shadow: 0 0 0 var(--s-3) var(--paper); }
  /* Quote form: a centred box over the page, with the backdrop, whole form and button in one screen */
  .cf-list.is-quoting .cf-quote {
    position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 70;
    width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
    padding: var(--s-6); border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
    box-shadow: 0 24px 48px -16px rgba(11, 14, 18, .35);
  }
  /* While the box is open the panel behind it steps out of the way (the backdrop dims the page) */
  .cf-list.is-quoting { z-index: 70; pointer-events: none; background: transparent; border-color: transparent; }
  .cf-list.is-quoting .cf-list__body > :not(.cf-quote) { visibility: hidden; }
  .cf-list.is-quoting .cf-quote { pointer-events: auto; visibility: visible; }
  .cf-list.is-quoting .cf-quote__title { font-size: 22px; }
  .cf-list__quick-short { display: none; }
  body.cf-has-picks.cf-send-off:not(.cf-quoting) .cf-list__quick {
    display: inline-flex; align-items: center; gap: var(--s-2); position: fixed; z-index: 56; bottom: var(--s-5); left: 50%; transform: translateX(-50%);
    min-height: 56px; padding: 0 var(--s-6); border: 0; border-radius: var(--radius); pointer-events: auto;
    background: var(--blue); color: var(--paper); font: 600 17px var(--sans); cursor: pointer;
    box-shadow: 0 14px 30px -12px rgba(11, 14, 18, 0.45);
  }
  body.cf-has-picks.cf-send-off:not(.cf-quoting) .cf-list__quick:hover { background: var(--blue-hover); }
  body.cf-quoting .cf-scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(11, 14, 18, 0.55); }
}

/* ---------- Phones */
@media (max-width: 767px) {
  .cf-intro { padding: var(--s-7) 0 var(--s-5); }
  .cf { padding-bottom: var(--s-8); }
  .cf-chips { flex-wrap: nowrap; overflow-x: auto; margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); padding: 2px var(--gutter) 6px; scrollbar-width: none; }
  .cf-chips::-webkit-scrollbar { display: none; }
  .cf-chips .chip { flex: none; }
  .cf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .cf-custom__open { padding: var(--s-3) var(--s-4); }
  .cf-custom__form { padding: 0 var(--s-4) var(--s-4); }
  .cf-custom__row { flex-direction: column; }
}
@media (max-width: 639px) {
  .cf-list { bottom: calc(var(--callbar-h) + env(safe-area-inset-bottom, 0px)); }
  body.cf-has-picks { padding-bottom: calc(var(--callbar-h) + 56px + env(safe-area-inset-bottom, 0px)); }
  /* site.css hides the call bar while the keyboard is up; the sheet drops to the bottom edge with it */
  body:has(:is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), textarea):focus) .cf-list { bottom: 0; }
}
/* Touch screens keep :hover after a tap; only tint on a real pointer */
@media (hover: none) {
  .cf-sw:hover { border-color: var(--line); }
  .cf-sw[aria-pressed="true"]:hover { border-color: var(--blue); }
  .cf-custom__open:hover { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .cf-sw, .cf-list__toggle .icon, .cf-custom__plus { transition: none; }
}

@media print {
  .cf-chips, .cf__search, .cf-more, .cf-list__toggle, .cf-list__send, .cf-item__remove, .cf-scrim, .cf-custom, .cf-quote { display: none !important; }
  .cf__layout { display: block; }
  .cf-list { position: static; display: block !important; box-shadow: none; }
  .cf-list__body { display: grid !important; max-height: none; }
  .cf-sw__chip, .cf-item__chip { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
