/* The client page: a listing-style business card, a conversion column, and the AI front desk.
   Brand colors come from the business profile via --accent / --accent-dark / --accent-2 on <html>. */

:root {
  --bg: #f3f3f1;
  --surface: #ffffff;
  --surface-2: #f6f6f4;
  --ink: #1c1b1f;
  --ink-2: #4d4b55;
  --ink-3: #807e88;
  --line: #e4e3df;
  --brand: var(--accent, #5b2bd6);
  --brand-soft: color-mix(in srgb, var(--brand) 10%, var(--surface));
  --open: #188038;
  --closed: #b06000;
  --danger: #c5221f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.9, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --surface: #1b1b1f;
    --surface-2: #232328;
    --ink: #ececf0;
    --ink-2: #b4b3bb;
    --ink-3: #84838c;
    --line: #2d2d33;
    --brand: var(--accent-dark, #a17dff);
    --open: #4cc38a;
    --closed: #f2a65a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
h1, h2, h3 { margin: 0; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.15s var(--ease);
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-tonal { background: var(--brand-soft); color: var(--brand); }
.btn-lg { padding: 14px 22px; border-radius: 12px; font-size: 1.02rem; }

/* ---------- the AI's face: voice bars on the brand color ---------- */

.voice {
  --level: 0;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 2.5px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand);
  transition: box-shadow 0.2s;
}
.voice i {
  width: 3px;
  height: 30%;
  border-radius: 2px;
  background: #fff;
  transform: scaleY(calc(1 + var(--level) * 1.6));
  animation: idle 1.6s ease-in-out infinite;
}
.voice i:nth-child(2) { animation-delay: 0.2s; }
.voice i:nth-child(3) { animation-delay: 0.4s; }
.voice i:nth-child(4) { animation-delay: 0.6s; }
.voice.small { width: 28px; height: 28px; gap: 2px; }
.voice.small i { width: 2.5px; }
.voice[data-mode="speaking"] i { animation-duration: 0.55s; }
.voice[data-mode="listening"] { box-shadow: 0 0 0 3px color-mix(in srgb, var(--open) 45%, transparent); }
.voice[data-mode="thinking"] i { animation-duration: 0.8s; }

/* ---------- top bar (wide screens) ---------- */

.topbar { display: none; }

/* ---------- page: one card on phones ---------- */

.page {
  max-width: 540px;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--surface);
}
/* Map-style grey bands between sections */
.page > section + section, .page > .foot { border-top: 8px solid var(--bg); }

.card { padding: 20px 16px 6px; }
.card-head { display: flex; align-items: center; gap: 14px; }
.tile {
  width: 64px;
  height: 64px;
  flex: none;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  object-fit: contain;
}
h1 { font-size: 1.55rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
.category { margin: 2px 0 0; color: var(--ink-2); font-size: 0.97rem; }

.status { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-weight: 500; font-size: 0.95rem; }
.dot { position: relative; width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--open); }
.dot::after { content: ""; position: absolute; inset: -4px; border: 2px solid var(--open); border-radius: 50%; opacity: 0; animation: ping 2.4s ease-out infinite; }
.status .status-text, .live .status-text { color: var(--open); }
.closed .dot { background: var(--closed); }
.closed .dot::after { display: none; }
.closed .status-text { color: var(--closed); }
.nudge { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); font-size: 0.92rem; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 18px 0 8px; }
.action {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}
.action .ico {
  box-sizing: content-box;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--brand);
  transition: transform 0.15s var(--ease);
}
.action:active .ico { transform: scale(0.94); }
.action.primary .ico { border-color: var(--brand); background: var(--brand); color: #fff; }
.action.tonal .ico { border-color: transparent; background: var(--brand-soft); }
.action.revealed span { color: var(--brand); }

.rows { margin: 8px 0 0; padding: 0; list-style: none; }
.rows li { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 0.95rem; }
.rows .ico { color: var(--brand); }
.rows a { text-decoration: none; }
.rows a:hover { text-decoration: underline; }
.row-ai .voice { justify-self: center; }
.row-ai button { padding: 6px 14px; border: 0; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 0.85rem; }

.hero { display: none; }

.block { padding: 18px 16px; }
.label { margin-bottom: 12px; font-size: 1.05rem; font-weight: 700; }

.highlights { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.highlights li { display: grid; grid-template-columns: 40px 1fr; align-items: start; gap: 12px; }
.highlights .ico { box-sizing: content-box; padding: 10px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); }
.highlights b { display: block; font-weight: 600; }
.highlights span { color: var(--ink-3); font-size: 0.9rem; }

.offer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.offer {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  transition: border-color 0.15s;
}
.offer:hover { border-color: var(--brand); }
.offer-name { color: var(--ink-2); font-size: 0.85rem; font-weight: 600; }
.offer-price { font-size: 1.6rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
.offer-price small { color: var(--ink-3); font-size: 0.85rem; font-weight: 500; }
.offer-detail { color: var(--ink-3); font-size: 0.82rem; line-height: 1.35; }
.note { margin: 10px 0 0; color: var(--ink-3); font-size: 0.85rem; }

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.cta .ico { width: 18px; height: 18px; }

.faq details { border-top: 1px solid var(--line); }
.faq details:first-of-type { border-top: 0; }
.faq summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; font-weight: 500; font-size: 0.95rem; list-style: none; cursor: pointer; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary .ico { width: 18px; height: 18px; color: var(--ink-3); transition: transform 0.2s var(--ease); }
.faq details[open] summary .ico { transform: rotate(180deg); }
.faq details p { margin: -4px 0 12px; color: var(--ink-2); font-size: 0.92rem; }

.foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; padding: 18px 16px; color: var(--ink-3); font-size: 0.82rem; }
.foot a { text-decoration: none; }

/* Call, ask and talk stay one thumb away on phones */
.dock {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(540px, 100%);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
  transform: translateX(-50%);
}
.dock-call, .dock-mic { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border: 0; border-radius: 50%; text-decoration: none; }
.dock-call { background: var(--brand); color: #fff; }
.dock-mic { background: var(--brand-soft); color: var(--brand); }
.dock-ask {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 48px;
  padding: 0 14px 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-3);
  text-align: left;
}
.dock-ask span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- the AI: a sheet over the card on phones ---------- */

.sheet {
  position: fixed;
  inset: max(8px, env(safe-area-inset-top)) 0 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  max-width: 540px;
  margin: 0 auto;
  border-radius: 16px 16px 0 0;
  background: var(--surface);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.25);
  visibility: hidden;
  transform: translateY(102%);
  transition: transform 0.4s var(--ease), visibility 0s linear 0.4s;
  touch-action: pan-y;
}
.sheet.open { visibility: visible; transform: none; transition: transform 0.4s var(--ease); }
.sheet.dragging { transition: none; }
body.sheet-open { overflow: hidden; }
body.sheet-open::after { content: ""; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.4); animation: fade 0.25s both; }

.sheet-head { position: relative; display: flex; align-items: center; gap: 12px; padding: 18px 12px 12px 16px; border-bottom: 1px solid var(--line); cursor: grab; }
.grip { position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: var(--line); }
.sheet-who { flex: 1; min-width: 0; }
.sheet-who b { display: block; line-height: 1.2; }
.sheet-who small { display: block; overflow: hidden; color: var(--ink-3); font-size: 0.82rem; white-space: nowrap; text-overflow: ellipsis; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-2);
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.thread { display: flex; flex: 1; flex-direction: column; gap: 10px; padding: 16px; overflow-y: auto; overscroll-behavior: contain; }
.msg { max-width: 86%; margin: 0; padding: 10px 14px; line-height: 1.5; overflow-wrap: anywhere; animation: rise 0.3s var(--ease) both; }
.msg.agent { align-self: flex-start; border-radius: 16px 16px 16px 4px; background: var(--surface-2); }
.msg.agent a { color: var(--brand); }
.msg.user { align-self: flex-end; border-radius: 16px 16px 4px 16px; background: var(--brand); color: #fff; }
.msg.user.file { padding: 4px; background: var(--surface-2); }
.msg.user.file img { display: block; max-width: 220px; max-height: 240px; border-radius: 12px; }
.note-line { align-self: center; margin: 0; color: var(--ink-3); font-size: 0.82rem; }

.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick button { padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--brand); font-size: 0.9rem; font-weight: 500; }
.quick button:hover { border-color: var(--brand); }

.typing { display: flex; align-self: flex-start; gap: 5px; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

/* panels the agent puts into the conversation */
.panel { align-self: stretch; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); animation: rise 0.35s var(--ease) both; }
.panel p { margin: 0; }
.kicker { margin: 0 0 10px !important; color: var(--ink-2); font-size: 0.85rem; font-weight: 700; }
.panel .steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: s; }
.panel .steps li { display: grid; grid-template-columns: 28px 1fr; column-gap: 10px; counter-increment: s; }
.panel .steps li::before { content: counter(s); grid-row: span 2; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 0.85rem; }
.panel .steps b { font-weight: 600; }
.panel .steps span { color: var(--ink-2); font-size: 0.9rem; }
.panel .phone { display: inline-block; margin: 0 0 4px; font-size: 1.8rem; font-weight: 700; text-decoration: none; }
.panel .muted { color: var(--ink-2); font-size: 0.92rem; }
.panel .btn { margin-top: 12px; }

.setup { display: grid; gap: 10px; }
.setup label { display: grid; gap: 4px; color: var(--ink-3); font-size: 0.8rem; }
.setup input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); font: inherit; font-size: 16px; }
.setup input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.progress { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.progress li { display: flex; align-items: center; gap: 10px; color: var(--ink-3); }
.progress li::before { content: ""; width: 15px; height: 15px; border: 2px solid var(--line); border-radius: 50%; }
.progress li.active { color: var(--ink); }
.progress li.active::before { border-color: var(--brand); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.progress li.done { color: var(--ink); }
.progress li.done::before { border-color: var(--open); background: var(--open); box-shadow: inset 0 0 0 3px var(--surface); }
.ready h3 { margin: 0 0 6px; font-size: 1.3rem; font-weight: 700; line-height: 1.25; }

.composer { padding: 10px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); }
.bar:focus-within { border-color: var(--brand); }
.bar input { flex: 1; min-width: 0; padding: 10px 6px; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 16px; }
.bar input::placeholder { color: var(--ink-3); }
.bar .send, .bar .mic { background: var(--brand); color: #fff; }
.bar .send { display: none; }
.bar.has-text .send { display: grid; }
.bar.has-text:not(.live) .mic { display: none; }
.bar .mic .stop { display: none; }
.bar.live .mic { position: relative; background: var(--danger); }
.bar.live .mic .ico:not(.stop) { display: none; }
.bar.live .mic .stop { display: block; fill: currentColor; stroke: none; }
.bar.live .mic::after { content: ""; position: absolute; inset: -3px; border: 2px solid var(--danger); border-radius: 50%; animation: ping 1.6s ease-out infinite; }
.fine { margin: 6px 4px 0; color: var(--ink-3); font-size: 0.7rem; text-align: center; }

.toast {
  position: fixed;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 60;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.9rem;
  transform: translateX(-50%);
  animation: rise 0.25s var(--ease) both;
}

/* ---------- tablets: the phone card, framed ---------- */

@media (min-width: 560px) and (max-width: 767px) {
  .page { margin: 16px auto; min-height: auto; overflow: clip; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
}

/* ---------- wide screens: a landing page built from the listing ---------- */

@media (min-width: 768px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 max(32px, calc((100vw - 1160px) / 2 + 32px));
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  .topbar-logo img { display: block; width: auto; height: 26px; }
  .topbar-right { display: flex; align-items: center; gap: 18px; }
  .live { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 500; }

  .page {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 20px 32px;
    align-items: start;
    max-width: 1160px;
    min-height: auto;
    margin: 28px auto 40px;
    padding: 0 32px;
    background: none;
  }
  .page > section + section, .page > .foot { border-top: 0; }
  .page > * { grid-column: 2; }

  .card {
    position: sticky;
    top: 88px;
    grid-column: 1;
    grid-row: 1 / span 8;
    padding: 22px 20px 8px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .hero { display: block; padding: 6px 0 4px; }
  .headline { font-size: clamp(2.2rem, 3.4vw, 3rem); font-weight: 700; line-height: 1.08; letter-spacing: -0.025em; }
  .lede { max-width: 40ch; margin: 12px 0 0; color: var(--ink-2); font-size: 1.15rem; }
  .hero-ctas { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }

  /* The conversation is already open: there's room for it */
  .sheet {
    position: static;
    z-index: auto;
    width: 100%;
    max-width: none;
    height: 480px;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    visibility: visible;
    transform: none;
    transition: none;
  }
  .sheet-head { padding-top: 14px; cursor: default; }
  .grip, .sheet .close { display: none; }
  body.sheet-open { overflow: auto; }
  body.sheet-open::after { display: none; }

  .block { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
  .highlights { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .highlights li { grid-template-columns: 1fr; gap: 10px; }
  .highlights .ico { justify-self: start; }
  .offers { display: grid; grid-template-columns: minmax(0, 1fr) 260px; column-gap: 20px; align-items: end; }
  .offers .label, .offers .offer-grid, .offers .note { grid-column: 1; }
  .offers .cta { grid-column: 2; grid-row: 2 / span 2; align-self: stretch; margin: 0; padding: 18px; flex-direction: column; font-size: 1.05rem; }
  .foot { justify-content: flex-start; padding: 4px 2px; }
  .dock { display: none; }
  .toast { bottom: 32px; }
}

@media (min-width: 768px) and (max-width: 1080px) {
  .page { grid-template-columns: 300px minmax(0, 1fr); gap: 16px 24px; padding: 0 20px; }
  .topbar { padding: 0 20px; }
  .card { padding: 18px 16px 6px; }
  .hero-ctas .btn-lg { padding: 12px 16px; font-size: 0.95rem; }
  .highlights { grid-template-columns: 1fr; }
  .highlights li { grid-template-columns: 40px 1fr; }
  .offers { grid-template-columns: 1fr; }
  .offers .cta { grid-column: 1; grid-row: auto; margin-top: 14px; flex-direction: row; }
}

/* ---------- motion ---------- */

@keyframes idle { 0%, 100% { height: 24%; } 50% { height: 46%; } }
@keyframes ping { from { opacity: 0.7; transform: scale(0.8); } to { opacity: 0; transform: scale(1.8); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
