/*
 * Build your cell (/cell-builder): the public page for the sales website.
 * Light and plain, Rapid Fusion purple, system font. Laid out for a phone first,
 * and for sitting inside an iframe on another site, so nothing is fixed to the window.
 */

:root {
  --cb-purple: #a74e9e;
  --cb-purple-dark: #8a3d82;
  --cb-purple-pale: #f7eef6;
  --cb-ink: #2b333c;
  --cb-soft: #5b6672;
  --cb-line: #dde2e7;
  --cb-page: #f5f6f8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--cb-page);
  color: var(--cb-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.cb { max-width: 980px; margin: 0 auto; padding: 16px; }

.cb-head h1 { margin: 0 0 4px; font-size: 26px; color: var(--cb-purple); }
.cb-head p { margin: 0 0 12px; color: var(--cb-soft); }

.cb-steps { display: flex; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; font-size: 14px; color: var(--cb-soft); }
.cb-steps li { display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; border-radius: 999px; background: #fff; border: 1px solid var(--cb-line); }
.cb-steps span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--cb-line); color: var(--cb-ink); font-weight: 600; font-size: 12px; }
.cb-steps .is-current { border-color: var(--cb-purple); color: var(--cb-ink); font-weight: 600; }
.cb-steps .is-current span, .cb-steps .is-done span { background: var(--cb-purple); color: #fff; }

.cb-card { background: #fff; border: 1px solid var(--cb-line); border-radius: 12px; padding: 16px; }
.cb-card h2 { margin: 0 0 10px; font-size: 19px; }
.cb-card h2:not(:first-child) { margin-top: 22px; }
.cb-card p { margin: 0 0 12px; }
.cb-loading, .cb-hint, .cb-small { color: var(--cb-soft); }
.cb-hint, .cb-small { font-size: 14px; }

.cb-systems { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.cb-system { position: relative; display: block; padding: 12px 14px; border: 2px solid var(--cb-line); border-radius: 10px; cursor: pointer; }
.cb-system input { position: absolute; opacity: 0; }
.cb-system strong { display: block; font-size: 17px; }
.cb-system span { font-size: 14px; color: var(--cb-soft); }
.cb-system:hover { border-color: #c9a3c5; }
.cb-system.is-chosen { border-color: var(--cb-purple); background: var(--cb-purple-pale); }
.cb-system:focus-within { outline: 3px solid rgba(167, 78, 158, 0.35); outline-offset: 2px; }

.cb-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.cb-option { padding: 12px 14px; border: 1px solid var(--cb-line); border-radius: 10px; font-size: 14px; color: var(--cb-soft); }
.cb-option > label, .cb-option strong { font-size: 16px; font-weight: 600; color: var(--cb-ink); }
.cb-option p { margin: 2px 0 8px; }
.cb-tick { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.cb-tick input, .cb-consent input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--cb-purple); }
.cb-tick.is-off { opacity: 0.55; cursor: default; }

.cb-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--cb-line); border-radius: 8px; overflow: hidden; }
.cb-stepper button { width: 44px; border: 0; background: var(--cb-purple-pale); color: var(--cb-purple-dark); font-size: 22px; cursor: pointer; }
.cb-stepper input { width: 64px; border: 0; text-align: center; font: inherit; font-weight: 600; color: var(--cb-ink); -moz-appearance: textfield; }
.cb-stepper input::-webkit-outer-spin-button, .cb-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.cb-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 16px; }

.cb-btn { min-height: 44px; padding: 8px 16px; border: 1px solid var(--cb-line); border-radius: 8px; background: #fff; color: var(--cb-ink); font: inherit; font-weight: 600; cursor: pointer; }
.cb-btn:hover:not(:disabled) { border-color: var(--cb-purple); color: var(--cb-purple-dark); }
.cb-btn:disabled { opacity: 0.45; cursor: default; }
.cb-btn-primary { background: var(--cb-purple); border-color: var(--cb-purple); color: #fff; }
.cb-btn-primary:hover:not(:disabled) { background: var(--cb-purple-dark); border-color: var(--cb-purple-dark); color: #fff; }
.cb-btn:focus-visible, .cb-stepper button:focus-visible, .cb-form input:focus-visible, .cb-form textarea:focus-visible, .cb-stepper input:focus-visible {
  outline: 3px solid rgba(167, 78, 158, 0.35);
  outline-offset: 1px;
}

.cb-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.cb-btn-toggle[aria-pressed="true"] { border-color: var(--cb-purple); background: var(--cb-purple-pale); color: var(--cb-purple-dark); }
.cb-gap { flex: 1 1 12px; }

.cb-stage-wrap { position: relative; height: clamp(300px, 62vh, 620px); border: 1px solid var(--cb-line); border-radius: 10px; overflow: hidden; background: #e9edf1; }
.cb-stage { position: absolute; inset: 0; }
.cb-stage-message { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; padding: 24px; text-align: center; color: var(--cb-soft); pointer-events: none; }
.cb-selected { position: absolute; left: 10px; bottom: 10px; margin: 0; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.92); border: 1px solid var(--cb-line); font-size: 13px; pointer-events: none; }
.cb-small { margin-top: 8px; }
.cb-small.cb-own-hint { margin: 0 0 10px; }

.cb-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cb-form label { display: block; font-size: 14px; font-weight: 600; }
.cb-form em { font-style: normal; font-weight: 400; color: var(--cb-soft); }
.cb-form input[type="text"], .cb-form input[type="email"], .cb-form input[type="tel"], .cb-form textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid #c5ccd3; border-radius: 8px; font: inherit; font-size: 16px; color: var(--cb-ink); background: #fff;
}
.cb-form textarea { resize: vertical; }
.cb-wide { grid-column: 1 / -1; }
.cb-form .cb-consent { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; font-size: 15px; cursor: pointer; }
.cb-privacy { padding: 12px 14px; border: 1px solid var(--cb-line); border-radius: 8px; background: var(--cb-page); font-size: 14px; }
.cb-privacy h3 { margin: 0 0 6px; font-size: 15px; }
.cb-privacy p { margin: 0 0 6px; }
.cb-privacy p:last-child { margin-bottom: 0; }
.cb-privacy a { color: var(--cb-purple-dark); font-weight: 600; }
/* A field people never see; anything that fills it in is not a person. */
.cb-website { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.cb-done h2 { color: var(--cb-purple); outline: none; }
.cb-done a { color: var(--cb-purple-dark); font-weight: 600; word-break: break-all; }

.cb-error { margin: 12px 0 0; padding: 10px 14px; border-radius: 8px; background: #fdecec; border: 1px solid #f2b8b8; color: #8a1f1f; }

/* The file chooser for "Your own part" is opened by its button. It is kept out of sight rather than
   switched off, because some phone browsers will not open a chooser that is not on the page. */
.cb-file { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; opacity: 0; overflow: hidden; pointer-events: none; }

/* The dialogs: one asks who the visitor is, the first time they want something to keep; one shows the link to a saved cell. */
.cb-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 16px; border: 1px solid var(--cb-line); border-radius: 12px; background: #fff; color: var(--cb-ink); }
.cb-dialog:not([open]) { display: none; }
.cb-dialog::backdrop { background: rgba(43, 51, 60, 0.55); }
.cb-dialog h2 { margin: 0 0 8px; font-size: 19px; }
.cb-dialog p { margin: 0 0 10px; }
.cb-dialog .cb-form > h2, .cb-dialog .cb-form > p { margin: 0; }
.cb-dialog .cb-error { margin: 0; }
.cb-saved-link { color: var(--cb-purple-dark); font-weight: 600; overflow-wrap: anywhere; -webkit-user-select: all; user-select: all; }
.cb-keep { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

/* While the phone buttons are over the bottom of the 3D view, the "Selected" note sits at the top. */
.cb-stage.twin-touch-on ~ .cb-selected { top: 10px; bottom: auto; }

/*
 * Phones. The 3D view runs edge to edge and takes most of the screen's height, the buttons above it
 * sit in a tidy grid, and "Change my choices" and "Next" stay in reach at the bottom of the screen.
 * Touching the 3D view never scrolls the page, so the page is scrolled by the strips above and below it.
 */
@media (max-width: 640px) {
  .cb { padding: 10px 0; overflow-x: clip; }
  .cb-head { padding: 0 12px; }
  .cb-head h1 { font-size: 22px; }
  .cb-head p { font-size: 15px; }
  .cb-steps { flex-wrap: wrap; margin-bottom: 10px; }
  .cb-card { padding: 12px; border-left: 0; border-right: 0; border-radius: 0; }
  .cb-error { margin: 12px 12px 0; }
  .cb-form { grid-template-columns: 1fr; }
  .cb-actions .cb-btn { flex: 1 1 auto; }
  .cb-done a { overflow-wrap: anywhere; }
  .cb-keep .cb-btn { flex: 1 1 100%; }
  .cb-dialog { width: calc(100vw - 16px); padding: 12px; }

  /* iOS zooms the page when a box with small type is tapped: keep every box at 16 px or more. */
  .cb input, .cb select, .cb textarea { font-size: 16px; }

  .cb-toolbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .cb-toolbar .cb-btn { padding: 8px 6px; min-width: 0; }
  .cb-toolbar #cb-own, .cb-toolbar #cb-callouts, .cb-toolbar #cb-drawing, .cb-toolbar #cb-save { grid-column: 1 / -1; }
  .cb-gap { display: none; }

  .cb-stage-wrap {
    height: calc(100vh - 150px);
    height: calc(100dvh - 150px);
    min-height: 320px;
    max-height: none;
    margin: 0 -12px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  /* Step 2's buttons stay at the bottom of the screen. Room is left on the right for Bob's round
     button, which sits in that corner, so he never covers "Next". */
  .cb-actions-sticky {
    position: sticky;
    bottom: 0;
    z-index: 6;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    margin: 12px -12px -12px;
    padding: 10px 84px calc(10px + env(safe-area-inset-bottom, 0px)) 12px;
    background: #fff;
    border-top: 1px solid var(--cb-line);
    box-shadow: 0 -4px 12px rgba(43, 51, 60, 0.08);
  }
  .cb-actions-sticky .cb-btn { min-height: 56px; padding: 6px 8px; font-size: 15px; line-height: 1.2; }

  /* Bob's "can I help" bubble would sit on the 3D view's buttons on a phone. His round button is enough here. */
  body #bob-embed-teaser { display: none !important; }
}

/* Phones: the 3D view comes first, straight under the heading, with the buttons below it.
   Turn and delete live in the bar over the 3D view there, so the toolbar copies are dropped. */
@media (max-width: 640px) {
  #cb-step-2:not([hidden]) { display: flex; flex-direction: column; }
  #cb-step-2 > .cb-stage-wrap { order: 1; }
  #cb-step-2 > .cb-hint { display: none; }
  #cb-step-2 > .cb-toolbar { order: 2; }
  #cb-step-2 > .cb-own-hint { order: 3; }
  #cb-step-2 > .cb-small { order: 4; }
  #cb-step-2 > .cb-actions { order: 5; }
  #cb-step-2 .cb-stage-wrap, #cb-step-2 .cb-stage { height: 58dvh; min-height: 300px; }
  #cb-rotate, #cb-delete { display: none; }
}

/* The toolbar reads in the order people work: add things, then change them. Printing and keeping have steps of their own. */
.cb-group { display: none; }
@media (max-width: 640px) {
  #cb-step-2 > .cb-toolbar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 14px 16px 4px; }
  #cb-step-2 .cb-gap { display: none; }
  #cb-step-2 .cb-group { display: block; grid-column: 1 / -1; margin-top: 8px; font-size: 13px; font-weight: 600; color: #5b6672; }
  #cb-step-2 .cb-group:first-child { margin-top: 0; }
  #cb-own { grid-column: 1 / -1; }
  #cb-callouts { grid-column: span 2; }
  #cb-step-2 > .cb-own-hint, #cb-step-2 > .cb-small { padding: 0 16px; }
  #cb-step-2 > .cb-small { margin-bottom: 84px; }
}

/* Dark, to match rapidfusion.co.uk: near-black purple page, lighter cards, the same purple for actions. */
:root {
  --cb-ink: #f3eef5;
  --cb-soft: #b8adbf;
  --cb-line: #3b2f43;
  --cb-page: #110a15;
  --cb-card: #1b1221;
  --cb-purple-pale: #2b1832;
  color-scheme: dark;
}
.cb-head h1 { color: #d67fcd; }
.cb-card, .cb-steps li, .cb-option, .cb-system, .cb-actions-sticky, .cb dialog, dialog,
.cb-btn:not(.cb-btn-primary), .cb input:not([type=checkbox]):not([type=radio]), .cb textarea, dialog input:not([type=checkbox]), dialog textarea, .cb-stepper button {
  background: var(--cb-card);
  color: var(--cb-ink);
  border-color: var(--cb-line);
}
.cb-btn:not(.cb-btn-primary):hover:not(:disabled) { background: #261a2d; }
.cb-btn:disabled { opacity: 0.45; }
dialog::backdrop { background: rgba(8, 4, 10, 0.72); }
.cb a { color: #e3a0dc; }
.cb-stage-wrap, .cb-stage { background: #140d18; }
.cb-selected { background: rgba(27, 18, 33, 0.92); color: var(--cb-ink); }
.cb-error { background: #3a1418; border-color: #7a2a31; color: #ffc9cd; }
.cb-btn-toggle[aria-pressed="true"], .cb-stepper button { color: #f0b5ea; }
.cb-stepper button { background: var(--cb-purple-pale); }
.cb-form input, .cb-form textarea, .cb-form select, .cb-dialog input:not([type=checkbox]), .cb-dialog textarea { background: #120b16; color: var(--cb-ink); border-color: #4a3b54; }
.cb-dialog, .cb-toolbar { background: var(--cb-card); color: var(--cb-ink); }
.cb-group { color: var(--cb-soft); }
@media (max-width: 640px) {
  .cb-keep, .cb-actions, .cb-sticky { background: var(--cb-card); box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.5); }
}
body .twin-touch-hint { background: rgba(27, 18, 33, 0.82); color: var(--cb-ink); }
/* The move buttons are clear glass over the light floor, so the part being moved shows through. */
body .twin-touch-bar { background: rgba(40, 24, 48, 0.18); border-color: rgba(255, 255, 255, 0.5); }
body .twin-touch-bar button { background: rgba(27, 18, 33, 0.42); border-color: rgba(255, 255, 255, 0.35); color: #fff; }
body .twin-touch-bar button:active:not(:disabled) { background: rgba(27, 18, 33, 0.8); }
body .twin-touch-bar .twin-touch-done { background: rgba(167, 78, 158, 0.88); border-color: transparent; color: #fff; }
body .twin-callout { background: rgba(27, 18, 33, 0.94); color: var(--cb-ink); }
body .twin-callout::after { background: rgba(243, 238, 245, 0.7); }
/* Embedded in another site there is no Bob in the corner, so the sticky buttons can use the full width. */
@media (max-width: 640px) {
  .cb-framed .cb-actions-sticky { padding-right: 12px; }
  .cb-framed #cb-step-2 > .cb-small { margin-bottom: 0; }
}

/* Why a part is not shown printing, with a way to ask us about it. */
.cb-print-note { margin: 10px 0; padding: 12px 14px; border: 1px solid var(--cb-purple); border-radius: 10px; background: var(--cb-purple-pale); }
.cb-print-note p { margin: 0 0 10px; }

/* Step 3, watch it print: the same 3D view, locked, so the part buttons and the "Selected" label are not shown. */
.cb-stage-wrap.is-sim .twin-touch, .cb-stage-wrap.is-sim .cb-selected { display: none !important; }
.cb-sim-end { margin: 12px 0 0; padding: 14px 16px; border: 1px solid var(--cb-purple); border-radius: 10px; background: var(--cb-purple-pale); }
.cb-sim-end h3 { margin: 0 0 6px; font-size: 17px; }
.cb-sim-end p { margin: 0 0 10px; }
.cb-sim-end .cb-actions { margin: 0; }
@media (max-width: 640px) {
  /* The print first, straight under the heading, as in step 2; what to do about it below. */
  #cb-step-3:not([hidden]) { display: flex; flex-direction: column; }
  #cb-step-3 > .cb-hint { display: none; }
  #cb-step-3 > .cb-stage-wrap { order: 1; }
  #cb-step-3 > .cb-print-note { order: 2; }
  #cb-step-3 > .cb-sim-end { order: 3; }
  #cb-step-3 > .cb-sim-bar { order: 4; display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
  #cb-step-3 > .cb-own-hint { order: 5; padding: 0 2px; }
  #cb-step-3 > .cb-actions-sticky { order: 6; }
  #cb-step-3 .cb-stage-wrap, #cb-step-3 .cb-stage { height: 52dvh; min-height: 280px; }

  /* Four steps do not fit on one line with their names: only the current one is named. */
  .cb-steps .cb-step-name { display: none; }
  .cb-steps .is-current .cb-step-name { display: inline; }
  .cb-steps li:not(.is-current) { padding-right: 4px; }
}
.cb-step-name { font-style: normal; }

/* The quick check of the visitor's own part. */
.cb-check-busy { color: var(--cb-soft); }
.cb-check-verdict { font-size: 17px; font-weight: 700; }
.cb-check-verdict[data-overall="good"] { color: #8fe0a6; }
.cb-check-verdict[data-overall="check"] { color: #f2cf73; }
.cb-check-verdict[data-overall="redesign"] { color: #ff9ea7; }
.cb-check-way { margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--cb-purple); border-radius: 8px; background: var(--cb-purple-pale); }
.cb-check-way p { margin: 0 0 8px; }
.cb-check-list { list-style: none; margin: 0 0 10px; padding: 0; }
.cb-check-list li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--cb-line); }
.cb-check-mark { flex: 0 0 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 50%; font-weight: 700; font-size: 13px; }
.cb-check-list li[data-status="pass"] .cb-check-mark { background: #1f4d2c; color: #8fe0a6; }
.cb-check-list li[data-status="warn"] .cb-check-mark { background: #4d3d14; color: #f2cf73; }
.cb-check-list li[data-status="fail"] .cb-check-mark { background: #4d1a20; color: #ff9ea7; }
.cb-check-estimate { color: var(--cb-soft); }
@media (max-width: 640px) {
  /* Stacked on a phone, the main button first, so it is never below the fold. */
  .cb-check .cb-actions { flex-direction: column; }
  .cb-check .cb-actions .cb-btn-primary { order: -1; }
}
.cb-check-advice { padding: 10px 12px; border-left: 3px solid var(--cb-purple); background: var(--cb-purple-pale); border-radius: 4px; }

/* On a reseller's website: their name and logo above ours. */
.cb-partner { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--cb-line); border-radius: 10px; background: var(--cb-card); color: var(--cb-soft); font-size: 14px; }
.cb-partner[hidden] { display: none; }
.cb-partner img { max-height: 36px; max-width: 140px; object-fit: contain; background: #fff; border-radius: 4px; padding: 3px 6px; }
.cb-partner strong { color: var(--cb-ink); }

/* The rail's length, under the rail tick box when it is ticked. */
.cb-rail-length[hidden] { display: none; }
