/* Alpinium Agent — chat widget on every page of alpinium.ai.
   Uses the site's own tokens from alpinium.css (--ink, --signal, --line, --font-*, --ease). */

:root {
  --agt-r: clamp(1rem, 2vw, 2rem);
  --agt-b: clamp(1rem, 2vw, 2rem);
  --agt-lh: 52px;
  --agt-bg: #0A0C13;
  --agt-raise: rgba(255, 255, 255, .045);
  --agt-edge: rgba(255, 255, 255, .12);
  --agt-ok: #3DDC97;
}
@media (min-width: 1181px) { :root { --agt-r: clamp(3rem, 4.4vw, 4.6rem); } }
@media (max-width: 640px) {
  :root {
    --agt-r: max(1rem, env(safe-area-inset-right));
    --agt-b: max(1rem, env(safe-area-inset-bottom));
    --agt-lh: 48px;
  }
}

/* The back-to-top button stacks above the launcher and steps aside while the panel is open. */
html.agt-on .top { bottom: calc(var(--agt-b) + var(--agt-lh) + .75rem); }
@media (max-width: 640px) { html.agt-on .top { right: var(--agt-r); } }
html.agt-open .top { opacity: 0 !important; pointer-events: none !important; }
html.agt-lock, html.agt-lock body { overflow: hidden; }

/* ---------- launcher ---------- */
.agt-launch {
  position: fixed; right: var(--agt-r); bottom: var(--agt-b); z-index: 84;
  height: var(--agt-lh);
  display: inline-flex; align-items: center; gap: .8rem;
  padding: 0 1.3rem 0 1.05rem;
  font-family: var(--font-text); font-size: .9375rem; font-weight: 500; letter-spacing: -.005em; line-height: 1;
  color: #fff;
  background: rgba(10, 12, 19, .9);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 4px;
  box-shadow: 0 18px 44px -14px rgba(0, 0, 0, .75);
  isolation: isolate; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  opacity: 0; transform: translateY(14px); pointer-events: none;
  transition: opacity .5s var(--ease), transform .5s var(--ease), color .38s var(--ease), border-color .38s var(--ease);
}
.agt-launch > * { position: relative; z-index: 2; }
.agt-launch::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: #fff;
  transform: scaleY(0); transform-origin: bottom;
  transition: transform .5s var(--ease);
}
.agt-launch__ic { width: 18px; height: 18px; flex: none; color: var(--signal-2); transition: color .38s var(--ease); }
.agt-launch.is-on { opacity: 1; transform: none; pointer-events: auto; }
html.agt-open .agt-launch,
body.menu-open .agt-launch { opacity: 0; transform: translateY(14px); pointer-events: none; }
@media (hover: hover) {
  .agt-launch:hover { color: var(--ink); border-color: #fff; }
  .agt-launch:hover .agt-launch__ic { color: var(--signal); }
  .agt-launch:hover::before { transform: scaleY(1); transform-origin: top; }
}
.agt-launch:focus-visible { outline: 2px solid var(--signal-2); outline-offset: 3px; }

/* ---------- panel ---------- */
.agt-panel {
  position: fixed; right: var(--agt-r); bottom: var(--agt-b); z-index: 89;
  width: min(25.5rem, calc(100vw - 2 * var(--agt-r)));
  height: min(38rem, calc(100vh - var(--hdr-h) - var(--agt-b) - 1rem));
  display: flex; flex-direction: column;
  font-family: var(--font-text); color: var(--fg);
  background: var(--agt-bg);
  border: 1px solid var(--agt-edge);
  border-radius: 6px;
  box-shadow: 0 40px 100px -24px rgba(0, 0, 0, .85), 0 0 0 1px rgba(0, 0, 0, .4);
  overflow: hidden;
  opacity: 0; visibility: hidden;
  transform: translateY(16px); transform-origin: 100% 100%;
  transition: opacity .38s var(--ease), transform .5s var(--ease), visibility 0s linear .5s;
}
@supports (height: 100dvh) {
  .agt-panel { height: min(38rem, calc(100dvh - var(--hdr-h) - var(--agt-b) - 1rem)); }
}
.agt-panel.is-open {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .38s var(--ease), transform .5s var(--ease), visibility 0s;
}
.agt-panel button { font: inherit; color: inherit; cursor: pointer; }
.agt-panel :focus-visible { outline: 2px solid var(--signal-2); outline-offset: 2px; }

/* header: who you are talking to */
.agt-head {
  flex: none; display: flex; align-items: center; gap: .25rem;
  padding: .85rem .6rem .85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, 0));
}
.agt-head__id { display: grid; gap: .3rem; min-width: 0; margin-right: auto; }
.agt-head__name {
  font-family: var(--font-display); font-size: 1.0625rem; font-weight: 500; letter-spacing: -.01em; line-height: 1.1;
  color: #fff;
}
.agt-head__st {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .75rem; line-height: 1.2; color: var(--fg-2);
  white-space: nowrap;
}
.agt-head__st i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--agt-ok);
  box-shadow: 0 0 0 3px rgba(61, 220, 151, .14);
}
.agt-ic {
  flex: none;
  width: 2.25rem; height: 2.25rem; display: grid; place-items: center;
  color: var(--fg-2); background: none; border: 0; border-radius: 4px;
  transition: color .25s var(--ease), background-color .25s var(--ease);
}
.agt-ic svg { width: 16px; height: 16px; }
.agt-ic:hover { color: #fff; background: rgba(255, 255, 255, .07); }

/* conversation */
.agt-log {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 1.25rem 1rem 1rem;
  display: flex; flex-direction: column; gap: 1.1rem;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .16) transparent;
}
.agt-log::-webkit-scrollbar { width: 6px; }
.agt-log::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 3px; }

/* first screen */
.agt-intro { display: grid; align-content: start; gap: 0; padding: .25rem .15rem 0; }
.agt-ttl {
  margin: .2rem 0 .55rem;
  font-family: var(--font-display); font-weight: 400;
  font-size: 1.625rem; line-height: 1.12; letter-spacing: -.025em;
  color: #fff; text-wrap: balance;
}
.agt-sub { margin: 0; font-size: .875rem; line-height: 1.55; color: var(--fg-2); text-wrap: pretty; }
.agt-sug { list-style: none; margin: 1.4rem 0 0; padding: 0; display: grid; gap: .5rem; }
.agt-sug button {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem .9rem;
  text-align: left; font-size: .9063rem; line-height: 1.35; color: var(--fg);
  background: var(--agt-raise);
  border: 1px solid var(--line); border-radius: 4px;
  transition: border-color .25s var(--ease), background-color .25s var(--ease);
}
.agt-sug svg { flex: none; width: 14px; height: 14px; color: var(--fg-3); transition: color .25s var(--ease), transform .35s var(--ease); }
@media (hover: hover) {
  .agt-sug button:hover { border-color: rgba(71, 86, 255, .7); background: rgba(71, 86, 255, .1); }
  .agt-sug button:hover svg { color: var(--signal-2); transform: translateX(2px); }
}

/* messages */
.agt-msg { display: flex; gap: .7rem; animation: agt-in .45s var(--ease) both; }
@keyframes agt-in { from { opacity: 0; transform: translateY(6px); } }
.agt-msg--me { justify-content: flex-end; }
.agt-msg--me .agt-txt {
  max-width: 85%;
  padding: .6rem .85rem;
  font-size: .9375rem; line-height: 1.5; color: #fff;
  background: var(--signal);
  border-radius: 6px 6px 2px 6px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.agt-msg--ai .agt-body { min-width: 0; flex: 1; display: grid; gap: .3rem; }
.agt-who { font-size: .75rem; font-weight: 500; line-height: 1.2; color: var(--fg-2); }
.agt-msg--ai .agt-txt {
  font-size: .9375rem; line-height: 1.6; color: rgba(255, 255, 255, .9);
  overflow-wrap: anywhere;
}
.agt-txt p { margin: 0; }
.agt-txt p + p, .agt-txt p + ul, .agt-txt p + ol, .agt-txt ul + p, .agt-txt ol + p { margin-top: .6em; }
.agt-txt ul, .agt-txt ol { margin: 0; padding: 0; list-style: none; display: grid; gap: .3em; }
.agt-txt li { position: relative; padding-left: 1.05em; }
.agt-txt ul > li::before {
  content: ""; position: absolute; left: .1em; top: .66em;
  width: 5px; height: 5px; border-radius: 1px; background: var(--signal-2);
}
.agt-txt ol { counter-reset: agt; }
.agt-txt ol > li { counter-increment: agt; padding-left: 1.5em; }
.agt-txt ol > li::before {
  content: counter(agt) "."; position: absolute; left: 0; top: 0;
  color: var(--signal-2); font-variant-numeric: tabular-nums;
}
.agt-txt strong { color: #fff; font-weight: 600; }
.agt-txt a {
  color: var(--signal-2);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em;
  text-decoration-color: rgba(110, 121, 255, .45);
  transition: text-decoration-color .25s var(--ease), color .25s var(--ease);
}
.agt-txt a:hover { color: #fff; text-decoration-color: currentColor; }
.agt-txt a[href^="tel:"], .agt-note a[href^="tel:"] { white-space: nowrap; }

/* while streaming, a caret sits at the end of the answer */
.agt-msg.is-live .agt-txt > :last-child::after {
  content: ""; display: inline-block;
  width: 2px; height: 1em; margin-left: .2em; vertical-align: -.15em;
  background: var(--signal-2);
  animation: agt-blink 1s steps(2, start) infinite;
}
@keyframes agt-blink { to { visibility: hidden; } }
.agt-wait { display: inline-flex; gap: 5px; padding: .5rem 0 .3rem; }
.agt-wait i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--fg-2);
  opacity: .3; animation: agt-wait 1.2s var(--ease) infinite;
}
.agt-wait i:nth-child(2) { animation-delay: .15s; }
.agt-wait i:nth-child(3) { animation-delay: .3s; }
@keyframes agt-wait { 30% { opacity: 1; transform: translateY(-2px); } 60%, 100% { opacity: .3; transform: none; } }
.agt-retry { margin-left: .6rem; font-size: .8125rem; color: var(--fg-2); }

.agt-note {
  padding: .65rem .8rem;
  font-size: .8125rem; line-height: 1.5; color: var(--fg-2);
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line); border-radius: 4px;
}
.agt-note a { color: var(--fg); text-decoration: underline; text-underline-offset: .2em; text-decoration-color: rgba(255, 255, 255, .3); }

/* composer */
.agt-cmp { flex: none; padding: .75rem .9rem 0; }
.agt-field {
  display: flex; align-items: flex-end; gap: .5rem;
  padding: .3rem .3rem .3rem .85rem;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 6px;
  transition: border-color .25s var(--ease), background-color .25s var(--ease);
}
.agt-field:focus-within { border-color: rgba(71, 86, 255, .85); background: rgba(255, 255, 255, .055); }
.agt-in {
  flex: 1; min-width: 0;
  min-height: 2.25rem; max-height: 8rem;
  margin: 0; padding: .45rem 0;
  resize: none; overflow-y: auto;
  font-family: var(--font-text); font-size: .9375rem; line-height: 1.45;
  color: var(--fg); background: transparent; border: 0; outline: none; border-radius: 0;
}
.agt-in::placeholder { color: var(--fg-3); opacity: 1; }
.agt-panel .agt-in:focus-visible { outline: none; }
.agt-send {
  flex: none;
  width: 2.25rem; height: 2.25rem;
  display: grid; place-items: center;
  color: #fff; background: var(--signal);
  border: 0; border-radius: 4px;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
.agt-send svg { width: 16px; height: 16px; }
.agt-send:hover { background: #3341E0; }
.agt-send:disabled { cursor: default; color: var(--fg-3); background: rgba(255, 255, 255, .07); }
.agt-send .is-stop-ic { display: none; }
.agt-send.is-stop .is-send-ic { display: none; }
.agt-send.is-stop .is-stop-ic { display: block; }

/* the disclosure the privacy policy promises, always in view */
.agt-foot {
  flex: none; margin: 0;
  padding: .55rem 1rem .7rem;
  font-size: .71875rem; line-height: 1.45; text-align: center;
  color: var(--fg-3);
}
.agt-foot a { color: var(--fg-2); text-decoration: underline; text-underline-offset: .18em; text-decoration-color: rgba(255, 255, 255, .25); transition: color .25s var(--ease); }
.agt-foot a:hover { color: #fff; }

/* ---------- phones: full-screen sheet ---------- */
@media (max-width: 640px) {
  .agt-launch { padding: 0 1.1rem 0 .95rem; font-size: .875rem; gap: .65rem; }
  .agt-panel {
    z-index: 95;
    top: var(--agt-top, 0); left: 0; right: 0; bottom: auto;
    width: 100%; height: var(--agt-vh, 100vh);
    border: 0; border-radius: 0; box-shadow: none;
    transform: translateY(24px); transform-origin: 50% 100%;
  }
  @supports (height: 100dvh) { .agt-panel { height: var(--agt-vh, 100dvh); } }
  .agt-head {
    padding-top: max(.85rem, calc(env(safe-area-inset-top) + .5rem));
    padding-right: max(.5rem, env(safe-area-inset-right));
    padding-left: max(1rem, env(safe-area-inset-left));
  }
  .agt-ic { width: 2.75rem; height: 2.75rem; }
  .agt-ic svg { width: 18px; height: 18px; }
  .agt-log { padding: 1.1rem max(1rem, env(safe-area-inset-left)) 1rem; }
  .agt-in { font-size: 16px; }           /* below 16px iOS zooms the page on focus */
  .agt-send { width: 2.5rem; height: 2.5rem; }
  .agt-foot { padding-bottom: max(.7rem, env(safe-area-inset-bottom)); }
}

/* short landscape screens: use the full height and sit above the header */
@media (min-width: 641px) and (max-height: 600px) {
  .agt-panel { z-index: 95; height: calc(100vh - 2 * var(--agt-b)); }
  @supports (height: 100dvh) { .agt-panel { height: calc(100dvh - 2 * var(--agt-b)); } }
}

@media (prefers-reduced-motion: reduce) {
  .agt-launch, .agt-panel, .agt-msg { transition: none !important; animation: none !important; }
  .agt-wait i { animation: none !important; opacity: 1; }
}
@media print { .agt-launch, .agt-panel { display: none !important; } }
