/*
  Scout: the "ask me about Sahil" guide on the homepage.
  Shown only on the home route. Colours are local so the site's theme swaps can't break contrast.
*/
.scout {
  --sc-bg: #0F100B; --sc-bg-2: #1A1C13; --sc-dark: #13140E;
  --sc-ink: #F4F3E8; --sc-ink-2: rgba(244, 243, 232, .64); --sc-ink-3: rgba(244, 243, 232, .46);
  --sc-line: rgba(244, 243, 232, .12); --sc-lime: #EBFC72; --sc-olive: #BACD31;
  --sc-mono: var(--f-mono, "Tabular", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  --sc-gutter: clamp(16px, 2.4vw, 28px);
  position: fixed; right: max(var(--sc-gutter), env(safe-area-inset-right)); bottom: max(var(--sc-gutter), env(safe-area-inset-bottom));
  z-index: 95; font-family: var(--f-sans); color: var(--sc-ink); pointer-events: none;
}
body:not([data-route-kind="home"]) .scout { display: none; }
.scout * { box-sizing: border-box; }
.scout svg.ic { width: 20px; height: 20px; flex: none; }
.scout-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- the character ---------- */
.scout-bot { display: block; overflow: visible; }
.scout-bot .sb-eye { transform-box: fill-box; transform-origin: center; }
.scout-bot .sb-happy { opacity: 0; }
.scout-bot.is-happy .sb-eyes { opacity: 0; }
.scout-bot.is-happy .sb-happy { opacity: 1; }
.scout-bot .sb-ping { transform-box: fill-box; transform-origin: center; opacity: 0; }

/* ---------- launcher: a HUD frame like the site mark ---------- */
.scout-launch { pointer-events: auto; position: relative; width: 68px; height: 68px; border: 0; padding: 0; border-radius: 8px;
  background: var(--sc-bg); display: grid; place-items: center; cursor: pointer; color: var(--sc-ink);
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .75), 0 0 0 1px var(--sc-line) inset;
  transition: box-shadow .4s ease; }
.scout-launch::before { content: ""; position: absolute; inset: -5px; pointer-events: none;
  --c: var(--sc-lime); --l: 14px; --w: 2px;
  background:
    linear-gradient(var(--c) 0 0) top left / var(--l) var(--w), linear-gradient(var(--c) 0 0) top left / var(--w) var(--l),
    linear-gradient(var(--c) 0 0) top right / var(--l) var(--w), linear-gradient(var(--c) 0 0) top right / var(--w) var(--l),
    linear-gradient(var(--c) 0 0) bottom left / var(--l) var(--w), linear-gradient(var(--c) 0 0) bottom left / var(--w) var(--l),
    linear-gradient(var(--c) 0 0) bottom right / var(--l) var(--w), linear-gradient(var(--c) 0 0) bottom right / var(--w) var(--l);
  background-repeat: no-repeat; transition: inset .45s var(--ease-out, ease); }
.scout-launch::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; z-index: -1;
  background: var(--sc-lime); filter: blur(22px); opacity: .22; transition: opacity .4s ease; }
.scout-launch:hover::before, .scout-launch:focus-visible::before { inset: -9px; }
.scout-launch:hover::after, .scout-launch:focus-visible::after { opacity: .4; }
.scout-launch:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--sc-lime); }
.scout-launch .scout-bot { width: 52px; height: 52px; }
.scout-launch__x { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; color: var(--sc-ink); }
.scout-launch__x svg.ic { width: 24px; height: 24px; }
.scout.is-open .scout-launch .scout-bot { opacity: 0; transform: scale(.6); }
.scout.is-open .scout-launch__x { opacity: 1; }
.scout-launch .scout-bot, .scout-launch__x { transition: opacity .3s ease, transform .4s var(--ease-out, ease); }

/* ---------- teaser bubble ---------- */
.scout-tease { pointer-events: auto; position: absolute; right: 0; bottom: calc(100% + 18px); width: max-content; max-width: min(300px, calc(100vw - 32px));
  background: var(--sc-lime); color: var(--sc-dark); border-radius: 8px 8px 2px 8px; padding: 12px 44px 12px 16px;
  font-size: 15px; line-height: 1.4; box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .7); opacity: 0; visibility: hidden; }
.scout-tease b { font-weight: 700; }
.scout-tease__open { all: unset; cursor: pointer; display: block; color: var(--sc-dark); }
.scout-tease__open::after { content: ""; position: absolute; inset: 0; }
.scout-tease__x { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border: 0; border-radius: 4px; background: none; display: grid; place-items: center; color: var(--sc-dark); z-index: 1; }
.scout-tease__x svg.ic { width: 16px; height: 16px; }
.scout-tease__x::before { content: ""; position: absolute; inset: -6px; } /* 44 px tap area */
.scout-tease__x:hover { background: rgba(19, 20, 14, .1); }

/* ---------- panel ---------- */
.scout-panel { pointer-events: auto; position: absolute; right: 0; bottom: calc(100% + 20px);
  width: min(412px, calc(100vw - 2 * var(--sc-gutter))); height: min(620px, calc(100dvh - 150px));
  display: flex; flex-direction: column; overflow: hidden; border-radius: 10px;
  background: radial-gradient(110% 55% at 100% 0%, rgba(235, 252, 114, .09), transparent 60%), var(--sc-bg);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .85), 0 0 0 1px var(--sc-line) inset;
  transform-origin: 100% 100%; visibility: hidden; opacity: 0; }
.scout.is-open .scout-panel { visibility: visible; opacity: 1; }

.scout-head { display: flex; align-items: center; gap: 12px; padding: 14px 10px 14px 16px; border-bottom: 1px solid var(--sc-line); }
.scout-head .scout-bot { width: 46px; height: 46px; flex: none; }
.scout-head__t { flex: 1; min-width: 0; }
.scout-head__t h2 { margin: 0; font-family: var(--f-display, var(--f-sans)); font-size: 17px; line-height: 1.25; font-weight: 700; letter-spacing: -.005em; color: var(--sc-ink); }
.scout-head__t p { margin: 4px 0 0; font-family: var(--sc-mono); font-size: 11px; line-height: 1.3; letter-spacing: .1em; text-transform: uppercase; color: var(--sc-ink-2); display: flex; align-items: center; gap: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scout-head__t p::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--sc-lime); box-shadow: 0 0 0 3px rgba(235, 252, 114, .18); }
.scout-iconbtn { width: 44px; height: 44px; border: 0; border-radius: 6px; background: none; color: var(--sc-ink-2); display: grid; place-items: center; transition: background .25s ease, color .25s ease; }
.scout-iconbtn:hover { background: rgba(244, 243, 232, .08); color: var(--sc-ink); }
.scout-iconbtn:focus-visible { outline: 2px solid var(--sc-lime); outline-offset: -2px; }
.scout-iconbtn svg.ic { transition: transform .35s var(--ease-out, ease); }
.scout-iconbtn:hover svg.ic { transform: rotate(-6deg); }

.scout-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 10px; display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin; scrollbar-color: rgba(244, 243, 232, .2) transparent; outline: none; }
.scout-msg { max-width: 88%; font-size: 15.5px; line-height: 1.5; padding: 11px 15px; border-radius: 10px; overflow-wrap: anywhere; }
.scout-msg p { margin: 0; }
.scout-msg p + p, .scout-msg p + ul, .scout-msg ul + p { margin-top: 8px; }
.scout-msg ul { margin: 0; padding-left: 18px; list-style: disc; }
.scout-msg li { margin: 0; }
.scout-msg li + li { margin-top: 4px; }
.scout-msg li::marker { color: var(--sc-lime); }
.scout-msg b { font-weight: 650; color: #fff; }
.scout-msg a { color: var(--sc-lime); text-decoration: underline; text-underline-offset: 3px; }
.scout-msg--bot { align-self: flex-start; background: var(--sc-bg-2); border: 1px solid rgba(244, 243, 232, .07); border-bottom-left-radius: 2px; color: var(--sc-ink); }
.scout-msg--me { align-self: flex-end; background: var(--sc-lime); color: var(--sc-dark); font-weight: 560; border-bottom-right-radius: 2px; }
.scout-msg--typing { display: inline-flex; gap: 5px; padding: 15px 16px; }
.scout-msg--typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--sc-lime); animation: scout-dot 1.1s ease-in-out infinite; }
.scout-msg--typing i:nth-child(2) { animation-delay: .15s; }
.scout-msg--typing i:nth-child(3) { animation-delay: .3s; }
@keyframes scout-dot { 0%, 60%, 100% { transform: none; opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }

/* actions follow the site buttons: mono caps, lime fill or outline */
.scout-acts { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 8px; max-width: 100%; }
.scout-act { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; padding: 0 16px; border-radius: 3px; border: 1px solid rgba(244, 243, 232, .28);
  background: transparent; color: var(--sc-ink); font-family: var(--sc-mono); font-size: 12.5px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; transition: background .25s ease, border-color .25s ease, color .25s ease; }
.scout-act:first-child { background: var(--sc-lime); border-color: var(--sc-lime); color: var(--sc-dark); }
.scout-act span { color: inherit; }
.scout-act svg.ic { width: 16px; height: 16px; transition: transform .35s var(--ease-out, ease); }
.scout-act:hover svg.ic { transform: translate(2px, -2px); }
.scout-act:hover { border-color: var(--sc-lime); }
.scout-act:first-child:hover { background: #F4FFA6; }
.scout-act:focus-visible { outline: 2px solid var(--sc-lime); outline-offset: 2px; }

.scout-chips { display: flex; gap: 8px; padding: 10px 16px 4px; overflow-x: auto; scrollbar-width: none; flex: none;
  -webkit-mask: linear-gradient(90deg, #000 85%, transparent); mask: linear-gradient(90deg, #000 85%, transparent); }
.scout-chips::-webkit-scrollbar { display: none; }
.scout-chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(244, 243, 232, .2); background: rgba(244, 243, 232, .03);
  color: var(--sc-ink); font-size: 14px; font-weight: 520; white-space: nowrap; cursor: pointer; transition: border-color .25s ease, background .25s ease, color .25s ease; position: relative; }
.scout-chip::before { content: ""; position: absolute; inset: -4px 0; } /* 44 px tap area */
.scout-chip:hover { border-color: var(--sc-lime); color: var(--sc-lime); background: rgba(235, 252, 114, .06); }
.scout-chip:focus-visible { outline: 2px solid var(--sc-lime); outline-offset: 2px; }

.scout-form { display: flex; align-items: center; gap: 8px; margin: 8px 12px 10px; padding: 4px 4px 4px 14px; border-radius: 8px;
  background: rgba(244, 243, 232, .05); border: 1px solid var(--sc-line); transition: border-color .25s ease, background .25s ease; }
.scout-form:focus-within { border-color: rgba(235, 252, 114, .6); background: rgba(244, 243, 232, .07); }
.scout-form input { flex: 1; min-width: 0; height: 44px; border: 0; background: none; color: var(--sc-ink); font: inherit; font-size: 16px; outline: none; }
.scout-form input::placeholder { color: var(--sc-ink-3); }
.scout-send { width: 44px; height: 44px; flex: none; border: 0; border-radius: 5px; background: var(--sc-lime); color: var(--sc-dark); display: grid; place-items: center; transition: opacity .25s ease; }
.scout-send:disabled { opacity: .28; cursor: default; }
.scout-send:not(:disabled):hover svg.ic { transform: translateX(2px); }
.scout-send svg.ic { transition: transform .35s var(--ease-out, ease); }
.scout-send:focus-visible { outline: 2px solid var(--sc-ink); outline-offset: 2px; }
.scout-foot { margin: 0 16px 12px; font-family: var(--sc-mono); font-size: 10.5px; line-height: 1.4; letter-spacing: .08em; text-transform: uppercase; color: var(--sc-ink-3); text-align: center; }

/* ---------- phones: bottom sheet ---------- */
@media (max-width: 600px) {
  .scout { right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); }
  .scout-launch { width: 58px; height: 58px; }
  .scout-launch .scout-bot { width: 44px; height: 44px; }
  .scout-panel { position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: min(88dvh, 720px); border-radius: 14px 14px 0 0;
    padding-bottom: env(safe-area-inset-bottom); transform-origin: 50% 100%; }
  .scout.is-open .scout-launch { opacity: 0; pointer-events: none; }
  .scout-msg { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .scout-msg--typing i { animation: none; }
  .scout * { transition: none !important; }
}
@media print { .scout { display: none; } }

.scout-bot .sb-blush, .scout-bot .sb-mouth { pointer-events: none; }
.scout-bot.is-happy .sb-mouth { opacity: 1; }
