/* Speed-to-lead demo: a Messages-style thread. Light theme, Code Space AI green, system type. */

:root {
  color-scheme: light;
  --page: #f2f2f7;
  --bg: #ffffff;
  --surface: #f5f5f7;
  --text: #111114;
  --text-2: #55555e; /* 7.3:1 on white */
  --text-3: #6b6b75; /* 5.3:1 on white */
  --separator: rgba(60, 60, 67, 0.16);
  --me: #047857; /* customer bubble: white text 5.5:1 */
  --me-text: #ffffff;
  --them: #e9e9eb;
  --them-text: #111114;
  --accent: #10b981; /* brand green, for marks and focus rings */
  --accent-strong: #047857;
  --glass: rgba(249, 249, 251, 0.78);
  --radius-bubble: 1.125rem;
  --header-h: 3.75rem;
  --dock-h: 5.5rem;
  --ease-settle: cubic-bezier(0.2, 0.9, 0.25, 1); /* close to a critically damped spring */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--page);
  color: var(--text);
  font: 100%/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent-strong);
  text-underline-offset: 0.15em;
}

/* The dark brand green: 5.5:1 on white, so the focus ring is always visible. */
:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Frame: one phone-width column, the thread scrolls under translucent bars ---- */

/* Fixed to the visible area. On phones, app.js narrows it to the space above the keyboard. */
.app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  max-width: 36rem;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

@media (min-width: 40rem) {
  .app {
    box-shadow: 0 0 0 1px var(--separator);
  }
}

.bar,
.dock {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}

.bar {
  top: 0;
  padding: max(0.625rem, env(safe-area-inset-top)) 1rem 0.625rem;
  transition: box-shadow 200ms ease;
}

.bar.scrolled {
  box-shadow: 0 1px 0 var(--separator);
}

.dock {
  bottom: 0;
  padding: 0.5rem 0.75rem max(0.375rem, env(safe-area-inset-bottom));
  box-shadow: 0 -1px 0 var(--separator);
}

/* ---- Header: the company as the contact ---- */

.contact {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(180deg, #a5a9b3, #868a95);
  color: #fff;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0;
}

.contact-text {
  min-width: 0;
}

.contact-name {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-status {
  margin: 0.0625rem 0 0;
  font-size: 0.75rem;
  line-height: 1.3;
  letter-spacing: 0.005em;
  color: var(--text-2);
}

.app[data-state="loading"] .contact-name {
  color: var(--text-3);
}

/* ---- Thread ---- */

.thread {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(var(--header-h) + 0.75rem) 0 calc(var(--dock-h) + 0.75rem);
  scroll-padding-bottom: calc(var(--dock-h) + 0.75rem);
}

.intro {
  margin: 0 0.75rem 1.25rem;
  padding: 1rem 1rem 0.5rem;
  background: var(--surface);
  border-radius: 1rem;
}

.app[data-state="loading"] .intro,
.app[data-state="missing"] .intro,
.app[data-state="landing"] .intro {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-2);
}

.brand img {
  border-radius: 0.3125rem;
}

.intro-title {
  margin: 0 0 0.375rem;
  font-size: 1.375rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.018em;
  text-wrap: balance;
}

.intro-text {
  margin: 0 0 0.875rem;
  font-size: 0.9375rem;
  line-height: 1.45;
  letter-spacing: -0.005em;
  color: var(--text-2);
}

.intro-text strong {
  color: var(--text);
  font-weight: 600;
}

/* Example first messages: a grouped list of rows (no pills). */
.starters {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  background: var(--bg);
  border-radius: 0.75rem;
  overflow: hidden;
}

.starters li + li {
  border-top: 1px solid var(--separator);
}

.starter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.625rem 0.875rem;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 0.9375rem;
  line-height: 1.35;
  letter-spacing: -0.005em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.starter::after {
  content: "";
  flex: none;
  width: 0.4375rem;
  height: 0.4375rem;
  border-top: 2px solid var(--text-3);
  border-right: 2px solid var(--text-3);
  transform: rotate(45deg);
}

.starter:active {
  background: var(--surface);
}

/* Draw the focus ring inside the row, so the rounded list doesn't clip it. */
.starter:focus-visible {
  outline-offset: -2px;
}

.intro.used .starters {
  display: none;
}

/* ---- Messages ---- */

.messages {
  list-style: none;
  margin: 0;
  padding: 0 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.1875rem;
}

.msg {
  max-width: 78%;
  padding: 0.4375rem 0.8125rem;
  border-radius: var(--radius-bubble);
  font-size: 1.0625rem;
  line-height: 1.3;
  letter-spacing: -0.012em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: bubble-in 320ms var(--ease-settle) both;
}

.msg.me {
  align-self: flex-end;
  background: var(--me);
  color: var(--me-text);
  transform-origin: 100% 100%;
}

.msg.jess {
  align-self: flex-start;
  background: var(--them);
  color: var(--them-text);
  transform-origin: 0 100%;
}

.msg.me a {
  color: inherit;
}

/* A new sender starts a new group. The last bubble of a group gets a tighter corner. */
.msg.me + .msg.jess,
.msg.jess + .msg.me,
.notice + .msg {
  margin-top: 0.625rem;
}

.msg.me:last-child,
.msg.me:has(+ :not(.me)) {
  border-bottom-right-radius: 0.375rem;
}

.msg.jess:last-child,
.msg.jess:has(+ :not(.jess)) {
  border-bottom-left-radius: 0.375rem;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Typing indicator: a Jess bubble with three dots. */
.typing {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
  margin: 0.625rem 0.75rem 0;
  padding: 0.75rem 0.875rem;
  border-bottom-left-radius: 0.375rem;
}

.typing[hidden] {
  display: none;
}

.typing span {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: #8e8e93;
  animation: typing-dot 1.2s ease-in-out infinite;
}

.typing span:nth-child(2) {
  animation-delay: 0.16s;
}

.typing span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes typing-dot {
  0%,
  60%,
  100% {
    opacity: 0.35;
  }
  30% {
    opacity: 1;
  }
}

/* System notices (errors, limits) sit centred in the thread, like a timestamp. */
.notice {
  align-self: center;
  max-width: 85%;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--text-2);
  text-align: center;
}

.notice button {
  display: block;
  margin: 0.125rem auto 0;
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 600;
  cursor: pointer;
}

/* ---- Full-page states: landing, link not found, could not load ---- */

.page-notice {
  margin: 2.5rem 1.5rem;
  text-align: center;
}

.page-notice h2 {
  margin: 0 0 0.5rem;
  font-size: 1.375rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.018em;
}

.page-notice p {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--text-2);
}

.page-notice-links a {
  display: inline-block;
  min-height: 2.75rem;
  padding: 0.6875rem 0.5rem;
  font-weight: 600;
}

.app[data-state="missing"] .dock,
.app[data-state="landing"] .dock,
.app[data-state="missing"] .bar,
.app[data-state="landing"] .bar {
  display: none;
}

.page-notice .brand {
  justify-content: center;
  margin-bottom: 1.25rem;
}

/* ---- Composer ---- */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.375rem;
}

.composer textarea {
  flex: 1;
  min-height: 2.75rem;
  max-height: 8rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--separator);
  border-radius: 1.375rem;
  background: var(--bg);
  font-size: 1.0625rem; /* 17px: also stops iOS from zooming in on focus */
  line-height: 1.3;
  letter-spacing: -0.012em;
  resize: none;
  overflow-y: auto;
}

.composer textarea::placeholder {
  color: var(--text-3);
}

.composer textarea:focus-visible {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 1px var(--accent-strong);
}

.send {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: var(--accent-strong);
  color: #fff;
  cursor: pointer;
  transition: transform 100ms ease-out, background-color 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

.send:active:not(:disabled) {
  transform: scale(0.94);
}

.send:disabled {
  background: #c7c7cc;
  cursor: default;
}

.footnote {
  margin: 0.375rem 0 0;
  font-size: 0.6875rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--text-3);
  text-align: center;
}

/* Small to look at, but a full 44px to tap: the padding is pulled back with a negative margin. */
.footnote a {
  display: inline-block;
  padding: 0.875rem 0.375rem;
  margin: -0.875rem -0.125rem;
  font-weight: 600;
}

/* ---- /call: the booking calendar inside our own page ---- */

.call-page {
  background: var(--bg);
}

.call {
  max-width: 44rem;
  margin: 0 auto;
  padding: max(1.5rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom));
}

.call h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.call-text {
  margin: 0 0 1.25rem;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text-2);
}

.call-calendar {
  display: block;
  width: 100%;
  height: max(48rem, 80vh);
  border: 0;
}

/* ---- Accessibility preferences ---- */

@media (prefers-reduced-motion: reduce) {
  .msg {
    animation: fade-in 150ms ease both;
  }

  .typing span {
    animation: none;
    opacity: 0.6;
  }

  .bar {
    transition: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .bar,
  .dock {
    background: #f9f9fb;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --separator: rgba(0, 0, 0, 0.45);
    --text-2: #3a3a40;
    --text-3: #45454c;
  }

  .bar,
  .dock {
    background: #ffffff;
  }

  .msg.jess {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  }
}
