/* =====================================================
   PATCH CHAT BUTTON
   Floating mascot button, bottom right. Head art is the
   inlined /images/brand/patch/patch-head-filled.svg, so
   its light state and expression come from classes on
   that <svg> (patch--idle / patch--thinking / patch--done).
===================================================== */
.patch-chat {
  --pc-size: 72px; /* laptop/desktop; smaller steps below */
  position: fixed;
  right: max(28px, calc(env(safe-area-inset-right, 0px) + 16px));
  bottom: max(28px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  z-index: 500; /* under the contact modal (600) and grain (900, no pointer events) */
  display: flex;
  align-items: flex-end;
  gap: 10px;
  transition: opacity 0.25s ease, transform 0.25s var(--ease, ease);
}
.patch-chat.is-hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.patch-chat-btn {
  width: var(--pc-size);
  height: var(--pc-size);
  flex: none;
  border-radius: 50%;
  background: #0D1117; /* midnight, so the graphite body reads */
  border: 1.5px solid #4ECBA0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  padding: 0;
  cursor: pointer;
  overflow: visible; /* the antenna rises past the ring */
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.patch-chat-btn svg,
.patch-chat-btn img {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.patch-chat-btn img { border-radius: 50%; overflow: hidden; }
.patch-chat-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(78, 203, 160, 0.12); }
.patch-chat-btn:focus-visible { outline: 2px solid #4ECBA0; outline-offset: 3px; }

/* Proactive greeting: a speech bubble with tap-to-ask chips, once per visit */
.patch-greet {
  position: relative;
  margin-bottom: calc(var(--pc-size) - 10px);
  width: 280px;
  background: #1E2328;
  border: 1px solid rgba(78, 203, 160, 0.28);
  border-radius: 16px 16px 4px 16px;
  padding: 14px 14px 12px;
  color: #E8F4F0;
  font: 400 14.5px/1.45 Figtree, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.3s ease, transform 0.3s var(--ease, ease);
}
.patch-greet.is-shown { opacity: 1; transform: none; }
.patch-greet-text { margin: 0 22px 10px 0; cursor: pointer; }
.patch-greet-chips { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.patch-greet-chip {
  border: 1px solid rgba(78, 203, 160, 0.4);
  background: transparent;
  color: #E8F4F0;
  font: 500 13.5px/1.3 Figtree, -apple-system, "Segoe UI", sans-serif;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.patch-greet-chip:hover { background: rgba(78, 203, 160, 0.12); border-color: #4ECBA0; }
.patch-greet-chip:focus-visible { outline: 2px solid #4ECBA0; outline-offset: 2px; }
.patch-greet-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(232, 244, 240, 0.55);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.patch-greet-close:hover { color: #E8F4F0; background: rgba(232, 244, 240, 0.06); }
.patch-greet-close:focus-visible { outline: 2px solid #4ECBA0; }

/* =====================================================
   CHAT PANEL
   Opens above the button; a near-full-screen sheet on phones.
===================================================== */
.patch-panel {
  --pp-gap: 16px;
  position: fixed;
  right: max(28px, calc(env(safe-area-inset-right, 0px) + 16px));
  bottom: calc(max(28px, calc(env(safe-area-inset-bottom, 0px) + 16px)) + 72px + var(--pp-gap));
  z-index: 550; /* over the button's layer, under the contact modal (600) */
  width: 384px;
  height: min(620px, calc(100vh - 160px));
  height: min(620px, calc(100dvh - 160px));
  display: flex;
  flex-direction: column;
  background: #10161E;
  border: 1px solid rgba(78, 203, 160, 0.22);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  color: #E8F4F0;
  font: 400 15px/1.5 Figtree, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s var(--ease, ease);
}
.patch-panel.is-open { opacity: 1; transform: none; }
.patch-panel[hidden] { display: none; }

.patch-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 14px 16px;
  border-bottom: 1px solid rgba(78, 203, 160, 0.12);
  background: #0D1117;
}
.patch-panel-avatar {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(78, 203, 160, 0.5);
  background: #0D1117;
  overflow: hidden;
}
.patch-panel-avatar img { width: 100%; height: 100%; display: block; transform: scale(1.36) translateY(-14.3%); } /* same framing as the button: face centred */
.patch-panel-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.patch-panel-title strong { font-weight: 500; font-size: 15px; }
.patch-panel-title span { font-size: 12.5px; color: rgba(232, 244, 240, 0.55); }
.patch-panel-reset,
.patch-panel-close {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(232, 244, 240, 0.6);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.patch-panel-reset svg { width: 17px; height: 17px; }
.patch-panel-reset:hover,
.patch-panel-close:hover { color: #E8F4F0; background: rgba(232, 244, 240, 0.06); }
.patch-panel-reset:focus-visible,
.patch-panel-close:focus-visible { outline: 2px solid #4ECBA0; outline-offset: 1px; }

.patch-log {
  position: relative; /* offsetTop of messages is measured from here */
  scrollbar-width: thin;
  scrollbar-color: rgba(78, 203, 160, 0.35) transparent;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.patch-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  overflow-wrap: anywhere;
}
.patch-msg--bot {
  align-self: flex-start;
  background: #1E2328;
  border-bottom-left-radius: 5px;
}
.patch-msg--user {
  align-self: flex-end;
  background: #4ECBA0;
  color: #0D1117;
  border-bottom-right-radius: 5px;
}
.patch-msg a { color: #4ECBA0; text-decoration: underline; text-underline-offset: 2px; }
.patch-msg strong { font-weight: 600; }
.patch-li { display: block; position: relative; padding-left: 16px; margin: 3px 0; }
.patch-li::before { content: ''; position: absolute; left: 3px; top: 0.65em; width: 5px; height: 5px; border-radius: 50%; background: #4ECBA0; }

/* Typing dots while waiting for the first words */
.patch-msg.is-typing { display: flex; gap: 5px; padding: 15px 16px; }
.patch-msg.is-typing::before,
.patch-msg.is-typing::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: rgba(232, 244, 240, 0.5); animation: patch-dot 1.1s infinite ease-in-out; }
.patch-msg.is-typing::after { animation-delay: 0.18s; }
@keyframes patch-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.patch-note {
  align-self: center;
  font-size: 12.5px;
  color: #4ECBA0;
  padding: 4px 12px;
  border: 1px solid rgba(78, 203, 160, 0.3);
  border-radius: 999px;
}

.patch-starters { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 12px; }
.patch-starters[hidden] { display: none; }
.patch-starter {
  border: 1px solid rgba(78, 203, 160, 0.35);
  background: transparent;
  color: #E8F4F0;
  font: 500 13.5px/1.3 Figtree, -apple-system, "Segoe UI", sans-serif;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.patch-starter:hover { background: rgba(78, 203, 160, 0.1); border-color: #4ECBA0; }
.patch-starter:focus-visible { outline: 2px solid #4ECBA0; outline-offset: 2px; }

.patch-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 4px 12px 0;
  padding: 6px 6px 6px 14px;
  background: #1E2328;
  border: 1px solid rgba(232, 244, 240, 0.1);
  border-radius: 14px;
}
.patch-form:focus-within { border-color: rgba(78, 203, 160, 0.6); }
.patch-input {
  flex: 1;
  min-height: 24px;
  max-height: 120px;
  margin: 6px 0;
  border: 0;
  background: transparent;
  color: #E8F4F0;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming on focus */
  line-height: 1.4;
  resize: none;
  outline: none;
}
.patch-input::placeholder { color: rgba(232, 244, 240, 0.4); }
.patch-send {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: #4ECBA0;
  color: #0D1117;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.patch-send svg { width: 18px; height: 18px; }
.patch-send:disabled { opacity: 0.45; cursor: default; }
.patch-send:focus-visible { outline: 2px solid #E8F4F0; outline-offset: 2px; }

.patch-foot {
  margin: 0;
  padding: 8px 16px 12px;
  font-size: 11.5px;
  line-height: 1.4;
  color: rgba(232, 244, 240, 0.45);
  text-align: center;
}
.patch-foot a { color: rgba(232, 244, 240, 0.7); }

.patch-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* =====================================================
   HERO CHAT (homepage)
   Patch peeks over a light card: the one light surface
   on the page. Same conversation as the panel.
===================================================== */
.ph { position: relative; z-index: 1; padding-top: 158px; }
.ph-patch {
  position: absolute;
  z-index: 0;
  top: 0;
  right: 36px;
  width: 168px;
  animation: ph-bob 4.5s ease-in-out infinite;
}
.ph-patch svg,
.ph-patch img { width: 100%; height: auto; display: block; overflow: visible; }
@keyframes ph-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.ph-card {
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, #1B2D2A 0%, #16232A 100%);
  color: #E8F4F0;
  border: 1.5px solid rgba(78, 203, 160, 0.55);
  border-radius: 16px;
  padding: 20px 20px 14px;
  box-shadow:
    0 40px 80px -30px rgba(0, 0, 0, 0.75),
    0 0 90px -12px rgba(78, 203, 160, 0.38);
}
.ph-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ph-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #4ECBA0;
}
.ph-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ECBA0; box-shadow: 0 0 0 3px rgba(78, 203, 160, 0.18); }
.ph.is-busy .ph-dot { animation: ph-blink 1s ease-in-out infinite; }
@keyframes ph-blink { 50% { opacity: 0.35; } }
.ph-tag {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: rgba(232, 244, 240, 0.5);
  border: 1px solid rgba(232, 244, 240, 0.16);
  border-radius: 999px;
  padding: 2px 8px;
}

.ph-log {
  position: relative; /* offsetTop of messages is measured from here */
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(78, 203, 160, 0.35) transparent;
}
.ph-log::-webkit-scrollbar, .patch-log::-webkit-scrollbar { width: 6px; }
.ph-log::-webkit-scrollbar-track, .patch-log::-webkit-scrollbar-track { background: transparent; }
.ph-log::-webkit-scrollbar-thumb, .patch-log::-webkit-scrollbar-thumb { background: rgba(78, 203, 160, 0.35); border-radius: 3px; }
.ph-card .patch-msg { font-size: 15px; line-height: 1.5; max-width: 88%; }
.ph-card .patch-msg--bot { background: #26393A; color: #F2FAF7; border: 1px solid rgba(78, 203, 160, 0.14); border-bottom-left-radius: 4px; }
.ph-card .patch-msg--user { background: #4ECBA0; color: #0D1117; border-bottom-right-radius: 4px; }
.ph-card .patch-msg a { color: #4ECBA0; }
.ph-card .patch-li::before { background: #4ECBA0; }
.ph-card .patch-msg.is-typing::before,
.ph-card .patch-msg.is-typing::after { background: rgba(232, 244, 240, 0.5); }
.ph-card .patch-note { color: #4ECBA0; border-color: rgba(78, 203, 160, 0.35); }

.ph-opts { display: grid; gap: 8px; margin-top: 12px; }
.ph-opts[hidden] { display: none; }
.ph-opt {
  text-align: left;
  font: 500 15px/1.3 Figtree, -apple-system, "Segoe UI", sans-serif;
  color: #E8F4F0;
  background: rgba(78, 203, 160, 0.06);
  border: 1px solid rgba(78, 203, 160, 0.4);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.ph-opt:hover { background: rgba(78, 203, 160, 0.1); border-color: #4ECBA0; }
.ph-opt:active { transform: scale(0.985); }
.ph-opt:focus-visible { outline: 2px solid #4ECBA0; outline-offset: 2px; }

.ph-input {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 5px 5px 5px 14px;
  border: 1px solid rgba(78, 203, 160, 0.35);
  border-radius: 12px;
  background: #0F1A1D;
}
.ph-input:focus-within { border-color: rgba(78, 203, 160, 0.6); }
.ph-input input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: 400 16px Figtree, -apple-system, "Segoe UI", sans-serif; /* 16px stops iOS zooming on focus */
  color: #E8F4F0;
}
.ph-input input::placeholder { color: rgba(232, 244, 240, 0.4); }
.ph-send {
  width: 34px;
  height: 34px;
  flex: none;
  border: 0;
  border-radius: 9px;
  background: #4ECBA0;
  color: #0D1117;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.ph-send svg { width: 17px; height: 17px; }
.ph-send:disabled { opacity: 0.4; cursor: default; }
.ph-send:focus-visible { outline: 2px solid #E8F4F0; outline-offset: 2px; }
.ph .ph-foot {
  margin: 10px 0 0;
  max-width: none;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(232, 244, 240, 0.45);
  text-align: center;
}
.ph-foot a { color: rgba(232, 244, 240, 0.75); text-decoration: underline; text-underline-offset: 2px; }

/* Hero at rest (no conversation yet): Patch is the hero, the card
   melts away and the greeting becomes his speech bubble. */
.ph.is-idle { padding-top: 0; }
.ph.is-idle .ph-patch {
  position: relative; top: auto; right: auto;
  width: 250px; margin: 0 auto 4px;
}
.ph.is-idle .ph-card { background: transparent; border-color: transparent; box-shadow: none; padding: 0; }
.ph.is-idle .ph-head { display: none; }
.ph.is-idle .ph-log { overflow: visible; max-height: none; padding: 0; }
.ph.is-idle .ph-greeting {
  position: relative; max-width: none;
  font-size: 17px; line-height: 1.5;
  background: #1B2D2A; border: 1.5px solid rgba(78, 203, 160, 0.55);
  border-radius: 16px; padding: 16px 18px;
  box-shadow: 0 0 60px -14px rgba(78, 203, 160, 0.35);
}
.ph.is-idle .ph-greeting::before {
  content: ''; position: absolute; top: -9px; left: 50%;
  width: 16px; height: 16px; transform: translateX(-50%) rotate(45deg);
  background: #1B2D2A;
  border-top: 1.5px solid rgba(78, 203, 160, 0.55);
  border-left: 1.5px solid rgba(78, 203, 160, 0.55);
}
.ph.is-idle .ph-opts { grid-template-columns: 1fr 1fr; }
.ph.is-idle .ph-opt { font-size: 14px; padding: 10px 12px; border-radius: 12px; text-align: center; display: flex; align-items: center; justify-content: center; }
.ph:not(.is-idle) .ph-card { animation: ph-in 0.35s ease; }
@keyframes ph-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) {
  .ph.is-idle .ph-patch { width: 140px; }
  .ph.is-idle .ph-opts { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .ph:not(.is-idle) .ph-card { animation: none; } }

@media (max-width: 1080px) {
  .ph { padding-top: 140px; }
  .ph-patch { width: 150px; right: 24px; }
}
@media (max-width: 600px) {
  .ph-card { padding: 18px 14px 12px; }
  .ph-log { max-height: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  .ph-patch, .ph.is-busy .ph-dot { animation: none; }
}

@media (max-width: 1080px) {
  .patch-panel {
    right: max(24px, calc(env(safe-area-inset-right, 0px) + 16px));
    bottom: calc(max(24px, calc(env(safe-area-inset-bottom, 0px) + 16px)) + 64px + var(--pp-gap));
  }
}

@media (max-width: 600px) {
  /* A floating sheet with the site still showing around the edges */
  .patch-panel {
    top: auto;
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    width: auto;
    height: min(560px, 74vh);
    height: min(560px, 74dvh);
    border-radius: 20px;
    box-shadow: 0 0 0 100vmax rgba(13, 17, 23, 0.4), 0 24px 64px rgba(0, 0, 0, 0.55);
    transform: translateY(24px);
  }
  .patch-msg { max-width: 90%; }
  html.patch-lock, html.patch-lock body { overflow: hidden; }
}

@media (max-width: 1080px) {
  .patch-chat { --pc-size: 64px; right: max(24px, calc(env(safe-area-inset-right, 0px) + 16px)); bottom: max(24px, calc(env(safe-area-inset-bottom, 0px) + 16px)); }
}

@media (max-width: 600px) {
  .patch-chat { --pc-size: 52px; right: max(16px, calc(env(safe-area-inset-right, 0px) + 12px)); bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px)); }
  .patch-greet { width: min(250px, calc(100vw - 100px)); font-size: 14px; padding: 12px 12px 10px; }
  .patch-greet-chip:nth-child(n+3) { display: none; } /* two questions is plenty on a phone */
  .patch-greet-chip { font-size: 13px; padding: 6px 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .patch-chat, .patch-chat-btn, .patch-greet, .patch-panel { transition: none; }
  .patch-msg.is-typing::before, .patch-msg.is-typing::after { animation: none; }
  .patch-chat-btn:hover { transform: none; }
}

/* Discovery-form link inside a reply, shown as a button */
.patch-msg a.patch-cta,
.ph-card .patch-msg a.patch-cta {
  display: flex; width: fit-content; align-items: center; gap: 6px;
  margin-top: 10px; padding: 9px 16px; border-radius: 999px;
  background: #4ECBA0; color: #0D1117; font-weight: 600; font-size: 14px;
  text-decoration: none; transition: filter 0.15s ease;
}
.patch-msg a.patch-cta:hover { filter: brightness(1.08); }
.patch-msg a.patch-cta:focus-visible { outline: 2px solid #E8F4F0; outline-offset: 2px; }
