/* ======================================================================
   Rolo by 5 Star Hosts — widget styles.
   Built on the site's own design system (relax-system.css tokens:
   --ink, --eucalyptus, --paper, --white, --ochre, --radius…), NOT a
   copy of the RWC look. The iPhone/dvh lessons from the RWC deployment
   are preserved: dvh with vh fallback, min-height also viewport-capped,
   safe-area padding on the composer, internal-scroll message area.
   ==================================================================== */

.rolo-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 950;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--eucalyptus);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px -8px rgba(16, 35, 31, 0.45);
  transition: transform 0.2s ease, background 0.2s ease;
}

.rolo-launcher:hover {
  background: var(--ink-2);
  transform: translateY(-2px);
}

.rolo-launcher svg {
  width: 26px;
  height: 26px;
}

.rolo-panel {
  position: fixed;
  right: 22px;
  bottom: 92px;
  z-index: 950;
  width: 396px;
  max-width: calc(100vw - 32px);
  /* Compact at rest; grows with the conversation up to a cap, then the
     body's own overflow-y takes over. min-height is ALSO viewport-capped
     (min-height beats max-height in CSS — a bare 500px would exceed a
     landscape phone's whole screen). vh-then-dvh pairs: dvh tracks the
     viewport iOS Safari actually shows; vh is the fallback. */
  min-height: min(500px, calc(100vh - 132px));
  min-height: min(500px, calc(100dvh - 132px));
  max-height: min(690px, calc(100vh - 132px));
  max-height: min(690px, calc(100dvh - 132px));
  background: var(--paper);
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 24px 60px -18px rgba(16, 35, 31, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rolo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: var(--ink);
  color: var(--white);
  flex: none;
}

.rolo-header-title strong {
  font-size: 15px;
  display: block;
  font-weight: 800;
}

.rolo-header-title span {
  font-size: 11.5px;
  color: var(--ochre-soft);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rolo-icon-btn {
  background: transparent;
  border: none;
  color: rgba(255, 253, 248, 0.85);
  cursor: pointer;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.rolo-icon-btn:hover {
  background: rgba(255, 253, 248, 0.12);
  color: var(--white);
}

.rolo-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rolo-welcome {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.6;
  background: var(--white);
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.rolo-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.rolo-chip {
  background: var(--white);
  border: 1px solid var(--eucalyptus);
  color: var(--eucalyptus);
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
}

.rolo-chip:hover {
  background: var(--eucalyptus);
  color: var(--white);
}

.rolo-msg-row {
  display: flex;
}

.rolo-msg-row.user {
  justify-content: flex-end;
}

.rolo-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.rolo-msg-row.user .rolo-msg {
  background: var(--eucalyptus);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.rolo-msg-row.assistant .rolo-msg {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line-light);
  border-bottom-left-radius: 4px;
}

/* Navigation links inside assistant bubbles — registry-resolved only,
   never model-authored HTML. */
.rolo-msg a {
  color: var(--eucalyptus);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rolo-msg a:hover {
  color: var(--ink-2);
}

.rolo-typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--line-light);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.rolo-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: rolo-typing-bounce 1.2s infinite ease-in-out;
}

.rolo-typing span:nth-child(2) { animation-delay: 0.15s; }
.rolo-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes rolo-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.rolo-card {
  background: var(--white);
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13.5px;
}

.rolo-handoff-card {
  background: #eef0e4;
  border-color: rgba(47, 98, 84, 0.28);
  color: var(--ink);
}

/* ------- estimate presentation ------- */

.rolo-estimate-eyebrow {
  color: var(--ochre);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.rolo-estimate-headline {
  font-family: "Newsreader", Georgia, serif;
  font-size: 24px;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 2px 0 4px;
}

.rolo-estimate-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.rolo-estimate-lines {
  display: grid;
  gap: 4px;
  margin: 10px 0 6px;
}

.rolo-estimate-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 12.5px;
  color: var(--ink);
  border-bottom: 1px solid rgba(16, 35, 31, 0.08);
  padding-bottom: 4px;
}

.rolo-estimate-line span:first-child {
  color: var(--muted);
}

.rolo-estimate-line strong {
  white-space: nowrap;
}

.rolo-estimate-line.total {
  border-bottom: 0;
  font-size: 13px;
}

.rolo-estimate-line.total span:first-child,
.rolo-estimate-line.total strong {
  color: var(--eucalyptus);
  font-weight: 800;
}

.rolo-estimate-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 8px;
}

/* Pinned current-estimate bar between header and messages. flex:none so
   the body keeps sole ownership of scrolling. */
.rolo-estimate-bar-wrap {
  flex: none;
  background: #ece7db;
  border-bottom: 1px solid var(--line-light);
}

.rolo-estimate-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 16px;
  min-width: 0;
}

.rolo-estimate-bar-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--eucalyptus);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.rolo-estimate-bar-label.updated {
  background: var(--ochre);
  color: var(--white);
  border-radius: 999px;
  padding: 2px 9px;
  overflow: visible;
}

.rolo-estimate-bar-total {
  margin-left: auto;
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
  flex: none;
  font-weight: 800;
}

.rolo-estimate-bar-toggle {
  flex: none;
  background: transparent;
  border: 1px solid var(--eucalyptus);
  color: var(--eucalyptus);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
}

.rolo-estimate-bar-toggle:hover {
  background: var(--eucalyptus);
  color: var(--white);
}

/* Inline accordion under the bar — height-capped with its own scroll so
   a long breakdown can never push the composer out of view. */
.rolo-estimate-bar-panel {
  border-top: 1px solid var(--line-light);
  background: var(--white);
  padding: 12px 16px 14px;
  max-height: min(300px, 45dvh);
  overflow-y: auto;
  animation: rolo-panel-in 0.16s ease;
}

@keyframes rolo-panel-in {
  from { opacity: 0.5; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* ------- CTA / lead form ------- */

.rolo-cta-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 9px 16px;
  border-radius: 999px;
  border: none;
  background: var(--ochre);
  color: var(--white);
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}

.rolo-cta-btn:hover {
  background: #b85d2f;
}

.rolo-cta-btn.secondary {
  background: transparent;
  border: 1px solid var(--eucalyptus);
  color: var(--eucalyptus);
}

.rolo-cta-btn.secondary:hover {
  background: var(--eucalyptus);
  color: var(--white);
}

.rolo-handoff-compact {
  display: flex;
}

.rolo-handoff-compact .rolo-cta-btn {
  margin-top: 0;
}

.rolo-lead-field label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.rolo-lead-field input,
.rolo-lead-field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-light);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  margin-bottom: 10px;
  background: var(--paper);
  color: var(--ink);
}

.rolo-lead-field input:focus,
.rolo-lead-field textarea:focus {
  border-color: var(--eucalyptus);
  outline: 0;
}

.rolo-lead-error {
  color: #a4482c;
  font-size: 12.5px;
  margin-bottom: 8px;
}

/* ------- composer ------- */

.rolo-composer {
  flex: none;
  border-top: 1px solid var(--line-light);
  background: var(--white);
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.rolo-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 16px; /* ≥16px stops iOS Safari zooming the page on focus */
  font-family: inherit;
  max-height: 110px;
  min-height: 42px;
  line-height: 1.4;
  background: var(--paper);
  color: var(--ink);
}

.rolo-composer textarea:focus-visible {
  outline: 2px solid var(--eucalyptus);
  outline-offset: 1px;
}

.rolo-send-btn {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--eucalyptus);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rolo-send-btn:disabled {
  background: var(--sand);
  cursor: default;
}

/* ------- retry ------- */

.rolo-retry-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: var(--eucalyptus);
  color: var(--white);
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}

/* ------- mobile: full-viewport panel, safe-area aware ------- */
@media (max-width: 560px) {
  .rolo-panel {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    width: 100%;
    /* With top/bottom/height all set the box resolves as top + height,
       so height is what sizes the panel. 100% resolves against the
       initial containing block, which iOS Safari sizes to the LARGE
       (toolbar-collapsed) viewport — with the toolbar visible that
       pushes the composer behind Safari's bottom bar. 100dvh is the
       visible viewport by definition and follows the toolbar and
       rotation; the 100% line is the no-dvh fallback. The iOS keyboard
       does not resize dvh — Safari pans to the focused field —
       so keyboard behaviour is unchanged. */
    height: 100%;
    height: 100dvh;
    min-height: 0;
    max-height: none;
    max-width: 100%;
    border-radius: 0;
    border: none;
  }

  .rolo-launcher {
    right: 16px;
    bottom: 16px;
  }
}

/* ------- homepage "Meet Rolo" introduction ------- */

.rolo-intro-note {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 14px;
}

.rolo-intro-sample {
  background: var(--white);
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  padding: 18px 16px;
  max-width: 420px;
  width: 100%;
  justify-self: center;
  display: grid;
  gap: 10px;
  box-shadow: var(--shadow);
}

.rolo-intro-sample-head {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .rolo-launcher {
    transition: none;
  }
  .rolo-typing span {
    animation: none;
    opacity: 1;
  }
  .rolo-estimate-bar-panel {
    animation: none;
  }
}
