/* ---------------------------------------------------------------------------
   Gib-San — Pool Care Assistant, surface
   Built on tokens.css. Square corners throughout: their brand does not round
   things, and an assistant with a 16px radius on it is the one element on the
   page that stops looking like Gib-San.
   --------------------------------------------------------------------------- */

/* ============================================================== launcher */

.gsa-launch {
  position: fixed;
  right: var(--gutter);
  bottom: calc(58px + var(--gutter) + env(safe-area-inset-bottom)); /* clears the action bar */
  z-index: var(--z-bar);

  display: inline-flex; align-items: center; gap: .55rem;
  min-height: 52px; padding: 0 1rem;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--accent); color: var(--ink-page);
  font-family: var(--font-head); font-weight: 700; font-size: .95rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out),
              background var(--dur-short) var(--ease-out);
}
.gsa-launch:hover { background: var(--accent-press); transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.gsa-launch:active { transform: translateY(0); box-shadow: none; }
.gsa-launch__icon { width: 22px; height: 22px; flex: 0 0 auto; }

@media (min-width: 49rem) {
  .gsa-launch { bottom: var(--gutter); }
}
@media (max-width: 24rem) {
  .gsa-launch__text { display: none; }
  .gsa-launch { padding: 0; width: 52px; justify-content: center; }
}

/* the launcher steps aside while the panel is up, so the two never overlap */
html.gsa-open .gsa-launch { opacity: 0; pointer-events: none; }
@media (min-width: 46rem) {
  html.gsa-open .gsa-launch { opacity: 1; pointer-events: auto; }
}

/* ================================================================= panel */

.gsa {
  display: flex; flex-direction: column;
  background: var(--pane-solid);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink-body);
  box-shadow: var(--shadow-glass);
  overflow: hidden;
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .gsa {
    background: rgba(250, 252, 255, 0.90);
    -webkit-backdrop-filter: blur(var(--glass-blur-lt)) saturate(150%);
    backdrop-filter: blur(var(--glass-blur-lt)) saturate(150%);
  }
}

.gsa--float {
  position: fixed;
  z-index: var(--z-sheet);
  right: 0; left: 0;
  bottom: 0;
  height: min(78vh, 620px);
  padding-bottom: env(safe-area-inset-bottom);
  border-width: 2px 0 0 0;
}
@media (min-width: 46rem) {
  .gsa--float {
    right: var(--gutter); left: auto;
    bottom: calc(var(--gutter) + 64px);
    width: min(420px, calc(100vw - 2 * var(--gutter)));
    height: min(70vh, 600px);
    border-width: 2px;
  }
}

.gsa--inline {
  /* a conversation set to 68ch reads like a wall; the panel keeps a column */
  max-width: 46rem;
  height: min(540px, 74vh);
  min-height: 420px;
}

.gsa[hidden] { display: none; }

/* --------------------------------------------------------------- head */

.gsa__head {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .9rem 1rem;
  background: var(--ink-950);
  color: var(--ink-inverse);
  border-bottom: 4px solid var(--secondary);
  box-shadow: var(--waterline);
}
.gsa__heading { flex: 1 1 auto; min-width: 0; }
.gsa__title {
  margin: 0; font-family: var(--font-head); font-weight: 700;
  font-size: 1.05rem; letter-spacing: var(--track-head);
  color: var(--ink-inverse); max-width: none;
}
.gsa__sub {
  margin: .15rem 0 0; font-size: .82rem; line-height: 1.35;
  color: var(--ink-on-dark-2); max-width: none;
}
.gsa__close {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--rule-on-dark-2); border-radius: var(--radius);
  background: transparent; color: var(--ink-inverse);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
  transition: background var(--dur-short) var(--ease-out);
}
.gsa__close:hover { background: rgba(255, 255, 255, .12); }
.gsa__close:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }

/* ---------------------------------------------------------------- log */

.gsa__log {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 1rem;
  display: flex; flex-direction: column; gap: .75rem;
  scroll-behavior: smooth;
}
.gsa__log:focus-visible { outline: 3px solid var(--secondary-deep); outline-offset: -3px; }

.gsa__msg { display: flex; max-width: 100%; }
.gsa__msg--you { justify-content: flex-end; }
.gsa__msg--bot { justify-content: flex-start; }

.gsa__bubble {
  max-width: 92%;
  padding: .7rem .85rem;
  border-radius: var(--radius);
  font-size: .93rem; line-height: 1.55;
}
.gsa__bubble p { margin: 0 0 .6rem; max-width: none; }
.gsa__bubble p:last-child { margin-bottom: 0; }

.gsa__msg--bot .gsa__bubble {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--secondary);
  color: var(--ink-body);
}
.gsa__msg--you .gsa__bubble {
  background: var(--ink-950);
  border: 1px solid var(--ink-950);
  color: var(--ink-inverse);
}

.gsa__answerTitle {
  font-family: var(--font-head); font-weight: 700;
  color: var(--ink-page); letter-spacing: var(--track-head);
  margin-bottom: .35rem !important;
}

.gsa__links {
  display: flex; flex-wrap: wrap; gap: .4rem;
  margin-top: .7rem !important;
}
.gsa__link {
  display: inline-flex; align-items: center;
  min-height: 38px; padding: 0 .7rem;
  border: 1.5px solid var(--ink-page); border-radius: var(--radius);
  background: transparent; color: var(--ink-page);
  font-family: var(--font-head); font-weight: 700; font-size: .82rem;
  text-decoration: none;
  transition: background var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}
.gsa__link:hover { background: var(--ink-page); color: var(--ink-inverse); }
.gsa__link:first-child { background: var(--accent); border-color: var(--ink-page); }
.gsa__link:first-child:hover { background: var(--accent-press); color: var(--ink-page); }

.gsa__related { font-size: .82rem; color: var(--ink-muted); margin-top: .55rem !important; }
.gsa__more {
  border: 0; background: none; padding: 0;
  font: inherit; color: var(--secondary-deep); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.gsa__more:hover { color: var(--ink-page); }

/* the wait — three dots on their cyan */
.gsa__bubble--thinking { display: inline-flex; gap: .3rem; align-items: center; padding: .85rem; }
.gsa__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--secondary);
  animation: gsa-pulse 1.1s var(--ease-in-out) infinite;
}
.gsa__dot:nth-child(2) { animation-delay: .16s; }
.gsa__dot:nth-child(3) { animation-delay: .32s; }
@keyframes gsa-pulse {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* -------------------------------------------------------------- chips */

.gsa__chips {
  display: flex; flex-wrap: wrap; gap: .4rem;
  padding: 0 1rem .75rem;
}
.gsa__chips[hidden] { display: none; }
.gsa__chip {
  min-height: 36px; padding: 0 .7rem;
  border: 1px solid var(--secondary-deep); border-radius: var(--radius);
  background: var(--paper); color: var(--secondary-deep);
  font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: background var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}
.gsa__chip:hover { background: var(--secondary-deep); color: var(--ink-inverse); }

/* --------------------------------------------------------------- form */

.gsa__form {
  display: flex; gap: .5rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--hairline);
  background: var(--paper);
}
.gsa__input {
  flex: 1 1 auto; min-width: 0;
  min-height: 46px; padding: 0 .75rem;
  border: 1px solid var(--hairline);
  border-bottom: 2px solid var(--ink-page);
  border-radius: var(--radius);
  background: var(--paper-field); color: var(--ink-page);
  font: inherit; font-size: 1rem; /* 16px — iOS must not zoom on focus */
}
.gsa__input::placeholder { color: var(--ink-muted); opacity: 1; }
.gsa__input:focus { outline: 3px solid var(--secondary-deep); outline-offset: 1px; }
.gsa__send {
  flex: 0 0 auto;
  min-height: 46px; padding: 0 1rem;
  border: 2px solid var(--ink-page); border-radius: var(--radius);
  background: var(--accent); color: var(--ink-page);
  font-family: var(--font-head); font-weight: 700; cursor: pointer;
  transition: background var(--dur-short) var(--ease-out);
}
.gsa__send:hover { background: var(--accent-press); }

.gsa__foot {
  margin: 0; padding: .55rem 1rem .8rem;
  font-size: .74rem; line-height: 1.45;
  color: var(--ink-muted); background: var(--paper);
  max-width: none;
}
.gsa__foot a { color: var(--secondary-deep); }

/* the inline instance sits in the page, so it carries the page's own frame */
.gsa--inline .gsa__head { border-bottom-width: 4px; }

/* ----------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .gsa-launch, .gsa__link, .gsa__chip, .gsa__close, .gsa__send { transition: none; }
  .gsa__dot { animation: none; opacity: .6; }
  .gsa__log { scroll-behavior: auto; }
}

/* the page carries the assistant itself — the launcher would land on its own
   send button, so it stands down until the panel scrolls away */
html.gsa-inline-visible .gsa-launch { opacity: 0; pointer-events: none; }

/* ---- Gib-San colours (Oct 19): the header and your own messages take the brand water
   as a deep blue (--gs-water-deep, white text 9:1), the gold stays as the rule and the
   send button. The bright logo blue (#00BDF2) is used only as a 3px accent, never under text. */
.gsa { --gs-water-deep: #0B4F6C; --gs-water: #00BDF2; }
.gsa__head { background: linear-gradient(135deg, var(--gs-water-deep) 0%, #0A6A8E 100%); border-bottom-color: var(--lx-gold, #C9A36A); }
.gsa__msg--bot .gsa__bubble { border-left-color: var(--gs-water); }
.gsa__msg--you .gsa__bubble { background: var(--gs-water-deep); border-color: var(--gs-water-deep); }
.gsa__chip { border-color: var(--lx-gold-ink, #7E5F2E); }

/* Round 16 (site-qa, Oct 30 2026): on phones the on-page assistant grows with its content, so the
   welcome text is not cut off above the question chips; chips and links are full 44px tap targets. */
@media (max-width: 40rem) {
  .gsa--inline { height: auto; min-height: 0; }
  .gsa--inline .gsa__log { flex: 0 1 auto; max-height: 28rem; }
  .gsa__chip, .gsa__link { min-height: 44px; }
}
