/* Reet — the front door's assistant.
 *
 * EVERY ANSWER REET GIVES IS A PUBLIC CLAIM (A-96), the same burden the rest of
 * marketing.html carries. The script lives in `reet.js` and says nothing this
 * page does not already say; the two prices come from `app/plans.py`, which is
 * what actually bills.
 *
 * NO COLOUR IS DECLARED HERE. Everything is a token from `returnready.css`, so
 * Reet cannot drift from the page it sits on and a palette change reaches it
 * for free. `--good`, `--bad` and `--warn` are deliberately untouched: R-035
 * reserves them for whether a figure is proved, and a chat bubble is not a
 * figure.
 */

.reet {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  /* The phone's home indicator sits where the launcher wants to be. */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ------------------------------------------------------------- the launcher */

/* **A DISC, NOT A PILL, AND IT BREATHES.**
 *
 * Pravin, comparing this with the Taxman 365 assistant: it did not feel as
 * good. Most of the gap was presence. A flat rectangle of text sits on the
 * page; a disc with a slow ring around it reads as something that is there.
 * The ring is the cheapest possible version of that and it is the one thing
 * on the page that moves on its own. */
.reet__open {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .18s ease, filter .18s ease;
}
.reet__open:hover { filter: brightness(1.06); transform: translateY(-2px); }
.reet__open:active { transform: translateY(0); }
.reet__open[hidden] { display: none !important; }
.reet__open .reet__mark {
  width: 30px; height: 30px;
  background: transparent;
  color: var(--bg);
  font-size: 23px;
  line-height: 30px;
}
.rr-motion .reet__open::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: reet-ping 2.6s cubic-bezier(.2, .6, .4, 1) infinite;
  pointer-events: none;
}
@keyframes reet-ping {
  0%   { transform: scale(.86); opacity: .55; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* The mark: a lowercase r with the wordmark's own underline beneath it, so the
   launcher reads as part of Return Ready rather than a bolted-on vendor pill. */
.reet__mark {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--bg);
  color: var(--accent);
  font-family: var(--serif);
  font-weight: 400;
  font-size: 16px;
  line-height: 22px;
  text-align: center;
  flex-shrink: 0;
}
.reet__mark::after {
  content: "";
  position: absolute;
  left: 5px; right: 5px; bottom: 4px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}
/* Bigger in the header, where it is the identity rather than an icon. */
.reet__head .reet__mark {
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 21px;
  line-height: 33px;
  background: var(--bg);
  color: var(--accent);
}
.reet__head .reet__mark::after { display: none; }

/* --------------------------------------------------------------- the panel */

.reet__panel {
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: min(600px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.reet__panel[hidden] { display: none !important; }

.rr-motion .reet__panel {
  animation: reet-in .22s cubic-bezier(.2, .7, .3, 1) both;
}
@keyframes reet-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* The head carries the accent rather than borrowing the body's grey. It is the
   one band of colour in the panel and it is what makes the thing read as a
   conversation with somebody instead of a box of text. */
.reet__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 14px 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--accent);
  color: var(--bg);
}
.reet__head .reet__name { color: var(--bg); }
.reet__head .reet__role { color: var(--bg); opacity: .72; }
.reet__head .reet__close { border-color: transparent; color: var(--bg); opacity: .75; }
.reet__head .reet__close:hover { opacity: 1; color: var(--bg);
                                 border-color: var(--bg); }

/* **THE GREEN "ONLINE" DOT IS NOT HERE, AND THAT IS A DECISION.**
 *
 * The Taxman 365 assistant has one, and it is the single detail that does most
 * to make a widget feel alive. It was written, and `test_reet_paints_no_colour_
 * a_theme_cannot_reach` caught the literal `#4ADE80` - correctly, because no
 * token can mean "online".
 *
 * Reaching for a token would have been the wrong fix. A presence dot says
 * somebody is there, and for a script nobody is - it is the same claim as
 * "usually replies within minutes", which was declined for the same reason.
 * The panel says what she is: answers from a script, a person if you ask.
 * A page that tells the truth in the footer and lies with a dot has still
 * lied. */
.reet__name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 400;
  line-height: 1.1;
  color: var(--ink);
  margin: 0;
}
.reet__role {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 3px;
}
.reet__close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.reet__close:hover { color: var(--ink); border-color: var(--border-strong); }

.reet__log {
  flex-grow: 1;
  /* WITHOUT THIS THE CONVERSATION IS 61px TALL. A flex item will not shrink
     below its content unless told to, so `flex-grow: 1` won a fight it should
     have lost: the panel is height-capped, the chips took their full height,
     and the log kept its scrollHeight while showing a third of it. Found by
     asking the browser for clientHeight, not by reading this file. */
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rr-motion .reet__msg,
.rr-motion .reet__chips { animation: reet-rise .28s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes reet-rise {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}

.reet__msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 13px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-line;
}
.reet__msg--reet {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  color: var(--ink);
}
.reet__msg--you {
  align-self: flex-end;
  background: var(--accent);
  border: 1px solid transparent;
  border-bottom-right-radius: 5px;
  color: var(--bg);
}
.reet__msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.reet__msg--reet a { color: var(--accent); }

/* Suggested questions. A scripted assistant lives or dies on these: they are
   the only honest way to show a visitor what it can actually answer, instead
   of letting an empty text box imply it can answer anything. */
.reet__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: -2px;
  max-width: 100%;
}
.reet__chip {
  padding: 8px 13px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.reet__chip:hover { background: var(--accent); color: var(--bg); }

.reet__form {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.reet__input {
  flex-grow: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.reet__input::placeholder { color: var(--ink-3); }
.reet__input:focus { outline: none; border-color: var(--accent); }
.reet__send {
  flex-shrink: 0;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--accent);
  color: var(--bg);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.reet__send:hover { filter: brightness(1.06); }

.reet__foot {
  padding: 0 16px 12px;
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-3);
}

/* The input needs a real label for a screen reader, and no room for one on
   screen. Namespaced because this stylesheet may not add a global utility to
   a page it is a guest on. */
.reet__vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Keyboard users must be able to see where they are. */
.reet :is(button, input, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .reet__panel { animation: none; }
  .reet__open { transition: none; }
}

/* On a phone the panel is the screen, not a card floating on it. */
@media (max-width: 520px) {
  .reet { right: 12px; bottom: 12px; left: 12px; align-items: stretch; }
  .reet__panel { width: auto; max-height: calc(100vh - 96px); }
  .reet__open { align-self: flex-end; }
}
/* ---------------------------------------------------- the hint and the badge
 *
 * The nudge before the panel. It is quieter than opening the whole thing over
 * somebody's first look at the page, and it is what the launcher says when it
 * has something unread.
 */
.reet__hint {
  max-width: 250px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 14px 14px 4px 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
}
.reet__hint[hidden] { display: none !important; }
.rr-motion .reet__hint { animation: reet-in .3s cubic-bezier(.2, .7, .3, 1) both; }

.reet__open { position: relative; }
.reet__badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 17px;
  text-align: center;
}
.reet__badge[hidden] { display: none !important; }

/* ------------------------------------------------------------ typing dots
 *
 * Reet is a script and answers instantly, which reads as a canned response
 * rather than an answer. The pause is not pretending to think - it is the
 * beat that lets somebody finish reading their own question before the reply
 * lands on top of it.
 */
.reet__typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 13px;
}
.reet__typing i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: reet-blink 1.15s infinite ease-in-out both;
}
.reet__typing i:nth-child(2) { animation-delay: .16s; }
.reet__typing i:nth-child(3) { animation-delay: .32s; }
@keyframes reet-blink {
  0%, 70%, 100% { opacity: .28; transform: translateY(0); }
  35%           { opacity: 1;   transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  .reet__typing i { animation: none; opacity: .5; }
  .reet__hint, .reet__msg, .reet__chips { animation: none; }
  .reet__open::before { animation: none; opacity: 0; }
}

/* A chip that starts something rather than asking something. */
.reet__chip--go {
  border-color: var(--accent);
  color: var(--accent);
}
.reet__chip--go:hover { color: var(--bg); background: var(--accent); border-color: var(--accent); }

/* The line under the input while Reet is taking a name and an address, so it
   is never a mystery what the box now wants. */
.reet__step {
  padding: 0 16px 10px;
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.reet__step[hidden] { display: none !important; }
