/* PitchLogix demo page. The product pane holds the captured app; everything else stays quiet so it reads first. */

:root {
  --bg: #f3f1ec;
  --panel: #ffffff;
  --ink: #0f2235;
  --ink-soft: #5b6b78;
  --line: #e4e0d6;
  --accent: #0e7c72;
  --accent-bright: #14b8a6;
  --accent-ink: #ffffff;
  --guide-bubble: #f0faf8;
  --you-bubble: #0f2235;
  --ring: #14b8a6;
  --dim: rgba(15, 34, 53, 0.4);
  --shadow: 0 1px 2px rgba(15, 34, 53, 0.06), 0 8px 28px rgba(15, 34, 53, 0.08);
  --float-shadow: 0 30px 60px -16px rgba(15, 34, 53, 0.5), 0 0 0 1px rgba(15, 34, 53, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b;
    --panel: #1a1e26;
    --ink: #e8eaef;
    --ink-soft: #9aa3b4;
    --line: #2a303b;
    --accent: #5eead4;
    --accent-bright: #2dd4bf;
    --accent-ink: #062a27;
    --guide-bubble: #1d2b31;
    --you-bubble: #2b3a4a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
    --float-shadow: 0 30px 60px -16px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.pl-demo {
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  height: 100dvh;
}

/* ---- Chat -------------------------------------------------------------------------------------- */

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

/* The guide's face; its drawing and motion are in avatar.css. */
.orb { width: 44px; height: 44px; flex: none; line-height: 0; }

.who { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.who span { color: var(--ink-soft); font-size: 13px; }

/* The recording notice: a small tag under the guide's name, its words in a tooltip on hover,
   focus or tap. */
.who .notice { position: relative; align-self: flex-start; margin-top: 2px; }
.notice-tag { font: inherit; font-size: 12px; color: var(--ink-soft); background: none; border: 0; padding: 0; cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.notice-tag:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
.who .notice-tip {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; width: min(300px, 80vw);
  padding: 10px 12px; border-radius: 10px; background: var(--ink); color: var(--panel);
  font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(-2px); transition: opacity .15s, transform .15s, visibility 0s .15s;
}
.notice:hover .notice-tip, .notice-tag:focus-visible + .notice-tip, .notice.open .notice-tip {
  opacity: 1; visibility: visible; transform: none; transition: opacity .15s, transform .15s;
}
@media (prefers-reduced-motion: reduce) { .who .notice-tip { transition: none; } }

.book {
  margin-left: auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

/* The guide's voice, on or off. Pressed means on; off shows the speaker crossed out. */
.sound, .dock, .shrink {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-soft);
  cursor: pointer;
}

.sound:not([hidden]) + .book { margin-left: 8px; }
.dock, .shrink { margin-left: 8px; }
.shrink[aria-pressed="true"] .less, .shrink[aria-pressed="false"] .more { display: none; }

/* Shrunk, a new line from the guide puts a dot on the button that brings the chat back. */
.shrink { position: relative; }
.shrink.unread::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 2px var(--panel);
}
.dock[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.sound[aria-pressed="true"] { color: var(--accent); }
.sound[aria-pressed="true"] .mute, .sound[aria-pressed="false"] .waves { display: none; }

/* The mic: on, it listens turn after turn, and pulses so the visitor knows it hears them. */
.compose .mic {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-soft);
}

.compose .mic[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  animation: listening 1.6s ease-in-out infinite;
}

.compose .mic[hidden] { display: none; }

@keyframes listening { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent); } }

@media (prefers-reduced-motion: reduce) { .compose .mic[aria-pressed="true"] { animation: none; } }

.book:focus-visible, .chip:focus-visible, .compose button:focus-visible, .collapse:focus-visible, .sound:focus-visible, .dock:focus-visible, .shrink:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.messages {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 16px;
  overflow-y: auto;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.messages li {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  overflow-wrap: anywhere;
}

.messages .guide { align-self: flex-start; background: var(--guide-bubble); border-bottom-left-radius: 4px; }
.messages .you { align-self: flex-end; background: var(--you-bubble); color: #fff; border-bottom-right-radius: 4px; }
.messages .note { align-self: center; color: var(--ink-soft); font-size: 13px; padding: 2px 8px; }

.messages .typing::after {
  content: "";
  display: inline-block;
  width: 28px;
  height: 8px;
  background: radial-gradient(circle, var(--ink-soft) 3px, transparent 3.5px) 0 50% / 10px 8px repeat-x;
  animation: typing 1s steps(3, end) infinite;
}

@keyframes typing { from { width: 8px; } to { width: 32px; } }

/* The contact form, a card in the chat. */
.messages .contact { align-self: stretch; max-width: none; background: var(--panel); border: 1px solid var(--line); }
.contact form { display: flex; flex-direction: column; gap: 10px; }
.contact p { margin: 0; }
.contact label { display: flex; flex-direction: column; gap: 4px; color: var(--ink-soft); font-size: 13px; font-weight: 600; }
.contact input {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 400;
}
.contact input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.contact .problem { color: #b3261e; font-size: 13px; }
.contact button {
  align-self: flex-start;
  padding: 9px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.contact button:disabled { opacity: 0.6; cursor: default; }
.contact button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.chips:empty { display: none; }

.chip {
  padding: 8px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.chip:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.compose {
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
}

.compose input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.compose button {
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--panel);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ---- Product pane ------------------------------------------------------------------------------ */

.product {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px;
  gap: 10px;
}

.product-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 13px;
}

.dots { display: inline-flex; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.screen-title { font-weight: 600; color: var(--ink); }

.collapse {
  display: none;
  margin-left: auto;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

/* The pane the stage is fitted into; whatever the stage leaves is page background, not a frame. */
.viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* The app at the pane's size, scaled by the player only when the pane is narrow; --scale keeps strokes and text legible. */
.stage {
  --scale: 1;
  position: absolute;
  transform-origin: 0 0;
  overflow: hidden;
  border-radius: calc(12px / var(--scale));
  background: #fff;
  box-shadow: 0 calc(1px / var(--scale)) calc(2px / var(--scale)) rgba(17, 22, 32, 0.08),
              0 calc(8px / var(--scale)) calc(28px / var(--scale)) rgba(17, 22, 32, 0.12);
}

.frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.frame.shown { opacity: 1; }

.overlay {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

.ring {
  position: absolute;
  border: calc(3px / var(--scale)) solid var(--ring);
  border-radius: calc(10px / var(--scale));
  box-shadow: 0 0 0 4000px var(--dim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, left 0.3s ease, top 0.3s ease, width 0.3s ease, height 0.3s ease;
}

.ring.on { opacity: 1; }

/* Pointing at something or typing into it: a soft ring, nothing dimmed. */
.ring.soft, .ring.handoff { box-shadow: none; border-width: calc(2px / var(--scale)); }

/* The prospect's turn: the ring breathes until they click what it marks. */
.ring.handoff { animation: handoff 1.4s ease-in-out infinite; }
@keyframes handoff { 50% { transform: scale(1.05); border-width: calc(4px / var(--scale)); } }

.caption, .hint {
  position: absolute;
  max-width: calc(320px / var(--scale));
  padding: calc(10px / var(--scale)) calc(14px / var(--scale));
  border-radius: calc(12px / var(--scale));
  background: #1d2330;
  color: #fff;
  font: 600 calc(14px / var(--scale)) / 1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 calc(6px / var(--scale)) calc(24px / var(--scale)) rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.caption.on, .hint.on { opacity: 1; }

.cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  margin: -4px 0 0 -4px;
  fill: #1d2330;
  stroke: #fff;
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
  transform: translate(1300px, 820px);
  transform-origin: 4px 2px;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.65s cubic-bezier(0.45, 0, 0.25, 1), opacity 0.2s ease;
}

.cursor.on { opacity: 1; }
.cursor.clicking path { fill: var(--ring); }

@media (prefers-reduced-motion: reduce) {
  .frame, .ring, .cursor, .caption, .hint { transition: none; }
  .ring.handoff { animation: none; }
  .messages .typing::after { animation: none; }
}

/* ---- Wide screens: the product fills the window, the chat floats over it or docks on the left -- */

@media (min-width: 821px) {
  .pl-demo { display: block; position: relative; }
  .product { height: 100%; }

  .chat {
    position: absolute;
    left: 36px;
    bottom: 36px;
    z-index: 5;
    width: min(440px, calc(100% - 72px));
    max-height: min(72vh, 640px);
    border: 0;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--float-shadow);
    transition: opacity 0.25s ease;
  }

  .chat .chat-head { padding: 14px 16px; }
  .chat .messages { min-height: 120px; }

  /* The header is the handle the card is dragged by. */
  .pl-demo:not(.docked) .chat-head { cursor: grab; touch-action: none; }
  .chat.dragging { transition: none; user-select: none; }
  .chat.dragging .chat-head { cursor: grabbing; }

  /* Shrunk: only the header strip and the message box. */
  .pl-demo:not(.docked) .chat.shrunk .messages,
  .pl-demo:not(.docked) .chat.shrunk .chips,
  .pl-demo:not(.docked) .chat.shrunk .who > span { display: none; }
  .pl-demo:not(.docked) .chat.shrunk .chat-head { padding: 10px 14px; border-bottom: 0; }
  .pl-demo:not(.docked) .chat.shrunk .orb { width: 30px; height: 30px; }
  .pl-demo:not(.docked) .chat.shrunk .compose { border-top: 0; padding-top: 0; }
  .pl-demo.docked .shrink { display: none; }

  /* The mouse is busy on the product: the card all but disappears and lets clicks through. */
  .chat.faded { opacity: 0.12; pointer-events: none; }

  .pl-demo.docked { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; }

  .pl-demo.docked .chat {
    position: static;
    width: auto;
    max-height: none;
    border-radius: 0;
    border-right: 1px solid var(--line);
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) { .chat { transition: none; } }

/* ---- Phone: chat full width, the product a card above the input, full screen on tap ------------ */

@media (max-width: 820px) {
  .pl-demo {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto auto;
  }

  .chat { display: contents; }
  .chat-head { grid-row: 1; background: var(--panel); }
  .product { grid-row: 2; padding: 10px 12px 0; }
  .messages { grid-row: 3; background: var(--panel); }
  .chips { grid-row: 4; background: var(--panel); }
  .compose { grid-row: 5; background: var(--panel); }

  .viewport { flex: none; height: 30vh; }
  .dock, .shrink { display: none; }
  .product-bar .dots { display: none; }

  .pl-demo.expanded .product {
    position: fixed;
    inset: 0;
    z-index: 10;
    padding: 12px;
    background: var(--bg);
  }

  .pl-demo.expanded .viewport { flex: 1; height: auto; }
  .pl-demo.expanded .collapse { display: inline-block; }
}

/* A wide app screen is small on a tall phone. */
@media (max-width: 820px) and (orientation: portrait) {
  .pl-demo.expanded .viewport::after {
    content: "Turn your phone sideways for a bigger view";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 16px;
    color: var(--ink-soft);
    font-size: 13px;
    text-align: center;
  }
}

/* ---- Live guide ------------------------------------------------------------------------------- */

a.chip { display: inline-flex; align-items: center; text-decoration: none; }
.compose.waiting button { opacity: 0.5; }

/* The product's own booking, over the demo. */
.booking-sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: rgba(15, 34, 53, 0.45); }
.booking-card {
  display: flex; flex-direction: column; width: min(720px, 100%); height: min(780px, 100%);
  overflow: hidden; border-radius: 16px; background: var(--panel); box-shadow: var(--float-shadow);
}
.booking-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--line); font-weight: 700; }
.booking-card iframe { flex: 1; width: 100%; min-height: 0; border: 0; background: var(--panel); }
.booking-close {
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.booking-close:hover { border-color: var(--accent); color: var(--accent); }
.booking-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 640px) {
  .booking-sheet { padding: 0; }
  .booking-card { width: 100%; height: 100%; border-radius: 0; }
}
