/* Rite Maps Chat: launcher and panel, light design.
   Colours and fonts come from the theme's tokens (BUILD-CONTRACT "Brand tokens", v5 light design) with the same values as fallbacks,
   so it still looks right under another theme. Stacking (v6): quote pop-up (top layer) > cookie notice > chat panel > chat launcher.
   On phones the launcher and the sheet sit above the cookie notice using --rm-cookie-offset, which Rite Maps Tools sets on <html>. */

.rmc {
  --rmc-blue: var(--rm-blue, #05357e);
  --rmc-orange: var(--rm-orange, #fa7818);
  --rmc-orange-hover: var(--rm-orange-hover, #ff8a33);
  --rmc-on-orange: var(--rm-on-orange, #170900);
  --rmc-orange-text: var(--rm-orange-text, #b04a00);
  --rmc-paper: var(--rm-paper, #f4f6f9);
  --rmc-white: var(--rm-white, #ffffff);
  --rmc-tint: var(--rm-tint, #eaf0f8);
  --rmc-tint-line: var(--rm-tint-line, #cfd9e6);
  --rmc-tick: var(--rm-tick, #a9b7cb);
  --rmc-text: var(--rm-text, #111827);
  --rmc-muted: var(--rm-muted, #4b5563);
  --rmc-line: var(--rm-line, #d9dee7);
  --rmc-field-line: var(--rm-field-line, #8b95a7);
  --rmc-error: #b42318; /* 6.6:1 on white */
  --rmc-radius: var(--rm-radius, 10px);
  --rmc-head: var(--rm-font-head, "Barlow Condensed", "Arial Narrow", sans-serif);
  --rmc-body: var(--rm-font-body, "Barlow", system-ui, sans-serif);
  --rmc-mono: var(--rm-font-mono, "IBM Plex Mono", ui-monospace, monospace);
  --rmc-gap: 24px;
  --rmc-offset: 0px;
  /* Above the sticky header (60), below the cookie notice. Override these if the cookie notice uses a lower z-index. */
  --rmc-z-launcher: 64;
  --rmc-z-panel: 66;
  font-family: var(--rmc-body);
  color: var(--rmc-text);
  -webkit-text-size-adjust: 100%;
}
.rmc[hidden], .rmc [hidden] { display: none !important; }
.rmc *, .rmc *::before, .rmc *::after { box-sizing: border-box; }
.rmc h2, .rmc h3, .rmc p { margin: 0; padding: 0; border: 0; text-transform: none; }
.rmc button, .rmc input, .rmc select { font-family: inherit; letter-spacing: normal; text-transform: none; margin: 0; }

.rmc-sr {
  position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0 0 0 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; border: 0 !important;
}

/* ---- Launcher ------------------------------------------------------------------------------------------------------------ */
.rmc-launcher {
  position: fixed; right: var(--rmc-gap); bottom: calc(var(--rmc-gap) + var(--rmc-offset)); z-index: var(--rmc-z-launcher);
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 54px; padding: 8px 20px 8px 8px;
  border: 1px solid var(--rmc-tint-line); border-radius: 999px;
  background: var(--rmc-white); color: var(--rmc-blue);
  box-shadow: 0 12px 32px rgba(5, 53, 126, .18), 0 2px 6px rgba(17, 24, 39, .08);
  font: 600 19px/1 var(--rmc-head); letter-spacing: .02em; white-space: nowrap;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s ease, box-shadow .15s ease, transform .15s ease, bottom .2s ease;
}
.rmc-launcher:hover { background: var(--rmc-tint); box-shadow: 0 14px 36px rgba(5, 53, 126, .24), 0 2px 6px rgba(17, 24, 39, .08); }
/* Logo blue like the theme's focus rings: 11.6:1 on white, 10.1:1 on the pale tint (orange was 2.7:1 on white). The radius is
   restated because the theme's own :focus-visible rule squares corners. */
.rmc-launcher:focus-visible { outline: 2px solid var(--rmc-blue); outline-offset: 2px; border-radius: 999px; }
.rmc-launcher__icon {
  position: relative; display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  background: var(--rmc-blue); color: var(--rmc-white);
}
.rmc-launcher__icon svg { display: block; width: 22px; height: 22px; }
.rmc[data-state="open"] .rmc-launcher { background: var(--rmc-tint); }
.rmc-launcher__badge {
  position: absolute; top: 4px; left: 36px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--rmc-orange); border: 2px solid var(--rmc-white);
}
/* The theme's phone menu is open: the launcher would sit on top of it. */
html:has(.rm-header.is-open) .rmc-launcher { display: none; }

/* ---- Panel --------------------------------------------------------------------------------------------------------------- */
.rmc-panel {
  position: fixed; right: var(--rmc-gap); bottom: calc(var(--rmc-gap) + var(--rmc-offset) + 66px); z-index: var(--rmc-z-panel);
  display: flex; flex-direction: column;
  width: min(400px, calc(100vw - 2 * var(--rmc-gap)));
  height: min(640px, calc(100vh - var(--rmc-offset) - 124px));
  height: min(640px, calc(100dvh - var(--rmc-offset) - 124px));
  /* clip, not just hide: a clipped panel can't be scrolled by focus or scrollIntoView, so its header never slides away. */
  overflow: hidden; overflow: clip;
  background: var(--rmc-white); border: 1px solid var(--rmc-line); border-radius: 16px;
  box-shadow: 0 28px 64px rgba(5, 53, 126, .22), 0 4px 14px rgba(17, 24, 39, .08);
  animation: rmc-in .18s ease-out;
}
@keyframes rmc-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.rmc-head {
  position: relative; display: flex; align-items: center; gap: 12px; flex: 0 0 auto;
  padding: 14px 10px 16px 16px;
  background: var(--rmc-tint); border-bottom: 1px solid var(--rmc-tint-line);
}
/* A survey-scale ruler along the bottom edge (decorative). */
.rmc-head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, var(--rmc-tick) 0 1px, transparent 1px 60px) 0 0 / 100% 6px no-repeat,
    repeating-linear-gradient(90deg, var(--rmc-tick) 0 1px, transparent 1px 12px) 0 3px / 100% 3px no-repeat;
  opacity: .75;
}
.rmc-head__mark {
  display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%;
  background: var(--rmc-white); border: 1px solid var(--rmc-tint-line); color: var(--rmc-blue);
}
.rmc-head__mark svg { display: block; }
.rmc-head__text { flex: 1 1 auto; min-width: 0; }
.rmc-title { font: 700 22px/1.1 var(--rmc-head); color: var(--rmc-blue); letter-spacing: .01em; overflow-wrap: anywhere; }
.rmc-title:focus { outline: none; }
.rmc-title:focus-visible { outline: 2px solid var(--rmc-blue); outline-offset: 2px; border-radius: 2px; }
.rmc-status {
  display: flex; align-items: center; gap: 7px; margin-top: 4px;
  font: 500 12px/1.3 var(--rmc-mono); letter-spacing: .03em; text-transform: uppercase; color: var(--rmc-muted);
}
.rmc-status__dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--rmc-blue); }
.rmc[data-conn="offline"] .rmc-status__dot { background: var(--rmc-field-line); }
.rmc[data-conn="waiting"] .rmc-status__dot, .rmc[data-conn="agent"] .rmc-status__dot { background: var(--rmc-orange); }
.rmc[data-conn="connecting"] .rmc-status__dot, .rmc[data-conn="waiting"] .rmc-status__dot { animation: rmc-pulse 1.2s ease-in-out infinite; }
@keyframes rmc-pulse { 50% { opacity: .3; } }

.rmc-close {
  display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--rmc-blue); cursor: pointer;
}
.rmc-close:hover { background: rgba(5, 53, 126, .08); }
.rmc-close:focus-visible { outline: 2px solid var(--rmc-blue); outline-offset: -2px; }
/* LinkedIn in the header: phones only (see the 600px block). Wider, the floating LinkedIn button stays beside the panel. */
.rmc-head__li { display: none; }

/* ---- Banner: offline, waiting for a person, live ------------------------------------------------------------------------- */
.rmc-banner { flex: 0 0 auto; padding: 10px 16px 12px; border-bottom: 1px solid var(--rmc-line); background: var(--rmc-paper); font-size: 15px; line-height: 1.45; }
.rmc-banner[data-mode="waiting"] { background: #fff5ec; border-bottom-color: #f6d3b5; }
.rmc-banner[data-mode="agent"] { background: var(--rmc-white); border-left: 4px solid var(--rmc-orange); }
.rmc-banner[data-mode="offline"], .rmc-banner[data-mode="lost"] { background: var(--rmc-paper); }
.rmc-banner__text { color: var(--rmc-text); }
.rmc-banner[data-mode="waiting"] .rmc-banner__text::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%;
  background: var(--rmc-orange); vertical-align: 1px; animation: rmc-pulse 1.2s ease-in-out infinite;
}
.rmc-banner__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* ---- Messages ------------------------------------------------------------------------------------------------------------ */
.rmc-view { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.rmc-log {
  position: relative; /* keeps the screen-reader-only labels inside the scrolling log */
  display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px;
  background-color: var(--rmc-paper);
  /* faint survey grid */
  background-image: linear-gradient(rgba(5, 53, 126, .04) 1px, transparent 1px), linear-gradient(90deg, rgba(5, 53, 126, .04) 1px, transparent 1px);
  background-size: 24px 24px;
}
.rmc-log, .rmc-view--callback { scrollbar-width: thin; scrollbar-color: var(--rmc-tick) transparent; }
.rmc-log:focus { outline: none; }
.rmc-log:focus-visible { outline: 2px solid var(--rmc-blue); outline-offset: -2px; }
.rmc-msg { position: relative; display: flex; flex-direction: column; gap: 4px; max-width: 88%; }
.rmc-msg__who { font: 500 11px/1.2 var(--rmc-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--rmc-muted); padding: 0 4px; }
.rmc-msg__text {
  padding: 10px 14px; border-radius: 14px;
  font: 400 16px/1.5 var(--rmc-body); white-space: pre-line; overflow-wrap: anywhere;
}
.rmc-msg--bot { align-self: flex-start; }
.rmc-msg--bot .rmc-msg__text { background: var(--rmc-white); border: 1px solid var(--rmc-line); border-top-left-radius: 4px; color: var(--rmc-text); }
.rmc-msg--visitor { align-self: flex-end; }
.rmc-msg--visitor .rmc-msg__text { background: var(--rmc-blue); color: var(--rmc-white); border-top-right-radius: 4px; }
.rmc-msg--agent { align-self: flex-start; }
.rmc-msg--agent .rmc-msg__who { color: var(--rmc-orange-text); }
.rmc-msg--agent .rmc-msg__text { background: var(--rmc-white); border: 1px solid var(--rmc-tint-line); border-left: 4px solid var(--rmc-orange); border-top-left-radius: 4px; color: var(--rmc-text); }
.rmc-msg--notice .rmc-msg__text { border-style: dashed; border-color: var(--rmc-field-line); }
.rmc-msg.is-sending .rmc-msg__text { opacity: .72; }
.rmc-msg.is-failed .rmc-msg__text { background: var(--rmc-white); color: var(--rmc-text); border: 1px solid var(--rmc-error); }
.rmc-msg__note { align-self: flex-end; font: 600 12px/1.2 var(--rmc-body); color: var(--rmc-error); padding: 0 4px; }
.rmc-link { color: var(--rmc-blue); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.rmc-link:hover { text-decoration-thickness: 2px; }
.rmc-link:focus-visible { outline: 2px solid var(--rmc-blue); outline-offset: 2px; border-radius: 2px; }
.rmc-msg--visitor .rmc-link { color: var(--rmc-white); }
.rmc-msg__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

.rmc-typing__dots { display: inline-flex; gap: 5px; align-items: center; padding: 14px 16px; border-radius: 14px; border-top-left-radius: 4px; background: var(--rmc-white); border: 1px solid var(--rmc-line); width: max-content; }
.rmc-typing__dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--rmc-tick); animation: rmc-dot 1s ease-in-out infinite; }
.rmc-typing__dots span:nth-child(2) { animation-delay: .15s; }
.rmc-typing__dots span:nth-child(3) { animation-delay: .3s; }
@keyframes rmc-dot { 0%, 80%, 100% { transform: none; opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }

/* ---- Buttons ------------------------------------------------------------------------------------------------------------- */
.rmc-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: 0 0 auto; padding: 12px 14px 4px; background: var(--rmc-white); border-top: 1px solid var(--rmc-line); }
.rmc-btn, .rmc-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 15px;
  border: 1.5px solid var(--rmc-blue); border-radius: 999px;
  background: var(--rmc-white); color: var(--rmc-blue); box-shadow: none;
  font: 600 16px/1.1 var(--rmc-head); letter-spacing: .02em; text-align: center; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.rmc-chip { min-height: 36px; padding: 6px 13px; font-size: 15px; }
.rmc-btn:hover, .rmc-chip:hover { background: var(--rmc-tint); color: var(--rmc-blue); }
.rmc-btn--primary, .rmc-chip--primary { background: var(--rmc-orange); border-color: var(--rmc-orange); color: var(--rmc-on-orange); }
.rmc-btn--primary:hover, .rmc-chip--primary:hover { background: var(--rmc-orange-hover); border-color: var(--rmc-orange-hover); color: var(--rmc-on-orange); }
.rmc-btn--quiet { border-color: var(--rmc-line); }
.rmc-btn:focus-visible, .rmc-chip:focus-visible { outline: 3px solid var(--rmc-blue); outline-offset: 2px; }
.rmc-btn--primary:focus-visible, .rmc-chip--primary:focus-visible { outline-color: var(--rmc-blue); }
.rmc-btn.is-busy, .rmc-btn[aria-disabled="true"], .rmc-btn:disabled { opacity: .6; cursor: progress; }

/* ---- Question box -------------------------------------------------------------------------------------------------------- */
.rmc-ask { display: flex; gap: 8px; flex: 0 0 auto; padding: 8px 14px 14px; background: var(--rmc-white); }
.rmc-ask__input {
  flex: 1 1 auto; min-width: 0; height: 48px; padding: 0 16px;
  border: 1px solid var(--rmc-field-line); border-radius: 999px; background: var(--rmc-white); color: var(--rmc-text);
  font: 400 16px/1.2 var(--rmc-body); box-shadow: none;
}
.rmc-ask__input::placeholder { color: var(--rmc-muted); opacity: 1; }
/* Focus: a solid logo-blue ring (the pale halo alone was about 1.4:1 against white). */
.rmc-ask__input:focus { outline: 2px solid var(--rmc-blue); outline-offset: 2px; border-color: var(--rmc-blue); box-shadow: none; }
.rmc-ask__send {
  display: grid; place-items: center; flex: 0 0 48px; width: 48px; height: 48px; padding: 0;
  border: 0; border-radius: 50%; background: var(--rmc-orange); color: var(--rmc-on-orange); cursor: pointer;
}
.rmc-ask__send:hover { background: var(--rmc-orange-hover); }
.rmc-ask__send:focus-visible { outline: 3px solid var(--rmc-blue); outline-offset: 2px; }

/* ---- Call-back form ------------------------------------------------------------------------------------------------------ */
.rmc-view--callback { position: relative; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 20px; background: var(--rmc-white); }
.rmc-callback__title { font: 700 22px/1.15 var(--rmc-head); color: var(--rmc-blue); }
.rmc-callback__title:focus { outline: none; }
.rmc-callback__intro { margin-top: 6px; font-size: 16px; line-height: 1.5; color: var(--rmc-muted); }
.rmc-field { display: grid; gap: 6px; margin-top: 14px; }
.rmc-field label { font: 600 15px/1.3 var(--rmc-body); color: var(--rmc-text); }
.rmc-field input, .rmc-field select, .rmc-field textarea {
  display: block; width: 100%; max-width: 100%; height: 48px; padding: 0 12px;
  border: 1px solid var(--rmc-field-line); border-radius: var(--rmc-radius); background: var(--rmc-white); color: var(--rmc-text);
  font: 400 16px/1.2 var(--rmc-body); box-shadow: none;
}
.rmc-field textarea { height: auto; min-height: 84px; padding: 10px 12px; line-height: 1.45; resize: vertical; }
.rmc-field input:focus, .rmc-field select:focus, .rmc-field textarea:focus { outline: 2px solid var(--rmc-blue); outline-offset: 2px; border-color: var(--rmc-blue); box-shadow: none; }
.rmc-check input[type="checkbox"]:focus-visible { outline: 2px solid var(--rmc-blue); outline-offset: 2px; }
.rmc-fineprint a:focus-visible { outline: 2px solid var(--rmc-blue); outline-offset: 2px; border-radius: 2px; }
.rmc-optional { font-weight: 400; color: var(--rmc-muted); }
.rmc-check { grid-template-columns: auto 1fr; align-items: start; column-gap: 10px; }
.rmc-check input[type="checkbox"] { width: 22px; height: 22px; margin: 1px 0 0; padding: 0; accent-color: var(--rmc-blue); cursor: pointer; }
.rmc-check label { font-weight: 500; line-height: 1.45; cursor: pointer; }
.rmc-check .rmc-field__error { grid-column: 1 / -1; }
.rmc-check input[aria-invalid="true"] { outline: 2px solid var(--rmc-error); outline-offset: 2px; }
.rmc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.rmc-row > .rmc-field { min-width: 0; }
@media (max-width: 340px) { .rmc-row { grid-template-columns: 1fr; } }
.rmc-field [aria-invalid="true"] { border-color: var(--rmc-error); border-width: 2px; }
.rmc-field__hint { font-size: 14px; line-height: 1.4; color: var(--rmc-muted); }
.rmc-field__error { font: 600 14px/1.4 var(--rmc-body); color: var(--rmc-error); }
.rmc-callback__status { margin-top: 12px; font-size: 15px; line-height: 1.45; min-height: 1px; }
.rmc-callback__status[data-kind="error"] { color: var(--rmc-error); font-weight: 600; }
.rmc-callback__status[data-kind="busy"] { color: var(--rmc-muted); }
.rmc-callback__buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.rmc-callback__buttons .rmc-btn { min-height: 46px; padding: 10px 18px; font-size: 17px; }
.rmc-fineprint { margin-top: 16px; font-size: 12px; line-height: 1.45; color: var(--rmc-muted); }
.rmc-fineprint a { color: var(--rmc-blue); }
.rmc-done:focus { outline: none; }
.rmc-done p { margin-top: 8px; font-size: 16px; line-height: 1.5; }
.rmc-hp { position: absolute !important; left: -10000px !important; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---- Phones and small tablets -------------------------------------------------------------------------------------------- */
/* Rite Maps Tools sets --rm-cookie-offset while its notice shows: a bar across the bottom up to 640px, a 436px card bottom-left
   above that. Up to 900px the panel (right 424px) and that card (left 460px) would overlap, so the chat moves up while the notice
   shows. Wider, the launcher stays put: the launcher carries data-cookie-keep-clear, so the card never moves under it. */
@media (max-width: 900px) {
  .rmc { --rmc-offset: var(--rm-cookie-offset, 0px); }
}
@media (max-width: 600px) {
  .rmc { --rmc-gap: 16px; }
  .rmc-launcher { min-width: 58px; min-height: 58px; padding: 9px; gap: 0; }
  .rmc-launcher__icon { width: 40px; height: 40px; }
  .rmc-launcher__text { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .rmc-launcher__badge { left: auto; right: 4px; top: 4px; }
  .rmc[data-state="open"] .rmc-launcher { display: none; }
  .rmc-head__li {
    display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; margin-right: -6px;
    border-radius: 8px; color: var(--rmc-blue); -webkit-tap-highlight-color: transparent;
  }
  .rmc-head__li:hover { background: rgba(5, 53, 126, .08); }
  .rmc-head__li:focus-visible { outline: 2px solid var(--rmc-blue); outline-offset: -2px; }
  .rmc-head__li svg { display: block; width: 24px; height: 24px; }
  /* A full-width sheet from the bottom of the screen (above the cookie notice while it shows). It stops below the site header
     (about 64px on phones) so the page's own logo and menu stay whole above it. */
  .rmc-panel {
    left: 0; right: 0; bottom: var(--rmc-offset); top: auto; width: auto;
    height: calc(100vh - var(--rmc-offset) - var(--rmc-sheet-top, 72px));
    height: calc(100dvh - var(--rmc-offset) - var(--rmc-sheet-top, 72px));
    min-height: min(320px, calc(100dvh - var(--rmc-offset)));
    max-height: 760px;
    border-width: 1px 0 0; border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(5, 53, 126, .2);
    animation-name: rmc-up;
  }
  .rmc-ask { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .rmc-view--callback { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .rmc-msg { max-width: 92%; }
  /* The three main buttons stay on one line that scrolls sideways, so the conversation keeps the room. */
  .rmc-actions { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; scroll-padding: 0 14px; }
  .rmc-actions::-webkit-scrollbar { display: none; }
  .rmc-actions > * { flex: 0 0 auto; }
}
@keyframes rmc-up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (pointer: coarse) {
  .rmc-btn, .rmc-chip { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .rmc *, .rmc *::before, .rmc *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .rmc-launcher, .rmc-panel, .rmc-btn, .rmc-chip, .rmc-msg__text, .rmc-ask__input, .rmc-ask__send { border: 1px solid CanvasText; }
  .rmc-status__dot, .rmc-launcher__badge { forced-color-adjust: none; }
}
@media print {
  .rmc { display: none !important; }
}
