/* VPT-250 — styles of the example page and its floating call widget.
   The SDK itself ships no CSS (§8.44 D6): this file belongs to the example
   page, and an integrator copies it into their own project.

   Token values are a verbatim copy of the editor palette
   (editor/src/styles.css, ТЗ №113/№115: OKLCH, hue 286.98) — sdk/ must not
   depend on editor/, and the example page has no build step to import
   through. When the brand palette changes, this block is updated by hand.

   Tokens live on the .ht-demo / .ht-widget / .ht-call roots and never on
   :root: loading this file must not repaint the page it is embedded into.
   Every class carries the ht- prefix for the same reason. */
.ht-demo,
.ht-call,
.ht-widget {
  --bg: oklch(0.145 0.004 286.98);
  --bg-panel: oklch(0.205 0.006 286.98);
  --bg-elev: oklch(0.269 0.008 286.98);
  --bg-input: oklch(0.145 0.004 286.98);
  --border: oklch(1 0.004 286.98 / 0.1);
  --border-strong: oklch(1 0.005 286.98 / 0.22);
  --text: oklch(0.985 0 0);
  --text-dim: oklch(0.82 0.008 286.98);
  --accent: oklch(0.82 0.065 286.98);
  --accent-soft: oklch(0.82 0.065 286.98 / 0.14);
  --accent-contrast: oklch(0.21 0.01 286.98);
  --ring: oklch(0.7 0.045 286.98);
  --green: oklch(0.85 0.168 155);
  --green-soft: oklch(0.85 0.168 155 / 0.13);
  --amber: oklch(0.85 0.103 75);
  --amber-soft: oklch(0.85 0.103 75 / 0.15);
  --red: oklch(0.85 0.065 25);
  --shadow-panel: oklch(0.1 0.005 286.98 / 0.62);
  --radius: 14px;
  --radius-sm: 10px;
  --dur-1: 120ms;
  --dur-2: 180ms;
  --dur-3: 260ms;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font-sans:
    'Geist Variable', 'Geist', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  .ht-demo,
  .ht-call,
  .ht-widget {
    --bg: oklch(0.965 0.002 286.98);
    --bg-panel: oklch(1 0 0);
    --bg-elev: oklch(0.97 0.002 286.98);
    --bg-input: oklch(1 0 0);
    --border: oklch(0.92 0.003 286.98);
    --border-strong: oklch(0.85 0.005 286.98);
    --text: oklch(0.145 0.006 286.98);
    --text-dim: oklch(0.5 0.012 286.98);
    --accent: oklch(0.248 0.086 286.98);
    --accent-soft: oklch(0.248 0.086 286.98 / 0.08);
    --accent-contrast: oklch(0.985 0 0);
    --ring: oklch(0.42 0.06 286.98);
    --green: oklch(0.52 0.103 155);
    --green-soft: oklch(0.52 0.103 155 / 0.1);
    --amber: oklch(0.52 0.088 75);
    --amber-soft: oklch(0.52 0.088 75 / 0.12);
    --red: oklch(0.55 0.178 25);
    --shadow-panel: oklch(0.25 0.01 286.98 / 0.22);
    color-scheme: light;
  }
}

/* --- demo backdrop: the host site the widget sits on --------------------- */

.ht-demo {
  margin: 0;
  padding: 48px 16px 140px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.55;
}
.ht-demo * {
  box-sizing: border-box;
}
.ht-page {
  max-width: 42rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ht-demo h1 {
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.01em;
}
.ht-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.ht-card p {
  margin: 0 0 8px;
}
.ht-card p:last-child {
  margin-bottom: 0;
}
.ht-demo code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg-elev);
  border-radius: 6px;
  padding: 1px 5px;
}
/* key warning — the .proposal-warning surface of the editor */
.ht-warn {
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
}
.ht-demo .ht-warn code {
  background: none;
  padding: 0;
}

/* --- the widget ---------------------------------------------------------- */

.ht-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.ht-widget * {
  box-sizing: border-box;
}
/* The UA rule for [hidden] is `display: none` at zero specificity, so any class
   rule that sets display (.ht-panel, .ht-launcher) silently wins and the
   collapsed state renders anyway. Restate it for the whole widget. */
.ht-widget [hidden] {
  display: none;
}
.ht-widget :focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* launcher: the collapsed state */
.ht-launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-left: auto;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  box-shadow: 0 6px 20px var(--accent-soft);
  transition:
    filter var(--dur-1) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}
.ht-launcher:hover {
  filter: brightness(1.08);
}
.ht-launcher:active {
  transform: scale(0.97);
}
/* an active call must stay visible while the panel is collapsed (§4.3) */
.ht-live-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

/* panel: the expanded state */
.ht-panel {
  display: flex;
  flex-direction: column;
  width: 360px;
  /* taller than the log alone would need: the panel also holds the call
     details form, and a squeezed log reads as broken */
  height: min(600px, 100dvh - 32px);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px var(--shadow-panel);
  overflow: hidden;
  animation: ht-rise var(--dur-3) var(--ease-out);
}
@keyframes ht-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.ht-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.ht-title {
  font-weight: 600;
  margin-right: auto;
}

/* agent state pill — the editor's .voice-state */
.ht-pill {
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}
.ht-pill.listening {
  color: var(--green);
  border-color: var(--green);
}
.ht-pill.speaking {
  color: var(--accent);
  border-color: var(--accent);
}
.ht-pill.thinking {
  color: var(--text);
}
.ht-timer {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

/* icon buttons — the base button of the editor */
.ht-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  font: inherit;
  color: inherit;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    border-color var(--dur-1) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}
.ht-icon:hover {
  border-color: var(--accent);
}
.ht-icon:active:not(:disabled) {
  transform: scale(0.97);
}
.ht-icon:disabled {
  opacity: 0.45;
  cursor: default;
}

/* transcript — the editor's .chat with .msg-agent / .msg-user / .msg-system */
.ht-log {
  flex: 1;
  min-height: 96px;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ht-msg {
  max-width: 85%;
  padding: 7px 11px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
}
.ht-msg.agent {
  background: var(--bg-elev);
  align-self: flex-start;
}
.ht-msg.user {
  background: var(--accent-soft);
  align-self: flex-end;
}
.ht-msg.interim {
  opacity: 0.6;
  font-style: italic;
}
.ht-msg.system {
  max-width: 100%;
  align-self: center;
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}
.ht-empty {
  color: var(--text-dim);
  font-size: 12px;
  margin: auto;
}

/* raw SDK state: the page is also a debugging tool for the integration */
.ht-debug {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  padding: 6px 14px;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  max-height: 5.5em;
  overflow-y: auto;
}

/* composer — the editor's .chat-input-row on a .test-input strip */
.ht-composer {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}
.ht-composer input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  transition: border-color var(--dur-1) var(--ease-out);
}
.ht-composer input:focus {
  border-color: var(--accent);
  outline: none;
}
.ht-composer input:disabled {
  opacity: 0.45;
}

/* call controls — the editor's .run-btn and .run-btn.danger */
.ht-actions {
  display: flex;
  gap: 8px;
  padding: 0 10px 12px;
}
.ht-btn {
  flex: 1;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  color: var(--accent-contrast);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  box-shadow: 0 1px 8px var(--accent-soft);
  transition:
    filter var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out);
}
.ht-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}
.ht-btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}
.ht-btn-danger {
  background: var(--red);
  border-color: var(--red);
  box-shadow: none;
}

@media (max-width: 480px) {
  .ht-widget {
    right: 8px;
    left: 8px;
    bottom: 8px;
  }
  .ht-panel {
    width: 100%;
    height: min(560px, 100dvh - 16px);
  }
}

/* --- dynamic-variable form: shared by the widget and the call page ------- */

/* Native <details> instead of a scripted toggle — the browser already owns
   the open state, the keyboard and the semantics. */
.ht-details {
  border-bottom: 1px solid var(--border);
  /* shrinkable, so however many fields are declared the panel still ends
     where it should — the block scrolls instead of pushing the composer out.
     During a call it is hidden altogether and the log takes the room back. */
  flex: 0 1 auto;
  max-height: 58%;
  overflow-y: auto;
}
.ht-details > summary {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none;
}
.ht-details > summary::marker,
.ht-details > summary::-webkit-details-marker {
  display: none;
}
.ht-details > summary::before {
  content: '▸';
  display: inline-block;
  width: 1em;
  transition: transform var(--dur-1) var(--ease-out);
}
.ht-details[open] > summary::before {
  transform: rotate(90deg);
}
.ht-details > summary:hover {
  color: var(--text);
}
.ht-details .ht-fields {
  padding: 0 14px 12px;
}
.ht-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.ht-field {
  display: flex;
  flex: 1 1 100%;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.ht-field.half {
  flex-basis: calc(50% - 5px);
}
.ht-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}
.ht-field input {
  font: inherit;
  width: 100%;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  transition: border-color var(--dur-1) var(--ease-out);
}
.ht-field input:hover:not(:read-only) {
  border-color: var(--ring);
}
.ht-field input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ht-field input:read-only {
  color: var(--text-dim);
  background: var(--bg-elev);
  cursor: default;
}
/* free-form page: a variable is a key/value row the visitor types */
.ht-pair {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.ht-pair input {
  flex: 1 1 0;
}
.ht-pair .ht-icon {
  flex: none;
}
.ht-details .ht-add-var {
  margin: 0 14px 12px;
}

.ht-field-note {
  flex: 1 1 100%;
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* the secondary action next to Call: chat-only, no microphone, no audio */
.ht-btn-ghost {
  color: var(--text);
  background: none;
  border-color: var(--border-strong);
  box-shadow: none;
}
.ht-btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  filter: none;
}

/* --- call page variant: the call is the page, not a corner widget -------- */

.ht-call {
  /* The hero is a brand block, so it does NOT follow the colour scheme: in
     dark mode the pastel --accent would put a glaring light slab down the
     middle of a dark page. Deep indigo in both schemes instead. */
  --hero-bg: oklch(0.248 0.086 286.98);
  --hero-text: oklch(0.985 0 0);
  margin: 0;
  min-height: 100dvh;
  padding: 24px;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
}
.ht-call,
.ht-call * {
  box-sizing: border-box;
}
.ht-call [hidden] {
  display: none;
}
.ht-call :focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.ht-call-shell {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  width: min(1080px, 100%);
  height: min(720px, calc(100dvh - 48px));
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 24px 70px var(--shadow-panel);
  overflow: hidden;
}

/* left column: who the visitor is about to talk to */
.ht-hero {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 36px 34px;
  overflow-y: auto;
  color: var(--hero-text);
  background:
    radial-gradient(120% 90% at 15% 0%, oklch(1 0 0 / 0.18), transparent 60%),
    var(--hero-bg);
}
.ht-hero-top {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* Brand lockup: the HubTalk AI wordmark itself, the same SVG the cabinet
   sidebar draws (editor/src/components/cabinet/brand.tsx, height 24) —
   the lettering is part of the logo, so there is no text to style here. */
.ht-brand,
.ht-call-brand {
  display: flex;
  align-items: center;
}
.ht-logo {
  height: 24px;
  width: auto;
  flex: none;
}
.ht-call-brand {
  color: var(--text);
}
.ht-eyebrow {
  margin: 12px 0 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  opacity: 0.75;
}
.ht-headline {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.ht-blurb {
  margin: 0;
  opacity: 0.82;
}
.ht-agent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: auto 0;
  text-align: center;
}
.ht-avatar {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  overflow: hidden;
  color: var(--hero-text);
  background: oklch(1 0 0 / 0.16);
  box-shadow: 0 0 0 6px oklch(1 0 0 / 0.1);
}
.ht-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* the glyph is the fallback: with a photo set, it has nothing to occupy */
.ht-avatar img:not([hidden]) ~ svg {
  display: none;
}
.ht-agent figcaption {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ht-agent-name {
  font-weight: 700;
}
.ht-agent-status {
  font-size: 13px;
  opacity: 0.75;
}
/* Attribution: the wordmark itself, not the name set in bold — same logo as
   the header, scaled to sit on a 12px line. */
.ht-powered {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.7;
  padding-top: 16px;
  border-top: 1px solid oklch(1 0 0 / 0.18);
}
.ht-powered .ht-logo {
  height: 15px;
}
.ht-powered-sm {
  margin: 0;
  padding: 0;
  border: none;
  color: var(--text-dim);
  justify-content: flex-start;
}
.ht-powered-sm a {
  color: inherit;
}

/* right column: the form before the call, the conversation during it */
.ht-call-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  padding: 32px 34px;
}
.ht-form {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}
.ht-form .ht-fields {
  flex: 1 1 auto;
  align-content: flex-start;
  min-height: 0;
  overflow-y: auto;
}
.ht-form h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.ht-form-hint {
  margin: -10px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}
.ht-form-hint code {
  font-family: var(--mono);
  font-size: 0.92em;
}
.ht-call-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 6px;
}
.ht-call-actions .ht-btn {
  padding: 12px 18px;
}
.ht-live {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ht-live .ht-head {
  background: var(--bg-panel);
}
.ht-live .ht-msg.agent {
  background: var(--bg-panel);
}
.ht-live .ht-call-actions {
  padding: 0 10px 10px;
}

@media (max-width: 860px) {
  .ht-call {
    padding: 0;
  }
  .ht-call-shell {
    grid-template-columns: minmax(0, 1fr);
    border: none;
    border-radius: 0;
    height: auto;
    min-height: 100dvh;
  }
  .ht-hero {
    overflow-y: visible;
  }
  .ht-form,
  .ht-form .ht-fields {
    overflow: visible;
  }
  .ht-live {
    min-height: 60dvh;
  }
  .ht-hero {
    gap: 16px;
    padding: 24px;
  }
  .ht-avatar {
    width: 96px;
    height: 96px;
  }
  .ht-headline {
    font-size: 24px;
  }
  .ht-call-main {
    padding: 24px;
  }
}
