/*
 * Bespoke plan builder (blocks/bespoke-builder), as in the Bespoke wireframe.
 *
 * - The services: a card for each, under its group's name, in three even columns where there's room (two on
 *   tablets, one on phones). A card in the plan turns pale teal and its button reads "✓ Added".
 * - The "Your plan" basket: deep teal, beside the services on laptops and larger, and kept in view while scrolling
 *   (sticky), scrolling inside itself when the plan is long. It lights up while a service is dragged over it.
 * - The booking step replaces the basket, in white, with the booking picker fitted to the narrow column.
 *
 * Inside the "Choose your services" section (plan-bespoke-builder-bnr) the block's own wrapper steps aside, so the
 * services and the basket take their places in the section's grid. On tablets and phones the basket comes after
 * the services, and a small "Your plan" link stays at the foot of the screen until it's in view.
 */

.bespoke-builder {
  display: contents;
}

/* Bespoke plans being set up: one line pointing to Contact, in the services' place */

.bespoke-builder--setting-up {
  display: block;
  grid-area: picker;
}

.bespoke-builder__setting-up {
  margin: 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--teal-pale);
  font-size: 16px;
  line-height: 1.55;
}

/* The services, group by group */

.bespoke-builder__picker {
  display: flex;
  grid-area: picker;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
  container-type: inline-size;
}

.bespoke-builder__group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bespoke-builder__group-name {
  margin: 0;
  color: var(--teal-dark);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Cards: three columns where there's room, two on tablets, one on phones */

.bespoke-builder__cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@container (max-width: 719px) {
  .bespoke-builder__cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (max-width: 459px) {
  .bespoke-builder__cards {
    grid-template-columns: minmax(0, 1fr);
  }
}

.bespoke-builder__card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--white);
  cursor: grab;
  transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

/* A card in the plan: pale teal with a darker edge. Its edge is the same width either way, so nothing shifts. */

.bespoke-builder__card.is-added {
  border-color: var(--teal-dark);
  background: var(--teal-light);
  box-shadow: inset 0 0 0 0.5px var(--teal-dark);
}

.bespoke-builder__card.is-dragging {
  opacity: 0.5;
}

.bespoke-builder__card-words {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.bespoke-builder__card-name {
  color: #0d3d39;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

.bespoke-builder__card-text {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

/* "+ Add" outlined, "✓ Added" filled; the same width either way, so the card's words never move */

.bespoke-builder__add {
  flex-shrink: 0;
  min-width: 92px;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--teal-dark);
  border-radius: 999px;
  background: var(--white);
  color: var(--teal-darker);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.bespoke-builder__add[aria-pressed="true"] {
  border-color: var(--teal-darker);
  background: var(--teal-darker);
  color: var(--white);
}

.bespoke-builder__add:focus-visible,
.bespoke-builder__remove:focus-visible,
.bespoke-builder__book:focus-visible,
.bespoke-builder__back:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

/*
 * The basket's column: kept in view below the sticky header, and scrolling inside itself when the plan is longer
 * than the screen. bespoke-builder.js sets --bespoke-sticky-top and --bespoke-max-height from the header's real height.
 */

.bespoke-builder__aside {
  grid-area: aside;
  position: sticky;
  top: var(--bespoke-sticky-top, 132px);
  min-width: 0;
  max-height: var(--bespoke-max-height, calc(100vh - 156px));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 20px;
  scrollbar-width: thin;
  scroll-margin-top: clamp(96px, 12vw, 132px);
}

/* The basket */

.bespoke-builder__basket {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  border-radius: 20px;
  background: #0d3d39;
  color: var(--white);
  outline: 3px solid transparent;
  outline-offset: 4px;
  transition: outline-color 0.2s ease;
}

.bespoke-builder__basket[hidden] {
  display: none;
}

.bespoke-builder__basket.is-over {
  outline-color: var(--teal);
}

.bespoke-builder__basket-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.bespoke-builder__basket-title {
  margin: 0;
  color: var(--white);
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 28px;
  font-weight: 400;
  line-height: 1.15;
  text-transform: none;
}

.bespoke-builder__count {
  color: var(--teal);
  font-size: 14px;
  font-weight: 600;
}

/* The empty basket: a dashed drop area */

.bespoke-builder__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 16px;
  border: 2px dashed var(--teal);
  border-radius: 14px;
  color: var(--teal-light);
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
}

.bespoke-builder__empty svg {
  color: var(--teal);
}

.bespoke-builder__empty[hidden],
.bespoke-builder__items:empty {
  display: none;
}

/* The services in the plan, each with a tick and "Remove" */

.bespoke-builder__items {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bespoke-builder__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--teal-darker);
  color: var(--white);
  font-size: 15px;
  line-height: 1.4;
}

.bespoke-builder__item-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bespoke-builder__item-name svg {
  flex-shrink: 0;
  color: var(--teal);
}

.bespoke-builder__remove {
  flex-shrink: 0;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--teal-dark);
  border-radius: 999px;
  background: transparent;
  color: var(--teal-light);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.bespoke-builder__remove:hover {
  border-color: var(--teal);
  color: var(--white);
}

/* The team size */

.bespoke-builder__employees {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--teal-light);
  font-size: 14px;
  font-weight: 500;
}

.bespoke-builder__employees select {
  padding: 12px 14px;
  border: 1px solid var(--teal-dark);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.bespoke-builder__note,
.bespoke-builder__noscript {
  margin: 0;
  color: var(--teal-light);
  font-size: 13px;
  line-height: 1.5;
}

.bespoke-builder__noscript a {
  color: var(--white);
}

/* "Book a call about my plan": light teal, dimmed while the plan is empty */

.bespoke-builder__book {
  padding: 15px 20px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: #0d3d39;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.bespoke-builder__book:hover {
  background: var(--teal-light);
}

.bespoke-builder__book:disabled {
  background: var(--teal-dark);
  color: var(--border);
  cursor: not-allowed;
}

/* The booking step: white, in place of the basket */

.bespoke-builder__booking:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  color: var(--text);
}

.bespoke-builder__back {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--teal-darker);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* The booking picker in the narrow column: five days to a row, three times, and the fields one under another */

.bespoke-builder .booking__days {
  --booking-days: 5;

  gap: 6px;
}

.bespoke-builder .booking__day {
  min-height: 54px;
  padding: 8px 2px;
}

.bespoke-builder .booking__times {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.bespoke-builder .booking__fields {
  grid-template-columns: minmax(0, 1fr);
}

.bespoke-builder .booking__confirm {
  width: 100%;
}

/* The plan's services, as chips under the booking step's title */

.booking__plan {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.booking__plan li {
  margin: 0;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--teal-light);
  color: var(--teal-darker);
  font-size: 13px;
}

/* Changes to the basket, said aloud by screen readers but not shown */

.bespoke-builder__announce {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The "Your plan" link: only on tablets and phones, where the basket comes after the services */

.bespoke-builder__jump {
  display: none;
}

/*
 * Tablets and phones: the basket follows the services in the page, so it isn't sticky and doesn't scroll inside
 * itself. A small link to it stays at the foot of the screen while a plan is being built and the basket is out of view.
 */

@media (max-width: 999px) {
  .bespoke-builder__aside {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .bespoke-builder__jump:not([hidden]) {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 900;
    display: inline-flex;
    align-items: center;
    padding: 12px 18px;
    border-radius: 999px;
    background: #0d3d39;
    box-shadow: 0 10px 24px rgba(4, 30, 28, 0.3);
    color: var(--white);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
  }

  .bespoke-builder__jump span {
    margin-left: 0.3em;
    color: var(--teal);
  }
}

@media (max-width: 480px) {
  .bespoke-builder__basket,
  .bespoke-builder__booking:not([hidden]) {
    padding: 22px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bespoke-builder__card,
  .bespoke-builder__basket,
  .bespoke-builder__book {
    transition: none;
  }
}
