/*
 * The build-your-own pages, such as Build Your Cam Kit.
 *
 * The tune configurator's palette and type: Sora for headings and prices,
 * Inter for everything else, on a near-black ground with gunmetal cards. The
 * colors are declared on the builder's own root rather than on :root, so the
 * configurator's variables and the theme's are left alone, and text color is
 * set here because the theme's body color is a mid grey.
 *
 * Written for a phone first. The total and the Add to cart button stay at the
 * bottom of the screen while the customer scrolls through the components.
 */
.ua-builder {
  --ground: #0B0D10;
  --surface: #15181D;
  --surface-2: #0F1216;
  --rule: #262A31;
  --rule-strong: #333944;
  --ink: #F5F5F3;
  --ink-2: #C7CBD1;
  --muted: #9299A3;
  --accent: #E33B4F;
  --accent-bright: #E5485D;
  --alert: #F05264;
  --alert-bg: #23151A;
  --warn-ink: #E0A64A;
  --warn-bg: #241D12;
  --font-head: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  max-width: 880px;
  margin: 0 auto;
  padding: 16px 12px 120px;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

.ua-builder *,
.ua-builder *::before,
.ua-builder *::after {
  box-sizing: border-box;
}

.ua-builder a {
  color: var(--accent-bright);
}

.ua-builder__eyebrow {
  margin: 0 0 4px;
  color: var(--accent-bright);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ua-builder__description {
  color: var(--ink-2);
}

.ua-builder__step {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
}

.ua-builder__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 600;
}

.ua-builder__required,
.ua-builder__optional {
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
}

.ua-builder__required {
  background: var(--alert-bg);
  color: var(--alert);
}

.ua-builder__optional {
  background: var(--surface-2);
  color: var(--muted);
}

.ua-builder__vehicle {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.ua-builder__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.ua-builder select,
.ua-builder input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}

/*
 * The theme styles every read-only field through !important rules that read
 * these variables: a light gray background and border, faded text, and
 * reduced opacity. That leaves the link to the build, which is read-only,
 * as pale text on pale gray. Setting the variables on the link gives it the
 * builder's own field colors.
 */
.ua-builder input[data-ua-link] {
  --mt-form-disabled-background-color: var(--surface-2);
  --mt-form-disabled-border-color: var(--rule-strong);
  --mt-form-disabled-color: var(--ink);
  --mt-form-disabled-opacity: 1;
}

.ua-builder select:disabled {
  opacity: 0.5;
}

.ua-builder__options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ua-builder__option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface-2);
}

.ua-builder__option:has(input:checked) {
  border-color: var(--accent);
}

.ua-builder__choice {
  display: flex;
  flex: 1 1 100%;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.ua-builder__choice input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.ua-builder__title {
  flex: 1;
}

/*
 * An amount such as $1,500.00 has no spaces, so it stays on one line. Wording
 * such as "Contact the shop for a price" wraps within half the row instead of
 * extending past the edge of a phone screen.
 */
.ua-builder__price {
  flex: 0 1 auto;
  max-width: 50%;
  font-family: var(--font-head);
  font-weight: 600;
  text-align: right;
}

.ua-builder__details {
  margin-left: 32px;
  font-size: 14px;
}

.ua-builder__part-options {
  display: grid;
  flex: 1 1 100%;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 8px 0 0 32px;
}

.ua-builder__part-options[hidden],
.ua-builder__field[hidden] {
  display: none;
}

.ua-builder__hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.ua-builder__notice {
  margin: 0 0 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.ua-builder__status {
  margin: 12px 0;
  color: var(--ink-2);
}

.ua-builder__share {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ua-builder__button {
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #FFFFFF;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.ua-builder__button:hover:not(:disabled) {
  background: var(--accent-bright);
}

.ua-builder__button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ua-builder__button--quiet {
  border: 1px solid var(--rule-strong);
  background: var(--surface-2);
  color: var(--ink);
}

.ua-builder__button--quiet:hover:not(:disabled) {
  background: var(--surface);
}

/* The total and the button, held at the bottom of the screen. */
.ua-builder__bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  transition: bottom 0.3s;
}

.ua-builder__bar[hidden] {
  display: none;
}

.ua-builder__total {
  display: flex;
  flex-direction: column;
}

.ua-builder__total-label {
  color: var(--muted);
  font-size: 13px;
}

.ua-builder__total-amount {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
}

.ua-builder__errors {
  flex: 1 1 100%;
  max-height: 40vh;
  overflow-y: auto;
}

.ua-builder__errors p {
  margin: 0 0 4px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--alert-bg);
  color: var(--alert);
  font-size: 14px;
}

.ua-builder__errors:empty {
  display: none;
}

/*
 * On a phone the theme floats its search and menu bar, 50 pixels high, along
 * the bottom of the screen once the page is scrolled. The total sits above it
 * rather than under it, where the Add to cart button could not be tapped.
 */
@media (max-width: 767px) {
  .ua-builder {
    padding-bottom: 180px;
  }

  body:has(.mt-mobile-menu-widget.show) .ua-builder__bar {
    bottom: 50px;
  }
}

/*
 * The theme's back to top button floats over the bottom right corner, where
 * the Add to cart button is. It is hidden while the total is shown.
 */
body:has(.ua-builder__bar:not([hidden])) .to-top {
  display: none;
}

@media (min-width: 640px) {
  .ua-builder {
    padding: 24px 16px 120px;
  }

  .ua-builder__vehicle {
    grid-template-columns: repeat(2, 1fr);
  }

  .ua-builder__choice {
    flex: 1;
  }

  .ua-builder__details {
    margin-left: 0;
  }

  .ua-builder__part-options {
    grid-template-columns: repeat(2, 1fr);
  }

  .ua-builder__share {
    flex-direction: row;
  }

  .ua-builder__share .ua-builder__button {
    flex: none;
  }
}

@media (min-width: 960px) {
  .ua-builder__vehicle {
    grid-template-columns: repeat(4, 1fr);
  }

  .ua-builder__bar {
    right: max(16px, calc((100vw - 880px) / 2));
    bottom: 16px;
    left: max(16px, calc((100vw - 880px) / 2));
    border: 1px solid var(--rule-strong);
    border-radius: 12px;
  }
}
