/* Two pieces, both in the site's own language. Uses the custom properties in
   tokens.css and the .btn styles in site.css.

   1. The enquiry: a full-screen take-over. A film still behind, one question
      in large light type, answers as lines to tap, fields as a single ruled line.
   2. The chat: a button in the bottom-right corner and the window it opens. */

html.sba-lock { overflow: hidden; }

.sba-sheet {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--sba-top, 0px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: var(--sba-h, 100dvh);
  overflow: hidden;
  isolation: isolate;
  background: var(--stock);
  color: var(--light);
}
.sba-sheet[hidden] { display: none; }

.sba-bg { position: absolute; inset: 0; z-index: -1; }
.sba-bg img { width: 100%; height: 100%; object-fit: cover; }
.sba-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  /* The questions sit in the middle of the left half, so that side goes dark and the still keeps the right. */
  background:
    linear-gradient(to right, rgba(20, 16, 12, 0.95) 0%, rgba(20, 16, 12, 0.84) 42%, rgba(20, 16, 12, 0.42) 100%),
    linear-gradient(to top, rgba(20, 16, 12, 0.6) 0%, rgba(20, 16, 12, 0) 55%);
}

/* ---------- Top row: the logo stays, with Back and Close ---------- */

.sba-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: calc(var(--pad-y) * 0.75 + env(safe-area-inset-top)) var(--pad) 0;
}
.sba-logo { width: clamp(124px, 11.6vw, 178px); height: auto; }
.sba-top__gap { flex: 1; }
.sba-text {
  min-height: 44px;
  padding: 0.5em 1.1em;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--hair);
  color: var(--light);
  font: inherit;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  cursor: pointer;
}
.sba-text:hover { background: rgba(245, 237, 226, 0.26); }
.sba-text[hidden] { display: none; }

/* ---------- The rail: what this is, what they've said, how far along ---------- */

.sba-rail { padding: clamp(16px, 3vh, 34px) var(--pad) 0; }
.sba-rail__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 24px;
  font-size: 0.9375rem;
  line-height: 1.4;
}
.sba-rail__title { color: var(--light); }
.sba-sofar { color: var(--dim); }
.sba-sofar:empty { display: none; }

/* The same segmented line as the reel: one segment for each screen. */
.sba-bar { display: flex; gap: 5px; width: 100%; margin-top: 12px; }
.sba-bar i { flex: 1; height: 2px; background: var(--hair); transition: background-color 0.3s linear; }
.sba-bar i.is-on { background: var(--light); }

/* ---------- The stage: one question at a time, in the middle of the screen ---------- */

.sba-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(20px, 4vh, 48px) var(--pad) calc(clamp(28px, 9vh, 110px) + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* Auto margins centre the panel when there is room, and let it start at the
   top and scroll when there is not. */
.sba-panel {
  width: min(100%, 46rem);
  margin-block: auto;
  animation: sba-step-on 0.36s var(--ease) both;
}
.sba-panel[data-dir="back"] { animation-name: sba-step-back; }
@keyframes sba-step-on {
  from { opacity: 0; transform: translateY(26px); }
}
@keyframes sba-step-back {
  from { opacity: 0; transform: translateY(-26px); }
}

.sba-where { margin-bottom: clamp(8px, 1.5vh, 16px); color: var(--gold); font-size: 1.0625rem; line-height: 1.4; }
.sba-where:empty { display: none; }
.sba-q {
  max-width: 16em;
  font-size: var(--t-title);
  font-weight: var(--w-light);
  line-height: 1.04;
  letter-spacing: -0.028em;
  text-wrap: balance;
  outline: none;
}
.sba-sheet.is-form .sba-q { font-size: clamp(1.75rem, min(3.3vw, 7vh), 3rem); }
.sba-help {
  max-width: 32em;
  margin-top: clamp(10px, 1.6vh, 18px);
  color: var(--dim);
  font-size: var(--t-lead);
  line-height: 1.42;
  text-wrap: pretty;
}
.sba-help:empty { display: none; }
.sba-body { width: 100%; margin-top: clamp(20px, 3.6vh, 40px); }
.sba-body:empty { display: none; }

/* Answers: full buttons, one under another. They fill on hover and on press. */
.sba-opts { display: grid; gap: 10px; width: min(100%, 30rem); }
.sba-opt {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 62px;
  padding: 0.6em 1.6em;
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(245, 237, 226, 0.13);
  box-shadow: inset 0 0 0 1px rgba(245, 237, 226, 0.22);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--light);
  font: inherit;
  font-size: clamp(1.125rem, 1.5vw, 1.3125rem);
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.18s linear, color 0.18s linear, transform 0.2s var(--ease);
}
@media (hover: hover) {
  .sba-opt:hover { background: var(--light); box-shadow: none; color: var(--stock); }
}
.sba-opt:active { transform: scale(0.985); }
.sba-opt.is-picked { background: var(--light); box-shadow: none; color: var(--stock); }

/* The one button that moves things on is the same size as an answer. */
.sba-go,
.sba-form .btn { min-height: 58px; padding: 0 2em; font-size: 1.0625rem; }

/* ---------- Fields: a label over a filled field ---------- */

.sba-form { display: grid; gap: clamp(10px, 1.8vh, 18px); width: min(100%, 30rem); }
.sba-form .btn { justify-self: start; margin-top: 6px; }
.sba-f { min-width: 0; }
.sba-f__label { display: block; margin-bottom: 7px; color: var(--dim); font-size: 0.9375rem; }
.sba-f__input {
  display: block;
  width: 100%;
  padding: 0.78em 1.05em;
  border: 0;
  border-radius: var(--r-field);
  background: rgba(245, 237, 226, 0.11);
  box-shadow: inset 0 0 0 1px rgba(245, 237, 226, 0.22);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--light);
  font: inherit;
  font-size: 1.125rem;
  line-height: 1.3;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.sba-f__input:focus { box-shadow: inset 0 0 0 2px var(--gold); }
.sba-f__input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px #ff9a88; }
/* A browser's saved details keep the field's own colours. */
.sba-f__input:-webkit-autofill {
  -webkit-text-fill-color: var(--light);
  caret-color: var(--light);
  box-shadow: inset 0 0 0 1px rgba(245, 237, 226, 0.22), inset 0 0 0 100px #2b241c;
}
textarea.sba-f__input { min-height: 4.4em; resize: none; }
.sba-f__err { margin-top: 6px; color: #ff9a88; font-size: 0.875rem; }
.sba-f__err:empty { display: none; }
.sba-row { display: grid; grid-template-columns: minmax(0, 1fr) 6.5rem; gap: 14px; }

.sba-check { display: flex; align-items: flex-start; gap: 12px; color: var(--dim); cursor: pointer; }
.sba-check input {
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 7px;
  background: rgba(245, 237, 226, 0.11);
  box-shadow: inset 0 0 0 1px rgba(245, 237, 226, 0.34);
  cursor: pointer;
}
.sba-check input:checked {
  background: var(--gold) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314100c' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'><path d='M6 12.5l4 4 8-9'/></svg>") center / 18px no-repeat;
  box-shadow: none;
}
.sba-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.sba-status { max-width: 34em; color: var(--light); }

/* ---------- The question field in the page's last frame ---------- */

.sba-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 34rem);
  border-bottom: 1px solid var(--faint);
}
.sba-inline:focus-within { border-bottom-color: var(--gold); box-shadow: 0 1px 0 var(--gold); }
.sba-inline__input {
  flex: 1;
  min-width: 0;
  padding: 0.6em 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--light);
  font: inherit;
  font-size: var(--t-lead);
  outline: none;
}
.sba-inline__input::placeholder { color: var(--dim); }
.sba-ask__send {
  min-height: 44px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--light);
  font: inherit;
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
  cursor: pointer;
}

.sba-ideas { display: flex; flex-wrap: wrap; gap: 0 22px; margin-top: 10px; }
.sba-idea {
  min-height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--dim);
  font: inherit;
  font-size: 0.9375rem;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
  cursor: pointer;
}
.sba-idea:hover { color: var(--light); text-decoration-color: var(--gold); }

/* ---------- The chat button: bottom right, on every frame ---------- */

.sba-fab {
  --fab: 56px;
  position: fixed;
  right: calc(var(--pad) + env(safe-area-inset-right));
  bottom: calc(var(--pad-y) + env(safe-area-inset-bottom));
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  height: var(--fab);
  min-width: var(--fab);
  padding: 0 calc((var(--fab) - 24px) / 2);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--light);
  color: var(--stock);
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.2s var(--ease), background-color 0.2s linear;
}
.sba-fab:hover { background: #fff; }
.sba-fab:active { transform: scale(0.96); }
.sba-fab__icon { display: grid; place-items: center; flex: none; width: 24px; height: 24px; }
.sba-fab__icon--shut { display: none; }
.sba-fab__label {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: max-width 0.4s var(--ease), margin 0.4s var(--ease), opacity 0.2s linear;
}
/* On the first frame the button says what it is; after that it tucks down to the mark. */
.sba-fab.is-wide .sba-fab__label { max-width: 9em; margin: 0 6px 0 10px; opacity: 1; }
html.sba-chat-open .sba-fab__icon--chat { display: none; }
html.sba-chat-open .sba-fab__icon--shut { display: grid; }
html.sba-chat-open .sba-fab .sba-fab__label,
html.sba-lock .sba-fab .sba-fab__label { max-width: 0; margin: 0; opacity: 0; }
html.film-open .sba-fab,
html.film-open .sba-chat,
html.film-open .sba-chat-scrim { display: none; }

/* ---------- The chat window ---------- */

.sba-chat {
  position: fixed;
  right: calc(var(--pad) + env(safe-area-inset-right));
  bottom: calc(var(--pad-y) + env(safe-area-inset-bottom) + 70px);
  z-index: 1101;
  display: flex;
  flex-direction: column;
  width: min(404px, calc(100vw - 2 * var(--pad)));
  height: min(560px, calc(100vh - 2 * var(--pad-y) - 146px));
  height: min(560px, calc(100dvh - 2 * var(--pad-y) - 146px));
  overflow: hidden;
  border-radius: 22px;
  background: rgba(30, 24, 18, 0.9);
  color: var(--light);
  -webkit-backdrop-filter: blur(26px) saturate(1.25);
  backdrop-filter: blur(26px) saturate(1.25);
  box-shadow: 0 0 0 1px var(--hair), 0 30px 80px rgba(0, 0, 0, 0.62);
  transform-origin: 100% 100%;
  animation: sba-chat-in 0.28s var(--ease);
}
.sba-chat[hidden] { display: none; }
@keyframes sba-chat-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
}
@keyframes sba-chat-up {
  from { transform: translateY(100%); }
}

.sba-chat__top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 12px 14px 20px;
}
.sba-chat__logo { flex: none; width: 60px; height: auto; }
.sba-chat__who { flex: 1; min-width: 0; }
.sba-chat__title { font-size: 1.0625rem; line-height: 1.2; }
.sba-chat__sub { margin-top: 3px; color: var(--faint); font-size: 0.8125rem; line-height: 1.2; }
.sba-chat__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--dim);
  cursor: pointer;
}
.sba-chat__close:hover { background: var(--hair); color: var(--light); }
.sba-chat__x { display: grid; place-items: center; }

/* The conversation. Their words sit on the right, ours on the left. */
.sba-thread {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 18px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--hair) transparent;
  outline: none;
  /* Older messages fade out under the header instead of being cut off. */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 22px);
}
.sba-thread > :first-child { margin-top: auto; } /* a short conversation rests at the bottom */

.sba-msg {
  max-width: 86%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 0.9688rem;
  line-height: 1.45;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  animation: sba-msg-in 0.26s var(--ease);
}
.sba-msg--us { align-self: flex-start; border-bottom-left-radius: 6px; background: var(--hair); }
.sba-msg--you { align-self: flex-end; border-bottom-right-radius: 6px; background: var(--light); color: var(--stock); }
.sba-msg__actions { margin: 12px 0 3px; }
@keyframes sba-msg-in {
  from { opacity: 0; transform: translateY(8px); }
}

.sba-msg.is-typing { display: inline-flex; align-items: center; gap: 5px; padding: 16px; }
.sba-msg.is-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--light);
  animation: sba-dot 1.1s ease-in-out infinite;
}
.sba-msg.is-typing i:nth-child(2) { animation-delay: 0.15s; }
.sba-msg.is-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes sba-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Things to ask: outlines of the bubbles they would become. */
.sba-chips { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin-top: 6px; }
.sba-chip {
  min-height: 42px;
  padding: 0.55em 1.05em;
  border: 0;
  border-radius: 18px;
  border-bottom-right-radius: 6px;
  background: none;
  box-shadow: inset 0 0 0 1px var(--faint);
  color: var(--light);
  font: inherit;
  font-size: 0.9375rem;
  text-align: left;
  cursor: pointer;
}
.sba-chip:hover { box-shadow: inset 0 0 0 1px var(--gold); }

.sba-chat__form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 12px;
  padding: 5px 5px 5px 20px;
  border-radius: var(--r-pill);
  background: var(--hair);
}
.sba-chat__form:focus-within { box-shadow: 0 0 0 1px var(--gold); }
.sba-chat__input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--light);
  font: inherit;
  font-size: 1rem; /* 16px keeps phones from zooming in on the field */
  outline: none;
}
.sba-chat__input::placeholder { color: var(--faint); }
.sba-chat__send {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--light);
  color: var(--stock);
  cursor: pointer;
}
.sba-chat__send:hover { background: #fff; }
.sba-chat__send:disabled { opacity: 0.4; cursor: default; }
.sba-chat__arrow { display: grid; place-items: center; }

.sba-chat-scrim { display: none; }

/* ---------- Phones: the chat rises from the bottom as a sheet ---------- */

@media (max-width: 720px) {
  .sba-fab { --fab: 52px; }
  .sba-fab.is-wide .sba-fab__label { max-width: 0; margin: 0; opacity: 0; }
  html.sba-chat-open .sba-fab,
  html.sba-on-form .sba-fab { display: none; }

  .sba-chat-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(10, 8, 6, 0.62);
  }
  .sba-chat-scrim[hidden] { display: none; }

  .sba-chat {
    left: 0;
    right: 0;
    bottom: var(--sba-kb, 0px);
    width: auto;
    height: 82vh;
    height: min(82dvh, calc(var(--sba-vvh, 100dvh) - 10px));
    padding-bottom: env(safe-area-inset-bottom);
    border-radius: 22px 22px 0 0;
    background: rgba(30, 24, 18, 0.96);
    transform-origin: 50% 100%;
    animation: sba-chat-up 0.34s var(--ease);
  }
  .sba-chat__top { padding-top: 14px; }
  .sba-msg { font-size: 1rem; }

  /* The enquiry on a phone: the still sits behind everything, so it goes darker all over. */
  .sba-bg::after { background: rgba(20, 16, 12, 0.84); }
  .sba-sofar { flex-basis: 100%; }
  .sba-opts,
  .sba-form { width: 100%; }
  /* Room at the foot for the chat button, so it never sits on the last answer. */
  .sba-stage { padding-bottom: calc(var(--pad-y) + 68px + env(safe-area-inset-bottom)); }
  .sba-sheet.is-form .sba-stage { padding-bottom: calc(var(--pad-y) + env(safe-area-inset-bottom)); }
}

/* Screens with fields start from the top on a phone or a short screen, so the keyboard never hides them. */
@media (max-width: 720px), (max-height: 640px) {
  .sba-sheet.is-form .sba-stage { padding-top: clamp(14px, 3vh, 28px); }
  .sba-sheet.is-form .sba-panel { margin-block: 0 auto; }
}

@media (max-width: 380px) {
  .sba-logo { width: 108px; }
}
@media (prefers-reduced-motion: reduce) {
  .sba-sheet * { scroll-behavior: auto; }
  .sba-chat,
  .sba-panel,
  .sba-msg,
  .sba-msg.is-typing i { animation: none; }
  .sba-fab,
  .sba-fab__label { transition: none; }
}
