/* ==========================================================================
   Routes Ask AI - glowing homepage pill + Kayak-style sidebar
   Scoped to .ra-* so it never fights the SPA or the home revamp.
   ========================================================================== */

:root {
  --ra-ink: #191c22;
  --ra-muted: #6b7280;
  --ra-line: rgba(16, 24, 40, 0.1);
  --ra-soft: #f2f4f7;
  --ra-orange: #ff6100;
  --ra-orange-deep: #d94f00;
  --ra-navy: #132a8e;
  --ra-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ra-display: "Plus Jakarta Sans", "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --ra-body: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --ra-z: 1500;
}

/* ---------- homepage floating FAB (desktop types; phone is an AI chip) ---------- */
#ra-fab.ra-pill {
  --ra-glow-a: rgba(255, 122, 132, 0.38);
  --ra-glow-b: rgba(186, 150, 230, 0.22);
  appearance: none;
  -webkit-appearance: none;
  position: fixed;
  right: 1.25rem;
  bottom: 1.35rem;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 17.75rem;
  max-width: calc(100vw - 2.5rem);
  height: 2.55rem;
  margin: 0;
  padding: 0 0.78rem 0 0.7rem;
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid rgba(255, 176, 168, 0.85);
  background: #fff;
  color: #3a3f48;
  font-family: var(--ra-body);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  min-height: 0;
  touch-action: manipulation;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 210, 204, 0.4),
    0 6px 14px -4px var(--ra-glow-a),
    0 14px 28px -10px var(--ra-glow-b);
  transition: transform 0.18s var(--ra-ease), box-shadow 0.18s var(--ra-ease), opacity 0.2s ease;
}
#ra-fab.ra-pill:hover {
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(255, 186, 176, 0.65),
    0 10px 20px -6px rgba(255, 97, 0, 0.28),
    0 18px 32px -10px rgba(190, 140, 220, 0.28);
}
#ra-fab.ra-pill:focus-visible {
  outline: 2px solid var(--ra-orange);
  outline-offset: 3px;
}
#ra-fab.ra-pill:active {
  transform: translateY(0);
}
#ra-fab[hidden],
html:not(.rv1) #ra-fab,
html.ra-open #ra-fab {
  display: none !important;
}

.ra-pill__spark {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  color: #151515;
}
.ra-pill__spark svg {
  display: block;
  width: 14px;
  height: 14px;
}
.ra-pill__type {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.ra-pill__text {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: #3a3f48;
}
.ra-pill__caret {
  flex: 0 0 auto;
  width: 1.5px;
  height: 0.85em;
  margin-left: 2px;
  border-radius: 1px;
  background: #2b2f36;
  animation: ra-caret 1s step-end infinite;
}
.ra-pill__ai {
  display: none;
  font-family: var(--ra-display);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #191c22;
}

@keyframes ra-caret {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@media (max-width: 767.98px) {
  #ra-fab.ra-pill {
    right: 1rem;
    bottom: calc(5.7rem + env(safe-area-inset-bottom, 0px));
    width: auto;
    height: 2.6rem;
    padding: 0 0.92rem 0 0.78rem;
    gap: 0.38rem;
    max-width: none;
    font-size: 0.8rem;
  }
  .ra-pill__type {
    display: none;
  }
  .ra-pill__ai {
    display: block;
  }
  .ra-pill__spark,
  .ra-pill__spark svg {
    width: 15px;
    height: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ra-pill__caret,
  .ra-shell,
  .ra-panel {
    animation: none !important;
  }
}

/* ---------- shell / overlay ---------- */
.ra-shell {
  position: fixed;
  inset: 0;
  z-index: var(--ra-z);
  pointer-events: none;
  font-family: var(--ra-body);
  color: var(--ra-ink);
}
.ra-shell.is-open {
  pointer-events: auto;
}
.ra-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 14, 20, 0.34);
  opacity: 0;
  transition: opacity 0.32s var(--ra-ease);
}
.ra-shell.is-open .ra-backdrop {
  opacity: 1;
}

.ra-panel {
  position: absolute;
  top: 0;
  right: 0;
  left: auto;
  height: 100%;
  width: min(26.5rem, 100%);
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: -18px 0 60px -24px rgba(10, 14, 24, 0.45);
  border-radius: 22px 0 0 22px;
  transform: translateX(104%);
  transition: transform 0.42s var(--ra-ease), width 0.38s var(--ra-ease);
  overflow: hidden;
}
.ra-shell.is-open .ra-panel {
  transform: none;
}
.ra-shell.is-wide .ra-panel {
  width: min(42rem, 100%);
}
.ra-shell.is-full .ra-panel {
  width: 100%;
  border-radius: 0;
}

html.ra-open,
html.ra-open body {
  overflow: hidden;
}

/* Replace the stock floating robot with the Ask AI pill + sidebar. */
button[aria-label="Open Routes Assistant"] {
  display: none !important;
}

/* ---------- header ---------- */
.ra-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.85rem 0.75rem 1.2rem;
  border-bottom: 1px solid var(--ra-line);
  flex: 0 0 auto;
}
.ra-head__title {
  margin: 0;
  flex: 1 1 auto;
  font-family: var(--ra-display);
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ra-ink);
}
.ra-head__title em {
  font-style: normal;
}
.ra-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 0 0.22em 0.12em;
  border-radius: 50%;
  background: var(--ra-orange);
  vertical-align: middle;
  box-shadow: 0 0 0 3px rgba(255, 97, 0, 0.16);
}
.ra-ico {
  appearance: none;
  border: 0;
  background: transparent;
  color: #4b5563;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.ra-ico:hover {
  background: var(--ra-soft);
  color: var(--ra-ink);
}
.ra-ico svg {
  width: 18px;
  height: 18px;
}

/* ---------- scroll body ---------- */
.ra-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 1.35rem 1.15rem 0.5rem;
  overscroll-behavior: contain;
}

.ra-welcome {
  padding: 0.35rem 0.15rem 0.4rem;
}
.ra-welcome__spark {
  width: 42px;
  height: 42px;
  color: var(--ra-orange);
  filter: drop-shadow(0 8px 14px rgba(255, 97, 0, 0.32));
  margin-bottom: 0.15rem;
}
.ra-welcome__spark svg {
  display: block;
  width: 42px;
  height: 42px;
}
.ra-welcome h2 {
  margin: 0.7rem 0 0.35rem;
  font-family: var(--ra-display);
  font-size: clamp(1.85rem, 4vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.05;
  color: var(--ra-ink);
}
.ra-loc {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font: 500 0.92rem/1.4 var(--ra-body);
  color: #4b5563;
  cursor: pointer;
}
.ra-loc strong {
  color: var(--ra-ink);
  font-weight: 700;
}
.ra-loc svg {
  width: 14px;
  height: 14px;
  color: #9aa1ac;
}

.ra-started {
  margin-top: 1.7rem;
}
.ra-started__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}
.ra-started h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ra-ink);
}
.ra-more {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: 500 0.88rem/1 var(--ra-body);
  color: #8b939e;
  cursor: pointer;
}
.ra-more:hover {
  color: var(--ra-ink);
}

.ra-suggest {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  margin: 0 0 0.55rem;
  padding: 0.85rem 0.95rem;
  border: 0;
  border-radius: 16px;
  background: var(--ra-soft);
  color: var(--ra-ink);
  font: 500 0.92rem/1.35 var(--ra-body);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.ra-suggest:hover {
  background: #e8ebf0;
}
.ra-suggest:active {
  transform: scale(0.99);
}
.ra-suggest__ico {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #3a3f48;
}
.ra-suggest__ico svg {
  width: 22px;
  height: 22px;
}

/* ---------- chat ---------- */
.ra-thread {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 0.6rem;
}
.ra-msg {
  max-width: 92%;
  animation: ra-msg-in 0.32s var(--ra-ease) both;
}
.ra-msg--user {
  align-self: flex-end;
  background: var(--ra-ink);
  color: #fff;
  padding: 0.7rem 0.9rem;
  border-radius: 16px 16px 4px 16px;
  font-size: 0.92rem;
  line-height: 1.45;
}
.ra-msg--bot {
  align-self: flex-start;
  color: var(--ra-ink);
  font-size: 0.95rem;
  line-height: 1.5;
}
.ra-msg--bot p {
  margin: 0 0 0.55rem;
}
.ra-msg--bot p:last-child {
  margin-bottom: 0;
}
.ra-cta {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.45rem 0.4rem 0 0;
  padding: 0.55rem 0.85rem;
  border: 0;
  border-radius: 999px;
  background: var(--ra-ink);
  color: #fff;
  font: 700 0.8rem/1 var(--ra-body);
  cursor: pointer;
}
.ra-cta:hover {
  background: #000;
}
.ra-cta--ghost {
  background: var(--ra-soft);
  color: var(--ra-ink);
}
.ra-typing {
  display: inline-flex;
  gap: 4px;
  padding: 0.35rem 0.1rem;
}
.ra-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c5cad3;
  animation: ra-dot 1.1s ease-in-out infinite;
}
.ra-typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.ra-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ra-msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes ra-dot {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ---------- composer ---------- */
.ra-foot {
  flex: 0 0 auto;
  padding: 0.55rem 0.95rem calc(0.7rem + env(safe-area-inset-bottom));
  background: #fff;
}
.ra-box {
  display: flex;
  flex-direction: column;
  border: 1.5px solid #d5d8de;
  border-radius: 22px;
  background: #fff;
  padding: 0.75rem 0.8rem 0.55rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ra-box:focus-within {
  border-color: #9aa1ac;
  box-shadow: 0 0 0 4px rgba(16, 24, 40, 0.04);
}
.ra-box textarea {
  width: 100%;
  border: 0;
  resize: none;
  outline: none;
  min-height: 2.6rem;
  max-height: 8.5rem;
  padding: 0.15rem 0.2rem 0.45rem;
  font: 500 1rem/1.4 var(--ra-body);
  color: var(--ra-ink);
  background: transparent;
}
.ra-box textarea::placeholder {
  color: #b0b6bf;
}
.ra-box__bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.ra-box__grow {
  flex: 1 1 auto;
}
.ra-box__bar .ra-ico {
  width: 34px;
  height: 34px;
  color: #3a3f48;
}
.ra-send {
  appearance: none;
  margin-left: 0.15rem;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #e6e8ee;
  color: #9aa1ac;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.ra-send.is-on {
  background: var(--ra-ink);
  color: #fff;
}
.ra-send.is-on:hover {
  background: #000;
}
.ra-send:disabled {
  cursor: default;
}
.ra-legal {
  margin: 0.55rem 0.15rem 0;
  font-size: 0.68rem;
  line-height: 1.4;
  color: #9aa1ac;
  text-align: center;
}
.ra-legal a {
  color: inherit;
  text-underline-offset: 2px;
}

/* ---------- history + location sheets ---------- */
.ra-sheet {
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 3;
  display: flex;
  flex-direction: column;
  transform: translateX(-8%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s var(--ra-ease), opacity 0.28s var(--ra-ease);
}
.ra-sheet.is-on {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}
.ra-sheet__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 0.85rem 0.75rem 0.7rem;
  border-bottom: 1px solid var(--ra-line);
}
.ra-sheet__head h3 {
  margin: 0;
  flex: 1;
  font-size: 1rem;
  font-weight: 800;
}
.ra-sheet__body {
  flex: 1;
  overflow: auto;
  padding: 0.7rem 0.85rem 1.2rem;
}
.ra-hist {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.8rem 0.85rem;
  margin: 0 0 0.4rem;
  border: 0;
  border-radius: 14px;
  background: var(--ra-soft);
  cursor: pointer;
  text-align: left;
  font: 600 0.9rem/1.3 var(--ra-body);
  color: var(--ra-ink);
}
.ra-hist span {
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--ra-muted);
}
.ra-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ra-muted);
  font-size: 0.9rem;
}
.ra-find {
  width: 100%;
  margin: 0 0 0.7rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--ra-line);
  border-radius: 12px;
  font: 500 0.92rem/1.3 var(--ra-body);
  outline: none;
}
.ra-find:focus {
  border-color: #9aa1ac;
}
.ra-branch {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  padding: 0.75rem 0.8rem;
  margin: 0 0 0.35rem;
  border: 0;
  border-radius: 12px;
  background: var(--ra-soft);
  cursor: pointer;
  text-align: left;
  font: 700 0.9rem/1.25 var(--ra-body);
  color: var(--ra-ink);
}
.ra-branch em {
  font-style: normal;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--ra-muted);
}

@media (max-width: 767.98px) {
  .ra-panel {
    width: 100%;
    border-radius: 0;
  }
  .ra-welcome h2 {
    font-size: 2rem;
  }
}
