/* Lean Digital, Anna: the voice assistant.
   One quiet button bottom right, and a small white panel that opens from it.
   Uses the site tokens from src/styles.css where they exist, with fallbacks,
   so the file also works on a page that does not load the main stylesheet. */

.pbv, .pbv-focus {
  --pbv-blue: var(--blue, #1740db);
  --pbv-blue-deep: var(--blue-deep, #0e2ba4);
  --pbv-ink: var(--ink, #0a1436);
  --pbv-paper: var(--paper, #f3f5fa);
  --pbv-muted: #4a5676;
  --pbv-line: rgba(10, 20, 54, 0.14);
  --pbv-ease: var(--ease, cubic-bezier(0.22, 1, 0.36, 1));
  --pbv-display: var(--ff-display, "Barlow Condensed", "Arial Narrow", sans-serif);
  --pbv-body: var(--ff-body, "Barlow", system-ui, sans-serif);
  --pbv-mono: var(--ff-mono, "JetBrains Mono", ui-monospace, Menlo, monospace);
  --pbv-edge: 20px;
}

.pbv [hidden] { display: none !important; }
.pbv button { -webkit-tap-highlight-color: transparent; }

/* ---------- the button ---------- */

/* Sits above the page, below the site header and the full-screen mobile menu. */
.pbv-launch {
  position: fixed; z-index: 52; right: var(--pbv-edge);
  bottom: calc(var(--pbv-edge) + var(--pbv-lift, 0px) + env(safe-area-inset-bottom, 0px));
  appearance: none; display: inline-flex; align-items: center; gap: 0.55rem;
  height: 2.75rem; padding: 0 1rem 0 0.8rem; margin: 0; cursor: pointer;
  border: 1px solid var(--pbv-line); border-radius: 8px;
  background: #fff; color: var(--pbv-ink);
  font: 600 0.9375rem/1 var(--pbv-body); white-space: nowrap;
  box-shadow: 0 12px 30px -16px rgba(10, 20, 54, 0.4);
  transition: border-color 0.25s var(--pbv-ease), box-shadow 0.25s var(--pbv-ease), bottom 0.4s var(--pbv-ease);
}
.pbv-launch svg { width: 1.15rem; height: 1.15rem; flex: none; color: var(--pbv-blue); }
.pbv-launch:hover { border-color: var(--pbv-blue); box-shadow: 0 14px 32px -16px rgba(23, 64, 219, 0.5); }
.pbv-slash { opacity: 0; }

/* ---------- the panel ---------- */

.pbv-panel {
  position: fixed; z-index: 52; right: var(--pbv-edge);
  bottom: calc(var(--pbv-edge) + var(--pbv-lift, 0px) + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box; width: min(21.5rem, calc(100vw - 24px)); padding: 1rem 1.1rem 1.1rem;
  border: 1px solid var(--pbv-line); border-radius: 10px;
  background: #fff; color: var(--pbv-ink);
  font: 400 0.9375rem/1.5 var(--pbv-body); text-align: left;
  box-shadow: 0 28px 60px -30px rgba(10, 20, 54, 0.5), 0 2px 8px -4px rgba(10, 20, 54, 0.12);
  animation: pbv-in 0.3s var(--pbv-ease) both;
}
@keyframes pbv-in { from { opacity: 0; transform: translateY(8px); } }
.pbv-panel p { margin: 0; }

.pbv-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; min-height: 2.25rem; }
.pbv-id { display: flex; align-items: baseline; gap: 0.6rem; }
.pbv-id strong { font: 600 1.5rem/1 var(--pbv-display); letter-spacing: 0.01em; }
.pbv-role { font: 500 0.6875rem/1.3 var(--pbv-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--pbv-muted); }

.pbv-icon {
  appearance: none; display: grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; padding: 0; margin: 0;
  border: 1px solid var(--pbv-line); border-radius: 6px; background: #fff; color: var(--pbv-ink); cursor: pointer;
  transition: border-color 0.25s var(--pbv-ease), background-color 0.25s var(--pbv-ease), color 0.25s var(--pbv-ease);
}
.pbv-icon svg { width: 1.1rem; height: 1.1rem; }
.pbv-icon:hover { border-color: var(--pbv-ink); }
.pbv-x { border-color: transparent; color: var(--pbv-muted); }
.pbv-x:hover { border-color: var(--pbv-line); color: var(--pbv-ink); }
.pbv-mic[aria-pressed="true"] { border-color: var(--pbv-blue); color: var(--pbv-blue); background: rgba(23, 64, 219, 0.06); }
.pbv-mic[aria-pressed="true"] .pbv-slash { opacity: 1; }

/* Before the start, and when the key is missing. */
.pbv-intro, .pbv-setup { margin-top: 0.6rem; }
.pbv-lead { color: var(--pbv-ink); text-wrap: pretty; }
.pbv-go {
  appearance: none; display: flex; align-items: center; justify-content: center; width: 100%; height: 2.9rem; margin: 0.9rem 0 0; padding: 0 1rem;
  border: 0; border-radius: 6px; background: var(--pbv-blue); color: #fff; cursor: pointer;
  font: 600 1rem/1 var(--pbv-body);
  transition: background-color 0.25s var(--pbv-ease);
}
.pbv-go:hover { background: var(--pbv-blue-deep); }
.pbv-panel .pbv-note { margin-top: 0.8rem; font-size: 0.8125rem; line-height: 1.45; color: var(--pbv-muted); text-wrap: pretty; }
.pbv-note a { color: var(--pbv-ink); text-decoration: underline; text-underline-offset: 2px; }
.pbv-note a:hover { color: var(--pbv-blue); }

/* While a conversation runs. */
.pbv-session { margin-top: 0.7rem; }
.pbv-row { display: flex; align-items: center; gap: 0.75rem; min-height: 2.25rem; }
.pbv-status {
  flex: 1; min-width: 0;
  font: 500 0.6875rem/1.35 var(--pbv-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--pbv-ink);
}
.pbv[data-phase="asleep"] .pbv-status, .pbv[data-phase="error"] .pbv-status { color: var(--pbv-muted); }
.pbv-ctrl { display: flex; align-items: center; gap: 0.4rem; }

/* The level indicator: five thin bars that follow the voice. */
.pbv-level { display: flex; align-items: center; gap: 3px; flex: none; height: 1.5rem; }
.pbv-level i {
  display: block; width: 3px; height: 100%; border-radius: 1.5px; background: var(--pbv-line);
  transform: scaleY(0.16); transition: transform 0.12s linear, background-color 0.3s var(--pbv-ease);
}
.pbv[data-phase="connecting"] .pbv-level i, .pbv[data-phase="live"] .pbv-level i { background: rgba(23, 64, 219, 0.35); }
.pbv-level[data-voice="out"] i { background: var(--pbv-blue) !important; }
.pbv-level[data-voice="in"] i { background: var(--pbv-ink) !important; }

.pbv-panel .pbv-caption {
  margin-top: 0.7rem; padding-top: 0.7rem; border-top: 1px solid var(--pbv-line);
  font-size: 0.9375rem; line-height: 1.45; color: var(--pbv-ink); text-wrap: pretty; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden;
}
.pbv-panel .pbv-msg { margin-top: 0.5rem; color: var(--pbv-ink); text-wrap: pretty; }

/* Phone and e-mail, where the voice conversation cannot help. */
.pbv-direct { list-style: none; margin: 0.9rem 0 0; padding: 0; border-bottom: 1px solid var(--pbv-line); }
.pbv-direct li { display: flex; align-items: baseline; gap: 1rem; padding: 0.55rem 0; border-top: 1px solid var(--pbv-line); }
.pbv-direct span { min-width: 3.6rem; font: 500 0.6875rem/1.3 var(--pbv-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--pbv-muted); }
.pbv-direct a { font: 600 1.25rem/1.1 var(--pbv-display); color: var(--pbv-ink); text-decoration: none; overflow-wrap: anywhere; }
.pbv-direct a:hover { color: var(--pbv-blue); }

@media (max-width: 520px) {
  .pbv { --pbv-edge: 12px; }
  .pbv-panel { left: var(--pbv-edge); width: auto; }
}

/* ---------- the frame Anna draws around what she shows ---------- */

.pbv-focus {
  position: fixed; z-index: 51; pointer-events: none; box-sizing: border-box; border-radius: 8px;
  border: 1.5px solid var(--pbv-blue);
  background: rgba(23, 64, 219, 0.035);
  opacity: 0; transition: opacity 0.5s var(--pbv-ease);
}
.pbv-focus.is-on { opacity: 1; }
.pbv-focus span {
  position: absolute; left: 14px; top: 0; transform: translateY(-50%); max-width: calc(100% - 28px);
  padding: 0.3rem 0.6rem; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font: 500 0.6875rem/1.3 var(--pbv-mono); letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--pbv-blue); color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .pbv-panel { animation: none; }
  .pbv-launch, .pbv-icon, .pbv-go, .pbv-level i, .pbv-focus { transition: none; }
}

@media print {
  .pbv, .pbv-focus { display: none !important; }
}

/* ---------- staying out of the way of the forms ---------- */

/* On phones the button is a round icon; the name stays for screen readers. */
@media (max-width: 620px) {
  .pbv-launch { width: 3rem; height: 3rem; padding: 0; justify-content: center; border-radius: 50%; }
  .pbv-launch span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .pbv-launch svg { width: 1.3rem; height: 1.3rem; }
}
/* While a text field has focus (html.is-typing, set by src/main.js) the closed
   button steps aside, so it never covers the field or the keyboard area. */
.pbv-launch { transition: border-color 0.25s var(--pbv-ease), box-shadow 0.25s var(--pbv-ease), bottom 0.4s var(--pbv-ease), opacity 0.25s var(--pbv-ease), transform 0.25s var(--pbv-ease), visibility 0s; }
html.is-typing .pbv-launch[aria-expanded="false"] {
  opacity: 0; visibility: hidden; transform: translateY(0.75rem);
  transition: opacity 0.2s var(--pbv-ease), transform 0.2s var(--pbv-ease), visibility 0s 0.2s;
}
/* Room under the last line of the page, and focused fields scroll clear of the button. */
body:has(> .pbv) .foot { padding-bottom: calc(2rem + 4rem + env(safe-area-inset-bottom, 0px)); }
html:has(body > .pbv) { scroll-padding-bottom: 5.5rem; }
